Oops, fix for resolving. development
authorJan Vrany <jan.vrany@fit.cvut.cz>
Sat, 05 Oct 2013 01:11:06 +0100
branchdevelopment
changeset 2794 cec025d0f359
parent 2793 f3cfee185a72
child 2795 92ae91b29303
Oops, fix for resolving. The JavaResolver depends on a funny interface of #javaClassName which has been changed in previous commit. The interface should be different, but to workaround it, just add a new method that behaves like #javaClassName before and call that method from resolver (#javaClassNameOrPrimitiveTypeId). However, there's bug. Consider class in default package named 'B'.
JavaClassRef2.st
JavaResolver.st
--- a/JavaClassRef2.st	Sat Oct 05 01:01:26 2013 +0100
+++ b/JavaClassRef2.st	Sat Oct 05 01:11:06 2013 +0100
@@ -117,6 +117,24 @@
     "Modified (format): / 04-10-2013 / 21:31:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
+javaClassNameOrPrimitiveTypeId
+    "return java class name as written in java programs e.g. java.util.String
+     in case of array, return class name without square brackets."
+    
+    | tmp |
+
+    "/ Argh, this implementation is rubbish!! Use indices to avoid 
+    "/ copying strings every now and again.
+    tmp := self name copy.
+    [ tmp startsWith: '[' ] whileTrue: [ tmp := tmp copyFrom: 2 ].
+    tmp := tmp replaceAll: $/ with: $..
+    (tmp startsWith: 'L') ifTrue: [ tmp := tmp copyFrom: 2 to: tmp size ].
+    (tmp endsWith: ';') ifTrue: [ tmp := tmp copyFrom: 1 to: tmp size - 1 ].
+    ^ tmp.
+
+    "Created: / 05-10-2013 / 01:05:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 name
     ^constantPool at: nameIndex.
 
--- a/JavaResolver.st	Sat Oct 05 01:01:26 2013 +0100
+++ b/JavaResolver.st	Sat Oct 05 01:11:06 2013 +0100
@@ -100,7 +100,7 @@
     | result |
     self validateClassRef: aJavaClassRef.
     result := self 
-         lookupClassIfAlreadyResolved: aJavaClassRef javaClassName
+         lookupClassIfAlreadyResolved: aJavaClassRef javaClassNameOrPrimitiveTypeId
          definedBy: aJavaClassRef classLoader.
             
 "/        result notNil ifTrue:[ 
@@ -154,7 +154,7 @@
     "Created: / 12-08-2011 / 22:19:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     "Modified (comment): / 03-10-2011 / 23:03:01 / m"
     "Modified: / 01-12-2012 / 13:44:54 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
-    "Modified: / 02-05-2013 / 01:21:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 05-10-2013 / 01:05:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !JavaResolver methodsFor:'class resolving helpers'!