Fix Constructor and Method to not expose their internals.

We shouldn't expose internal arrays without copying. Behavior confirmed
by testing against RI.

Also connect up the dalvik ThreadsTest test that had fallen by the wayside.

Bug: 2102273
diff --git a/libcore/luni-kernel/src/main/java/java/lang/reflect/Constructor.java b/libcore/luni-kernel/src/main/java/java/lang/reflect/Constructor.java
index c6927eb..3918d7e 100644
--- a/libcore/luni-kernel/src/main/java/java/lang/reflect/Constructor.java
+++ b/libcore/luni-kernel/src/main/java/java/lang/reflect/Constructor.java
@@ -161,12 +161,12 @@
         appendArrayGenericType(sb, 
                 Types.getClonedTypeArray(genericParameterTypes));
         sb.append(')');
-        // append exeptions if any
-        Type[] genericEceptionTypeArray = 
+        // append exceptions if any
+        Type[] genericExceptionTypeArray = 
                 Types.getClonedTypeArray(genericExceptionTypes);
-        if (genericEceptionTypeArray.length > 0) {
+        if (genericExceptionTypeArray.length > 0) {
             sb.append(" throws ");
-            appendArrayGenericType(sb, genericEceptionTypeArray);
+            appendArrayGenericType(sb, genericExceptionTypeArray);
         }
         return sb.toString();
     }
@@ -314,7 +314,7 @@
     public Class<?>[] getExceptionTypes() {
         if (exceptionTypes == null)
             return new Class[0];
-        return exceptionTypes;
+        return exceptionTypes.clone();
     }
 
     /**
@@ -354,7 +354,7 @@
      * @since Android 1.0
      */
     public Class<?>[] getParameterTypes() {
-        return parameterTypes;
+        return parameterTypes.clone();
     }
 
     /**
diff --git a/libcore/luni-kernel/src/main/java/java/lang/reflect/Method.java b/libcore/luni-kernel/src/main/java/java/lang/reflect/Method.java
index 473726d..dabf9a4 100644
--- a/libcore/luni-kernel/src/main/java/java/lang/reflect/Method.java
+++ b/libcore/luni-kernel/src/main/java/java/lang/reflect/Method.java
@@ -383,7 +383,7 @@
             return new Class[0];
         }
 
-        return exceptionTypes;
+        return exceptionTypes.clone();
     }
 
     /**
@@ -424,7 +424,7 @@
      * @since Android 1.0
      */
     public Class<?>[] getParameterTypes() {
-        return parameterTypes;
+        return parameterTypes.clone();
     }
 
     /**
@@ -521,7 +521,7 @@
         return invokeNative (receiver, args, declaringClass, parameterTypes, returnType, slot, flag);
     }
 
-    private native Object invokeNative(Object obj, Object[] args, Class<?> declaringClass, Class<?>[] parameterTYpes, Class<?> returnType, int slot, boolean noAccessCheck)
+    private native Object invokeNative(Object obj, Object[] args, Class<?> declaringClass, Class<?>[] parameterTypes, Class<?> returnType, int slot, boolean noAccessCheck)
     throws IllegalAccessException,
              IllegalArgumentException,
              InvocationTargetException;
diff --git a/libcore/luni-kernel/src/test/java/tests/api/org/apache/harmony/kernel/dalvik/AllTests.java b/libcore/luni-kernel/src/test/java/tests/api/org/apache/harmony/kernel/dalvik/AllTests.java
new file mode 100644
index 0000000..a59cc3e
--- /dev/null
+++ b/libcore/luni-kernel/src/test/java/tests/api/org/apache/harmony/kernel/dalvik/AllTests.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package tests.api.org.apache.harmony.kernel.dalvik;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class AllTests {
+    public static final Test suite() {
+        TestSuite suite = tests.TestSuiteFactory.createTestSuite();
+        suite.addTestSuite(tests.api.org.apache.harmony.kernel.dalvik.ThreadsTest.class);
+        return suite;
+    }
+}
diff --git a/libcore/luni/src/test/java/tests/AllTests.java b/libcore/luni/src/test/java/tests/AllTests.java
index 893cdf0..3a38c5f 100644
--- a/libcore/luni/src/test/java/tests/AllTests.java
+++ b/libcore/luni/src/test/java/tests/AllTests.java
@@ -54,6 +54,8 @@
         suite.addTest(tests.xml.AllTests.suite());
         suite.addTest(tests.xnet.AllTests.suite());
 
+        suite.addTest(tests.api.org.apache.harmony.kernel.dalvik.AllTests.suite());
+        suite.addTest(java.lang.reflect.AllTests.suite());
         suite.addTest(org.apache.harmony.luni.platform.AllTests.suite());
         
         return suite;