--- a/JavaUnresolvedClassConstant.st Fri Nov 22 21:09:21 2002 +0100
+++ b/JavaUnresolvedClassConstant.st Fri Nov 22 21:14:07 2002 +0100
@@ -1,10 +1,6 @@
"
- COPYRIGHT (c) 1996-2011 by Claus Gittinger
- COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
- SWING Research Group, Czech Technical University in Prague
-
- Parts of the code written by Claus Gittinger are under following
- license:
+ COPYRIGHT (c) 1997 by eXept Software AG
+ All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
@@ -12,33 +8,10 @@
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
-
- Parts of the code written at SWING Reasearch Group [1] are MIT licensed:
-
- Permission is hereby granted, free of charge, to any person
- obtaining a copy of this software and associated documentation
- files (the 'Software'), to deal in the Software without
- restriction, including without limitation the rights to use,
- copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the
- Software is furnished to do so, subject to the following
- conditions:
+"
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
- HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- OTHER DEALINGS IN THE SOFTWARE.
- [1] Code written at SWING Research Group contain a signature
- of one of the above copright owners.
-"
"{ Package: 'stx:libjava' }"
JavaUnresolvedConstant subclass:#JavaUnresolvedClassConstant
@@ -52,12 +25,8 @@
copyright
"
- COPYRIGHT (c) 1996-2011 by Claus Gittinger
- COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
- SWING Research Group, Czech Technical University in Prague
-
- Parts of the code written by Claus Gittinger are under following
- license:
+ COPYRIGHT (c) 1997 by eXept Software AG
+ All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
@@ -65,34 +34,9 @@
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
-
- Parts of the code written at SWING Reasearch Group [1] are MIT licensed:
-
- Permission is hereby granted, free of charge, to any person
- obtaining a copy of this software and associated documentation
- files (the 'Software'), to deal in the Software without
- restriction, including without limitation the rights to use,
- copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the
- Software is furnished to do so, subject to the following
- conditions:
+"
- The above copyright notice and this permission notice shall be
- included in all copies or substantial portions of the Software.
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
- HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- OTHER DEALINGS IN THE SOFTWARE.
-
- [1] Code written at SWING Research Group contain a signature
- of one of the above copright owners.
-
-"
! !
!JavaUnresolvedClassConstant class methodsFor:'instance creation'!
@@ -125,15 +69,6 @@
"Modified: / 4.2.1998 / 22:13:38 / cg"
! !
-!JavaUnresolvedClassConstant methodsFor:'* As yet uncategorized *'!
-
-javaClassForNew
-
- ^self javaClass
-
- "Created: / 16-03-2011 / 16:09:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-
!JavaUnresolvedClassConstant methodsFor:'accessing'!
className
@@ -179,9 +114,7 @@
!
javaClass
- | cls clsName |
-
- "/fullName first == $[ ifTrue:[self halt].
+ |clsName|
fullName isNil ifTrue:[
self preResolve.
@@ -189,41 +122,14 @@
self halt.
]
].
- (fullName first = $[)
- ifTrue:
- [cls := (JavaDescriptor fromString: fullName) javaClass]
- ifFalse:
- [cls := Java classForName:fullName].
- constantPool at: constantPoolIndex put: cls.
- ^cls
-
- "old code:"
- "
(fullName startsWith:$[) ifTrue:[
- self halt.
- clsName := self className.
- (Java classForName:clsName) ifNil:
- [self error: 'Cannot resolve class ' , clsName].
- cls := (JavaDescriptor fromString: fullName) javaClass.
+ clsName := self className
] ifFalse:[
clsName := fullName
].
- cls := Java classForName:clsName.
- constantPool at: constantPoolIndex put: cls.
- ^cls
- "
+ ^ Java classForName:clsName.
- "Modified: / 10-11-1998 / 19:29:28 / cg"
- "Modified: / 11-02-2011 / 07:53:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-lastName
-
- | idx |
- idx := fullName lastIndexOf: $/.
- ^idx ifNil:[fullName] ifNotNil:[fullName copyFrom: idx + 1].
-
- "Created: / 18-10-2010 / 22:20:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 10.11.1998 / 19:29:28 / cg"
!
name
@@ -332,7 +238,7 @@
!JavaUnresolvedClassConstant methodsFor:'resolving'!
preResolve
- |clsName cls nm ref|
+ |clsName cls nm s ref|
fullName isNil ifTrue:[
"/ first, resolve my name ...
@@ -342,62 +248,198 @@
clsName isString ifFalse:[
self halt:'oops - no class name string in const pool'.
].
+
fullName := clsName
].
"/ try to resolve the class
- (fullName size == 1) ifTrue:[
- "/ good - this is a primitive
- ref := JavaBuiltInClassPointerRef class:(JavaDescriptor fromString: fullName) javaClass nameandType:fullName.
- constantPool at:constantPoolIndex put:ref.
- ^ ref
+ "/ 'resolve: ' print. fullName printCR.
+
+ cls := Java classNamed:fullName.
+ cls notNil ifTrue:[
+ "/ good - the class is already loaded.
+
+ constantPool at:constantPoolIndex put:cls.
+ ^ cls
].
- (fullName includes:$[) ifFalse:[
- cls := Java classNamed:fullName.
- cls notNil ifTrue:[
- "/ good - the class is already loaded.
- constantPool at:constantPoolIndex put:cls.
- ^ cls
+ fullName size == 2 ifTrue:[
+ "/ look for specials like byte[], int[] etc.
+ "/ there are only a few of them - forgive me nameing them here ...
+ fullName = '[B' ifTrue:[ "/ byte[]
+ ref := JavaBuiltInClassPointerRef class:ByteArray nameandType:fullName.
+ constantPool at:constantPoolIndex put:ref.
+ ^ ref
+ ].
+ fullName = '[Z' ifTrue:[ "/ boolean[]
+ ref := JavaBuiltInClassPointerRef class:ByteArray nameandType:fullName.
+ constantPool at:constantPoolIndex put:ref.
+ ^ ref
+ ].
+ fullName = '[I' ifTrue:[ "/ int[]
+ ref := JavaBuiltInClassPointerRef class:SignedIntegerArray nameandType:fullName.
+ constantPool at:constantPoolIndex put:ref.
+ ^ ref
].
- ] ifTrue:[
- "
- Deal with Sun's malformed class refs generated by
- sun.misc.ProxyGenerator - it generates
- java/lang/annotation/ElementType[] instead of
- [Ljava/lang/annotation/ElementType[];
- as the spec requires!!
- "
- (fullName last == $] and:[(fullName at: fullName size - 1) == $[]) ifTrue:
- [fullName := '[L', (fullName copyTo: fullName size - 2) , ';'].
-
- (fullName includes: $L) ifFalse:[
- "/ good - this is a primitive array
- ref := JavaBuiltInClassPointerRef class:(JavaDescriptor fromString: fullName) javaClass nameandType:fullName.
+ fullName = '[J' ifTrue:[ "/ long[]
+ ref := JavaBuiltInClassPointerRef class:Array nameandType:fullName.
+ constantPool at:constantPoolIndex put:ref.
+ ^ ref
+ ].
+ fullName = '[S' ifTrue:[ "/ short[]
+ ref := JavaBuiltInClassPointerRef class:SignedWordArray nameandType:fullName.
+ constantPool at:constantPoolIndex put:ref.
+ ^ ref
+ ].
+ fullName = '[C' ifTrue:[ "/ char[]
+ "/ should be TwoByteString ...
+ ref := JavaBuiltInClassPointerRef class:String nameandType:fullName.
+ constantPool at:constantPoolIndex put:ref.
+ ^ ref
+ ].
+ fullName = '[F' ifTrue:[ "/ float[]
+ ref := JavaBuiltInClassPointerRef class:FloatArray nameandType:fullName.
+ constantPool at:constantPoolIndex put:ref.
+ ^ ref
+ ].
+ fullName = '[D' ifTrue:[ "/ double[]
+ ref := JavaBuiltInClassPointerRef class:DoubleArray nameandType:fullName.
constantPool at:constantPoolIndex put:ref.
^ ref
].
].
+ (fullName startsWith:$[) ifTrue:[
+ "/ a ref for newarray or new
- (fullName startsWith:$[) ifFalse:[
+ s := fullName readStream.
+ [s peek == $[ ] whileTrue:[
+ s next
+ ].
+ nm := s upToEnd.
+
+ (nm startsWith:$L) ifFalse:[
+ nm = 'F' ifTrue:[ "/ float[][]
+ ref := JavaBuiltInClassPointerRef class:Array nameandType:fullName.
+ constantPool at:constantPoolIndex put:ref.
+ ^ ref
+ ].
+ nm = 'D' ifTrue:[ "/ double[][]
+ ref := JavaBuiltInClassPointerRef class:Array nameandType:fullName.
+ constantPool at:constantPoolIndex put:ref.
+ ^ ref
+ ].
+ nm = 'I' ifTrue:[ "/ int[][]
+ ref := JavaBuiltInClassPointerRef class:Array nameandType:fullName.
+ constantPool at:constantPoolIndex put:ref.
+ ^ ref
+ ].
+ nm = 'C' ifTrue:[ "/ char[][]
+ ref := JavaBuiltInClassPointerRef class:Array nameandType:fullName.
+ constantPool at:constantPoolIndex put:ref.
+ ^ ref
+ ].
+ nm = 'B' ifTrue:[ "/ byte[][]
+ ref := JavaBuiltInClassPointerRef class:Array nameandType:fullName.
+ constantPool at:constantPoolIndex put:ref.
+ ^ ref
+ ].
+ nm = 'Z' ifTrue:[ "/ bool[][]
+ ref := JavaBuiltInClassPointerRef class:Array nameandType:fullName.
+ constantPool at:constantPoolIndex put:ref.
+ ^ ref
+ ].
+ nm = 'S' ifTrue:[ "/ short[][]
+ ref := JavaBuiltInClassPointerRef class:Array nameandType:fullName.
+ constantPool at:constantPoolIndex put:ref.
+ ^ ref
+ ].
+ self halt.
+ ].
+ nm := nm copyFrom:2.
+ (nm endsWith:$;) ifFalse:[
+ self halt.
+ ].
+ nm := nm copyWithoutLast:1.
+
+ cls := Java classNamed:nm.
+ cls notNil ifTrue:[
+ ref := JavaClassPointerRef class:cls nameandType:fullName.
+ constantPool at:constantPoolIndex put:ref.
+ ^ ref
+ ].
+ self rememberForResolveWith:nm.
+ ^ self.
+
+ nm := JavaMethod retvalSpecFromStream:(ReadStream on:fullName) in:nil.
+ [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
+ ].
+
+ (fullName startsWith:'[[') ifTrue:[
+ fullName = '[[F' ifTrue:[ "/ float[][]
+ ref := JavaBuiltInClassPointerRef class:Array nameandType:fullName.
+ constantPool at:constantPoolIndex put:ref.
+ ^ ref
+ ].
+ fullName = '[[D' ifTrue:[ "/ double[][]
+ ref := JavaBuiltInClassPointerRef class:Array nameandType:fullName.
+ constantPool at:constantPoolIndex put:ref.
+ ^ ref
+ ].
+ fullName = '[[I' ifTrue:[ "/ int[][]
+ ref := JavaBuiltInClassPointerRef class:Array nameandType:fullName.
+ constantPool at:constantPoolIndex put:ref.
+ ^ ref
+ ].
+ fullName = '[[C' ifTrue:[ "/ char[][]
+ ref := JavaBuiltInClassPointerRef class:Array nameandType:fullName.
+ constantPool at:constantPoolIndex put:ref.
+ ^ ref
+ ].
+ fullName = '[[B' ifTrue:[ "/ byte[][]
+ ref := JavaBuiltInClassPointerRef class:Array nameandType:fullName.
+ constantPool at:constantPoolIndex put:ref.
+ ^ ref
+ ].
+ fullName = '[[Z' ifTrue:[ "/ bool[][]
+ ref := JavaBuiltInClassPointerRef class:Array nameandType:fullName.
+ constantPool at:constantPoolIndex put:ref.
+ ^ ref
+ ].
+ fullName = '[[S' ifTrue:[ "/ short[][]
+ ref := JavaBuiltInClassPointerRef class:Array nameandType:fullName.
+ constantPool at:constantPoolIndex put:ref.
+ ^ ref
+ ].
+ ].
+ (fullName startsWith:'[L') ifFalse:[
+ (fullName startsWith:'[[L') ifFalse:[
+ ('JAVA: oops - unresolvable funny class: ' , fullName) errorPrintCR.
+ self halt.
+ ]
+ ]
+ ] ifFalse:[
nm := self className.
- self rememberForResolveWith:nm.
].
+
+ self rememberForResolveWith:nm.
^ self
- "Created: / 15-04-1996 / 15:51:42 / cg"
- "Modified: / 06-07-1999 / 23:41:04 / cg"
- "Modified: / 11-02-2011 / 10:41:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Created: / 15.4.1996 / 15:51:42 / cg"
+ "Modified: / 6.7.1999 / 23:41:04 / cg"
! !
!JavaUnresolvedClassConstant class methodsFor:'documentation'!
version
- ^ '$Id: JavaUnresolvedClassConstant.st,v 1.44 2011/08/18 18:42:48 vrany Exp $'
-!
-
-version_SVN
- ^ '$Id: JavaUnresolvedClassConstant.st,v 1.44 2011/08/18 18:42:48 vrany Exp $'
-! !
\ No newline at end of file
+ ^ '$Header: /cvs/stx/stx/libjava/JavaUnresolvedClassConstant.st,v 1.43 2002-11-22 20:11:24 cg Exp $'
+! !