--- a/JavaClass.st Tue Aug 05 09:27:47 2014 +0100
+++ b/JavaClass.st Tue Aug 05 21:57:28 2014 +0100
@@ -621,9 +621,11 @@
!
annotations
- ^ annotations ifNil:[JavaClassAnnotationContainer empty].
-
- "Modified: / 03-03-2011 / 22:52:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ ^ annotations isNil ifTrue:[
+ JavaClassAnnotationContainer empty
+ ].
+
+ "Modified: / 04-08-2014 / 15:54:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
annotations:something
@@ -711,27 +713,20 @@
!
enclosingClass
+ "Returns the immediately enclosing class of the underlying
+ this class. If the this class is a top level class this
+ method returns nil."
+
| enclosingMethodAttr |
enclosingMethodAttr := self getAttribute: #EnclosingMethod.
enclosingMethodAttr isNil ifTrue:[
- "/ Funny, for some inner classes the enclosing method attributes is not generated...
- | dollar |
- ^ ((dollar := binaryName lastIndexOf: $$) == 0) ifTrue:[
- nil
- ] ifFalse:[
- | enclosingClassName |
-
- enclosingClassName := binaryName copyTo: dollar - 1.
- enclosingClassName notEmptyOrNil ifTrue:[
- JavaVM classForName: enclosingClassName definedBy: classLoader
- ]
- ]
+ ^ self declaringClass
].
^ enclosingMethodAttr first resolve: false.
"Created: / 13-09-2013 / 01:26:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 14-10-2013 / 16:16:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified (comment): / 05-08-2014 / 09:49:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
enclosingMethod
@@ -748,11 +743,14 @@
!
ensureHasAnnotations
- annotations ifNil: [ annotations := JavaAnnotationContainer for: self ].
+ annotations isNil ifTrue:[
+ annotations := JavaAnnotationContainer for:self
+ ].
^ annotations
"Created: / 25-02-2011 / 16:02:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 16-03-2011 / 17:13:47 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 04-08-2014 / 15:54:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
fields
@@ -901,11 +899,16 @@
!
runtimeVisibleAnnotationsAsBytesOrNil
- annotations ifNil:[ ^ nil ].
- annotations runtimeVisible ifNil:[ ^ nil ].
+ annotations isNil ifTrue:[
+ ^ nil
+ ].
+ annotations runtimeVisible isNil ifTrue:[
+ ^ nil
+ ].
^ annotations runtimeVisible bytes
"Created: / 25-02-2011 / 16:48:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 04-08-2014 / 15:54:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
setSignature: aSymbol
@@ -1632,7 +1635,17 @@
(((accessFlags bitAnd: ACX_INITIALIZED) == 0) and:[(accessFlags bitAnd: ACX_INITIALIZING) == 0]) ifTrue: [
accessFlags := accessFlags bitOr: ACX_INITIALIZING.
superclass ~~ JavaObject ifTrue: [ superclass classInit ].
- "JV@2011-12-03: Also call initializeStaticFields"
+
+ "JV@2014-08-04: Flush caches here."
+ "/ Class reader does not flush caches, instead caches are flushed
+ "/ here, at the very last moment, when a class is actually initialized. This should
+ "/ be sufficent as an object cannot be sent a message unless a class is
+ "/ initialized first. This saves us a little bit of time when reading classes
+ "/ but cost time when initializing the class, so normally this is not much
+ "/ of a saving. However, this helps in cases Java class is only read into memory
+ "/ and never initialized - that's what JBrowser Workspace does.
+ ObjectMemory flushCaches.
+ "JV@2011-12-03: Also call initializeStaticFields"
self initializeStaticFields.
m := self compiledMethodAt: #'<clinit>()V'.
m notNil ifTrue: [
@@ -1669,7 +1682,7 @@
"Modified: / 12-11-1998 / 15:41:11 / cg"
"Modified: / 18-08-2011 / 19:37:33 / jv"
"Modified: / 08-12-2011 / 21:05:21 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
- "Modified: / 08-12-2013 / 22:28:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified (comment): / 04-08-2014 / 17:05:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
classInitInternal