src/JavaClass.st
branchjk_new_structure
changeset 1246 2e7d85df01f8
parent 1241 ff354f93e3ad
child 1247 59574ba88702
equal deleted inserted replaced
1245:7cf4e252749a 1246:2e7d85df01f8
  1167 
  1167 
  1168 !JavaClass methodsFor:'java initialization'!
  1168 !JavaClass methodsFor:'java initialization'!
  1169 
  1169 
  1170 classInit
  1170 classInit
  1171     "call the classes JAVA clinit function"
  1171     "call the classes JAVA clinit function"
  1172 
  1172     
  1173     |m|                                                                                    
  1173     | m |
  1174 
  1174     (accessFlags bitAnd: A_INITIALIZED) ~~ 0 ifTrue: [ ^ self ].
  1175     (accessFlags bitAnd:A_INITIALIZED) ~~ 0 ifTrue:[^ self].
  1175     accessFlags := accessFlags bitOr: A_INITIALIZED.
  1176 
  1176     superclass ~~ JavaObject ifTrue: [ superclass classInit ].
  1177     accessFlags := accessFlags bitOr:A_INITIALIZED.
  1177      "JV@2011-12-03: Also call initializeStaticFields"
  1178 
       
  1179     superclass ~~ JavaObject ifTrue:[
       
  1180         superclass classInit
       
  1181     ].
       
  1182 
       
  1183     "JV@2011-12-03: Also call initializeStaticFields"
       
  1184     self initializeStaticFields.
  1178     self initializeStaticFields.
  1185 
  1179     m := self compiledMethodAt: #'<clinit>()V'.
  1186     m := self compiledMethodAt:#'<clinit>()V'.    
  1180     m notNil ifTrue: [
  1187     m notNil ifTrue:[
       
  1188         "/'calling <clinit>() of ' print. self fullName printNL.
  1181         "/'calling <clinit>() of ' print. self fullName printNL.
  1189         [
  1182         [
  1190             OrderOfClassInits notNil ifTrue:[
  1183             OrderOfClassInits notNil ifTrue: [ OrderOfClassInits add: self. ].
  1191                 OrderOfClassInits add:self.
  1184             m 
  1192             ].
  1185                 valueWithReceiver: self
  1193 
  1186                 arguments: #()
  1194             m
  1187                 selector: #'<clinit>()V'
  1195                 valueWithReceiver:self
  1188                 search: self class
  1196                 arguments:#()
  1189                 sender: nil
  1197                 selector:#'<clinit>()V'
  1190         ] valueOnUnwindDo: [ accessFlags := accessFlags bitXor: A_INITIALIZED. ].
  1198                 search:self class
  1191         
  1199                 sender:nil
       
  1200         ] valueOnUnwindDo:[
       
  1201             accessFlags := accessFlags bitXor:A_INITIALIZED.
       
  1202         ].
       
  1203         "/'calling <clinit>() done ' print. self fullName printNL.
  1192         "/'calling <clinit>() done ' print. self fullName printNL.
  1204     ] ifFalse:[
  1193     ] ifFalse: [
  1205 "/        self fullName print. ' has no clinit()' printNL.
  1194         "/        self fullName print. ' has no clinit()' printNL.
  1206     ].
  1195     ].
  1207 
  1196     (JavaVM booted and: [JavaVM eagerResolvingEnabled] )ifTrue: [
       
  1197         JavaClassReader classLoaderQuerySignal answer: classLoader
       
  1198             do: [ self resolveAll. ]
       
  1199     ].
  1208 
  1200 
  1209     "
  1201     "
  1210      JavaVM instructionTrace:true.
  1202      JavaVM instructionTrace:true.
  1211      JavaVM callTrace:true.
  1203      JavaVM callTrace:true.
  1212 
  1204 
  1213      (Java classNamed:'java.lang.String') classInit
  1205      (Java classNamed:'java.lang.String') classInit
  1214      (Java classNamed:'java.lang.System') classInit
  1206      (Java classNamed:'java.lang.System') classInit
  1215 
  1207 
  1216      (Java classNamed:'java/io/FileDescriptor') classInit
  1208      (Java classNamed:'java/io/FileDescriptor') classInit
  1217      (Java classNamed:'java.util.Properties') classInit
  1209      (Java classNamed:'java.util.Properties') classInit"
  1218     "
       
  1219 
  1210 
  1220     "Modified: / 12-11-1998 / 15:41:11 / cg"
  1211     "Modified: / 12-11-1998 / 15:41:11 / cg"
  1221     "Modified: / 18-08-2011 / 19:37:33 / jv"
  1212     "Modified: / 18-08-2011 / 19:37:33 / jv"
  1222     "Modified: / 03-12-2011 / 12:19:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  1213     "Modified: / 03-12-2011 / 12:19:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
  1214     "Modified: / 08-12-2011 / 21:05:21 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
  1223 !
  1215 !
  1224 
  1216 
  1225 initializeStaticFields
  1217 initializeStaticFields
  1226     staticFields isNil ifTrue:[^ self].
  1218     staticFields isNil ifTrue:[^ self].
  1227 
  1219 
  1260     "Modified: / 03-12-2011 / 12:28:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  1252     "Modified: / 03-12-2011 / 12:28:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  1261 !
  1253 !
  1262 
  1254 
  1263 resolveAll
  1255 resolveAll
  1264     "resolve every ref in constantPool"
  1256     "resolve every ref in constantPool"
  1265     
       
  1266     Logger 
       
  1267         log: self class name , ': trying to resolve whole constant pool'
       
  1268         severity: #debug
       
  1269         facility: #JVM.
       
  1270     self breakPoint: #mh.
       
  1271     constantPool do: [
  1257     constantPool do: [
  1272         :each | 
  1258         :each | 
  1273         (each isJavaRef or: [ each isJavaNameAndType ]) ifTrue: [ each resolve ]
  1259         (each isJavaRef or: [ each isJavaNameAndType ]) ifTrue: [ each resolve ]
  1274     ].
  1260     ].
  1275 
  1261 
  1832 
  1818 
  1833     "Created: / 18-03-1997 / 17:48:01 / cg"
  1819     "Created: / 18-03-1997 / 17:48:01 / cg"
  1834     "Created: / 07-08-2011 / 15:50:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  1820     "Created: / 07-08-2011 / 15:50:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  1835 !
  1821 !
  1836 
  1822 
       
  1823 isFullyResolved
       
  1824 constantPool do: [:each | (each isJavaRef and: [each isResolved not]) ifTrue: [^false]].
       
  1825 ^ true.
       
  1826 
       
  1827     "Created: / 08-12-2011 / 20:44:06 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
       
  1828 !
       
  1829 
  1837 isJavaArrayClass
  1830 isJavaArrayClass
  1838 
  1831 
  1839     ^false
  1832     ^false
  1840 
  1833 
  1841     "Created: / 05-02-2011 / 22:20:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  1834     "Created: / 05-02-2011 / 22:20:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"