OSDN Git Service

android-2.1_r1 snapshot
authorThe Android Open Source Project <initial-contribution@android.com>
Tue, 12 Jan 2010 23:18:14 +0000 (15:18 -0800)
committerThe Android Open Source Project <initial-contribution@android.com>
Tue, 12 Jan 2010 23:18:14 +0000 (15:18 -0800)
libcore/luni/src/test/java/tests/api/java/lang/reflect/GenericReflectionCornerCases.java
libcore/luni/src/test/java/tests/api/java/lang/reflect/GenericTypesTest.java
libcore/luni/src/test/java/tests/api/java/lang/reflect/ParameterizedTypeTest.java
libcore/nio_char/src/test/java/tests/api/java/nio/charset/CharsetProviderTest.java
libnativehelper/JNIHelp.c
libnativehelper/include/nativehelper/JNIHelp.h
vm/Exception.c

index 8919652..0ef69ec 100644 (file)
@@ -16,6 +16,7 @@
 
 package tests.api.java.lang.reflect;
 
+import dalvik.annotation.BrokenTest;
 import dalvik.annotation.KnownFailure;
 import dalvik.annotation.TestTargets;
 import dalvik.annotation.TestLevel;
@@ -169,6 +170,7 @@ public class GenericReflectionCornerCases extends GenericReflectionTestsBase {
         )
     })
     @SuppressWarnings("unchecked")
+    @BrokenTest(value = "fails when run using CTS harness bug 2155700")
     public void testMultipleBoundedWildcardUnEquality() throws Exception {
         Class<? extends MultipleBoundedWildcardUnEquality> clazz = MultipleBoundedWildcardUnEquality.class;
 
@@ -238,6 +240,7 @@ public class GenericReflectionCornerCases extends GenericReflectionTestsBase {
         )
     })
     @SuppressWarnings("unchecked")
+    @BrokenTest(value = "fails when run using CTS harness bug 2155700")
     public void testMultipleBoundedWildcard() throws Exception {
         Class<? extends MultipleBoundedWildcardEquality> clazz = MultipleBoundedWildcardEquality.class;
 
index 7db5dbe..d258d1e 100644 (file)
 
 package tests.api.java.lang.reflect;
 
-import dalvik.annotation.KnownFailure;
-import dalvik.annotation.TestTargets;
+import dalvik.annotation.BrokenTest;
 import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTargetNew;
 import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.TestTargetNew;
 
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Method;
@@ -201,6 +200,7 @@ public class GenericTypesTest extends GenericReflectionTestsBase {
         args = {}
     )
     @SuppressWarnings("unchecked")
+    @BrokenTest(value = "fails when run using CTS harness bug 2155700")
     public void testSimpleInheritance() throws Exception {
         Class<? extends SimpleInheritance> clazz = SimpleInheritance.class;
         TypeVariable<Class> subTypeVariable = getTypeParameter(clazz);
index bf3698e..9d0008b 100644 (file)
 
 package tests.api.java.lang.reflect;
 
+import dalvik.annotation.BrokenTest;
 import dalvik.annotation.KnownFailure;
-import dalvik.annotation.TestTargets;
 import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTargetNew;
 import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
 
 import java.lang.reflect.Field;
 import java.lang.reflect.ParameterizedType;
@@ -55,6 +56,7 @@ public class ParameterizedTypeTest extends GenericReflectionTestsBase {
             args = {}
         )
     })
+    @BrokenTest(value = "fails when run using CTS harness bug 2155700")
     public void testStringParameterizedSuperClass() {
         Class<? extends B> clazz = B.class;
         Type genericSuperclass = clazz.getGenericSuperclass();
@@ -91,6 +93,7 @@ public class ParameterizedTypeTest extends GenericReflectionTestsBase {
             args = {}
         )
     })
+    @BrokenTest(value = "fails when run using CTS harness bug 2155700")
     public void testTypeParameterizedSuperClass() {
         Class<? extends D> clazz = D.class;
         Type genericSuperclass = clazz.getGenericSuperclass();
index 903c689..da1956f 100644 (file)
@@ -15,6 +15,7 @@
  */
 package tests.api.java.nio.charset;
 
+import dalvik.annotation.BrokenTest;
 import dalvik.annotation.KnownFailure;
 import dalvik.annotation.TestLevel;
 import dalvik.annotation.TestTargetClass;
@@ -266,6 +267,7 @@ public class CharsetProviderTest extends TestCase {
         method = "charsetForName",
         args = {String.class}
     )
+    @BrokenTest(value = "fails when run using CTS harness bug 2155700")
     public void testIsSupported_InsufficientPrivilege() throws Exception {
         SecurityManager oldMan = System.getSecurityManager();
         System.setSecurityManager(new MockSecurityManager());
@@ -299,6 +301,7 @@ public class CharsetProviderTest extends TestCase {
         method = "charsetForName",
         args = {String.class}
     )
+    @BrokenTest(value = "fails when run using CTS harness bug 2155700")
     public void testForName_InsufficientPrivilege() throws Exception {
         SecurityManager oldMan = System.getSecurityManager();
         System.setSecurityManager(new MockSecurityManager());
index aacecb6..748d8ff 100644 (file)
@@ -55,7 +55,15 @@ int jniThrowException(JNIEnv* env, const char* className, const char* msg)
 }
 
 /*
- * Throw a java.IO.IOException, generating the message from errno.
+ * Throw a java.lang.RuntimeException, with an optional message.
+ */
+int jniThrowRuntimeException(JNIEnv* env, const char* msg)
+{
+    return jniThrowException(env, "java/lang/RuntimeException", msg);
+}
+
+/*
+ * Throw a java.io.IOException, generating the message from errno.
  */
 int jniThrowIOException(JNIEnv* env, int errnum)
 {
@@ -85,4 +93,3 @@ int jniThrowIOException(JNIEnv* env, int errnum)
 
     return jniThrowException(env, "java/io/IOException", message);
 }
-
index 3982797..698cba7 100644 (file)
@@ -53,7 +53,12 @@ int jniRegisterNativeMethods(C_JNIEnv* env, const char* className,
 int jniThrowException(C_JNIEnv* env, const char* className, const char* msg);
 
 /*
- * Throw a java.IO.IOException, generating the message from errno.
+ * Throw a java.lang.RuntimeException, with an optional message.
+ */
+int jniThrowRuntimeException(JNIEnv* env, const char* msg);
+
+/*
+ * Throw a java.io.IOException, generating the message from errno.
  */
 int jniThrowIOException(C_JNIEnv* env, int errnum);
 
index 3a56cc3..808b0b2 100644 (file)
@@ -338,6 +338,45 @@ void dvmThrowExceptionByClassWithClassMessage(ClassObject* exceptionClass,
 }
 
 /*
+ * Find and return an exception constructor method that can take the
+ * indicated parameters, or return NULL if no such constructor exists.
+ */
+static Method* findExceptionInitMethod(ClassObject* excepClass,
+    bool hasMessage, bool hasCause)
+{
+    if (hasMessage) {
+        Method* result;
+
+        if (hasCause) {
+            result = dvmFindDirectMethodByDescriptor(
+                    excepClass, "<init>",
+                    "(Ljava/lang/String;Ljava/lang/Throwable;)V");
+        } else {
+            result = dvmFindDirectMethodByDescriptor(
+                    excepClass, "<init>", "(Ljava/lang/String;)V");
+        }
+
+        if (result != NULL) {
+            return result;
+        }
+
+        if (hasCause) {
+            return dvmFindDirectMethodByDescriptor(
+                    excepClass, "<init>",
+                    "(Ljava/lang/Object;Ljava/lang/Throwable;)V");
+        } else {
+            return dvmFindDirectMethodByDescriptor(
+                    excepClass, "<init>", "(Ljava/lang/Object;)V");
+        }
+    } else if (hasCause) {
+        return dvmFindDirectMethodByDescriptor(
+                excepClass, "<init>", "(Ljava/lang/Throwable;)V");
+    } else {
+        return dvmFindDirectMethodByDescriptor(excepClass, "<init>", "()V");
+    }
+}
+
+/*
  * Initialize an exception with an appropriate constructor.
  *
  * "exception" is the exception object to initialize.
@@ -418,43 +457,45 @@ static bool initException(Object* exception, const char* msg, Object* cause,
      * not #2.  (Some might argue that the constructor is actually not #3,
      * because it doesn't take the message string as an argument, but it
      * has the same effect and we can work with it here.)
+     *
+     * java.lang.AssertionError is also a strange case -- it has a
+     * constructor that takes an Object, but not one that takes a String.
+     * There may be other cases like this, as well, so we generally look
+     * for an Object-taking constructor if we can't find one that takes
+     * a String.
      */
     if (cause == NULL) {
         if (msgStr == NULL) {
-            initMethod = dvmFindDirectMethodByDescriptor(excepClass, "<init>", "()V");
+            initMethod = findExceptionInitMethod(excepClass, false, false);
             initKind = kInitNoarg;
         } else {
-            initMethod = dvmFindDirectMethodByDescriptor(excepClass, "<init>",
-                            "(Ljava/lang/String;)V");
+            initMethod = findExceptionInitMethod(excepClass, true, false);
             if (initMethod != NULL) {
                 initKind = kInitMsg;
             } else {
                 /* no #2, try #3 */
-                initMethod = dvmFindDirectMethodByDescriptor(excepClass, "<init>",
-                                "(Ljava/lang/String;Ljava/lang/Throwable;)V");
-                if (initMethod != NULL)
+                initMethod = findExceptionInitMethod(excepClass, true, true);
+                if (initMethod != NULL) {
                     initKind = kInitMsgThrow;
+                }
             }
         }
     } else {
         if (msgStr == NULL) {
-            initMethod = dvmFindDirectMethodByDescriptor(excepClass, "<init>",
-                            "(Ljava/lang/Throwable;)V");
+            initMethod = findExceptionInitMethod(excepClass, false, true);
             if (initMethod != NULL) {
                 initKind = kInitThrow;
             } else {
-                initMethod = dvmFindDirectMethodByDescriptor(excepClass, "<init>", "()V");
+                initMethod = findExceptionInitMethod(excepClass, false, false);
                 initKind = kInitNoarg;
                 needInitCause = true;
             }
         } else {
-            initMethod = dvmFindDirectMethodByDescriptor(excepClass, "<init>",
-                            "(Ljava/lang/String;Ljava/lang/Throwable;)V");
+            initMethod = findExceptionInitMethod(excepClass, true, true);
             if (initMethod != NULL) {
                 initKind = kInitMsgThrow;
             } else {
-                initMethod = dvmFindDirectMethodByDescriptor(excepClass, "<init>",
-                                "(Ljava/lang/String;)V");
+                initMethod = findExceptionInitMethod(excepClass, true, false);
                 initKind = kInitMsg;
                 needInitCause = true;
             }