JavaExceptionTableEntry.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Fri, 25 Jan 2013 00:15:51 +0000
branchrefactoring-classpath
changeset 2000 13a10b73aa83
parent 1864 60a8dc26c8c6
child 2069 75d40b7b986f
permissions -rw-r--r--
Closing branch refactoring-classpath

"
 COPYRIGHT (c) 1996-2011 by Claus Gittinger

 New code and modifications done at SWING Research Group [1]:

 COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
                            SWING Research Group, Czech Technical University in Prague

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.

 [1] Code written at SWING Research Group contains a signature
     of one of the above copright owners. For exact set of such code,
     see the differences between this version and version stx:libjava
     as of 1.9.2010
"
"{ Package: 'stx:libjava' }"

Object subclass:#JavaExceptionTableEntry
	instanceVariableNames:'startPC endPC handlerPC catchType'
	classVariableNames:''
	poolDictionaries:''
	category:'Languages-Java-Support'
!

!JavaExceptionTableEntry class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 1996-2011 by Claus Gittinger

 New code and modifications done at SWING Research Group [1]:

 COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
                            SWING Research Group, Czech Technical University in Prague

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.

 [1] Code written at SWING Research Group contains a signature
     of one of the above copright owners. For exact set of such code,
     see the differences between this version and version stx:libjava
     as of 1.9.2010

"
! !

!JavaExceptionTableEntry class methodsFor:'instance creation'!

startPC:start_pc endPC:end_pc handlerPC:handler_pc catchType:catch_type
    ^ self new startPC:start_pc endPC:end_pc handlerPC:handler_pc catchType:catch_type

    "Created: 16.4.1996 / 12:11:13 / cg"
! !

!JavaExceptionTableEntry methodsFor:'accessing'!

catchType
    "return the value of the instance variable 'catchType' (automatically generated)"

    ^ catchType

    "Created: 7.2.1997 / 21:01:23 / cg"
!

endPC
    "return the value of the instance variable 'endPC' (automatically generated)"

    ^ endPC

    "Created: 7.2.1997 / 20:53:23 / cg"
!

handlerPC
    "return the value of the instance variable 'handlerPC' (automatically generated)"

    ^ handlerPC

    "Created: 7.2.1997 / 20:06:31 / cg"
!

startPC
    "return the value of the instance variable 'startPC' (automatically generated)"

    ^ startPC

    "Created: 7.2.1997 / 20:53:20 / cg"
! !

!JavaExceptionTableEntry methodsFor:'printing & storing'!

displayString
    ^ super displayString , '(' , catchType displayString,
                                  ' in ' , startPC printString , '..' ,
                                  endPC printString , '->' ,
                                  handlerPC printString , ')'

    "Modified: 15.8.1997 / 03:33:51 / cg"
!

printOn: aStream
    super printOn: aStream.
    aStream nextPut:$(.
    catchType printOn: aStream.
    aStream nextPutAll:' in ' , startPC printString , '..' ,
                                  endPC printString , '->' ,
                                  handlerPC printString , ')'

    "Modified: / 15-08-1997 / 03:33:51 / cg"
    "Created: / 25-02-2011 / 09:08:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!JavaExceptionTableEntry methodsFor:'private accessing'!

handlerPCFor:exception at:pc in:aMethod
    "if there is a handler for exceptionClass, with given pc,
     return the handler-PC; otherwise, return nil."

    |cls|
    "JV+MH@2011-02-25: You may wonder why there is endPC - 1:
    The Java VM Spec, 3rd edition, sec 4.7.3, page 78:

    The fact that end_pc is exclusive is a historical mistake in the design of the
    Java virtual machine: if the Java virtual machine code for a method is exactly
    65535 bytes long and ends with an instruction that is 1 byte long, then that
    instruction cannot be protected by an exception handler. A compiler writer can
    work around this bug by limiting the maximum size of the generated Java
    virtual machine code for any method, instance initialization method, or static
    initializer (the size of any code array) to 65534 bytes.

    "

    (pc between:startPC and:endPC - 1) ifTrue:[
        (catchType == 0) ifTrue:[^ handlerPC].
        (catchType isNil) ifTrue:[^ handlerPC].
        cls := aMethod javaClass.
        exception notNil ifTrue:[
            catchType := catchType javaClass.

            (catchType isKindOf:JavaClass) ifFalse:[
                self halt.
                ^ nil
            ].
            (exception isKindOf:catchType) ifTrue:[
                ^ handlerPC
            ].
            ^ nil
        ]
    ].
    ^ nil

    "Modified: / 07-01-1998 / 15:30:14 / cg"
    "Modified: / 03-09-2012 / 18:50:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

startPC:start_pc endPC:end_pc handlerPC:handler_pc catchType:catch_type
    startPC := start_pc.
    endPC := end_pc.
    handlerPC := handler_pc.
    catchType := catch_type

    "Created: 16.4.1996 / 12:11:45 / cg"
! !

!JavaExceptionTableEntry class methodsFor:'documentation'!

version
    ^ '$Header$'
!

version_HG

    ^ '$Changeset: <not expanded> $'
!

version_SVN
    ^ '§Id§'
! !