Fixes for invoke0 native jk_new_structure
authorvranyj1
Sun, 14 Aug 2011 19:36:39 +0000
branchjk_new_structure
changeset 914 0331f83c542a
parent 913 1781f130b005
child 915 cf0d328465c2
Fixes for invoke0 native
src/JavaField.st
src/JavaVM.st
--- a/src/JavaField.st	Sun Aug 14 18:49:52 2011 +0000
+++ b/src/JavaField.st	Sun Aug 14 19:36:39 2011 +0000
@@ -250,16 +250,6 @@
     ^ signature
 
     "Created: / 15.10.1998 / 10:37:06 / cg"
-!
-
-signatureWithoutTypeVariables
-
-    (signature includes: $<) ifFalse:[^signature].
-
-    ^(signature upTo: $<) , ';'
-
-    "Created: / 15-10-1998 / 10:37:06 / cg"
-    "Created: / 13-08-2011 / 00:42:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !JavaField methodsFor:'initialization'!
@@ -336,9 +326,9 @@
 !JavaField methodsFor:'queries'!
 
 initialValue
-    ^ JavaClass initialValueFromSignature:signature
+    ^ JavaClass initialValueFromSignature: descriptor
 
-
+    "Modified: / 14-08-2011 / 19:59:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 isFinal
@@ -392,10 +382,10 @@
 
 typeClass
 
-    ^(JavaDescriptor fromString: signature) javaClass.
+    ^(JavaDescriptor fromString: descriptor) javaClass.
 
     "Created: / 23-11-2010 / 17:02:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 25-11-2010 / 18:35:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 14-08-2011 / 19:59:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !JavaField class methodsFor:'documentation'!
--- a/src/JavaVM.st	Sun Aug 14 18:49:52 2011 +0000
+++ b/src/JavaVM.st	Sun Aug 14 19:36:39 2011 +0000
@@ -2466,6 +2466,12 @@
 canCast: s to: t
     "Helper for _CHECKCAST:_:"
     | sc tc |
+
+    "Not specified in JVM spec, sigh"
+    s isJavaPrimitiveType ifTrue:[
+        "FIXME"
+        ^s == t
+    ].
     "
     Java VM Spec, 3rd edition, p 280:
 
@@ -2527,7 +2533,7 @@
 
     "Modified: / 09-01-1999 / 00:45:21 / cg"
     "Created: / 11-02-2011 / 08:21:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 25-06-2011 / 08:46:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 14-08-2011 / 20:13:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 javaArrayClassFor:aClass 
@@ -4765,16 +4771,17 @@
 
     jClass := aJavaContext receiver.
     cls := self reflection classForJavaClassObject:jClass.
+    cls isJavaPrimitiveType ifTrue:[^nil].
     loader := cls classLoader.
-    loader isNil ifTrue:[
-        cls := (Java at:'java/lang/ClassLoader').
-        clc notNil ifTrue:[loader := clc instVarNamed: #scl].
-    ].
+"/    loader isNil ifTrue:[
+"/        cls := (Java at:'java/lang/ClassLoader').
+"/        clc notNil ifTrue:[loader := clc instVarNamed: #scl].
+"/    ].
     ^ loader
 
     "Created: / 25-10-2010 / 22:49:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     "Modified: / 28-01-2011 / 15:18:54 / Marcel Hlopko <hlopik@gmail.com>"
-    "Modified: / 10-08-2011 / 23:02:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 14-08-2011 / 20:14:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _java_lang_Class_getComponentType: nativeContext
@@ -4844,6 +4851,10 @@
 
     class := self reflection 
                 classForJavaClassObject:(javaClassObject := aJavaContext argAt:0).
+    (class isJavaPrimitiveType or:[class isJavaArrayClass]) ifTrue:[
+        ^(self classForName:'java.lang.reflect.Field') javaArrayClass new:0.
+    ].
+    
     publicOnly := (aJavaContext argAt:1) == 1.
     fields := class fields.
     publicOnly ifTrue:[ fields := fields select:[:f | f isPublic ] ].
@@ -4854,7 +4865,7 @@
 
     "Created: / 10-11-2010 / 16:22:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     "Modified: / 28-01-2011 / 15:19:06 / Marcel Hlopko <hlopik@gmail.com>"
-    "Modified: / 16-03-2011 / 15:43:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 14-08-2011 / 20:19:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _java_lang_Class_getDeclaredMethods0:aJavaContext 
@@ -4914,7 +4925,9 @@
 
     <javanative: 'java/lang/Class' name: 'getEnclosingMethod0'>
 
-    ^ UnimplementedNativeMethodSignal raise
+    ^nil "/Not true"
+
+    "Modified: / 14-08-2011 / 20:05:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _java_lang_Class_getGenericSignature: nativeContext
@@ -14438,10 +14451,20 @@
     args := nativeContext argAt: 3.
 
     method := self reflection methodForJavaMethodObject: m.
+    method isStatic ifTrue:[
+        obj := method javaClass.
+    ].
+
+    obj isNil ifTrue:[
+        self throwNullPointerException.
+        ^nil.            
+    ].
+
+
 
     "Possibly unbox arguments"
     args notEmptyOrNil ifTrue:[
-        adescriptors := (JavaDescriptor fromString: method signature) parameters.
+        adescriptors := method descriptor parameters.
         uargs := Array new: args size.
         1 to: args size do:[:i|
             uargs at: i put: ((adescriptors at: i) javaClass javaUnbox: (args at:i))
@@ -14450,13 +14473,11 @@
         uargs := #()
     ].
     "Fire the method"
-    ^method
-        valueWithReceiver: obj
-        arguments: uargs
+    ^obj perform: method selector withArguments: uargs
 
     "Created: / 06-02-2011 / 00:00:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     "Modified: / 28-02-2011 / 16:57:31 / Marcel Hlopko <hlopik@gmail.com>"
-    "Modified: / 05-08-2011 / 19:13:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 14-08-2011 / 20:30:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _sun_reflect_Reflection_getCallerClass: aJavaContext