harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gshiman...@apache.org
Subject svn commit: r547333 - in /harmony/enhanced/drlvm/trunk: src/test/regression/H3908/ src/test/regression/H3908/InvokeTest.java vm/vmcore/src/reflection/reflection.cpp
Date Thu, 14 Jun 2007 17:48:16 GMT
Author: gshimansky
Date: Thu Jun 14 10:48:15 2007
New Revision: 547333

URL: http://svn.apache.org/viewvc?view=rev&rev=547333
Log:
Applied patch from HARMONY-3908
[drlvm][kernel] Drlvm crashes on Method.invoke(obj, {arg}) if arg extends Number instead of
expected primitive type wrapper


Added:
    harmony/enhanced/drlvm/trunk/src/test/regression/H3908/
    harmony/enhanced/drlvm/trunk/src/test/regression/H3908/InvokeTest.java   (with props)
Modified:
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/reflection/reflection.cpp

Added: harmony/enhanced/drlvm/trunk/src/test/regression/H3908/InvokeTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/src/test/regression/H3908/InvokeTest.java?view=auto&rev=547333
==============================================================================
--- harmony/enhanced/drlvm/trunk/src/test/regression/H3908/InvokeTest.java (added)
+++ harmony/enhanced/drlvm/trunk/src/test/regression/H3908/InvokeTest.java Thu Jun 14 10:48:15
2007
@@ -0,0 +1,54 @@
+package org.apache.harmony.drlvm.tests.regression.h3908;
+
+import junit.framework.TestCase;
+
+import java.lang.reflect.Method;
+
+public class InvokeTest extends TestCase {
+
+    byte b = 0;
+
+    public static void main(String args[]) {
+        (new InvokeTest()).test();
+    }
+
+    public void test() {
+        boolean status = false;
+
+        try {
+            Method method = InvokeTest.class.getDeclaredMethod("method", new Class[] {Byte.TYPE});
+            method.invoke(new InvokeTest(), new Object[] {new N()});
+            System.out.println("TEST FAILED: no exception");
+        } catch(IllegalArgumentException e) {
+            status = true;
+            System.out.println("TEST PASSED: " + e);
+        } catch(Exception e) {
+            System.out.println("TEST FAILED: unexpected " + e);
+        }
+
+        assertTrue(status);
+    }
+
+    public void method(byte b) {
+        this.b = b;
+    }
+}
+
+class N extends Number {
+
+    public double doubleValue() {
+        return 0;
+    }
+
+    public float floatValue() {
+        return 0;
+    }
+
+    public int intValue() {
+        return 0;
+    }
+
+    public long longValue() {
+        return 0;
+    }
+}

Propchange: harmony/enhanced/drlvm/trunk/src/test/regression/H3908/InvokeTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/reflection/reflection.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/reflection/reflection.cpp?view=diff&rev=547333&r1=547332&r2=547333
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/reflection/reflection.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/reflection/reflection.cpp Thu Jun 14 10:48:15
2007
@@ -309,9 +309,13 @@
             char arg_sig = is_wrapper_class(arg_clss->get_name()->bytes);
             char param_sig = (char)type;
 
-            ASSERT(arg_sig, "Reflection arguments mismatch: expected " 
-                << param_sig << " but was " << arg_clss->get_name()->bytes);
-            
+            // actual parameter is not a wrapper
+            if (0 == arg_sig) {
+                ThrowNew_Quick(jenv, "java/lang/IllegalArgumentException",
+                    "actual parameter for the primitive argument is not a wrapper object");
+                return false;
+            }
+
             array[arg_number] = unwrap_primitive(jenv, arg, arg_sig);
 
             if (!widen_primitive_jvalue(array + arg_number, arg_sig, param_sig)) {



Mime
View raw message