JavaConstantPool: bug fix: JavaConstanPool new: size did not return a constant pool
--- a/src/JavaConstantPool.st Fri Apr 08 15:08:34 2011 +0000
+++ b/src/JavaConstantPool.st Sat Apr 09 07:28:53 2011 +0000
@@ -13,7 +13,7 @@
Array variableSubclass:#JavaConstantPool
instanceVariableNames:'owner'
- classVariableNames:''
+ classVariableNames:'ConstantPools'
poolDictionaries:''
category:'Languages-Java-Reader-Support'
!
@@ -36,6 +36,48 @@
! !
+!JavaConstantPool class methodsFor:'initialization'!
+
+initialize
+ ConstantPools := OrderedCollection new: 1000.
+
+ "Modified: / 08-04-2011 / 17:28:07 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 09-04-2011 / 09:25:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!JavaConstantPool class methodsFor:'instance creation'!
+
+new: size
+ "return an initialized instance"
+
+ ^ ConstantPools add:
+ ((super new: size)
+ initialize;
+ yourself)
+
+ "Created: / 08-04-2011 / 16:56:18 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 09-04-2011 / 09:24:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!JavaConstantPool class methodsFor:'accessing'!
+
+allConstantPools
+ "linked list of all constant pools in system"
+ ^ ConstantPools.
+
+ "Created: / 08-04-2011 / 16:53:58 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 09-04-2011 / 09:24:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+allConstantPools: aLinkedList
+ "linked list of all constant pools in system"
+
+ ConstantPools := aLinkedList.
+
+ "Created: / 08-04-2011 / 17:07:28 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+ "Modified: / 09-04-2011 / 09:24:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
!JavaConstantPool class methodsFor:'special'!
compressPools
@@ -85,6 +127,21 @@
"
"Modified: 19.8.1997 / 14:04:25 / cg"
+!
+
+invalidateForClass: internalJavaClassName
+ "Only alias, everybody calls invalidateForClass so why not me :)"
+
+ ^self invalidateReferencesToClass: internalJavaClassName.
+
+ "Created: / 08-04-2011 / 16:52:52 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
+invalidateReferencesToClass: internalJavaClassName
+"Go over all constant pools and call invalidateForClass on all references. (usable when given class was unloaded etc)"
+allConstantPools do: [:each | each invalidateForClass: internalJavaClassName].
+
+ "Created: / 08-04-2011 / 16:09:03 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
! !
!JavaConstantPool methodsFor:'accessing'!
@@ -105,6 +162,17 @@
"Created: 28.6.1996 / 21:12:22 / cg"
! !
+!JavaConstantPool methodsFor:'initialization'!
+
+initialize
+ "Invoked when a new instance is created."
+
+ "/ please change as required (and remove this comment)
+ "/ owner := nil.
+
+ "/ super initialize. -- commented since inherited method does nothing
+! !
+
!JavaConstantPool methodsFor:'printing & storing'!
displayString
@@ -167,6 +235,14 @@
"Created: / 4.1.1998 / 00:40:11 / cg"
!
+invalidateForClass: internalJavaClassName
+"go over all entries and call invalidateForClass on all references"
+
+self do: [:entry | entry isJavaRef ifTrue:[entry invalidateForClass: internalJavaClassName]].
+
+ "Created: / 08-04-2011 / 16:11:36 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
updateClassRefsFrom:oldClass to:newClass
owner == oldClass ifTrue:[
self halt.
@@ -226,3 +302,5 @@
version_SVN
^ '$Id$'
! !
+
+JavaConstantPool initialize!