JavaRef2.st
branchdevelopment
changeset 2992 732f9db2a195
parent 2976 a384a02381c0
child 3214 c38fcee7b0da
--- a/JavaRef2.st	Thu Jan 30 23:40:39 2014 +0000
+++ b/JavaRef2.st	Fri Jan 31 09:19:51 2014 +0000
@@ -21,7 +21,7 @@
 "{ Package: 'stx:libjava' }"
 
 Object subclass:#JavaRef2
-	instanceVariableNames:'valueCache constantPool'
+	instanceVariableNames:'resolvedValue constantPool'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'Languages-Java-Reader-Support-new'
@@ -51,6 +51,42 @@
      as of 1.9.2010
 
 "
+!
+
+documentation
+"
+    An abstract superclass for symbolic references in Java class files.
+    A reference is either ''unresolved'' (when `resolvedValue` instvar nil)
+    or ''resolved'' (when ``resolvedValue`` instvar is not nil).
+
+    IMPORTANT: The exact physical structure of (sub)instances is known
+    by the VM and therefore changing number, order or meaning of individual
+    instance variables would imply to change the VM accordingly.
+    See comments in individual subclasses which instvars are accessed by the VM.
+
+    IMPORTANT: There's a naming convention:
+    Slots whose name starts with ''resolved'' are valid only after the reference
+    is resolved. Otherwise, they MUST have nil value.
+    Other slots MUST be valid once JavaClassReader finishes reading of the 
+    .class file.
+
+    [author:]
+        Marcel Hlopko <marcel.hlopko@fit.cvut.cz>
+        Jan Vrany <jan.vrany@fit.cvut.cz>
+
+    [instance variables:]
+      !! resolvedValue ..... resolved value whatever it is (class, method, field...).
+                            It also serve as an indicator whether the reference
+                            is unresolved (nil value) or resolved (non-nil value).
+                            !!!!!! Used by the VM !!!!!!
+        constantPool ...... a constant pool to which this reference belongs.
+
+    [class variables:]
+
+    [see also:]
+        Subclasses
+
+"
 ! !
 
 !JavaRef2 class methodsFor:'instance creation'!
@@ -81,10 +117,11 @@
 !
 
 isResolved
-    ^ valueCache isNil not.
+    ^ resolvedValue notNil.
 
     "Created: / 08-04-2011 / 11:36:03 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
     "Modified: / 08-04-2011 / 17:39:42 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+    "Modified: / 31-01-2014 / 02:30:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 name
@@ -105,54 +142,37 @@
     "Modified: / 12-05-2011 / 18:32:04 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
 !
 
-valueCache
-    ^ valueCache.
-
-    "Created: / 08-04-2011 / 11:37:31 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+resolvedValue
+    ^ resolvedValue
 ! !
 
 !JavaRef2 methodsFor:'comparing'!
 
 = anotherJavaRef
-^ self subclassResponsibility.
+
+    ^ self subclassResponsibility.
 
     "Created: / 08-04-2011 / 12:15:36 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+    "Modified (format): / 31-01-2014 / 03:14:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 hash
 
-^ self subclassResponsibility.
+    ^ self subclassResponsibility.
 
     "Created: / 08-04-2011 / 12:15:51 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+    "Modified (format): / 31-01-2014 / 03:14:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !JavaRef2 methodsFor:'initialization'!
 
 initialize
-    valueCache := nil.
+    resolvedValue := nil.
     super initialize.
 
     "Modified: / 08-04-2011 / 17:39:23 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
 ! !
 
-!JavaRef2 methodsFor:'logging'!
-
-info: arg
-
-    Logger log: arg severity: #info facility: 'JVM'
-
-    "Created: / 10-05-2011 / 16:50:48 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
-    "Modified: / 14-09-2011 / 21:47:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-warning: arg 
-
-    Logger log: arg severity: #warn facility: 'JVM'
-
-    "Created: / 10-05-2011 / 15:01:08 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
-    "Modified: / 14-09-2011 / 21:47:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-
 !JavaRef2 methodsFor:'printing'!
 
 displayString
@@ -206,8 +226,8 @@
 
     | invalidated |
 
-    invalidated := valueCache notNil.
-    valueCache := nil.
+    invalidated := resolvedValue notNil.
+    resolvedValue := nil.
     ^ invalidated
 
     "Created: / 08-04-2011 / 11:42:43 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
@@ -237,27 +257,17 @@
     "Created: / 15-10-2012 / 23:13:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
-preresolve
-    "Pre-resolve some caches. Called when the constant pool
-     is loaded. MUST NOT load new nor modify any existing class!!!!!!
-     Ask JV for what this is needed"
-
-    "Nothing by default"
-
-    "Created: / 15-10-2012 / 23:08:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
 resolve
     "
      Do it all method - resolves current reference and returns expected element (JavaMethod, JavaField etc.)
      Hides implementation details of the way of dealing with invalidation etc. User should not need to call anything
      else."
     
-     self resolve: true.
-    ^ valueCache.
+     ^ self resolve: true.
 
     "Created: / 08-04-2011 / 11:30:21 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
     "Modified: / 23-02-2012 / 17:21:39 / Marcel Hlopko <hlopik@gmail.com>"
+    "Modified (format): / 31-01-2014 / 09:08:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 resolve: doClassInit
@@ -274,27 +284,18 @@
             ].
         ]
     ].
-    ^ valueCache.
+    ^ resolvedValue.
 
     "Created: / 08-04-2011 / 11:30:21 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
     "Created: / 09-02-2012 / 23:08:15 / mh <hlopik@gmail.com>"
     "Modified: / 23-12-2013 / 23:02:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-updateClassRefsFrom: oldOwner to: newOwner 
-    self owner = oldOwner ifTrue: [
-        self owner: newOwner.
-    ].
-
-    "Created: / 10-05-2011 / 16:50:48 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
-    "Modified: / 04-06-2011 / 17:54:16 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
 ! !
 
 !JavaRef2 methodsFor:'testing'!
 
 isUnresolved
 
-    ^valueCache isNil
+    ^resolvedValue isNil
 
     "Created: / 22-05-2011 / 14:01:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !