--- a/JavaClass.st Thu Jun 27 07:12:53 1996 +0000
+++ b/JavaClass.st Thu Jun 27 14:25:32 1996 +0000
@@ -135,6 +135,10 @@
^ constantPool
!
+fields
+ ^ fields
+!
+
fullName
^ fullName
!
@@ -170,6 +174,10 @@
sourceFile
^ sourceFile
+!
+
+staticFields
+ ^ staticFields
! !
!JavaClass methodsFor:'java initialization'!
@@ -537,6 +545,10 @@
^ true
!
+isAbstract
+ ^ (accessFlags bitAnd:16r0400) ~~ 0
+!
+
isClass
^ true
!
@@ -667,6 +679,6 @@
!JavaClass class methodsFor:'documentation'!
version
- ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaClass.st,v 1.30 1996/06/26 12:13:04 cg Exp $'
+ ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaClass.st,v 1.31 1996/06/27 14:23:57 cg Exp $'
! !
JavaClass initialize!
--- a/JavaClassReader.st Thu Jun 27 07:12:53 1996 +0000
+++ b/JavaClassReader.st Thu Jun 27 14:25:32 1996 +0000
@@ -20,7 +20,9 @@
initializeClassPath
self initializeClassPath:#('/home/cg/java/').
- self initializeClassPath:#('/home/cg/java/JDK/classes/' '/home/cg/java/JWS/classes' ).
+ self initializeClassPath:#('/home/cg/java/JDK/classes/'
+ '/home/cg/java/JWS/classes/'
+ '/home/cg/java/' ).
"/ self initializeClassPath:#(
"/ '/phys/ibm3/java/lib/'
@@ -441,10 +443,15 @@
!JavaClassReader methodsFor:'file reading - attributes'!
readAttribute:attributeName for:something
+
(attributeName = 'Code') ifTrue:[
self readCodeAttributeFor:something.
^ true.
].
+ (attributeName = 'Exceptions') ifTrue:[
+ self readExceptionsAttributeFor:something.
+ ^ true.
+ ].
(attributeName = 'LineNumberTable') ifTrue:[
self readLineNumberTableAttributeFor:something.
^ true.
@@ -461,12 +468,10 @@
self readSourceFileAttributeFor:something.
^ true.
].
+
+ ('JAVA: unrecognized attribute: ' , attributeName) infoPrintCR.
^ false
- "
- JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'
- "
-
"Modified: 15.4.1996 / 15:33:28 / cg"
"Created: 15.4.1996 / 15:40:17 / cg"
!
@@ -1018,7 +1023,7 @@
handlerPC:handler_pc
catchType:catch_type).
].
- aJavaMethod setExceptionTable:exception_table.
+ aJavaMethod setExceptionHandlerTable:exception_table.
].
aJavaMethod
@@ -1040,6 +1045,32 @@
"Created: 15.4.1996 / 15:40:17 / cg"
!
+readExceptionsAttributeFor:aJavaMethod
+ |attribute_length exception_table_length exception_table|
+
+ attribute_length := self nextU4.
+
+ exception_table_length := self nextU2.
+ exception_table_length ~~ 0 ifTrue:[
+ exception_table := Array new:exception_table_length.
+ 1 to:exception_table_length do:[:i |
+ |idx ex|
+
+ idx := self nextU2.
+ ex := constants at:idx.
+ exception_table at:i put:ex.
+ ].
+ ].
+
+ Verbose ifTrue:[Transcript showCR:'method has an exceptionTable'].
+
+ aJavaMethod setExceptionTable:exception_table.
+ ^ true
+
+ "Modified: 15.4.1996 / 15:33:28 / cg"
+ "Created: 15.4.1996 / 15:40:17 / cg"
+!
+
readLineNumberTableAttributeFor:aJavaMethod
|attribute_length line_number_table_length line_number_table|
@@ -1199,6 +1230,6 @@
!JavaClassReader class methodsFor:'documentation'!
version
- ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaClassReader.st,v 1.26 1996/06/26 08:39:43 cg Exp $'
+ ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaClassReader.st,v 1.27 1996/06/27 14:24:39 cg Exp $'
! !
JavaClassReader initialize!
--- a/JavaField.st Thu Jun 27 07:12:53 1996 +0000
+++ b/JavaField.st Thu Jun 27 14:25:32 1996 +0000
@@ -87,16 +87,20 @@
!
-isThreadsafe
+isTransient
+ ^ (accessFlags bitAnd:16r0080) ~~ 0
+!
+
+isVolatile
^ (accessFlags bitAnd:16r0040) ~~ 0
!
-isTransient
- ^ (accessFlags bitAnd:16r0080) ~~ 0
+type
+ ^ JavaMethod typeFromSignature:signature
! !
-!JavaField class methodsFor:'documentation'!
+!JavaField class methodsFor:'documentation'!
version
- ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaField.st,v 1.7 1996/05/07 09:54:47 cg Exp $'
+ ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaField.st,v 1.8 1996/06/27 14:24:10 cg Exp $'
! !
--- a/JavaFieldref.st Thu Jun 27 07:12:53 1996 +0000
+++ b/JavaFieldref.st Thu Jun 27 14:25:32 1996 +0000
@@ -16,11 +16,11 @@
!JavaFieldref methodsFor:'resolving'!
isDouble
- ^ (JavaMethod returnTypeFromSignature:nameandType signature) == #double
+ ^ (JavaMethod typeFromSignature:nameandType signature) == #double
!
isLong
- ^ (JavaMethod returnTypeFromSignature:nameandType signature) == #long
+ ^ (JavaMethod typeFromSignature:nameandType signature) == #long
!
name
@@ -42,7 +42,7 @@
nm := nameandType name asSymbol.
sig := nameandType signature.
- type := JavaMethod returnTypeFromSignature:sig.
+ type := JavaMethod typeFromSignature:sig.
offset := class instVarOffsetOf:nm.
^ offset.
!
@@ -80,12 +80,12 @@
sig := nameandType signature.
- type := JavaMethod returnTypeFromSignature:sig.
+ type := JavaMethod typeFromSignature:sig.
^ type.
! !
!JavaFieldref class methodsFor:'documentation'!
version
- ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaFieldref.st,v 1.9 1996/06/26 15:54:07 cg Exp $'
+ ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaFieldref.st,v 1.10 1996/06/27 14:24:23 cg Exp $'
! !
--- a/JavaMethod.st Thu Jun 27 07:12:53 1996 +0000
+++ b/JavaMethod.st Thu Jun 27 14:25:32 1996 +0000
@@ -1,6 +1,7 @@
CompiledCode subclass:#JavaMethod
instanceVariableNames:'javaByteCode numArgs numLocals returnType accessFlags name
- signature exceptionTable lineNumberTable javaClass numStack'
+ signature exceptionHandlerTable exceptionTable lineNumberTable
+ localVariableTable javaClass numStack'
classVariableNames:'SignatureTypeCodes'
poolDictionaries:''
category:'Java-Classes'
@@ -214,7 +215,7 @@
returnsVoidFromSignature:aSignature
"given a signature, return true if it returns void, false if not"
- ^ (self returnTypeFromSignature:aSignature) = 'void'
+ ^ (self typeFromSignature:aSignature) = 'void'
"
JavaMethod returnsVoidFromSignature:'(LObject;)V'
@@ -253,6 +254,37 @@
JavaMethod specFromSignature:'(LObject;)V' withName:'foo'
JavaMethod specFromSignature:'(BB)S' withName:'foo'
"
+!
+
+typeFromSignature:aSignature
+ "given a signature, return its type as a string"
+
+ |s c argSpec retvalSpec|
+
+ s := aSignature readStream.
+ (c := s peek) ~~ $( ifTrue:[
+ c == $' ifTrue:[
+ s next.
+ [s peek ~= $'] whileTrue:[s next].
+ s next.
+ ^ (self retvalSpecFromStream:s)
+ ].
+ ^ (self retvalSpecFromStream:s)
+ ].
+
+ s next.
+ self argSpecFromStream:s.
+ s next ~~ $) ifTrue:[self halt. ^ nil].
+
+ ^ (self retvalSpecFromStream:s)
+
+ "
+ JavaMethod typeFromSignature:'(LObject;)V'
+ JavaMethod typeFromSignature:'(BB)S'
+ JavaMethod typeFromSignature:'()J'
+ JavaMethod typeFromSignature:'J'
+ JavaMethod typeFromSignature:'''first''J'
+ "
! !
!JavaMethod methodsFor:'accessing'!
@@ -276,6 +308,13 @@
^ s contents
!
+exceptionTable
+ ^ exceptionTable
+
+ "Created: 16.4.1996 / 12:34:04 / cg"
+ "Modified: 16.4.1996 / 12:49:06 / cg"
+!
+
javaByteCode
^ javaByteCode
@@ -360,6 +399,12 @@
!
+setExceptionHandlerTable:anArray
+ exceptionHandlerTable := anArray.
+
+ "Created: 16.4.1996 / 12:34:04 / cg"
+!
+
setExceptionTable:anArray
exceptionTable := anArray.
@@ -381,7 +426,7 @@
!
setLocalVariableTable:anArray
- "/ localVariableTable := anArray.
+ localVariableTable := anArray.
!
setName:aString
@@ -394,7 +439,7 @@
signature := aString asSymbol.
self numberOfMethodArgs:(self class numArgsFromSignature:aString).
- returnType := self class returnTypeFromSignature:aString.
+ returnType := self class typeFromSignature:aString.
"Created: 16.4.1996 / 11:34:29 / cg"
!
@@ -454,8 +499,8 @@
!JavaMethod methodsFor:'queries'!
hasHandlerFor:anException at:pc
- exceptionTable isNil ifTrue:[^ false].
- exceptionTable do:[:entry |
+ exceptionHandlerTable isNil ifTrue:[^ false].
+ exceptionHandlerTable do:[:entry |
|hpc|
hpc := entry handlerPCFor:anException at:pc in:self.
@@ -535,9 +580,11 @@
text keysAndValuesDo:[:lineNr :line |
|nr|
- nr := Integer readFrom:line onError:0.
- nr >= pc ifTrue:[
- ^ lineNr
+ (line startsWith:' ') ifFalse:[
+ nr := Integer readFrom:line onError:0.
+ nr >= pc ifTrue:[
+ ^ lineNr
+ ]
]
].
^ num
@@ -556,6 +603,6 @@
!JavaMethod class methodsFor:'documentation'!
version
- ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaMethod.st,v 1.18 1996/06/26 15:54:18 cg Exp $'
+ ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaMethod.st,v 1.19 1996/06/27 14:23:45 cg Exp $'
! !
JavaMethod initialize!
--- a/JavaObject.st Thu Jun 27 07:12:53 1996 +0000
+++ b/JavaObject.st Thu Jun 27 14:25:32 1996 +0000
@@ -210,6 +210,32 @@
^ JavaObject convertJavaObject:val signature:(aJavaMethod retValSignature)
+!
+
+invokeJavaMethod:aJavaMethod with:arg1 with:arg2 with:arg3 with:arg4
+ "invoke a java method, with 4 arguments.
+ CAVEAT: these cannot be long or doubles currently."
+
+ |i val|
+
+ aJavaMethod numArgs ~~ 4 ifTrue:[
+ self halt:'argument count'
+ ].
+ aJavaMethod isStatic ifTrue:[
+ self halt:'static function'
+ ].
+
+ i := JavaInterpreter new.
+ i push:self.
+ i push:arg1.
+ i push:arg2.
+ i push:arg3.
+ i push:arg4.
+
+ val := i interpret:aJavaMethod sender:thisContext sender.
+
+ ^ JavaObject convertJavaObject:val signature:(aJavaMethod retValSignature)
+
! !
!JavaObject methodsFor:'printing & storing'!
@@ -389,6 +415,77 @@
"
!
+invoke:selector with:arg1 with:arg2 with:arg3 with:arg4
+ "send a message, with 4 arguments.
+ TEMPORARY: This method needs more work."
+
+ |sel method cls argClass jSel |
+
+ sel := selector asSymbolIfInterned.
+ sel notNil ifTrue:[
+"/ "/
+"/ "/ hard to do - must find a matching method probably
+"/ "/
+"/ (argument isKindOf:JavaObject) ifTrue:[
+"/ argClass := argument class.
+"/ ] ifFalse:[
+"/ "/
+"/ "/ map to Java:
+"/ "/ String -> [c
+"/ "/
+"/ (argument isMemberOf:String) ifTrue:[
+"/ jSel := (selector , '([C)V') asSymbolIfInterned.
+"/ jSel notNil ifTrue:[
+"/ ^ self invokeJava:jSel with:argument
+"/ ]
+"/ ]
+"/ ].
+
+ method := self lookupMethod:sel numArgs:4.
+ method notNil ifTrue:[
+ ^ self invokeJavaMethod:method with:arg1 with:arg2 with:arg3 with:arg4
+ ].
+
+"/ cls := self class.
+"/ [cls notNil and:[cls ~~ JavaObject]] whileTrue:[
+"/ cls methodDictionary keysAndValuesDo:[:sel :aMethod |
+"/ aMethod name == sel ifTrue:[
+"/ aMethod numArgs == 1 ifTrue:[
+"/ "/
+"/ "/ this is not completely correct:
+"/ "/ must look for the best type-match,
+"/ "/ (especially: have to look for best match
+"/ "/ over whole superclass chain ...)
+"/ "/ for now take the first with matching number of args
+"/ "/
+"/ ^ self invokeJavaMethod:aMethod with:argument
+"/ ]
+"/ ]
+"/ ].
+"/ cls := cls superclass.
+"/ ].
+ ].
+
+ ^ self doesNotUnderstand:(Message selector:selector)
+
+ "
+ |stack|
+
+ stack := (Java at:'java/util/Stack') new.
+ stack invoke:#push with:1.
+ "
+ "
+ |stack|
+
+ stack := (Java at:'java/util/Stack') new.
+ stack invoke:#push with:1.
+ stack invoke:#push with:2.
+ stack invoke:#pop.
+ stack invoke:#pop.
+ stack invoke:#pop.
+ "
+!
+
lookupMethod:selector numArgs:nargs
"lookup a method"
@@ -428,5 +525,5 @@
!JavaObject class methodsFor:'documentation'!
version
- ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaObject.st,v 1.14 1996/06/26 12:00:30 cg Exp $'
+ ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaObject.st,v 1.15 1996/06/27 14:25:32 cg Exp $'
! !
--- a/JavaUnresolvedClassConstant.st Thu Jun 27 07:12:53 1996 +0000
+++ b/JavaUnresolvedClassConstant.st Thu Jun 27 14:25:32 1996 +0000
@@ -54,9 +54,9 @@
displayString
fullName isNil ifTrue:[
- ^ 'Unresolved(** nil **)'
+ ^ 'UnresolvedClass(** nil **)'
].
- ^ 'Unresolved(' , (fullName copy replaceAll:$/ by:$.) , ')'
+ ^ 'UnresolvedClass(' , (fullName copy replaceAll:$/ by:$.) , ')'
! !
!JavaUnresolvedClassConstant methodsFor:'resolving'!
@@ -126,5 +126,5 @@
!JavaUnresolvedClassConstant class methodsFor:'documentation'!
version
- ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaUnresolvedClassConstant.st,v 1.12 1996/06/25 19:55:27 cg Exp $'
+ ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaUnresolvedClassConstant.st,v 1.13 1996/06/27 14:25:01 cg Exp $'
! !
--- a/JavaUnresolvedConstant.st Thu Jun 27 07:12:53 1996 +0000
+++ b/JavaUnresolvedConstant.st Thu Jun 27 14:25:32 1996 +0000
@@ -6,7 +6,7 @@
!
-!JavaUnresolvedConstant class methodsFor:'instance creation'!
+!JavaUnresolvedConstant class methodsFor:'instance creation'!
index:index
^ self new index:index
@@ -14,7 +14,7 @@
! !
-!JavaUnresolvedConstant class methodsFor:'resolving'!
+!JavaUnresolvedConstant class methodsFor:'resolving'!
resolve:aPossiblyUnresolvedConstant from:aConstantTable
(aPossiblyUnresolvedConstant isKindOf:JavaUnresolvedConstant) ifTrue:[
@@ -32,8 +32,16 @@
"Created: 15.4.1996 / 15:59:45 / cg"
! !
-!JavaUnresolvedConstant class methodsFor:'documentation'!
+!JavaUnresolvedConstant methodsFor:'printing & storing'!
+
+displayString
+ ^ 'Unresolved( idx= ' , index printString , ')'
+
+
+! !
+
+!JavaUnresolvedConstant class methodsFor:'documentation'!
version
- ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaUnresolvedConstant.st,v 1.1 1996/04/15 14:58:30 cg Exp $'
+ ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaUnresolvedConstant.st,v 1.2 1996/06/27 14:25:11 cg Exp $'
! !