- JavaVM jk_new_structure
authorvranyj1
Wed, 04 Jul 2012 10:08:00 +0000
branchjk_new_structure
changeset 1505 25a5199822a9
parent 1504 26d35dc9ded2
child 1506 fd879888a9f6
- JavaVM changed: #_sun_reflect_Reflection_getCallerClass: #exceptionDebugPatterns #invoke:receiver:arguments:
src/JavaVM.st
--- a/src/JavaVM.st	Fri Jun 29 18:02:16 2012 +0000
+++ b/src/JavaVM.st	Wed Jul 04 10:08:00 2012 +0000
@@ -2629,6 +2629,7 @@
     ExceptionDebugPatterns add: 'java/lang/SecurityException*'.
     ExceptionDebugPatterns add: 'java/net/ConnectException*'.
     ExceptionDebugPatterns add: 'java/lang/IllegalArgumentException'.
+    ExceptionDebugPatterns add: 'java/lang/IllegalAccessException'.
     ExceptionDebugPatterns add: 'java/lang/ClassNotFoundException'.
     ExceptionDebugPatterns add: 'java/io/IOException'.
     ExceptionDebugPatterns add: 'java/io/FileNotFoundException'.
@@ -3008,7 +3009,7 @@
             cls := (adescriptors at: i) javaClass.
             cls isJavaPrimitiveType ifTrue:[
                 bargs at: bi put: (cls javaUnbox: (args at:i) onError:[
-                    self breakPoint: #jv.
+"/                    self breakPoint: #jv.
                     self throwIllegalArgumentException:'illegal unbox'. ^nil
                 ]).
                 (cls == LargeInteger or:[cls == Float]) ifTrue:[bi := bi + 1].
@@ -3022,7 +3023,7 @@
             bi := bi + 1.
        ].
         bi <= bargss ifTrue:[
-             self breakPoint: #jv.
+"/             self breakPoint: #jv.
              self throwExceptionClassName: 'java.lang.reflect.InvocationTargetException'
                               withMessage: 'not enough arguments'
         ].
@@ -3031,10 +3032,15 @@
     ].
 
     "Fire the method"
-    method isStatic ifTrue:[
-        retval := method valueWithReceiver: method javaClass arguments: bargs.
-    ] ifFalse:[
-        retval := obj perform: method selector withArguments: bargs.
+    [
+        method isStatic ifTrue:[
+            retval := method valueWithReceiver: method javaClass arguments: bargs.
+        ] ifFalse:[
+            retval := obj perform: method selector withArguments: bargs.
+        ].
+    ] on: Object messageNotUnderstoodSignal do:[
+        self throwIllegalArgumentException:'Message not understood - invalid class for ''this'''. 
+        ^nil    
     ].
     retcls := descriptor return.
     retcls notNil ifTrue:[
@@ -17008,15 +17014,33 @@
 _sun_reflect_Reflection_getCallerClass: aJavaContext
 
     <javanative: 'sun/reflect/Reflection' name: 'getCallerClass'>
-
+    "
+    /** Returns the class of the method <code>realFramesToSkip</code>
+        frames up the stack (zero-based), ignoring frames associated
+        with java.lang.reflect.Method.invoke() and its implementation.
+        The first frame is that associated with this method, so
+        <code>getCallerClass(0)</code> returns the Class object for
+        sun.reflect.Reflection. Frames associated with
+        java.lang.reflect.Method.invoke() and its implementation are
+        completely ignored and do not count toward the number of 'real'
+        frames skipped. */
+    "
     
     | framesToSkip framesSkipped frame |
+
+
     framesToSkip := aJavaContext argAt: 1.
     framesSkipped := 0.
     frame := aJavaContext.
-    [ framesSkipped == framesToSkip ] whileFalse:
-        [frame := frame sender.
-        framesSkipped := framesSkipped + 1].
+    [ framesSkipped == framesToSkip ] whileFalse:[
+        frame := frame sender.
+        "Frames for java,lang.reflect.Method.invoke() does not count, sigh.
+         What a crappy implementation"
+        (frame selector == #'invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;' 
+            and:[ frame receiver class name = #'java/lang/reflect/Method']) ifFalse:[
+                framesSkipped := framesSkipped + 1
+            ]
+    ].
 
     ^JavaVM javaClassObjectForClass:
         (frame receiver class theNonMetaclass)