JavaExceptionTableEntry.st
author Claus Gittinger <cg@exept.de>
Thu, 24 Nov 2011 13:02:13 +0100
branchinitialV
changeset 2333 b1a55b7337c9
parent 2261 5407ec1e59e4
child 2353 fa7400d022a0
permissions -rw-r--r--
checkin from stx browser
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
454
38f590639d65 *** empty log message ***
cg
parents: 264
diff changeset
     1
"
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2108
diff changeset
     2
 COPYRIGHT (c) 1996-2011 by Claus Gittinger
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2108
diff changeset
     3
 COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
2237
726251e07487 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 2151
diff changeset
     4
                            SWING Research Group, Czech Technical University in Prague (*)
454
38f590639d65 *** empty log message ***
cg
parents: 264
diff changeset
     5
38f590639d65 *** empty log message ***
cg
parents: 264
diff changeset
     6
 This software is furnished under a license and may be used
38f590639d65 *** empty log message ***
cg
parents: 264
diff changeset
     7
 only in accordance with the terms of that license and with the
38f590639d65 *** empty log message ***
cg
parents: 264
diff changeset
     8
 inclusion of the above copyright notice.   This software may not
38f590639d65 *** empty log message ***
cg
parents: 264
diff changeset
     9
 be provided or otherwise made available to, or used by, any
38f590639d65 *** empty log message ***
cg
parents: 264
diff changeset
    10
 other person.  No title to or ownership of the software is
38f590639d65 *** empty log message ***
cg
parents: 264
diff changeset
    11
 hereby transferred.
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2108
diff changeset
    12
2237
726251e07487 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 2151
diff changeset
    13
 (*) extensions, changes and fixes for java1.1 compatibility.
726251e07487 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 2151
diff changeset
    14
     For a list of changes, see a list of diffs against the last stable version before 2011-08.
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2108
diff changeset
    15
"
713
75e92ac63bf1 category change
cg
parents: 454
diff changeset
    16
"{ Package: 'stx:libjava' }"
75e92ac63bf1 category change
cg
parents: 454
diff changeset
    17
6
b23a6474754f intitial checkin
cg
parents:
diff changeset
    18
Object subclass:#JavaExceptionTableEntry
b23a6474754f intitial checkin
cg
parents:
diff changeset
    19
	instanceVariableNames:'startPC endPC handlerPC catchType'
b23a6474754f intitial checkin
cg
parents:
diff changeset
    20
	classVariableNames:''
b23a6474754f intitial checkin
cg
parents:
diff changeset
    21
	poolDictionaries:''
713
75e92ac63bf1 category change
cg
parents: 454
diff changeset
    22
	category:'Languages-Java-Support'
6
b23a6474754f intitial checkin
cg
parents:
diff changeset
    23
!
b23a6474754f intitial checkin
cg
parents:
diff changeset
    24
454
38f590639d65 *** empty log message ***
cg
parents: 264
diff changeset
    25
!JavaExceptionTableEntry class methodsFor:'documentation'!
38f590639d65 *** empty log message ***
cg
parents: 264
diff changeset
    26
38f590639d65 *** empty log message ***
cg
parents: 264
diff changeset
    27
copyright
38f590639d65 *** empty log message ***
cg
parents: 264
diff changeset
    28
"
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2108
diff changeset
    29
 COPYRIGHT (c) 1996-2011 by Claus Gittinger
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2108
diff changeset
    30
 COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
2237
726251e07487 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 2151
diff changeset
    31
                            SWING Research Group, Czech Technical University in Prague (*)
454
38f590639d65 *** empty log message ***
cg
parents: 264
diff changeset
    32
38f590639d65 *** empty log message ***
cg
parents: 264
diff changeset
    33
 This software is furnished under a license and may be used
38f590639d65 *** empty log message ***
cg
parents: 264
diff changeset
    34
 only in accordance with the terms of that license and with the
38f590639d65 *** empty log message ***
cg
parents: 264
diff changeset
    35
 inclusion of the above copyright notice.   This software may not
38f590639d65 *** empty log message ***
cg
parents: 264
diff changeset
    36
 be provided or otherwise made available to, or used by, any
38f590639d65 *** empty log message ***
cg
parents: 264
diff changeset
    37
 other person.  No title to or ownership of the software is
38f590639d65 *** empty log message ***
cg
parents: 264
diff changeset
    38
 hereby transferred.
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2108
diff changeset
    39
2237
726251e07487 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 2151
diff changeset
    40
 (*) extensions, changes and fixes for java1.1 compatibility.
726251e07487 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 2151
diff changeset
    41
     For a list of changes, see a list of diffs against the last stable version before 2011-08.
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2108
diff changeset
    42
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2108
diff changeset
    43
"
454
38f590639d65 *** empty log message ***
cg
parents: 264
diff changeset
    44
! !
6
b23a6474754f intitial checkin
cg
parents:
diff changeset
    45
135
098936234135 *** empty log message ***
cg
parents: 122
diff changeset
    46
!JavaExceptionTableEntry class methodsFor:'instance creation'!
6
b23a6474754f intitial checkin
cg
parents:
diff changeset
    47
b23a6474754f intitial checkin
cg
parents:
diff changeset
    48
startPC:start_pc endPC:end_pc handlerPC:handler_pc catchType:catch_type
b23a6474754f intitial checkin
cg
parents:
diff changeset
    49
    ^ self new startPC:start_pc endPC:end_pc handlerPC:handler_pc catchType:catch_type
b23a6474754f intitial checkin
cg
parents:
diff changeset
    50
b23a6474754f intitial checkin
cg
parents:
diff changeset
    51
    "Created: 16.4.1996 / 12:11:13 / cg"
b23a6474754f intitial checkin
cg
parents:
diff changeset
    52
! !
b23a6474754f intitial checkin
cg
parents:
diff changeset
    53
135
098936234135 *** empty log message ***
cg
parents: 122
diff changeset
    54
!JavaExceptionTableEntry methodsFor:'accessing'!
098936234135 *** empty log message ***
cg
parents: 122
diff changeset
    55
098936234135 *** empty log message ***
cg
parents: 122
diff changeset
    56
catchType
098936234135 *** empty log message ***
cg
parents: 122
diff changeset
    57
    "return the value of the instance variable 'catchType' (automatically generated)"
098936234135 *** empty log message ***
cg
parents: 122
diff changeset
    58
098936234135 *** empty log message ***
cg
parents: 122
diff changeset
    59
    ^ catchType
098936234135 *** empty log message ***
cg
parents: 122
diff changeset
    60
098936234135 *** empty log message ***
cg
parents: 122
diff changeset
    61
    "Created: 7.2.1997 / 21:01:23 / cg"
098936234135 *** empty log message ***
cg
parents: 122
diff changeset
    62
!
098936234135 *** empty log message ***
cg
parents: 122
diff changeset
    63
098936234135 *** empty log message ***
cg
parents: 122
diff changeset
    64
endPC
098936234135 *** empty log message ***
cg
parents: 122
diff changeset
    65
    "return the value of the instance variable 'endPC' (automatically generated)"
098936234135 *** empty log message ***
cg
parents: 122
diff changeset
    66
098936234135 *** empty log message ***
cg
parents: 122
diff changeset
    67
    ^ endPC
098936234135 *** empty log message ***
cg
parents: 122
diff changeset
    68
098936234135 *** empty log message ***
cg
parents: 122
diff changeset
    69
    "Created: 7.2.1997 / 20:53:23 / cg"
098936234135 *** empty log message ***
cg
parents: 122
diff changeset
    70
!
098936234135 *** empty log message ***
cg
parents: 122
diff changeset
    71
098936234135 *** empty log message ***
cg
parents: 122
diff changeset
    72
handlerPC
098936234135 *** empty log message ***
cg
parents: 122
diff changeset
    73
    "return the value of the instance variable 'handlerPC' (automatically generated)"
098936234135 *** empty log message ***
cg
parents: 122
diff changeset
    74
098936234135 *** empty log message ***
cg
parents: 122
diff changeset
    75
    ^ handlerPC
098936234135 *** empty log message ***
cg
parents: 122
diff changeset
    76
098936234135 *** empty log message ***
cg
parents: 122
diff changeset
    77
    "Created: 7.2.1997 / 20:06:31 / cg"
098936234135 *** empty log message ***
cg
parents: 122
diff changeset
    78
!
098936234135 *** empty log message ***
cg
parents: 122
diff changeset
    79
098936234135 *** empty log message ***
cg
parents: 122
diff changeset
    80
startPC
098936234135 *** empty log message ***
cg
parents: 122
diff changeset
    81
    "return the value of the instance variable 'startPC' (automatically generated)"
098936234135 *** empty log message ***
cg
parents: 122
diff changeset
    82
098936234135 *** empty log message ***
cg
parents: 122
diff changeset
    83
    ^ startPC
098936234135 *** empty log message ***
cg
parents: 122
diff changeset
    84
098936234135 *** empty log message ***
cg
parents: 122
diff changeset
    85
    "Created: 7.2.1997 / 20:53:20 / cg"
098936234135 *** empty log message ***
cg
parents: 122
diff changeset
    86
! !
098936234135 *** empty log message ***
cg
parents: 122
diff changeset
    87
164
724c443e6f79 *** empty log message ***
cg
parents: 135
diff changeset
    88
!JavaExceptionTableEntry methodsFor:'printing & storing'!
724c443e6f79 *** empty log message ***
cg
parents: 135
diff changeset
    89
724c443e6f79 *** empty log message ***
cg
parents: 135
diff changeset
    90
displayString
226
a48121c92205 better displayString
cg
parents: 164
diff changeset
    91
    ^ super displayString , '(' , catchType displayString,
a48121c92205 better displayString
cg
parents: 164
diff changeset
    92
                                  ' in ' , startPC printString , '..' ,
164
724c443e6f79 *** empty log message ***
cg
parents: 135
diff changeset
    93
                                  endPC printString , '->' ,
724c443e6f79 *** empty log message ***
cg
parents: 135
diff changeset
    94
                                  handlerPC printString , ')'
724c443e6f79 *** empty log message ***
cg
parents: 135
diff changeset
    95
226
a48121c92205 better displayString
cg
parents: 164
diff changeset
    96
    "Modified: 15.8.1997 / 03:33:51 / cg"
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2108
diff changeset
    97
!
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2108
diff changeset
    98
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2108
diff changeset
    99
printOn: aStream
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2108
diff changeset
   100
    super printOn: aStream.
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2108
diff changeset
   101
    aStream nextPut:$(.
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2108
diff changeset
   102
    catchType printOn: aStream.
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2108
diff changeset
   103
    aStream nextPutAll:' in ' , startPC printString , '..' ,
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2108
diff changeset
   104
                                  endPC printString , '->' ,
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2108
diff changeset
   105
                                  handlerPC printString , ')'
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2108
diff changeset
   106
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2108
diff changeset
   107
    "Modified: / 15-08-1997 / 03:33:51 / cg"
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2108
diff changeset
   108
    "Created: / 25-02-2011 / 09:08:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
164
724c443e6f79 *** empty log message ***
cg
parents: 135
diff changeset
   109
! !
724c443e6f79 *** empty log message ***
cg
parents: 135
diff changeset
   110
6
b23a6474754f intitial checkin
cg
parents:
diff changeset
   111
!JavaExceptionTableEntry methodsFor:'private accessing'!
b23a6474754f intitial checkin
cg
parents:
diff changeset
   112
47
b5f63f59c2c1 some net primitives added
cg
parents: 6
diff changeset
   113
handlerPCFor:exception at:pc in:aMethod
b5f63f59c2c1 some net primitives added
cg
parents: 6
diff changeset
   114
    "if there is a handler for exceptionClass, with given pc,
b5f63f59c2c1 some net primitives added
cg
parents: 6
diff changeset
   115
     return the handler-PC; otherwise, return nil."
b5f63f59c2c1 some net primitives added
cg
parents: 6
diff changeset
   116
107
86a831b6728a *** empty log message ***
cg
parents: 100
diff changeset
   117
    |cls|
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2108
diff changeset
   118
    "JV+MH@2011-02-25: You may wonder why there is endPC - 1:
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2108
diff changeset
   119
    The Java VM Spec, 3rd edition, sec 4.7.3, page 78:
47
b5f63f59c2c1 some net primitives added
cg
parents: 6
diff changeset
   120
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2108
diff changeset
   121
    The fact that end_pc is exclusive is a historical mistake in the design of the
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2108
diff changeset
   122
    Java virtual machine: if the Java virtual machine code for a method is exactly
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2108
diff changeset
   123
    65535 bytes long and ends with an instruction that is 1 byte long, then that
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2108
diff changeset
   124
    instruction cannot be protected by an exception handler. A compiler writer can
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2108
diff changeset
   125
    work around this bug by limiting the maximum size of the generated Java
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2108
diff changeset
   126
    virtual machine code for any method, instance initialization method, or static
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2108
diff changeset
   127
    initializer (the size of any code array) to 65534 bytes.
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2108
diff changeset
   128
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2108
diff changeset
   129
    "
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2108
diff changeset
   130
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2108
diff changeset
   131
    (pc between:startPC and:endPC - 1) ifTrue:[
107
86a831b6728a *** empty log message ***
cg
parents: 100
diff changeset
   132
        (catchType == 0) ifTrue:[^ handlerPC].
122
e731a1c1d499 *** empty log message ***
cg
parents: 114
diff changeset
   133
        (catchType isNil) ifTrue:[^ handlerPC].
100
4b0da648dcc5 *** empty log message ***
cg
parents: 91
diff changeset
   134
        cls := aMethod javaClass.
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2108
diff changeset
   135
        catchType := catchType javaClass.
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2108
diff changeset
   136
107
86a831b6728a *** empty log message ***
cg
parents: 100
diff changeset
   137
        (catchType isKindOf:JavaClass) ifFalse:[
47
b5f63f59c2c1 some net primitives added
cg
parents: 6
diff changeset
   138
            self halt.
b5f63f59c2c1 some net primitives added
cg
parents: 6
diff changeset
   139
            ^ nil
b5f63f59c2c1 some net primitives added
cg
parents: 6
diff changeset
   140
        ].
111
23243f9273fa *** empty log message ***
cg
parents: 107
diff changeset
   141
        (exception isKindOf:catchType) ifTrue:[
47
b5f63f59c2c1 some net primitives added
cg
parents: 6
diff changeset
   142
            ^ handlerPC
b5f63f59c2c1 some net primitives added
cg
parents: 6
diff changeset
   143
        ].
b5f63f59c2c1 some net primitives added
cg
parents: 6
diff changeset
   144
        ^ nil
b5f63f59c2c1 some net primitives added
cg
parents: 6
diff changeset
   145
    ].
b5f63f59c2c1 some net primitives added
cg
parents: 6
diff changeset
   146
    ^ nil
255
2d8b3948a08a *** empty log message ***
cg
parents: 226
diff changeset
   147
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2108
diff changeset
   148
    "Modified: / 07-01-1998 / 15:30:14 / cg"
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2108
diff changeset
   149
    "Modified: / 31-05-2011 / 09:53:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
47
b5f63f59c2c1 some net primitives added
cg
parents: 6
diff changeset
   150
!
b5f63f59c2c1 some net primitives added
cg
parents: 6
diff changeset
   151
6
b23a6474754f intitial checkin
cg
parents:
diff changeset
   152
startPC:start_pc endPC:end_pc handlerPC:handler_pc catchType:catch_type
b23a6474754f intitial checkin
cg
parents:
diff changeset
   153
    startPC := start_pc.
b23a6474754f intitial checkin
cg
parents:
diff changeset
   154
    endPC := end_pc.
b23a6474754f intitial checkin
cg
parents:
diff changeset
   155
    handlerPC := handler_pc.
b23a6474754f intitial checkin
cg
parents:
diff changeset
   156
    catchType := catch_type
b23a6474754f intitial checkin
cg
parents:
diff changeset
   157
b23a6474754f intitial checkin
cg
parents:
diff changeset
   158
    "Created: 16.4.1996 / 12:11:45 / cg"
b23a6474754f intitial checkin
cg
parents:
diff changeset
   159
! !
b23a6474754f intitial checkin
cg
parents:
diff changeset
   160
135
098936234135 *** empty log message ***
cg
parents: 122
diff changeset
   161
!JavaExceptionTableEntry class methodsFor:'documentation'!
6
b23a6474754f intitial checkin
cg
parents:
diff changeset
   162
b23a6474754f intitial checkin
cg
parents:
diff changeset
   163
version
2261
5407ec1e59e4 fixed: #version_SVN ($ to §)
Claus Gittinger <cg@exept.de>
parents: 2237
diff changeset
   164
    ^ '$Header: /cvs/stx/stx/libjava/JavaExceptionTableEntry.st,v 1.18 2011-11-24 11:52:51 cg Exp $'
2237
726251e07487 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 2151
diff changeset
   165
!
726251e07487 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 2151
diff changeset
   166
726251e07487 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 2151
diff changeset
   167
version_CVS
2261
5407ec1e59e4 fixed: #version_SVN ($ to §)
Claus Gittinger <cg@exept.de>
parents: 2237
diff changeset
   168
    ^ '$Header: /cvs/stx/stx/libjava/JavaExceptionTableEntry.st,v 1.18 2011-11-24 11:52:51 cg Exp $'
2151
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2108
diff changeset
   169
!
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2108
diff changeset
   170
c0b6570c6f9b Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2108
diff changeset
   171
version_SVN
2237
726251e07487 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 2151
diff changeset
   172
    ^ '§Id: JavaExceptionTableEntry.st,v 1.16 2011/08/18 18:42:48 vrany Exp §'
2108
ca8c4e7db2e8 category change
Claus Gittinger <cg@exept.de>
parents: 749
diff changeset
   173
! !