JavaClass.st
changeset 2118 b73d5b8e93c0
parent 2107 f4509f6767fa
child 2143 4fe17c2f531c
equal deleted inserted replaced
2117:b3671565853d 2118:b73d5b8e93c0
     1 "
     1 "
     2  COPYRIGHT (c) 1997 by eXept Software AG
     2  COPYRIGHT (c) 1997 by eXept Software AG
     3               All Rights Reserved
     3 	      All Rights Reserved
     4 
     4 
     5  This software is furnished under a license and may be used
     5  This software is furnished under a license and may be used
     6  only in accordance with the terms of that license and with the
     6  only in accordance with the terms of that license and with the
     7  inclusion of the above copyright notice.   This software may not
     7  inclusion of the above copyright notice.   This software may not
     8  be provided or otherwise made available to, or used by, any
     8  be provided or otherwise made available to, or used by, any
     9  other person.  No title to or ownership of the software is
     9  other person.  No title to or ownership of the software is
    10  hereby transferred.
    10  hereby transferred.
    11 "
    11 "
    12 
    12 
    13 
       
    14 
       
    15 
       
    16 "{ Package: 'stx:libjava' }"
    13 "{ Package: 'stx:libjava' }"
    17 
    14 
    18 Class subclass:#JavaClass
    15 JavaBehavior subclass:#JavaClass
    19 	instanceVariableNames:'constantPool interfaces accessFlags classLoader fullName
    16 	instanceVariableNames:'classLoader fullName
    20 		sourceFile binaryFilePath fields initValues staticFields'
    17 		sourceFile binaryFilePath fields initValues staticFields'
    21 	classVariableNames:'InitialValuePerType A_OBSOLETE A_INTERFACE A_PUBLIC A_FINAL
    18 	classVariableNames:'ArgumentConversionErrorSignal OrderOfClassInits'
    22 		A_ABSTRACT A_INITIALIZED A_SMALLTALK A_ABSTRACT_OR_INTERFACE
       
    23 		A_STATIC A_NATIVE ArgumentConversionErrorSignal OrderOfClassInits'
       
    24 	poolDictionaries:''
    19 	poolDictionaries:''
    25 	category:'Languages-Java-Classes'
    20 	category:'Languages-Java-Classes'
    26 !
    21 !
    27 
    22 
    28 !JavaClass class methodsFor:'documentation'!
    23 !JavaClass class methodsFor:'documentation'!
    29 
    24 
    30 copyright
    25 copyright
    31 "
    26 "
    32  COPYRIGHT (c) 1997 by eXept Software AG
    27  COPYRIGHT (c) 1997 by eXept Software AG
    33               All Rights Reserved
    28 	      All Rights Reserved
    34 
    29 
    35  This software is furnished under a license and may be used
    30  This software is furnished under a license and may be used
    36  only in accordance with the terms of that license and with the
    31  only in accordance with the terms of that license and with the
    37  inclusion of the above copyright notice.   This software may not
    32  inclusion of the above copyright notice.   This software may not
    38  be provided or otherwise made available to, or used by, any
    33  be provided or otherwise made available to, or used by, any
    39  other person.  No title to or ownership of the software is
    34  other person.  No title to or ownership of the software is
    40  hereby transferred.
    35  hereby transferred.
    41 "
    36 "
    42 
       
    43 
       
    44 
       
    45 !
    37 !
    46 
    38 
    47 documentation
    39 documentation
    48 "
    40 "
    49     fields upTo-and-including accessFlags are known & used by the VM
    41     fields upTo-and-including accessFlags are known & used by the VM
    56     (Java at:'java.util.Stack') new inspect
    48     (Java at:'java.util.Stack') new inspect
    57     (Java at:'java.util.Vector') new inspect
    49     (Java at:'java.util.Vector') new inspect
    58 "
    50 "
    59 ! !
    51 ! !
    60 
    52 
    61 !JavaClass class methodsFor:'initialization'!
       
    62 
       
    63 initialize
       
    64     "/ those are defined in Java and read from the classFile
       
    65     A_PUBLIC      := 16r000001.
       
    66     "/ A_PRIVATE     := 16r000002.
       
    67     "/ A_PROTECTED   := 16r000004.
       
    68     A_STATIC      := 16r000008.
       
    69     A_FINAL       := 16r000010.
       
    70     "/ A_SUPER         := 16r000020.
       
    71     "/ A_SYNCHRONIZED  := 16r000020.
       
    72     "/ A_VOLATILE      := 16r000040.
       
    73     "/ A_TRANSIENT     := 16r000080.
       
    74     A_NATIVE        := 16r000100.
       
    75 
       
    76     A_INTERFACE   := 16r000200.
       
    77     A_ABSTRACT    := 16r000400.
       
    78     A_OBSOLETE    := 16r008000.
       
    79 
       
    80     "/ those are local to the ST/X implementation
       
    81     A_INITIALIZED := 16r100000.
       
    82     A_SMALLTALK   := 16r200000.
       
    83 
       
    84     A_ABSTRACT_OR_INTERFACE := A_ABSTRACT bitOr:A_INTERFACE.
       
    85 
       
    86     InitialValuePerType := IdentityDictionary new.
       
    87     InitialValuePerType at:$B put:0.
       
    88     InitialValuePerType at:$C put:0.
       
    89     InitialValuePerType at:$D put:0.0.
       
    90     InitialValuePerType at:$F put:(0.0 asShortFloat).
       
    91     InitialValuePerType at:$I put:0.
       
    92     InitialValuePerType at:$J put:0.
       
    93     InitialValuePerType at:$S put:0.
       
    94     InitialValuePerType at:$Z put:0.
       
    95     InitialValuePerType at:$L put:nil.
       
    96     InitialValuePerType at:$[ put:nil.
       
    97 
       
    98     ArgumentConversionErrorSignal := ErrorSignal newSignal mayProceed:true.
       
    99 
       
   100     "
       
   101      JavaClass initialize
       
   102     "
       
   103 
       
   104     "Modified: / 13.11.1998 / 14:09:52 / cg"
       
   105 ! !
       
   106 
       
   107 !JavaClass class methodsFor:'instance creation'!
    53 !JavaClass class methodsFor:'instance creation'!
   108 
    54 
   109 fullName:aString
    55 fullName:aString
   110     self shouldNotImplement.
    56     self shouldNotImplement.
   111     ^ self new flags:0; setFullName:aString
    57     ^ self new flags:0; setFullName:aString
   115 fullName:aString numStatic:nStatic
    61 fullName:aString numStatic:nStatic
   116     |meta cls s ns nameComponents|
    62     |meta cls s ns nameComponents|
   117 
    63 
   118     "/ check for a JAVA nameSpace to exist
    64     "/ check for a JAVA nameSpace to exist
   119     JAVA isNil ifTrue:[
    65     JAVA isNil ifTrue:[
   120         NameSpace name:'JAVA'
    66 	NameSpace name:'JAVA'
   121     ].
    67     ].
   122 
    68 
   123     "create the metaclass first"
    69     "create the metaclass first"
   124 
    70 
   125     meta := Metaclass new.
    71     meta := Metaclass new.
   146     "/ simulate one by separating its name into individual components,
    92     "/ simulate one by separating its name into individual components,
   147     "/ prepending 'java'"
    93     "/ prepending 'java'"
   148 
    94 
   149     nameComponents := aString asCollectionOfSubstringsSeparatedBy:$/.
    95     nameComponents := aString asCollectionOfSubstringsSeparatedBy:$/.
   150     nameComponents size > 1 ifTrue:[
    96     nameComponents size > 1 ifTrue:[
   151         cls category:((nameComponents asStringWith:$/ from:1 to:(nameComponents size - 1))
    97 	cls category:((nameComponents asStringWith:$/ from:1 to:(nameComponents size - 1))
   152                             replaceAll:$/ with:$. ).
    98 			    replaceAll:$/ with:$. ).
   153     ].
    99     ].
   154 
   100 
   155     nameComponents size > 1 ifTrue:[
   101     nameComponents size > 1 ifTrue:[
   156         cls setPackage:((nameComponents copyWithoutLast:1) asStringWith:$/) asSymbol
   102 	cls setPackage:((nameComponents copyWithoutLast:1) asStringWith:$/) asSymbol
   157     ] ifFalse:[
   103     ] ifFalse:[
   158         cls setPackage:aString asSymbol
   104 	cls setPackage:aString asSymbol
   159     ].
   105     ].
   160 
   106 
   161     "/ break up the package and create nameSpaces
   107     "/ break up the package and create nameSpaces
   162     "/ for each package component.
   108     "/ for each package component.
   163     "/ This allows java.foo.bar to be visible in ST/X
   109     "/ This allows java.foo.bar to be visible in ST/X
   164     "/ under the name JAVA::java::foo::bar
   110     "/ under the name JAVA::java::foo::bar
   165 
   111 
   166     ns := JAVA.
   112     ns := JAVA.
   167 
   113 
   168     nameComponents size > 1 ifTrue:[
   114     nameComponents size > 1 ifTrue:[
   169         s := '' writeStream.
   115 	s := '' writeStream.
   170         s nextPutAll:'JAVA'.
   116 	s nextPutAll:'JAVA'.
   171         nameComponents from:1 to:(nameComponents size - 1) do:[:aPart |
   117 	nameComponents from:1 to:(nameComponents size - 1) do:[:aPart |
   172             s nextPutAll:'::'.
   118 	    s nextPutAll:'::'.
   173             s nextPutAll:aPart
   119 	    s nextPutAll:aPart
   174         ].
   120 	].
   175         Metaclass confirmationQuerySignal answer:false do:[
   121 	Metaclass confirmationQuerySignal answer:false do:[
   176             Class updateChangeFileQuerySignal answer:false do:[
   122 	    Class updateChangeFileQuerySignal answer:false do:[
   177                 ns := NameSpace fullName:(s contents).
   123 		ns := NameSpace fullName:(s contents).
   178             ]
   124 	    ]
   179         ]
   125 	]
   180     ].
   126     ].
   181     ns isNameSpace ifTrue:[
   127     ns isNameSpace ifTrue:[
   182         ns at:nameComponents last asSymbol put:cls.
   128 	ns at:nameComponents last asSymbol put:cls.
   183     ].
   129     ].
   184 
   130 
   185     "/ for ST/X browsing
   131     "/ for ST/X browsing
   186     Smalltalk at:('JAVA::' , aString) asSymbol put:cls.
   132     Smalltalk at:('JAVA::' , aString) asSymbol put:cls.
   187 
   133 
   195     self shouldNotImplement
   141     self shouldNotImplement
   196 
   142 
   197     "Created: 15.4.1996 / 15:52:55 / cg"
   143     "Created: 15.4.1996 / 15:52:55 / cg"
   198 ! !
   144 ! !
   199 
   145 
   200 !JavaClass class methodsFor:'constants'!
       
   201 
       
   202 A_NATIVE
       
   203     ^ A_NATIVE
       
   204 
       
   205     "Created: / 16.5.1998 / 01:18:43 / cg"
       
   206 !
       
   207 
       
   208 A_PUBLIC
       
   209     ^ A_PUBLIC
       
   210 
       
   211     "Created: / 13.5.1998 / 13:03:18 / cg"
       
   212 !
       
   213 
       
   214 A_STATIC
       
   215     ^ A_STATIC
       
   216 
       
   217     "Created: / 16.5.1998 / 00:02:07 / cg"
       
   218 ! !
       
   219 
       
   220 !JavaClass class methodsFor:'method lookup'!
   146 !JavaClass class methodsFor:'method lookup'!
   221 
   147 
   222 canConvertArgsToJava:argArray asSpecifiedIn:argSigSpecArray
   148 canConvertArgsToJava:argArray asSpecifiedIn:argSigSpecArray
   223     "given a smalltalk argument array, return true, if these can be converted to java objects as appropriate."
   149     "given a smalltalk argument array, return true, if these can be converted to java objects as appropriate."
   224 
   150 
   225     argArray 
   151     argArray
   226         with:argSigSpecArray 
   152 	with:argSigSpecArray
   227         do:[:arg :type | 
   153 	do:[:arg :type |
   228                 self 
   154 		self
   229                     convertToJava:arg 
   155 		    convertToJava:arg
   230                     type:type 
   156 		    type:type
   231                     ifFail:[:msg :default| ^ false]].
   157 		    ifFail:[:msg :default| ^ false]].
   232     ^ true
   158     ^ true
   233 
   159 
   234     "Created: / 5.11.1998 / 18:25:05 / cg"
   160     "Created: / 5.11.1998 / 18:25:05 / cg"
   235     "Modified: / 6.11.1998 / 00:45:58 / cg"
   161     "Modified: / 6.11.1998 / 00:45:58 / cg"
   236 !
   162 !
   243 
   169 
   244     sigIndex := newArgIndex := 1.
   170     sigIndex := newArgIndex := 1.
   245 
   171 
   246     newArgArray := Array new:na.
   172     newArgArray := Array new:na.
   247     argArray do:[:arg |
   173     argArray do:[:arg |
   248         |type newArg|
   174 	|type newArg|
   249 
   175 
   250         type := argSigSpecArray at:sigIndex.
   176 	type := argSigSpecArray at:sigIndex.
   251         sigIndex := sigIndex + 1.
   177 	sigIndex := sigIndex + 1.
   252         newArg := self convertToJava:arg type:type.
   178 	newArg := self convertToJava:arg type:type.
   253         newArgArray at:newArgIndex put:newArg.
   179 	newArgArray at:newArgIndex put:newArg.
   254         newArgIndex := newArgIndex + 1.
   180 	newArgIndex := newArgIndex + 1.
   255         (type == #long or:[type == #double]) ifTrue:[
   181 	(type == #long or:[type == #double]) ifTrue:[
   256             newArgIndex > na ifTrue:[
   182 	    newArgIndex > na ifTrue:[
   257                 self halt:'should not happen'
   183 		self halt:'should not happen'
   258             ].
   184 	    ].
   259             newArgArray at:newArgIndex put:nil.
   185 	    newArgArray at:newArgIndex put:nil.
   260             newArgIndex := newArgIndex + 1.
   186 	    newArgIndex := newArgIndex + 1.
   261         ]
   187 	]
   262     ].
   188     ].
   263 
   189 
   264     ^ newArgArray
   190     ^ newArgArray
   265 
   191 
   266     "Created: / 5.11.1998 / 18:30:57 / cg"
   192     "Created: / 5.11.1998 / 18:30:57 / cg"
   268 !
   194 !
   269 
   195 
   270 convertToJava:arg type:type
   196 convertToJava:arg type:type
   271     "given a smalltalk argument, convert to a java object as appropriate."
   197     "given a smalltalk argument, convert to a java object as appropriate."
   272 
   198 
   273     ^ self 
   199     ^ self
   274         convertToJava:arg 
   200 	convertToJava:arg
   275         type:type 
   201 	type:type
   276         ifFail:[:msg :default |
   202 	ifFail:[:msg :default |
   277                     ArgumentConversionErrorSignal 
   203 		    ArgumentConversionErrorSignal
   278                         raiseWith:arg
   204 			raiseWith:arg
   279                         errorString:msg.
   205 			errorString:msg.
   280                     default
   206 		    default
   281                ]
   207 	       ]
   282 
   208 
   283     "Modified: / 5.11.1998 / 18:43:33 / cg"
   209     "Modified: / 5.11.1998 / 18:43:33 / cg"
   284     "Created: / 6.11.1998 / 00:45:13 / cg"
   210     "Created: / 6.11.1998 / 00:45:13 / cg"
   285 !
   211 !
   286 
   212 
   289      Currently, only a few types are converted."
   215      Currently, only a few types are converted."
   290 
   216 
   291     |expectedCls f failValue|
   217     |expectedCls f failValue|
   292 
   218 
   293     type == #boolean ifTrue:[
   219     type == #boolean ifTrue:[
   294         arg == true ifTrue:[
   220 	arg == true ifTrue:[
   295             ^ 1
   221 	    ^ 1
   296         ].
   222 	].
   297         arg == false ifTrue:[
   223 	arg == false ifTrue:[
   298             ^ 0
   224 	    ^ 0
   299         ].
   225 	].
   300         ^ failBlock value:('cannot convert argument to ' , type) value:0
   226 	^ failBlock value:('cannot convert argument to ' , type) value:0
   301     ].
   227     ].
   302 
   228 
   303     type == #int ifTrue:[
   229     type == #int ifTrue:[
   304         arg isInteger ifTrue:[
   230 	arg isInteger ifTrue:[
   305             (arg between:-16r8000000 and:16r7FFFFFFF) ifTrue:[
   231 	    (arg between:-16r8000000 and:16r7FFFFFFF) ifTrue:[
   306                 ^ arg
   232 		^ arg
   307             ].
   233 	    ].
   308             ^ failBlock value:('integer range; cannot convert argument to ' , type) value:0.
   234 	    ^ failBlock value:('integer range; cannot convert argument to ' , type) value:0.
   309         ].
   235 	].
   310         ^ failBlock value:('cannot convert argument to ' , type) value:0
   236 	^ failBlock value:('cannot convert argument to ' , type) value:0
   311     ].
   237     ].
   312 
   238 
   313     type == #long ifTrue:[
   239     type == #long ifTrue:[
   314         arg isInteger ifTrue:[
   240 	arg isInteger ifTrue:[
   315             (arg between:-16r800000000000000 and:16r7FFFFFFFFFFFFFFF) ifTrue:[
   241 	    (arg between:-16r800000000000000 and:16r7FFFFFFFFFFFFFFF) ifTrue:[
   316                 ^ arg
   242 		^ arg
   317             ].
   243 	    ].
   318             ^ failBlock value:('integer range; cannot convert argument to ' , type) value:0
   244 	    ^ failBlock value:('integer range; cannot convert argument to ' , type) value:0
   319         ].
   245 	].
   320         ^ failBlock value:('cannot convert argument to ' , type) value:0
   246 	^ failBlock value:('cannot convert argument to ' , type) value:0
   321     ].
   247     ].
   322 
   248 
   323     (type == #float) ifTrue:[
   249     (type == #float) ifTrue:[
   324         arg isLimitedPrecisionReal ifTrue:[
   250 	arg isLimitedPrecisionReal ifTrue:[
   325             ^ arg asShortFloat
   251 	    ^ arg asShortFloat
   326         ].
   252 	].
   327         ^ failBlock value:('cannot convert argument to ' , type) value:0.0.
   253 	^ failBlock value:('cannot convert argument to ' , type) value:0.0.
   328     ].
   254     ].
   329 
   255 
   330     (type = 'java.lang.Float') ifTrue:[
   256     (type = 'java.lang.Float') ifTrue:[
   331         arg isLimitedPrecisionReal ifTrue:[
   257 	arg isLimitedPrecisionReal ifTrue:[
   332             f := (Java at:'java.lang.Float') new.
   258 	    f := (Java at:'java.lang.Float') new.
   333             f perform:#'<init>(F)V' with:(arg asShortFloat).
   259 	    f perform:#'<init>(F)V' with:(arg asShortFloat).
   334 self halt.
   260 self halt.
   335             ^ f.
   261 	    ^ f.
   336         ].
   262 	].
   337         ^ failBlock value:('cannot convert argument to ' , type) value:0.0.
   263 	^ failBlock value:('cannot convert argument to ' , type) value:0.0.
   338     ].
   264     ].
   339     (type = 'java.lang.Double') ifTrue:[
   265     (type = 'java.lang.Double') ifTrue:[
   340         arg isLimitedPrecisionReal ifTrue:[
   266 	arg isLimitedPrecisionReal ifTrue:[
   341             f := (Java at:'java.lang.Double') new.
   267 	    f := (Java at:'java.lang.Double') new.
   342             f perform:#'<init>(D)V' with:(arg asFloat).
   268 	    f perform:#'<init>(D)V' with:(arg asFloat).
   343 self halt.
   269 self halt.
   344             ^ f.
   270 	    ^ f.
   345         ].
   271 	].
   346         ^ failBlock value:('cannot convert argument to ' , type) value:0.0.
   272 	^ failBlock value:('cannot convert argument to ' , type) value:0.0.
   347     ].
   273     ].
   348 
   274 
   349     (type == #double) ifTrue:[
   275     (type == #double) ifTrue:[
   350         arg isLimitedPrecisionReal ifTrue:[
   276 	arg isLimitedPrecisionReal ifTrue:[
   351             ^ arg asFloat
   277 	    ^ arg asFloat
   352         ].
   278 	].
   353         ^ failBlock value:('cannot convert argument to ' , type) value:0.0.
   279 	^ failBlock value:('cannot convert argument to ' , type) value:0.0.
   354     ].
   280     ].
   355 
   281 
   356     (type == #char) ifTrue:[
   282     (type == #char) ifTrue:[
   357         arg isCharacter ifTrue:[
   283 	arg isCharacter ifTrue:[
   358             ^ arg asciiValue
   284 	    ^ arg asciiValue
   359         ].
   285 	].
   360         ^ failBlock value:('cannot convert argument to ' , type) value:0
   286 	^ failBlock value:('cannot convert argument to ' , type) value:0
   361     ].    
   287     ].
   362 
   288 
   363     (type = 'char[]') ifTrue:[
   289     (type = 'char[]') ifTrue:[
   364         arg isString ifTrue:[
   290 	arg isString ifTrue:[
   365             ^ arg
   291 	    ^ arg
   366         ].
   292 	].
   367         ^ failBlock value:('cannot convert argument to ' , type) value:''
   293 	^ failBlock value:('cannot convert argument to ' , type) value:''
   368     ].    
   294     ].
   369 
   295 
   370     (type = 'int[]') ifTrue:[
   296     (type = 'int[]') ifTrue:[
   371         (arg isArray or:[arg isMemberOf:SignedIntegerArray]) ifTrue:[
   297 	(arg isArray or:[arg isMemberOf:SignedIntegerArray]) ifTrue:[
   372             ^ arg
   298 	    ^ arg
   373         ].
   299 	].
   374         ^ failBlock value:('cannot convert argument to ' , type) value:''
   300 	^ failBlock value:('cannot convert argument to ' , type) value:''
   375     ].    
   301     ].
   376     (type = 'long[]') ifTrue:[
   302     (type = 'long[]') ifTrue:[
   377         (arg isArray or:[arg isMemberOf:SignedIntegerArray]) ifTrue:[
   303 	(arg isArray or:[arg isMemberOf:SignedIntegerArray]) ifTrue:[
   378             ^ arg
   304 	    ^ arg
   379         ].
   305 	].
   380         ^ failBlock value:('cannot convert argument to ' , type) value:''
   306 	^ failBlock value:('cannot convert argument to ' , type) value:''
   381     ].    
   307     ].
   382     (type = 'float[]') ifTrue:[
   308     (type = 'float[]') ifTrue:[
   383         (arg isArray or:[arg isMemberOf:FloatArray]) ifTrue:[
   309 	(arg isArray or:[arg isMemberOf:FloatArray]) ifTrue:[
   384             ^ arg
   310 	    ^ arg
   385         ].
   311 	].
   386         ^ failBlock value:('cannot convert argument to ' , type) value:''
   312 	^ failBlock value:('cannot convert argument to ' , type) value:''
   387     ].    
   313     ].
   388     (type = 'double[]') ifTrue:[
   314     (type = 'double[]') ifTrue:[
   389         (arg isArray or:[arg isMemberOf:DoubleArray]) ifTrue:[
   315 	(arg isArray or:[arg isMemberOf:DoubleArray]) ifTrue:[
   390             ^ arg
   316 	    ^ arg
   391         ].
   317 	].
   392         ^ failBlock value:('cannot convert argument to ' , type) value:''
   318 	^ failBlock value:('cannot convert argument to ' , type) value:''
   393     ].    
   319     ].
   394 
   320 
   395     (type endsWith:'[]') ifTrue:[
   321     (type endsWith:'[]') ifTrue:[
   396         (arg isArray or:[arg isNil]) ifTrue:[
   322 	(arg isArray or:[arg isNil]) ifTrue:[
   397             ^ arg
   323 	    ^ arg
   398         ].
   324 	].
   399         ^ failBlock value:('cannot convert argument to ' , type) value:''
   325 	^ failBlock value:('cannot convert argument to ' , type) value:''
   400     ].
   326     ].
   401 
   327 
   402     (type = 'java.lang.Object') ifTrue:[
   328     (type = 'java.lang.Object') ifTrue:[
   403         "/ matches any
   329 	"/ matches any
   404         ^ arg
   330 	^ arg
   405     ].
   331     ].
   406     (type = 'java.lang.String') ifTrue:[
   332     (type = 'java.lang.String') ifTrue:[
   407         arg isString ifTrue:[
   333 	arg isString ifTrue:[
   408             ^ Java as_String:arg
   334 	    ^ Java as_String:arg
   409         ].
   335 	].
   410         failValue := ''
   336 	failValue := ''
   411     ].
   337     ].
   412     expectedCls := Java classForName:type.
   338     expectedCls := Java classForName:type.
   413     (arg isKindOf:expectedCls) ifTrue:[
   339     (arg isKindOf:expectedCls) ifTrue:[
   414         "/ matches class and subclasses
   340 	"/ matches class and subclasses
   415         ^ arg
   341 	^ arg
   416     ].
   342     ].
   417     arg isNil ifTrue:[
   343     arg isNil ifTrue:[
   418         "/ matches any
   344 	"/ matches any
   419         ^ arg
   345 	^ arg
   420     ].
   346     ].
   421 self halt.
   347 self halt.
   422     ^ failBlock value:('cannot convert argument to ' , type) value:failValue
   348     ^ failBlock value:('cannot convert argument to ' , type) value:failValue
   423 
   349 
   424     "Created: / 6.11.1998 / 00:46:19 / cg"
   350     "Created: / 6.11.1998 / 00:46:19 / cg"
   425     "Modified: / 6.11.2001 / 13:28:29 / cg"
   351     "Modified: / 6.11.2001 / 13:28:29 / cg"
   426 !
   352 !
   427 
   353 
   428 convertToSmalltalk:jObj type:type 
   354 convertToSmalltalk:jObj type:type
   429     "given a java return value, convert to a smalltalk object as appropriate.
   355     "given a java return value, convert to a smalltalk object as appropriate.
   430      Currently, only a few types are converted."
   356      Currently, only a few types are converted."
   431 
   357 
   432     type == #boolean ifTrue:[
   358     type == #boolean ifTrue:[
   433         jObj == 0 ifTrue:[
   359 	jObj == 0 ifTrue:[
   434             ^ false
   360 	    ^ false
   435         ].
   361 	].
   436         ^ true
   362 	^ true
   437     ].
   363     ].
   438 
   364 
   439     type == #void ifTrue:[
   365     type == #void ifTrue:[
   440         ^ nil
   366 	^ nil
   441     ].
   367     ].
   442 
   368 
   443     (type = 'java.lang.String') ifTrue:[
   369     (type = 'java.lang.String') ifTrue:[
   444         ^ Java as_ST_String:jObj
   370 	^ Java as_ST_String:jObj
   445     ].
   371     ].
   446 
   372 
   447 "/    (type = 'java.lang.Float') ifTrue:[
   373 "/    (type = 'java.lang.Float') ifTrue:[
   448 "/        ^ jObj instVarNamed:'value'
   374 "/        ^ jObj instVarNamed:'value'
   449 "/    ].
   375 "/    ].
   450 "/    (type = 'java.lang.Double') ifTrue:[
   376 "/    (type = 'java.lang.Double') ifTrue:[
   451 "/        ^ jObj instVarNamed:'value'
   377 "/        ^ jObj instVarNamed:'value'
   452 "/    ].
   378 "/    ].
   453 
   379 
   454     (type == #char) ifTrue:[
   380     (type == #char) ifTrue:[
   455         jObj isInteger ifTrue:[
   381 	jObj isInteger ifTrue:[
   456             ^ Character value:jObj
   382 	    ^ Character value:jObj
   457         ].
   383 	].
   458     ].    
   384     ].
   459 
   385 
   460     ^ jObj
   386     ^ jObj
   461 
   387 
   462     "Created: / 6.11.1998 / 00:49:53 / cg"
   388     "Created: / 6.11.1998 / 00:49:53 / cg"
   463     "Modified: / 11.11.1998 / 02:08:11 / cg"
   389     "Modified: / 11.11.1998 / 02:08:11 / cg"
   468 
   394 
   469     |method cls sel|
   395     |method cls sel|
   470 
   396 
   471     sel := selector.
   397     sel := selector.
   472     (sel includes:$:) ifTrue:[
   398     (sel includes:$:) ifTrue:[
   473         sel := sel copyTo:(sel indexOf:$:)-1    
   399 	sel := sel copyTo:(sel indexOf:$:)-1
   474     ].
   400     ].
   475 
   401 
   476     sel := sel asSymbolIfInterned.
   402     sel := sel asSymbolIfInterned.
   477     sel notNil ifTrue:[
   403     sel notNil ifTrue:[
   478         cls := aClass.
   404 	cls := aClass.
   479 
   405 
   480         [cls notNil 
   406 	[cls notNil
   481         and:[cls ~~ JavaObject
   407 	and:[cls ~~ JavaObject
   482         and:[cls ~~ JavaClass]]] whileTrue:[
   408 	and:[cls ~~ JavaClass]]] whileTrue:[
   483             cls methodDictionary keysAndValuesDo:[:jSel :m |
   409 	    cls methodDictionary keysAndValuesDo:[:jSel :m |
   484                 |aMethod|
   410 		|aMethod|
   485 
   411 
   486                 aMethod := m.
   412 		aMethod := m.
   487                 aMethod isWrapped ifTrue:[
   413 		aMethod isWrapped ifTrue:[
   488                     aMethod := aMethod originalMethod
   414 		    aMethod := aMethod originalMethod
   489                 ].
   415 		].
   490                 
   416 
   491                 ((jSel == sel)
   417 		((jSel == sel)
   492                 or:[aMethod name = sel 
   418 		or:[aMethod name = sel
   493                 or:[aMethod signatureNameWithoutReturnType = sel]])
   419 		or:[aMethod signatureNameWithoutReturnType = sel]])
   494                 ifTrue:[
   420 		ifTrue:[
   495                     aMethod numArgs == nargs ifTrue:[
   421 		    aMethod numArgs == nargs ifTrue:[
   496                         staticMethod == (aMethod isStatic) ifTrue:[
   422 			staticMethod == (aMethod isStatic) ifTrue:[
   497                             ^ m
   423 			    ^ m
   498                         ]
   424 			]
   499                     ]
   425 		    ]
   500                 ]
   426 		]
   501             ].
   427 	    ].
   502 
   428 
   503             cls := cls superclass.
   429 	    cls := cls superclass.
   504         ].
   430 	].
   505     ].
   431     ].
   506 "/ self halt.
   432 "/ self halt.
   507     ^ nil
   433     ^ nil
   508 
   434 
   509     "Created: / 17.8.1997 / 18:25:47 / cg"
   435     "Created: / 17.8.1997 / 18:25:47 / cg"
   517 
   443 
   518     |methods cls sel|
   444     |methods cls sel|
   519 
   445 
   520     sel := selector.
   446     sel := selector.
   521     (sel includes:$:) ifTrue:[
   447     (sel includes:$:) ifTrue:[
   522         sel := sel copyTo:(sel indexOf:$:)-1    
   448 	sel := sel copyTo:(sel indexOf:$:)-1
   523     ].
   449     ].
   524 
   450 
   525     sel := sel asSymbolIfInterned.
   451     sel := sel asSymbolIfInterned.
   526     sel notNil ifTrue:[
   452     sel notNil ifTrue:[
   527         cls := aClass.
   453 	cls := aClass.
   528 
   454 
   529         [cls notNil 
   455 	[cls notNil
   530         and:[cls ~~ JavaObject
   456 	and:[cls ~~ JavaObject
   531         and:[cls ~~ JavaClass]]] whileTrue:[
   457 	and:[cls ~~ JavaClass]]] whileTrue:[
   532             cls methodDictionary keysAndValuesDo:[:jSel :aMethod |
   458 	    cls methodDictionary keysAndValuesDo:[:jSel :aMethod |
   533                 ((jSel == sel)
   459 		((jSel == sel)
   534                 or:[aMethod name = sel 
   460 		or:[aMethod name = sel
   535                 or:[aMethod signatureNameWithoutReturnType = sel]])
   461 		or:[aMethod signatureNameWithoutReturnType = sel]])
   536                 ifTrue:[
   462 		ifTrue:[
   537                     (nargs isNil
   463 		    (nargs isNil
   538                     or:[aMethod numArgs == nargs]) ifTrue:[
   464 		    or:[aMethod numArgs == nargs]) ifTrue:[
   539                         staticMethod == (aMethod isStatic) ifTrue:[
   465 			staticMethod == (aMethod isStatic) ifTrue:[
   540                             methods isNil ifTrue:[
   466 			    methods isNil ifTrue:[
   541                                 methods := OrderedCollection new
   467 				methods := OrderedCollection new
   542                             ].
   468 			    ].
   543                             methods add:aMethod
   469 			    methods add:aMethod
   544                         ]
   470 			]
   545                     ]
   471 		    ]
   546                 ]
   472 		]
   547             ].
   473 	    ].
   548 
   474 
   549             cls := cls superclass.
   475 	    cls := cls superclass.
   550         ].
   476 	].
   551     ].
   477     ].
   552     ^ methods ? #()
   478     ^ methods ? #()
   553 
   479 
   554     "Created: / 4.11.1998 / 19:04:51 / cg"
   480     "Created: / 4.11.1998 / 19:04:51 / cg"
   555     "Modified: / 4.11.1998 / 19:31:33 / cg"
   481     "Modified: / 4.11.1998 / 19:31:33 / cg"
   564 
   490 
   565     s := aSignature readStream.
   491     s := aSignature readStream.
   566     ^ self initialValueFromStream:s.
   492     ^ self initialValueFromStream:s.
   567 
   493 
   568     "
   494     "
   569      JavaClass initialValueFromSignature:'LObject;'    
   495      JavaClass initialValueFromSignature:'LObject;'
   570      JavaClass initialValueFromSignature:'B'        
   496      JavaClass initialValueFromSignature:'B'
   571      JavaClass initialValueFromSignature:'I'        
   497      JavaClass initialValueFromSignature:'I'
   572     "
   498     "
   573 
   499 
   574 
   500 
   575 !
       
   576 
       
   577 initialValueFromStream:s
       
   578     "parse a fieldTypeSpec - see java doc"
       
   579 
       
   580     |typeChar|
       
   581 
       
   582     typeChar := s next.
       
   583     ^ InitialValuePerType at:typeChar ifAbsent:nil.
       
   584 ! !
   501 ! !
   585 
   502 
   586 !JavaClass class methodsFor:'special'!
   503 !JavaClass class methodsFor:'special'!
   587 
   504 
   588 flushClassesInitOrder
   505 flushClassesInitOrder
   629 
   546 
   630     |nameComponents|
   547     |nameComponents|
   631 
   548 
   632     nameComponents := fullName asCollectionOfSubstringsSeparatedBy:$/.
   549     nameComponents := fullName asCollectionOfSubstringsSeparatedBy:$/.
   633     nameComponents size <= 1 ifTrue:[
   550     nameComponents size <= 1 ifTrue:[
   634         ^ 'java' "/ fullName  
   551 	^ 'java' "/ fullName
   635     ].
   552     ].
   636     ^ ((nameComponents asStringWith:$/ from:1 to:(nameComponents size - 1))) 
   553     ^ ((nameComponents asStringWith:$/ from:1 to:(nameComponents size - 1)))
   637         replaceAll:$/ with:$.
   554 	replaceAll:$/ with:$.
   638 
   555 
   639     "Modified: 30.7.1997 / 15:35:22 / cg"
   556     "Modified: 30.7.1997 / 15:35:22 / cg"
   640 !
   557 !
   641 
   558 
   642 classLoader
   559 classLoader
   652 
   569 
   653     |m|
   570     |m|
   654 
   571 
   655     m := super compiledMethodAt:name.
   572     m := super compiledMethodAt:name.
   656     m isNil ifTrue:[
   573     m isNil ifTrue:[
   657         name = self lastName ifTrue:[
   574 	name = self lastName ifTrue:[
   658             ^ super compiledMethodAt:#'<init>()V'
   575 	    ^ super compiledMethodAt:#'<init>()V'
   659         ].
   576 	].
   660     ].
   577     ].
   661     ^ m
   578     ^ m
   662 
   579 
   663     "
   580     "
   664      JAVA::java::lang::Object compiledMethodAt:#Object
   581      JAVA::java::lang::Object compiledMethodAt:#Object
   717      (with '/'s replaced by dots) extract from the fullName"
   634      (with '/'s replaced by dots) extract from the fullName"
   718 
   635 
   719     ^ fullName copyReplaceAll:$/ with:$.
   636     ^ fullName copyReplaceAll:$/ with:$.
   720 
   637 
   721     "
   638     "
   722      Java allClasses first fullName    
   639      Java allClasses first fullName
   723      Java allClasses first name    
   640      Java allClasses first name
   724      Java allClasses first javaName    
   641      Java allClasses first javaName
   725      Java allClasses first javaPackage  
   642      Java allClasses first javaPackage
   726      Java allClasses first package      
   643      Java allClasses first package
   727     "
   644     "
   728 !
   645 !
   729 
   646 
   730 javaPackage
   647 javaPackage
   731     "the javaPackage - as seen by a java programmer.
   648     "the javaPackage - as seen by a java programmer.
   733 
   650 
   734     |components|
   651     |components|
   735 
   652 
   736     components := fullName asCollectionOfSubstringsSeparatedBy:$/.
   653     components := fullName asCollectionOfSubstringsSeparatedBy:$/.
   737     components size > 1 ifTrue:[
   654     components size > 1 ifTrue:[
   738         ^ (components copyWithoutLast:1) asStringWith:$.
   655 	^ (components copyWithoutLast:1) asStringWith:$.
   739     ].
   656     ].
   740     ^ fullName
   657     ^ fullName
   741 
   658 
   742     "
   659     "
   743      Java allClasses first fullName    
   660      Java allClasses first fullName
   744      Java allClasses first javaPackage  
   661      Java allClasses first javaPackage
   745      Java allClasses first package      
   662      Java allClasses first package
   746     "
   663     "
   747 !
   664 !
   748 
   665 
   749 lastName
   666 lastName
   750     ^ fullName copyFrom:(fullName lastIndexOf:$/)+1
   667     ^ fullName copyFrom:(fullName lastIndexOf:$/)+1
   781     |components p i|
   698     |components p i|
   782 
   699 
   783     i := fullName lastIndexOf:$/.
   700     i := fullName lastIndexOf:$/.
   784     p := fullName copyTo:i - 1.
   701     p := fullName copyTo:i - 1.
   785     p size == 0 ifTrue:[
   702     p size == 0 ifTrue:[
   786         ^ 'java'
   703 	^ 'java'
   787     ].
   704     ].
   788 "/    components := fullName asCollectionOfSubstringsSeparatedBy:$/.
   705 "/    components := fullName asCollectionOfSubstringsSeparatedBy:$/.
   789 "/    components size > 1 ifTrue:[
   706 "/    components size > 1 ifTrue:[
   790 "/        p := (components copyWithoutLast:1) asStringWith:$/
   707 "/        p := (components copyWithoutLast:1) asStringWith:$/
   791 "/    ] ifFalse:[
   708 "/    ] ifFalse:[
   793 "/    ].
   710 "/    ].
   794 
   711 
   795     ^ 'java:' , p
   712     ^ 'java:' , p
   796 
   713 
   797     "
   714     "
   798      Java allClasses first fullName   
   715      Java allClasses first fullName
   799      Java allClasses first package    
   716      Java allClasses first package
   800      Java allClasses first javaPackage  
   717      Java allClasses first javaPackage
   801     "
   718     "
   802 !
   719 !
   803 
   720 
   804 source
   721 source
   805     ^ Java classSourceOf:self
   722     ^ Java classSourceOf:self
   829 	]
   746 	]
   830     ].
   747     ].
   831     self error:'no such field'
   748     self error:'no such field'
   832 
   749 
   833     "
   750     "
   834      (JAVA at:#'java/awt/image/ColorModel') typeOfField:'pixel_bits' 
   751      (JAVA at:#'java/awt/image/ColorModel') typeOfField:'pixel_bits'
   835     "
   752     "
   836 
   753 
   837     "Modified: 21.1.1997 / 22:48:28 / cg"
   754     "Modified: 21.1.1997 / 22:48:28 / cg"
   838 ! !
   755 ! !
   839 
   756 
   849 
   766 
   850 isVisualStartable
   767 isVisualStartable
   851     "return true, if this is an application class,
   768     "return true, if this is an application class,
   852      which can be started via #open"
   769      which can be started via #open"
   853 
   770 
   854     "/ if I have a main() method, I am 
   771     "/ if I have a main() method, I am
   855 
   772 
   856     (self compiledMethodAt:#'main([Ljava/lang/String;)V') notNil ifTrue:[
   773     (self compiledMethodAt:#'main([Ljava/lang/String;)V') notNil ifTrue:[
   857         ^ true
   774 	^ true
   858     ].
   775     ].
   859 
   776 
   860     (self isSubclassOf:(Java at:'java.applet.Applet')) ifTrue:[
   777     (self isSubclassOf:(Java at:'java.applet.Applet')) ifTrue:[
   861         ^ true.
   778 	^ true.
   862     ].
   779     ].
   863 
   780 
   864     ^ false
   781     ^ false
   865 !
   782 !
   866 
   783 
   868     "start a thread for my main method"
   785     "start a thread for my main method"
   869 
   786 
   870     "/ if I have a main, call it ...
   787     "/ if I have a main, call it ...
   871 
   788 
   872     (self compiledMethodAt:#'main([Ljava/lang/String;)V') notNil ifTrue:[
   789     (self compiledMethodAt:#'main([Ljava/lang/String;)V') notNil ifTrue:[
   873         ^ self startMain
   790 	^ self startMain
   874     ].
   791     ].
   875 
   792 
   876     "/ otherwise, create a frame and wrap me;
   793     "/ otherwise, create a frame and wrap me;
   877     "/ as in:
   794     "/ as in:
   878 
   795 
   895 ! !
   812 ! !
   896 
   813 
   897 !JavaClass methodsFor:'compiler interface'!
   814 !JavaClass methodsFor:'compiler interface'!
   898 
   815 
   899 browserClass
   816 browserClass
   900     "return the browser to use for this class - 
   817     "return the browser to use for this class -
   901      this can be redefined in special classes, to get different browsers"
   818      this can be redefined in special classes, to get different browsers"
   902 
   819 
   903 "/    ^ JavaBrowser
   820 "/    ^ JavaBrowser
   904     ^ super browserClass.
   821     ^ super browserClass.
   905 
   822 
   906     "Modified: / 14.10.1998 / 15:28:38 / cg"
   823     "Modified: / 14.10.1998 / 15:28:38 / cg"
   907 !
   824 !
   908 
   825 
   909 compilerClass
   826 compilerClass
   910     "return the compiler to use for this class - 
   827     "return the compiler to use for this class -
   911      this can be redefined in special classes, to compile classes with
   828      this can be redefined in special classes, to compile classes with
   912      Lisp, Prolog, ASN1, Basic :-) or whatever syntax."
   829      Lisp, Prolog, ASN1, Basic :-) or whatever syntax."
   913 
   830 
   914     ^ JavaCompiler ? Compiler
   831     ^ JavaCompiler ? Compiler
   915 !
   832 !
   916 
   833 
   917 evaluatorClass
   834 evaluatorClass
   918     "return the compiler to use for expression evaluation for this class - 
   835     "return the compiler to use for expression evaluation for this class -
   919      this can be redefined in special classes, to evaluate expressions with
   836      this can be redefined in special classes, to evaluate expressions with
   920      Lisp, Prolog, ASN1, Basic :-) or whatever syntax."
   837      Lisp, Prolog, ASN1, Basic :-) or whatever syntax."
   921 
   838 
   922     ^ JavaParser ? Parser.
   839     ^ JavaParser ? Parser.
   923 
   840 
   924 !
   841 !
   925 
   842 
   926 parserClass
   843 parserClass
   927     "return the parser to use for parsing this class - 
   844     "return the parser to use for parsing this class -
   928      this can be redefined in special classes, to parse classes with
   845      this can be redefined in special classes, to parse classes with
   929      Lisp, Prolog, ASN1, Basic :-) or whatever syntax."
   846      Lisp, Prolog, ASN1, Basic :-) or whatever syntax."
   930 
   847 
   931     ^ JavaParser ? Parser.
   848     ^ JavaParser ? Parser.
   932 
   849 
   933 !
   850 !
   934 
   851 
   935 syntaxHighlighterClass
   852 syntaxHighlighterClass
   936     "return the class to use for syntaxHighlighting (prettyPrinting) this class - 
   853     "return the class to use for syntaxHighlighting (prettyPrinting) this class -
   937      this can be redefined in special classes, to highlight classes with
   854      this can be redefined in special classes, to highlight classes with
   938      Lisp, Prolog, ASN1, Basic :-) or whatever syntax."
   855      Lisp, Prolog, ASN1, Basic :-) or whatever syntax."
   939 
   856 
   940     ^ JavaSyntaxHighlighter "/ ? SyntaxHighlighter
   857     ^ JavaSyntaxHighlighter "/ ? SyntaxHighlighter
   941 ! !
   858 ! !
  1007 
   924 
  1008     me perform:#'init()V'.
   925     me perform:#'init()V'.
  1009     me perform:#'start()V'.
   926     me perform:#'start()V'.
  1010 self halt.
   927 self halt.
  1011 
   928 
  1012     f perform:#'add(Ljava/lang/String;Ljava/awt/Component;)Ljava/awt/Component;' 
   929     f perform:#'add(Ljava/lang/String;Ljava/awt/Component;)Ljava/awt/Component;'
  1013          with:(Java as_String:'Center')
   930 	 with:(Java as_String:'Center')
  1014          with:me.
   931 	 with:me.
  1015 self halt.
   932 self halt.
  1016     f perform:#'setSize(II)V' with:300 with:300.
   933     f perform:#'setSize(II)V' with:300 with:300.
  1017 self halt.
   934 self halt.
  1018     f perform:#'show()V'.
   935     f perform:#'show()V'.
  1019 self halt.
   936 self halt.
  1049 
   966 
  1050     me perform:#'init()V'.
   967     me perform:#'init()V'.
  1051     me perform:#'start()V'.
   968     me perform:#'start()V'.
  1052 self halt.
   969 self halt.
  1053 
   970 
  1054     f perform:#'add(Ljava/lang/String;Ljava/awt/Component;)Ljava/awt/Component;' 
   971     f perform:#'add(Ljava/lang/String;Ljava/awt/Component;)Ljava/awt/Component;'
  1055          with:(Java as_String:'Center')
   972 	 with:(Java as_String:'Center')
  1056          with:me.
   973 	 with:me.
  1057 self halt.
   974 self halt.
  1058     f perform:#'setSize(II)V' with:300 with:300.
   975     f perform:#'setSize(II)V' with:300 with:300.
  1059 self halt.
   976 self halt.
  1060     f perform:#'show()V'.
   977     f perform:#'show()V'.
  1061 self halt.
   978 self halt.
  1076 
   993 
  1077     |p|
   994     |p|
  1078 
   995 
  1079     p := Java javaProcessForMainOf:self argumentString:aCommandLineString.
   996     p := Java javaProcessForMainOf:self argumentString:aCommandLineString.
  1080     p notNil ifTrue:[
   997     p notNil ifTrue:[
  1081         p resume.
   998 	p resume.
  1082         Object abortSignal handle:[:ex |
   999 	Object abortSignal handle:[:ex |
  1083 p == JavaVM javaScreenUpdaterThread ifTrue:[self halt].
  1000 p == JavaVM javaScreenUpdaterThread ifTrue:[self halt].
  1084 p == JavaVM javaEventQueueThread ifTrue:[self halt].
  1001 p == JavaVM javaEventQueueThread ifTrue:[self halt].
  1085             p terminate.
  1002 	    p terminate.
  1086             ex reject.
  1003 	    ex reject.
  1087         ] do:[
  1004 	] do:[
  1088             p waitUntilTerminated
  1005 	    p waitUntilTerminated
  1089         ].
  1006 	].
  1090     ]
  1007     ]
  1091 
  1008 
  1092     "Modified: / 24.12.1999 / 02:35:04 / cg"
  1009     "Modified: / 24.12.1999 / 02:35:04 / cg"
  1093 ! !
  1010 ! !
  1094 
  1011 
  1117     (accessFlags bitAnd:A_INITIALIZED) ~~ 0 ifTrue:[^ self].
  1034     (accessFlags bitAnd:A_INITIALIZED) ~~ 0 ifTrue:[^ self].
  1118 
  1035 
  1119     accessFlags := accessFlags bitOr:A_INITIALIZED.
  1036     accessFlags := accessFlags bitOr:A_INITIALIZED.
  1120 
  1037 
  1121     superclass ~~ JavaObject ifTrue:[
  1038     superclass ~~ JavaObject ifTrue:[
  1122         superclass classInit
  1039 	superclass classInit
  1123     ].
  1040     ].
  1124 "/    "/ also, all referenced classes must be ...
  1041 "/    "/ also, all referenced classes must be ...
  1125 "/    constantPool classReferencesDo:[:aClass |
  1042 "/    constantPool classReferencesDo:[:aClass |
  1126 "/        aClass classInit
  1043 "/        aClass classInit
  1127 "/    ].
  1044 "/    ].
  1128 
  1045 
  1129     m := self compiledMethodAt:#'<clinit>()V'.
  1046     m := self compiledMethodAt:#'<clinit>()V'.
  1130     m notNil ifTrue:[
  1047     m notNil ifTrue:[
  1131 "/        'calling clinit() of ' print. self fullName printNL.
  1048 "/        'calling clinit() of ' print. self fullName printNL.
  1132         [
  1049 	[
  1133             OrderOfClassInits notNil ifTrue:[
  1050 	    OrderOfClassInits notNil ifTrue:[
  1134                 OrderOfClassInits add:self.
  1051 		OrderOfClassInits add:self.
  1135             ].
  1052 	    ].
  1136 
  1053 
  1137             m 
  1054 	    m
  1138                 valueWithReceiver:self 
  1055 		valueWithReceiver:self
  1139                 arguments:#() 
  1056 		arguments:#()
  1140                 selector:#'<clinit>()V' 
  1057 		selector:#'<clinit>()V'
  1141                 search:self class
  1058 		search:self class
  1142                 sender:nil
  1059 		sender:nil
  1143         ] valueOnUnwindDo:[
  1060 	] valueOnUnwindDo:[
  1144             accessFlags := accessFlags bitXor:A_INITIALIZED.
  1061 	    accessFlags := accessFlags bitXor:A_INITIALIZED.
  1145         ]
  1062 	]
  1146     ] ifFalse:[
  1063     ] ifFalse:[
  1147 "/        self fullName print. ' has no clinit()' printNL.
  1064 "/        self fullName print. ' has no clinit()' printNL.
  1148     ].
  1065     ].
  1149 
  1066 
  1150     "
  1067     "
  1153 
  1070 
  1154      (Java classNamed:'java.lang.String') classInit
  1071      (Java classNamed:'java.lang.String') classInit
  1155      (Java classNamed:'java.lang.System') classInit
  1072      (Java classNamed:'java.lang.System') classInit
  1156 
  1073 
  1157      (Java classNamed:'java/io/FileDescriptor') classInit
  1074      (Java classNamed:'java/io/FileDescriptor') classInit
  1158      (Java classNamed:'java.util.Properties') classInit 
  1075      (Java classNamed:'java.util.Properties') classInit
  1159     "
  1076     "
  1160 
  1077 
  1161     "Modified: / 12.11.1998 / 15:41:11 / cg"
  1078     "Modified: / 12.11.1998 / 15:41:11 / cg"
  1162 !
  1079 !
  1163 
  1080 
  1176 	    ] ifFalse:[type == #int ifTrue:[
  1093 	    ] ifFalse:[type == #int ifTrue:[
  1177 		val := 0.
  1094 		val := 0.
  1178 	    ] ifFalse:[type == #float ifTrue:[
  1095 	    ] ifFalse:[type == #float ifTrue:[
  1179 		val := 0.0 asShortFloat
  1096 		val := 0.0 asShortFloat
  1180 	    ] ifFalse:[type == #double ifTrue:[
  1097 	    ] ifFalse:[type == #double ifTrue:[
  1181 		val := 0.0 
  1098 		val := 0.0
  1182 	    ] ifFalse:[type == #byte ifTrue:[
  1099 	    ] ifFalse:[type == #byte ifTrue:[
  1183 		val := 0.
  1100 		val := 0.
  1184 	    ] ifFalse:[type == #char ifTrue:[
  1101 	    ] ifFalse:[type == #char ifTrue:[
  1185 		val := 0.
  1102 		val := 0.
  1186 	    ] ifFalse:[type == #'unsigned short' ifTrue:[
  1103 	    ] ifFalse:[type == #'unsigned short' ifTrue:[
  1235      however, <init> is not invoked for it."
  1152      however, <init> is not invoked for it."
  1236 
  1153 
  1237     |newJavaObject sz "{ Class: SmallInteger }" |
  1154     |newJavaObject sz "{ Class: SmallInteger }" |
  1238 
  1155 
  1239     (accessFlags bitAnd:A_ABSTRACT_OR_INTERFACE) ~~ 0 ifTrue:[
  1156     (accessFlags bitAnd:A_ABSTRACT_OR_INTERFACE) ~~ 0 ifTrue:[
  1240         JavaVM throwInstantiationExceptionFor:self.
  1157 	JavaVM throwInstantiationExceptionFor:self.
  1241         ^ nil
  1158 	^ nil
  1242     ].
  1159     ].
  1243 
  1160 
  1244     newJavaObject := super basicNew.
  1161     newJavaObject := super basicNew.
  1245     initValues notNil ifTrue:[
  1162     initValues notNil ifTrue:[
  1246         sz := self instSize.
  1163 	sz := self instSize.
  1247         1 to:sz do:[:i |
  1164 	1 to:sz do:[:i |
  1248             newJavaObject instVarAt:i put:(initValues at:i)
  1165 	    newJavaObject instVarAt:i put:(initValues at:i)
  1249         ].
  1166 	].
  1250     ].
  1167     ].
  1251 
  1168 
  1252     ^ newJavaObject
  1169     ^ newJavaObject
  1253 
  1170 
  1254     "
  1171     "
  1265      and call its JAVA init function passing a String arg"
  1182      and call its JAVA init function passing a String arg"
  1266 
  1183 
  1267     |newJavaObject|
  1184     |newJavaObject|
  1268 
  1185 
  1269     newJavaObject := self newCleared.
  1186     newJavaObject := self newCleared.
  1270     newJavaObject 
  1187     newJavaObject
  1271         perform:#'<init>(Ljava/lang/String;)V' 
  1188 	perform:#'<init>(Ljava/lang/String;)V'
  1272         with:(Java as_String:argString).
  1189 	with:(Java as_String:argString).
  1273     ^ newJavaObject
  1190     ^ newJavaObject
  1274 
  1191 
  1275     "
  1192     "
  1276      ((Java classNamed:'java.lang.ArrayStoreException') newWith_String:'foo') inspect
  1193      ((Java classNamed:'java.lang.ArrayStoreException') newWith_String:'foo') inspect
  1277     "
  1194     "
  1312     numArgs := args size.
  1229     numArgs := args size.
  1313     sel := aMessage selector.
  1230     sel := aMessage selector.
  1314 
  1231 
  1315     methods := JavaClass lookupMethods:sel numArgs:numArgs in:self static:true.
  1232     methods := JavaClass lookupMethods:sel numArgs:numArgs in:self static:true.
  1316     methods size == 1 ifTrue:[
  1233     methods size == 1 ifTrue:[
  1317         javaMethod := methods first.
  1234 	javaMethod := methods first.
  1318         "/ there is only one - try that one.
  1235 	"/ there is only one - try that one.
  1319     ] ifFalse:[
  1236     ] ifFalse:[
  1320         methods size > 1 ifTrue:[
  1237 	methods size > 1 ifTrue:[
  1321             "/ more than one - select the ones that could be used.
  1238 	    "/ more than one - select the ones that could be used.
  1322             methods := methods select:[:aMethod |
  1239 	    methods := methods select:[:aMethod |
  1323                 |argSignature|
  1240 		|argSignature|
  1324 
  1241 
  1325                 argSignature := aMethod argSignature.
  1242 		argSignature := aMethod argSignature.
  1326                 (JavaClass canConvertArgsToJava:args asSpecifiedIn:argSignature) 
  1243 		(JavaClass canConvertArgsToJava:args asSpecifiedIn:argSignature)
  1327             ].
  1244 	    ].
  1328             methods size == 1 ifTrue:[
  1245 	    methods size == 1 ifTrue:[
  1329                 javaMethod := methods first.
  1246 		javaMethod := methods first.
  1330             ]
  1247 	    ]
  1331         ]
  1248 	]
  1332     ].
  1249     ].
  1333 
  1250 
  1334     javaMethod notNil ifTrue:[
  1251     javaMethod notNil ifTrue:[
  1335         (ArgumentConversionErrorSignal catch:[
  1252 	(ArgumentConversionErrorSignal catch:[
  1336             args notNil ifTrue:[
  1253 	    args notNil ifTrue:[
  1337                 args := JavaClass 
  1254 		args := JavaClass
  1338                             convertArgsToJava:args 
  1255 			    convertArgsToJava:args
  1339                             asSpecifiedIn:(javaMethod argSignature)
  1256 			    asSpecifiedIn:(javaMethod argSignature)
  1340                             numArgs:numArgs.
  1257 			    numArgs:numArgs.
  1341             ].
  1258 	    ].
  1342         ]) ifFalse:[
  1259 	]) ifFalse:[
  1343             retVal := javaMethod 
  1260 	    retVal := javaMethod
  1344                         valueWithReceiver:self "/ (javaMethod javaClass) 
  1261 			valueWithReceiver:self "/ (javaMethod javaClass)
  1345                         arguments:args
  1262 			arguments:args
  1346                         selector:(javaMethod selector)
  1263 			selector:(javaMethod selector)
  1347                         search:self "/ (javaMethod javaClass class)
  1264 			search:self "/ (javaMethod javaClass class)
  1348                         sender:nil.
  1265 			sender:nil.
  1349             ^ JavaClass convertToSmalltalk:retVal type:(javaMethod returnType).
  1266 	    ^ JavaClass convertToSmalltalk:retVal type:(javaMethod returnType).
  1350         ].
  1267 	].
  1351         ^ MessageNotUnderstoodSignal
  1268 	^ MessageNotUnderstoodSignal
  1352                     raiseRequestWith:aMessage
  1269 		    raiseRequestWith:aMessage
  1353                          errorString:'no method for given argument(s)'
  1270 			 errorString:'no method for given argument(s)'
  1354                                   in:thisContext "sender"
  1271 				  in:thisContext "sender"
  1355     ].
  1272     ].
  1356 
  1273 
  1357     anyMethodsFound := false.
  1274     anyMethodsFound := false.
  1358 
  1275 
  1359     "/ try all with that name (the number of args could be different ...
  1276     "/ try all with that name (the number of args could be different ...
  1360 
  1277 
  1361     methods := JavaClass lookupMethods:sel numArgs:nil in:self static:true.
  1278     methods := JavaClass lookupMethods:sel numArgs:nil in:self static:true.
  1362     methods size > 0 ifTrue:[
  1279     methods size > 0 ifTrue:[
  1363         anyMethodsFound := true.
  1280 	anyMethodsFound := true.
  1364         numArgs > 0 ifTrue:[
  1281 	numArgs > 0 ifTrue:[
  1365             methods do:[:methodToTry |
  1282 	    methods do:[:methodToTry |
  1366                 (ArgumentConversionErrorSignal catch:[
  1283 		(ArgumentConversionErrorSignal catch:[
  1367                     newArgs := JavaClass 
  1284 		    newArgs := JavaClass
  1368                                 convertArgsToJava:args 
  1285 				convertArgsToJava:args
  1369                                 asSpecifiedIn:(methodToTry argSignature)
  1286 				asSpecifiedIn:(methodToTry argSignature)
  1370                                 numArgs:methodToTry numArgs.
  1287 				numArgs:methodToTry numArgs.
  1371                 ]) ifFalse:[
  1288 		]) ifFalse:[
  1372                     retVal :=  methodToTry 
  1289 		    retVal :=  methodToTry
  1373                                     valueWithReceiver:self "/ (methodToTry javaClass) 
  1290 				    valueWithReceiver:self "/ (methodToTry javaClass)
  1374                                     arguments:newArgs
  1291 				    arguments:newArgs
  1375                                     selector:(methodToTry selector)
  1292 				    selector:(methodToTry selector)
  1376                                     search:self "/ (methodToTry javaClass class)
  1293 				    search:self "/ (methodToTry javaClass class)
  1377                                     sender:nil.
  1294 				    sender:nil.
  1378                     ^ JavaClass convertToSmalltalk:retVal type:(methodToTry returnType).
  1295 		    ^ JavaClass convertToSmalltalk:retVal type:(methodToTry returnType).
  1379                 ].
  1296 		].
  1380             ].
  1297 	    ].
  1381         ]
  1298 	]
  1382     ].
  1299     ].
  1383 
  1300 
  1384     anyMethodsFound ifTrue:[
  1301     anyMethodsFound ifTrue:[
  1385         methods size == 1 ifTrue:[
  1302 	methods size == 1 ifTrue:[
  1386             javaMethod := methods first.
  1303 	    javaMethod := methods first.
  1387 
  1304 
  1388             ^ MessageNotUnderstoodSignal
  1305 	    ^ MessageNotUnderstoodSignal
  1389                         raiseRequestWith:aMessage
  1306 			raiseRequestWith:aMessage
  1390                              errorString:(sel , ' expects ' , javaMethod argSignature size printString , ' argument(s)')
  1307 			     errorString:(sel , ' expects ' , javaMethod argSignature size printString , ' argument(s)')
  1391                                       in:thisContext "sender"
  1308 				      in:thisContext "sender"
  1392         ].
  1309 	].
  1393         ^ MessageNotUnderstoodSignal
  1310 	^ MessageNotUnderstoodSignal
  1394                     raiseRequestWith:aMessage
  1311 		    raiseRequestWith:aMessage
  1395                          errorString:'no method for given argument count or type'
  1312 			 errorString:'no method for given argument count or type'
  1396                                   in:thisContext "sender"
  1313 				  in:thisContext "sender"
  1397     ].
  1314     ].
  1398     ^ super doesNotUnderstand:aMessage
  1315     ^ super doesNotUnderstand:aMessage
  1399 
  1316 
  1400     "Modified: / 6.11.1998 / 00:57:22 / cg"
  1317     "Modified: / 6.11.1998 / 00:57:22 / cg"
  1401 !
  1318 !
  1421 
  1338 
  1422     |javaMethod sel|
  1339     |javaMethod sel|
  1423 
  1340 
  1424     sel := selector asSymbolIfInterned.
  1341     sel := selector asSymbolIfInterned.
  1425     sel notNil ifTrue:[
  1342     sel notNil ifTrue:[
  1426         javaMethod := methodDictionary at:sel.
  1343 	javaMethod := methodDictionary at:sel.
  1427         javaMethod notNil ifTrue:[
  1344 	javaMethod notNil ifTrue:[
  1428             javaMethod isStatic ifTrue:[
  1345 	    javaMethod isStatic ifTrue:[
  1429                 ^ javaMethod 
  1346 		^ javaMethod
  1430                     valueWithReceiver:self 
  1347 		    valueWithReceiver:self
  1431                     arguments:#()
  1348 		    arguments:#()
  1432             ]
  1349 	    ]
  1433         ].
  1350 	].
  1434     ].
  1351     ].
  1435 
  1352 
  1436     ^ self doesNotUnderstand:(Message selector:selector)
  1353     ^ self doesNotUnderstand:(Message selector:selector)
  1437 
  1354 
  1438     "Modified: / 15.1.1998 / 00:31:27 / cg"
  1355     "Modified: / 15.1.1998 / 00:31:27 / cg"
  1444 
  1361 
  1445     |javaMethod sel|
  1362     |javaMethod sel|
  1446 
  1363 
  1447     sel := selector asSymbolIfInterned.
  1364     sel := selector asSymbolIfInterned.
  1448     sel notNil ifTrue:[
  1365     sel notNil ifTrue:[
  1449         javaMethod := methodDictionary at:sel.
  1366 	javaMethod := methodDictionary at:sel.
  1450         javaMethod notNil ifTrue:[
  1367 	javaMethod notNil ifTrue:[
  1451             javaMethod isStatic ifTrue:[
  1368 	    javaMethod isStatic ifTrue:[
  1452                 ^ javaMethod  
  1369 		^ javaMethod
  1453                     valueWithReceiver:self 
  1370 		    valueWithReceiver:self
  1454                     arguments:(Array with:arg)
  1371 		    arguments:(Array with:arg)
  1455                     selector:selector 
  1372 		    selector:selector
  1456                     search:nil
  1373 		    search:nil
  1457                     sender:nil
  1374 		    sender:nil
  1458             ]
  1375 	    ]
  1459         ].
  1376 	].
  1460     ].
  1377     ].
  1461 
  1378 
  1462     ^ self doesNotUnderstand:(Message selector:selector argument:arg)
  1379     ^ self doesNotUnderstand:(Message selector:selector argument:arg)
  1463 
  1380 
  1464     "Modified: / 15.1.1998 / 00:31:27 / cg"
  1381     "Modified: / 15.1.1998 / 00:31:27 / cg"
  1533     ^ true
  1450     ^ true
  1534 
  1451 
  1535     "Created: 20.1.1997 / 13:00:48 / cg"
  1452     "Created: 20.1.1997 / 13:00:48 / cg"
  1536 !
  1453 !
  1537 
  1454 
  1538 makeObsolete
       
  1539     accessFlags := accessFlags bitOr:A_OBSOLETE
       
  1540 
       
  1541     "Created: 7.8.1997 / 19:04:48 / cg"
       
  1542 !
       
  1543 
       
  1544 markUninitialized
       
  1545     (accessFlags bitAnd:A_INITIALIZED) ~~ 0 ifTrue:[
       
  1546 	accessFlags := accessFlags bitXor:A_INITIALIZED
       
  1547     ].
       
  1548 !
       
  1549 
       
  1550 setAccessFlags:flags
  1455 setAccessFlags:flags
  1551     accessFlags := flags.
  1456     accessFlags := flags.
  1552 
  1457 
  1553     "Created: 15.4.1996 / 16:42:52 / cg"
  1458     "Created: 15.4.1996 / 16:42:52 / cg"
  1554 !
  1459 !
  1569     JavaClass setInstanceVariableStringFromFields:f in:self.
  1474     JavaClass setInstanceVariableStringFromFields:f in:self.
  1570 
  1475 
  1571     instSize := superclass instSize + f size.
  1476     instSize := superclass instSize + f size.
  1572 
  1477 
  1573     fields := f.
  1478     fields := f.
  1574     vals := self allInstVarNames 
  1479     vals := self allInstVarNames
  1575                 collect:[:nm |
  1480 		collect:[:nm |
  1576                             self initValueFor:nm
  1481 			    self initValueFor:nm
  1577                         ].
  1482 			].
  1578     vals isEmpty ifTrue:[
  1483     vals isEmpty ifTrue:[
  1579         initValues := nil
  1484 	initValues := nil
  1580     ] ifFalse:[
  1485     ] ifFalse:[
  1581         (vals detect:[:el | el notNil] ifNone:nil) isNil ifTrue:[
  1486 	(vals detect:[:el | el notNil] ifNone:nil) isNil ifTrue:[
  1582             initValues := nil
  1487 	    initValues := nil
  1583         ] ifFalse:[
  1488 	] ifFalse:[
  1584             initValues := vals asArray
  1489 	    initValues := vals asArray
  1585         ]
  1490 	]
  1586     ]
  1491     ]
  1587 
  1492 
  1588     "Created: / 15.4.1996 / 16:42:52 / cg"
  1493     "Created: / 15.4.1996 / 16:42:52 / cg"
  1589     "Modified: / 6.11.1998 / 01:53:01 / cg"
  1494     "Modified: / 6.11.1998 / 01:53:01 / cg"
  1590 !
  1495 !
  1665 hasInterface:aJavaInterface
  1570 hasInterface:aJavaInterface
  1666     "return true, if I respond to all methods as
  1571     "return true, if I respond to all methods as
  1667      required by the argument, an aJavaInterface"
  1572      required by the argument, an aJavaInterface"
  1668 
  1573 
  1669     interfaces size > 0 ifTrue:[
  1574     interfaces size > 0 ifTrue:[
  1670         self interfaces do:[:if |
  1575 	self interfaces do:[:if |
  1671             aJavaInterface == if ifTrue:[
  1576 	    aJavaInterface == if ifTrue:[
  1672                 ^ true
  1577 		^ true
  1673             ].
  1578 	    ].
  1674         ]
  1579 	]
  1675     ].
  1580     ].
  1676     superclass isJavaClass ifTrue:[
  1581     superclass isJavaClass ifTrue:[
  1677         ^ superclass hasInterface:aJavaInterface
  1582 	^ superclass hasInterface:aJavaInterface
  1678     ].
  1583     ].
  1679     ^ false.
  1584     ^ false.
  1680 
  1585 
  1681 "/    aJavaInterface methodDictionary keysAndValuesDo:[:sel :mthd |
  1586 "/    aJavaInterface methodDictionary keysAndValuesDo:[:sel :mthd |
  1682 "/        (self canUnderstand:sel) ifFalse:[
  1587 "/        (self canUnderstand:sel) ifFalse:[
  1687 
  1592 
  1688     "Modified: / 28.1.1998 / 01:46:16 / cg"
  1593     "Modified: / 28.1.1998 / 01:46:16 / cg"
  1689 
  1594 
  1690 !
  1595 !
  1691 
  1596 
  1692 isAbstract
       
  1693     "return true, if the receiver is abstract
       
  1694      (i.e. may not have instances)"
       
  1695 
       
  1696     ^ (accessFlags bitAnd:A_ABSTRACT) ~~ 0
       
  1697 
       
  1698     "Modified: / 7.5.1998 / 12:24:42 / cg"
       
  1699 !
       
  1700 
       
  1701 isFinal
       
  1702     "return true, if the receiver is final
       
  1703      (i.e. may not be subclassed)"
       
  1704 
       
  1705     ^ (accessFlags bitAnd:A_FINAL) ~~ 0
       
  1706 
       
  1707     "Modified: / 7.5.1998 / 12:24:21 / cg"
       
  1708 !
       
  1709 
       
  1710 isInitialized
       
  1711     "return true, if the receiver is initialized"
       
  1712 
       
  1713     ^ (accessFlags bitAnd:A_INITIALIZED) ~~ 0
       
  1714 
       
  1715     "Modified: / 7.5.1998 / 12:23:54 / cg"
       
  1716 !
       
  1717 
       
  1718 isInterface
       
  1719     "return true, if the receiver is an interface"
       
  1720 
       
  1721     ^ (accessFlags bitAnd:A_INTERFACE) ~~ 0
       
  1722 
       
  1723     "Modified: / 7.5.1998 / 12:23:39 / cg"
       
  1724 !
       
  1725 
       
  1726 isJavaClass
  1597 isJavaClass
  1727     ^ self ~~ JavaClass
  1598     ^ self ~~ JavaClass
  1728 
  1599 
  1729     "Created: 18.3.1997 / 17:48:01 / cg"
  1600     "Created: 18.3.1997 / 17:48:01 / cg"
  1730 !
  1601 !
  1733     ^ false
  1604     ^ false
  1734 
  1605 
  1735     "Created: / 9.11.1999 / 15:42:10 / cg"
  1606     "Created: / 9.11.1999 / 15:42:10 / cg"
  1736 !
  1607 !
  1737 
  1608 
  1738 isObsolete 
       
  1739     "return true, if the receiver is obsolete 
       
  1740      Java classes are never."
       
  1741 
       
  1742     ^ (accessFlags bitAnd:A_OBSOLETE) ~~ 0.
       
  1743 
       
  1744     "Modified: 7.8.1997 / 19:04:28 / cg"
       
  1745 !
       
  1746 
       
  1747 isPublic
       
  1748     "return true, if the receiver is public" 
       
  1749 
       
  1750     ^ (accessFlags bitAnd:A_PUBLIC) ~~ 0
       
  1751 
       
  1752     "Modified: / 7.5.1998 / 12:22:44 / cg"
       
  1753 !
       
  1754 
       
  1755 isUnresolved
  1609 isUnresolved
  1756     "return true, if the receiver is unresolved;
  1610     "return true, if the receiver is unresolved;
  1757      javaClasses are never; JavaUnresolvedClasses are always" 
  1611      javaClasses are never; JavaUnresolvedClasses are always"
  1758 
  1612 
  1759     ^ false
  1613     ^ false
  1760 
  1614 
  1761     "Modified: / 7.5.1998 / 12:23:14 / cg"
  1615     "Modified: / 7.5.1998 / 12:23:14 / cg"
  1762 !
  1616 !
  1772 
  1626 
  1773     parts := self fullName asCollectionOfSubstringsSeparatedBy:$/.
  1627     parts := self fullName asCollectionOfSubstringsSeparatedBy:$/.
  1774     s := '' writeStream.
  1628     s := '' writeStream.
  1775     s nextPutAll:'JAVA'.
  1629     s nextPutAll:'JAVA'.
  1776     parts from:1 to:(parts size - 1) do:[:aPart |
  1630     parts from:1 to:(parts size - 1) do:[:aPart |
  1777         s nextPutAll:'::'.
  1631 	s nextPutAll:'::'.
  1778         s nextPutAll:aPart
  1632 	s nextPutAll:aPart
  1779     ].
  1633     ].
  1780     ^ s contents
  1634     ^ s contents
  1781 
  1635 
  1782     "
  1636     "
  1783      JAVA::java::lang::Object fullName        
  1637      JAVA::java::lang::Object fullName
  1784      JAVA::java::lang::Object nameSpacePath   
  1638      JAVA::java::lang::Object nameSpacePath
  1785      JAVA::java::lang::Object name            
  1639      JAVA::java::lang::Object name
  1786     "
  1640     "
  1787 
  1641 
  1788     "Modified: / 19.10.1998 / 20:07:24 / cg"
  1642     "Modified: / 19.10.1998 / 20:07:24 / cg"
  1789 !
  1643 !
  1790 
  1644 
  1797 
  1651 
  1798 typeName
  1652 typeName
  1799     ^ 'L' , self fullName
  1653     ^ 'L' , self fullName
  1800 
  1654 
  1801     "
  1655     "
  1802      (Java at:'java.util.Stack') typeName 
  1656      (Java at:'java.util.Stack') typeName
  1803     "
  1657     "
  1804 
  1658 
  1805     "Modified: / 10.2.1998 / 17:13:26 / cg"
  1659     "Modified: / 10.2.1998 / 17:13:26 / cg"
  1806 ! !
  1660 ! !
  1807 
  1661 
  1808 !JavaClass methodsFor:'special'!
  1662 !JavaClass methodsFor:'special'!
  1809 
  1663 
  1810 arrayClass
  1664 arrayClass
  1811 "/ self halt.
  1665 "/ self halt.
  1812         ^ Array
  1666 	^ Array
  1813 
  1667 
  1814     "Created: / 10.11.1998 / 02:07:32 / cg"
  1668     "Created: / 10.11.1998 / 02:07:32 / cg"
  1815     "Modified: / 8.1.1999 / 14:11:34 / cg"
  1669     "Modified: / 8.1.1999 / 14:11:34 / cg"
  1816 !
  1670 !
  1817 
  1671 
  1822     "Created: / 10.11.1998 / 02:07:01 / cg"
  1676     "Created: / 10.11.1998 / 02:07:01 / cg"
  1823     "Modified: / 8.1.1999 / 14:11:26 / cg"
  1677     "Modified: / 8.1.1999 / 14:11:26 / cg"
  1824 !
  1678 !
  1825 
  1679 
  1826 deref
  1680 deref
  1827         ^ self
  1681 	^ self
  1828 
  1682 
  1829     "Created: / 10.11.1998 / 02:08:06 / cg"
  1683     "Created: / 10.11.1998 / 02:08:06 / cg"
  1830 !
  1684 !
  1831 
  1685 
  1832 updateClassRefsFrom:oldClass to:newClass
  1686 updateClassRefsFrom:oldClass to:newClass
  1833     self == oldClass ifTrue:[
  1687     self == oldClass ifTrue:[
  1834         self makeObsolete.
  1688 	self makeObsolete.
  1835         ^ self
  1689 	^ self
  1836     ].
  1690     ].
  1837 
  1691 
  1838     constantPool updateClassRefsFrom:oldClass to:newClass.
  1692     constantPool updateClassRefsFrom:oldClass to:newClass.
  1839     interfaces notNil ifTrue:[
  1693     interfaces notNil ifTrue:[
  1840         interfaces := interfaces collect:[:anInterface |
  1694 	interfaces := interfaces collect:[:anInterface |
  1841                                             anInterface == oldClass ifTrue:[
  1695 					    anInterface == oldClass ifTrue:[
  1842                                                 newClass isNil ifTrue:[
  1696 						newClass isNil ifTrue:[
  1843                                                     nil "/ replace by an unresolvedInterface
  1697 						    nil "/ replace by an unresolvedInterface
  1844                                                 ] ifFalse:[
  1698 						] ifFalse:[
  1845                                                     newClass
  1699 						    newClass
  1846                                                 ]
  1700 						]
  1847                                             ] ifFalse:[
  1701 					    ] ifFalse:[
  1848                                                 anInterface
  1702 						anInterface
  1849                                             ]
  1703 					    ]
  1850                                          ]
  1704 					 ]
  1851     ]
  1705     ]
  1852 
  1706 
  1853     "Modified: / 4.2.1998 / 22:08:19 / cg"
  1707     "Modified: / 4.2.1998 / 22:08:19 / cg"
  1854 ! !
  1708 ! !
  1855 
  1709 
  1856 !JavaClass class methodsFor:'documentation'!
  1710 !JavaClass class methodsFor:'documentation'!
  1857 
  1711 
  1858 version
  1712 version
  1859     ^ '$Header: /cvs/stx/stx/libjava/JavaClass.st,v 1.124 2002-11-22 20:09:17 cg Exp $'
  1713     ^ '$Header: /cvs/stx/stx/libjava/JavaClass.st,v 1.125 2005-08-12 16:31:06 cg Exp $'
  1860 ! !
  1714 ! !
  1861 
  1715 
  1862 JavaClass initialize!
  1716 JavaClass initialize!