diff options
author | Elliott Hughes <enh@google.com> | 2009-10-13 18:18:21 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2009-10-13 18:18:21 -0700 |
commit | 5310d25cec568714f8174f05ef34a89b4662cd03 (patch) | |
tree | 174487e4e9a4085106142b72a5a99930b1c15a59 /luni-kernel/src | |
parent | 2b67cf0c34a0069f6761b003fbf1e1f7d9c76c8c (diff) | |
download | libcore-5310d25cec568714f8174f05ef34a89b4662cd03.zip libcore-5310d25cec568714f8174f05ef34a89b4662cd03.tar.gz libcore-5310d25cec568714f8174f05ef34a89b4662cd03.tar.bz2 |
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
Diffstat (limited to 'luni-kernel/src')
3 files changed, 37 insertions, 9 deletions
diff --git a/luni-kernel/src/main/java/java/lang/reflect/Constructor.java b/luni-kernel/src/main/java/java/lang/reflect/Constructor.java index c6927eb..3918d7e 100644 --- a/luni-kernel/src/main/java/java/lang/reflect/Constructor.java +++ b/luni-kernel/src/main/java/java/lang/reflect/Constructor.java @@ -161,12 +161,12 @@ public final class Constructor<T> extends AccessibleObject implements GenericDec 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 final class Constructor<T> extends AccessibleObject implements GenericDec public Class<?>[] getExceptionTypes() { if (exceptionTypes == null) return new Class[0]; - return exceptionTypes; + return exceptionTypes.clone(); } /** @@ -354,7 +354,7 @@ public final class Constructor<T> extends AccessibleObject implements GenericDec * @since Android 1.0 */ public Class<?>[] getParameterTypes() { - return parameterTypes; + return parameterTypes.clone(); } /** diff --git a/luni-kernel/src/main/java/java/lang/reflect/Method.java b/luni-kernel/src/main/java/java/lang/reflect/Method.java index 473726d..dabf9a4 100644 --- a/luni-kernel/src/main/java/java/lang/reflect/Method.java +++ b/luni-kernel/src/main/java/java/lang/reflect/Method.java @@ -383,7 +383,7 @@ public final class Method extends AccessibleObject implements GenericDeclaration return new Class[0]; } - return exceptionTypes; + return exceptionTypes.clone(); } /** @@ -424,7 +424,7 @@ public final class Method extends AccessibleObject implements GenericDeclaration * @since Android 1.0 */ public Class<?>[] getParameterTypes() { - return parameterTypes; + return parameterTypes.clone(); } /** @@ -521,7 +521,7 @@ public final class Method extends AccessibleObject implements GenericDeclaration 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/luni-kernel/src/test/java/tests/api/org/apache/harmony/kernel/dalvik/AllTests.java b/luni-kernel/src/test/java/tests/api/org/apache/harmony/kernel/dalvik/AllTests.java new file mode 100644 index 0000000..a59cc3e --- /dev/null +++ b/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; + } +} |