--- a/JavaUnresolvedClassConstant.st Fri Jun 28 21:39:41 1996 +0000
+++ b/JavaUnresolvedClassConstant.st Fri Jun 28 21:39:53 1996 +0000
@@ -1,5 +1,5 @@
JavaUnresolvedConstant subclass:#JavaUnresolvedClassConstant
- instanceVariableNames:'fullName pool poolIndex'
+ instanceVariableNames:'nameIndex fullName'
classVariableNames:''
poolDictionaries:''
category:'Java-Reader-Support'
@@ -9,11 +9,18 @@
!JavaUnresolvedClassConstant class methodsFor:'instance creation'!
fullName:nm
- ^ self new fullName:nm
+ |ref|
+
+ ref := Java unresolvedClassRefFor:nm.
+ ref notNil ifTrue:[^ ref].
+
+ ref := self new fullName:nm.
+ Java rememberUnresolved:ref.
+ ^ ref
!
-nameIndex:index pool:aConstantPool slotIndex:slotIndex
- ^ self new index:index pool:aConstantPool slotIndex:slotIndex
+pool:aPool poolIndex:slotIndex nameIndex:index
+ ^ self new pool:aPool poolIndex:slotIndex nameIndex:index
! !
!JavaUnresolvedClassConstant methodsFor:'accessing'!
@@ -36,17 +43,35 @@
fullName
^ fullName
-!
+! !
+
+!JavaUnresolvedClassConstant ignoredMethodsFor:'accessing'!
fullName:nm
fullName := nm
+! !
+
+!JavaUnresolvedClassConstant methodsFor:'accessing'!
+
+javaClass
+ |cls|
+
+ fullName isNil ifTrue:[
+ self halt.
+ ].
+ cls := Java at:fullName.
+ cls notNil ifTrue:[^ cls].
+
+(' *** late loading: ' , fullName) infoPrintCR.
+ ^ JavaClassReader loadClass:fullName.
+
!
-index:index pool:aConstantPool slotIndex:slotIndex
- super index:index.
- pool := aConstantPool.
- poolIndex := slotIndex.
+pool:aPool poolIndex:slotIndex nameIndex:name_index
+ constantPool := aPool.
+ constantPoolIndex := slotIndex.
+ nameIndex := name_index.
! !
@@ -61,30 +86,102 @@
!JavaUnresolvedClassConstant methodsFor:'resolving'!
-resolve
- |cls|
+preResolve
+ |clsName cls nm s ref|
+
+ fullName isNil ifTrue:[
+ "/ first, resolve my name ...
+
+ clsName := constantPool at:nameIndex.
+ "/ DEBUGGING
+ clsName isString ifFalse:[
+ self halt:'oops - no class name string in const pool'.
+ ].
+
+ fullName := clsName
+ ].
+
+ "/ try to resolve the class
+
+ "/ 'resolve: ' print. fullName printCR.
cls := Java classNamed:fullName.
cls notNil ifTrue:[
- pool notNil ifTrue:[
- pool at:poolIndex put:cls
+ "/ good - the class is already loaded.
+
+ constantPool at:constantPoolIndex put:cls.
+ ^ cls
+ ].
+
+ (fullName startsWith:$[) ifTrue:[
+ "/ a ref for newarray or new
+
+ nm := JavaMethod retvalSpecFromStream:(ReadStream on:fullName).
+ [nm endsWith:'[]'] whileTrue:[
+ nm := nm copyWithoutLast:2
+ ].
+
+ cls := Java classNamed:nm.
+ cls notNil ifTrue:[
+ ref := JavaClassPointerRef class:cls nameandType:fullName.
+ constantPool at:constantPoolIndex put:ref.
+ ^ ref
].
] ifFalse:[
- Java rememberUnresolved:self.
+ nm := self className.
].
- ^ cls
+
+ self rememberForResolveWith:nm.
+ ^ self
+
+ "Created: 15.4.1996 / 15:51:42 / cg"
+ "Modified: 15.4.1996 / 16:26:05 / cg"
+! !
+
+!JavaUnresolvedClassConstant ignoredMethodsFor:'resolving'!
+
+resolve
+ |cls nm|
+
+ cls := Java at:fullName.
+ cls isNil ifTrue:[
+ nm := self className.
+ cls := Java at:nm.
+ ].
+ cls notNil ifTrue:[
+ constantPool notNil ifTrue:[
+ constantPool at:constantPoolIndex put:cls
+ ].
+ ^ cls
+ ].
+
+ Java rememberUnresolved:self.
+ ^ nil
"Created: 15.4.1996 / 15:51:42 / cg"
"Modified: 15.4.1996 / 16:26:05 / cg"
!
resolveClass
- |cls|
+ |cls nm|
- cls := Java classNamed:self className.
+ nm := self className.
+ cls := Java at:nm.
cls isNil ifTrue:[
- Java rememberUnresolved:self.
+ cls := JavaClassReader loadClass:nm.
+ cls isNil ifTrue:[
+ ('JAVA: unresolved class remains: ' , nm) errorPrintCR.
+ ^ nil.
+ ].
+"/ Java rememberUnresolved:self.
].
+
+ cls notNil ifTrue:[
+ constantPool notNil ifTrue:[
+ constantPool at:constantPoolIndex put:cls
+ ].
+ ].
+
^ cls
"Created: 15.4.1996 / 15:51:42 / cg"
@@ -92,9 +189,23 @@
!
resolveFrom:aConstantTable
- |cls nm s ref|
+ |clsName cls nm s ref|
+
+self halt.
+ fullName isNil ifTrue:[
+ "/ first, resolve my name ...
- fullName := self class resolve:(aConstantTable at:index) from:aConstantTable.
+ clsName := aConstantTable at:constantPoolIndex.
+ clsName isString ifTrue:[
+ fullName := clsName
+ ] ifFalse:[
+self halt:'oops - no class name string in const pool'.
+ fullName := self class resolve:clsName from:aConstantTable.
+ ].
+ ].
+
+ "/ try to resolve the class
+
"/ 'resolve: ' print. fullName printCR.
cls := Java classNamed:fullName.
@@ -117,6 +228,7 @@
Java rememberUnresolved:self.
^ self
+
"/ ^ JavaClass fullName:fullName
"Created: 15.4.1996 / 15:51:42 / cg"
@@ -126,5 +238,5 @@
!JavaUnresolvedClassConstant class methodsFor:'documentation'!
version
- ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaUnresolvedClassConstant.st,v 1.13 1996/06/27 14:25:01 cg Exp $'
+ ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaUnresolvedClassConstant.st,v 1.14 1996/06/28 21:39:12 cg Exp $'
! !