OpenJDK 8u121 verify: More java.lang.reflect
Adding improved change markers for various reflection classes.
Contains 2 8u121 updates associated with "@since 1.8" javadoc
in Constructor and Method and removal of "@since 1.8" on the
same method in Executable.
Bug: 35910877
Test: Build
Change-Id: Idca6e729b04dec7d238b48856ae9a6f0515df9b0
diff --git a/ojluni/src/main/java/java/lang/reflect/Constructor.java b/ojluni/src/main/java/java/lang/reflect/Constructor.java
index de7176b..cf6b29f 100644
--- a/ojluni/src/main/java/java/lang/reflect/Constructor.java
+++ b/ojluni/src/main/java/java/lang/reflect/Constructor.java
@@ -29,6 +29,7 @@
import dalvik.annotation.optimization.FastNative;
import libcore.util.EmptyArray;
+import sun.reflect.CallerSensitive;
import java.lang.annotation.Annotation;
import java.util.Comparator;
@@ -53,6 +54,11 @@
* @author Nakul Saraiya
*/
public final class Constructor<T> extends Executable {
+ // Android-changed: Extensive modifications made throughout the class for ART.
+ // Android-changed: Many fields and methods removed / modified.
+ // Android-removed: Type annotations runtime code. Not supported on Android.
+ // Android-removed: Declared vs actual parameter annotation indexes handling.
+
private static final Comparator<Method> ORDER_BY_SIGNATURE = null; // Unused; must match Method.
private final Class<?> serializationClass;
@@ -77,7 +83,7 @@
@Override
boolean hasGenericInformation() {
- // Android-changed: Signature retrieval is handled in Executable.
+ // Android-changed: hasGenericInformation() implemented using Executable.
return super.hasGenericInformationInternal();
}
@@ -85,9 +91,9 @@
* {@inheritDoc}
*/
@Override
+ // Android-changed: getDeclaringClass() implemented using Executable.
@SuppressWarnings({"rawtypes", "unchecked"})
public Class<T> getDeclaringClass() {
- // Android-changed: This is handled by Executable.
return (Class<T>) super.getDeclaringClassInternal();
}
@@ -105,7 +111,7 @@
*/
@Override
public int getModifiers() {
- // Android-changed: This is handled by Executable.
+ // Android-changed: getModifiers() implemented using Executable.
return super.getModifiersInternal();
}
@@ -117,7 +123,7 @@
@Override
@SuppressWarnings({"rawtypes", "unchecked"})
public TypeVariable<Constructor<T>>[] getTypeParameters() {
- // Android-changed: This is mostly handled by Executable.
+ // Android-changed: getTypeParameters() partly implemented using Executable.
GenericInfo info = getMethodOrConstructorGenericInfoInternal();
return (TypeVariable<Constructor<T>>[]) info.formalTypeParameters.clone();
}
@@ -128,7 +134,7 @@
*/
@Override
public Class<?>[] getParameterTypes() {
- // Android-changed: This is handled by Executable.
+ // Android-changed: getParameterTypes() partly implemented using Executable.
Class<?>[] paramTypes = super.getParameterTypesInternal();
if (paramTypes == null) {
return EmptyArray.CLASS;
@@ -142,7 +148,7 @@
* @since 1.8
*/
public int getParameterCount() {
- // Android-changed: This is handled by Executable.
+ // Android-changed: getParameterCount() implemented using Executable.
return super.getParameterCountInternal();
}
@@ -162,6 +168,7 @@
* {@inheritDoc}
*/
@Override
+ // Android-changed: getExceptionTypes() implemented in native code.
@FastNative
public native Class<?>[] getExceptionTypes();
@@ -187,7 +194,7 @@
if (obj != null && obj instanceof Constructor) {
Constructor<?> other = (Constructor<?>)obj;
if (getDeclaringClass() == other.getDeclaringClass()) {
- // Android-changed: Use getParameterTypes.
+ // Android-changed: Use getParameterTypes() instead of deleted parameterTypes field
return equalParamTypes(getParameterTypes(), other.getParameterTypes());
}
}
@@ -222,7 +229,7 @@
* @jls 8.8.3. Constructor Modifiers
*/
public String toString() {
- // Android-changed: Use getParameterTypes().
+ // Android-changed: Use getParameterTypes() / getExceptionTypes() instead of deleted fields
return sharedToString(Modifier.constructorModifiers(),
false,
getParameterTypes(),
@@ -326,6 +333,8 @@
* @exception ExceptionInInitializerError if the initialization provoked
* by this method fails.
*/
+ // BEGIN Android-changed: newInstance(Object...) implemented differently.
+ @CallerSensitive
public T newInstance(Object ... initargs)
throws InstantiationException, IllegalAccessException,
IllegalArgumentException, InvocationTargetException
@@ -344,6 +353,7 @@
@FastNative
private native T newInstance0(Object... args) throws InstantiationException,
IllegalAccessException, IllegalArgumentException, InvocationTargetException;
+ // END Android-changed: newInstance(Object...) implemented differently.
/**
* {@inheritDoc}
@@ -387,7 +397,7 @@
*/
@Override
public Annotation[][] getParameterAnnotations() {
- // Android-changed: This is handled by Executable.
+ // Android-changed: getParameterAnnotations() implemented using Executable.
return super.getParameterAnnotationsInternal();
}
}
diff --git a/ojluni/src/main/java/java/lang/reflect/Executable.java b/ojluni/src/main/java/java/lang/reflect/Executable.java
index 7945ad6..6782d00 100644
--- a/ojluni/src/main/java/java/lang/reflect/Executable.java
+++ b/ojluni/src/main/java/java/lang/reflect/Executable.java
@@ -43,6 +43,11 @@
*/
public abstract class Executable extends AccessibleObject
implements Member, GenericDeclaration {
+
+ // Android-changed: Extensive modifications made throughout the class for ART.
+ // Android-removed: Declared vs actual parameter annotation indexes handling.
+ // Android-removed: Type annotations runtime code. Not supported on Android.
+
/*
* Only grant package-visibility to the constructor.
*/
@@ -226,7 +231,6 @@
* declared or implicitly declared or neither) for the executable
* represented by this object.
*
- * @since 1.8
* @return The number of formal parameters for the executable this
* object represents
*/
@@ -261,7 +265,7 @@
* type that cannot be instantiated for any reason
*/
public Type[] getGenericParameterTypes() {
- // Android-changed: Changed to use Types / getMethodOrConstructorGenericInfoInternal()
+ // Android-changed: getGenericParameterTypes() implementation for use with ART.
return Types.getTypeArray(
getMethodOrConstructorGenericInfoInternal().genericParameterTypes, false);
}
@@ -323,7 +327,6 @@
* have unique names, or names that are legal identifiers in the
* Java programming language (JLS 3.8).
*
- * @since 1.8
* @throws MalformedParametersException if the class file contains
* a MethodParameters attribute that is improperly formatted.
* @return an array of {@code Parameter} objects representing all
@@ -380,6 +383,7 @@
Parameter[] tmp = parameters;
if (tmp == null) {
+
// Otherwise, go to the JVM to get them
try {
tmp = getParameters0();
@@ -420,6 +424,7 @@
private transient volatile boolean hasRealParameterData;
private transient volatile Parameter[] parameters;
+ // Android-changed: Added @FastNative to getParameters0()
@FastNative
private native Parameter[] getParameters0();
@@ -457,7 +462,7 @@
* parameterized type that cannot be instantiated for any reason
*/
public Type[] getGenericExceptionTypes() {
- // Android-changed: Changed to use Types / getMethodOrConstructorGenericInfoInternal()
+ // Android-changed: getGenericExceptionTypes() implementation for use with ART.
return Types.getTypeArray(
getMethodOrConstructorGenericInfoInternal().genericExceptionTypes, false);
}
@@ -478,7 +483,7 @@
* to take a variable number of arguments.
*/
public boolean isVarArgs() {
- // Android-changed: Slightly more efficient.
+ // Android-changed: isVarArgs() made slightly more efficient.
return (accessFlags & Modifier.VARARGS) != 0;
}
@@ -492,7 +497,7 @@
* @jls 13.1 The Form of a Binary
*/
public boolean isSynthetic() {
- // Android-changed: Slightly more efficient.
+ // Android-changed: isSynthetic() made slightly more efficient.
return (accessFlags & Modifier.SYNTHETIC) != 0;
}
@@ -532,20 +537,21 @@
*/
public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
Objects.requireNonNull(annotationClass);
- // Android-changed: Implemented natively.
+ // Android-changed: Implemented getAnnotation(Class) natively.
return getAnnotationNative(annotationClass);
}
+
+ // Android-changed: Implemented getAnnotation(Class) natively.
@FastNative
private native <T extends Annotation> T getAnnotationNative(Class<T> annotationClass);
/**
* {@inheritDoc}
* @throws NullPointerException {@inheritDoc}
- * @since 1.8
*/
@Override
public <T extends Annotation> T[] getAnnotationsByType(Class<T> annotationClass) {
- // Android-changed: Uses AnnotatedElements instead.
+ // Android-changed: getAnnotationsByType(Class), Android uses AnnotatedElements instead.
return AnnotatedElements.getDirectOrIndirectAnnotationsByType(this, annotationClass);
}
@@ -553,14 +559,16 @@
* {@inheritDoc}
*/
public Annotation[] getDeclaredAnnotations() {
- // Android-changed: Implemented natively.
+ // Android-changed: Implemented getDeclaredAnnotations() natively.
return getDeclaredAnnotationsNative();
}
+
+ // Android-added: Implemented getDeclaredAnnotations() natively.
@FastNative
private native Annotation[] getDeclaredAnnotationsNative();
- // Android-changed: Additional ART-related fields and logic below that is shared between
- // Method and Constructor.
+ // BEGIN Android-added: Additional ART-related fields and logic.
+ // This code is shared for Method and Constructor.
/** Bits encoding access (e.g. public, private) as well as other runtime specific flags */
@SuppressWarnings("unused") // set by runtime
@@ -737,4 +745,6 @@
final boolean isBridgeMethodInternal() {
return (accessFlags & Modifier.BRIDGE) != 0;
}
+ // END Android-added: Additional ART-related fields and logic.
+
}
diff --git a/ojluni/src/main/java/java/lang/reflect/Field.java b/ojluni/src/main/java/java/lang/reflect/Field.java
index a691766..2bcf9e9 100644
--- a/ojluni/src/main/java/java/lang/reflect/Field.java
+++ b/ojluni/src/main/java/java/lang/reflect/Field.java
@@ -27,7 +27,7 @@
package java.lang.reflect;
import dalvik.annotation.optimization.FastNative;
-
+import sun.reflect.CallerSensitive;
import java.lang.annotation.Annotation;
import java.util.Objects;
import libcore.reflect.AnnotatedElements;
@@ -55,6 +55,9 @@
*/
public final
class Field extends AccessibleObject implements Member {
+ // Android-changed: Extensive modifications made throughout the class for ART.
+ // Android-changed: Many fields and methods removed / modified.
+ // Android-removed: Type annotations runtime code. Not supported on Android.
private int accessFlags;
private Class<?> declaringClass;
@@ -70,6 +73,7 @@
* that declares the field represented by this {@code Field} object.
*/
public Class<?> getDeclaringClass() {
+ // Android-changed: Adjust code for different field names.
return declaringClass;
}
@@ -77,6 +81,7 @@
* Returns the name of the field represented by this {@code Field} object.
*/
public String getName() {
+ // Android-changed: getName() implemented differently.
if (dexFieldIndex == -1) {
// Proxy classes have 1 synthesized static field with no valid dex index.
if (!declaringClass.isProxy()) {
@@ -88,6 +93,7 @@
return getNameInternal();
}
+ // Android-added: getName() implemented differently.
@FastNative
private native String getNameInternal();
@@ -99,6 +105,7 @@
* @see Modifier
*/
public int getModifiers() {
+ // Android-changed: Adjust getModifiers() implementation to mask extra bits used on Android.
return accessFlags & 0xffff; // mask out bits not used by Java
}
@@ -163,6 +170,7 @@
* @since 1.5
*/
public Type getGenericType() {
+ // Android-changed: getGenericType() implemented differently.
String signatureAttribute = getSignatureAttribute();
ClassLoader cl = declaringClass.getClassLoader();
GenericSignatureParser parser = new GenericSignatureParser(cl);
@@ -174,6 +182,7 @@
return genericType;
}
+ // BEGIN Android-added: getGenericType() implemented differently.
private String getSignatureAttribute() {
String[] annotation = getSignatureAnnotation();
if (annotation == null) {
@@ -187,6 +196,7 @@
}
@FastNative
private native String[] getSignatureAnnotation();
+ // END Android-added: getGenericType() implemented differently.
/**
@@ -319,6 +329,8 @@
* @exception ExceptionInInitializerError if the initialization provoked
* by this method fails.
*/
+ @CallerSensitive
+ // Android-changed: get*(Object) implemented natively.
@FastNative
public native Object get(Object obj)
throws IllegalArgumentException, IllegalAccessException;
@@ -345,6 +357,8 @@
* by this method fails.
* @see Field#get
*/
+ @CallerSensitive
+ // Android-changed: get*(Object) implemented natively.
@FastNative
public native boolean getBoolean(Object obj)
throws IllegalArgumentException, IllegalAccessException;
@@ -371,6 +385,8 @@
* by this method fails.
* @see Field#get
*/
+ @CallerSensitive
+ // Android-changed: get*(Object) implemented natively.
@FastNative
public native byte getByte(Object obj)
throws IllegalArgumentException, IllegalAccessException;
@@ -399,6 +415,8 @@
* by this method fails.
* @see Field#get
*/
+ @CallerSensitive
+ // Android-changed: get*(Object) implemented natively.
@FastNative
public native char getChar(Object obj)
throws IllegalArgumentException, IllegalAccessException;
@@ -427,6 +445,8 @@
* by this method fails.
* @see Field#get
*/
+ @CallerSensitive
+ // Android-changed: get*(Object) implemented natively.
@FastNative
public native short getShort(Object obj)
throws IllegalArgumentException, IllegalAccessException;
@@ -455,6 +475,8 @@
* by this method fails.
* @see Field#get
*/
+ @CallerSensitive
+ // Android-changed: get*(Object) implemented natively.
@FastNative
public native int getInt(Object obj)
throws IllegalArgumentException, IllegalAccessException;
@@ -483,6 +505,8 @@
* by this method fails.
* @see Field#get
*/
+ @CallerSensitive
+ // Android-changed: get*(Object) implemented natively.
@FastNative
public native long getLong(Object obj)
throws IllegalArgumentException, IllegalAccessException;
@@ -511,6 +535,8 @@
* by this method fails.
* @see Field#get
*/
+ @CallerSensitive
+ // Android-changed: get*(Object) implemented natively.
@FastNative
public native float getFloat(Object obj)
throws IllegalArgumentException, IllegalAccessException;
@@ -539,6 +565,8 @@
* by this method fails.
* @see Field#get
*/
+ @CallerSensitive
+ // Android-changed: get*(Object) implemented natively.
@FastNative
public native double getDouble(Object obj)
throws IllegalArgumentException, IllegalAccessException;
@@ -609,6 +637,8 @@
* @exception ExceptionInInitializerError if the initialization provoked
* by this method fails.
*/
+ @CallerSensitive
+ // Android-changed: set*(Object, ...) implemented natively.
@FastNative
public native void set(Object obj, Object value)
throws IllegalArgumentException, IllegalAccessException;
@@ -637,6 +667,8 @@
* by this method fails.
* @see Field#set
*/
+ @CallerSensitive
+ // Android-changed: set*(Object, ...) implemented natively.
@FastNative
public native void setBoolean(Object obj, boolean z)
throws IllegalArgumentException, IllegalAccessException;
@@ -665,6 +697,8 @@
* by this method fails.
* @see Field#set
*/
+ @CallerSensitive
+ // Android-changed: set*(Object, ...) implemented natively.
@FastNative
public native void setByte(Object obj, byte b)
throws IllegalArgumentException, IllegalAccessException;
@@ -693,6 +727,8 @@
* by this method fails.
* @see Field#set
*/
+ @CallerSensitive
+ // Android-changed: set*(Object, ...) implemented natively.
@FastNative
public native void setChar(Object obj, char c)
throws IllegalArgumentException, IllegalAccessException;
@@ -721,6 +757,8 @@
* by this method fails.
* @see Field#set
*/
+ @CallerSensitive
+ // Android-changed: set*(Object, ...) implemented natively.
@FastNative
public native void setShort(Object obj, short s)
throws IllegalArgumentException, IllegalAccessException;
@@ -749,6 +787,8 @@
* by this method fails.
* @see Field#set
*/
+ @CallerSensitive
+ // Android-changed: set*(Object, ...) implemented natively.
@FastNative
public native void setInt(Object obj, int i)
throws IllegalArgumentException, IllegalAccessException;
@@ -777,6 +817,8 @@
* by this method fails.
* @see Field#set
*/
+ @CallerSensitive
+ // Android-changed: set*(Object, ...) implemented natively.
@FastNative
public native void setLong(Object obj, long l)
throws IllegalArgumentException, IllegalAccessException;
@@ -805,6 +847,8 @@
* by this method fails.
* @see Field#set
*/
+ @CallerSensitive
+ // Android-changed: set*(Object, ...) implemented natively.
@FastNative
public native void setFloat(Object obj, float f)
throws IllegalArgumentException, IllegalAccessException;
@@ -833,6 +877,8 @@
* by this method fails.
* @see Field#set
*/
+ @CallerSensitive
+ // Android-changed: set*(Object, ...) implemented natively.
@FastNative
public native void setDouble(Object obj, double d)
throws IllegalArgumentException, IllegalAccessException;
@@ -841,11 +887,12 @@
* @throws NullPointerException {@inheritDoc}
* @since 1.5
*/
- @Override
public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
Objects.requireNonNull(annotationClass);
+ // Android-changed: getAnnotation(Class) implemented differently.
return getAnnotationNative(annotationClass);
}
+ // Android-added: getAnnotation(Class) implemented differently.
@FastNative
private native <A extends Annotation> A getAnnotationNative(Class<A> annotationType);
@@ -856,12 +903,13 @@
*/
@Override
public <T extends Annotation> T[] getAnnotationsByType(Class<T> annotationClass) {
- // Android-changed: Uses AnnotatedElements instead.
+ // Android-added: getAnnotationsByType(Class) implemented differently.
return AnnotatedElements.getDirectOrIndirectAnnotationsByType(this, annotationClass);
}
-
- @Override public boolean isAnnotationPresent(Class<? extends Annotation> annotationType) {
+ // BEGIN Android-added: isAnnotationPresent(Class) overridden in Field.
+ @Override
+ public boolean isAnnotationPresent(Class<? extends Annotation> annotationType) {
if (annotationType == null) {
throw new NullPointerException("annotationType == null");
}
@@ -869,6 +917,7 @@
}
@FastNative
private native boolean isAnnotationPresentNative(Class<? extends Annotation> annotationType);
+ // END Android-added: isAnnotationPresent(Class) overridden in Field.
/**
* {@inheritDoc}
@@ -877,6 +926,7 @@
@FastNative
public native Annotation[] getDeclaredAnnotations();
+ // BEGIN Android-added: Methods for use by Android-specific code.
/**
* Returns the index of this field's ID in its dex file.
*
@@ -900,4 +950,5 @@
*/
@FastNative
public native long getArtField();
+ // END Android-added: Methods for use by Android-specific code.
}
diff --git a/ojluni/src/main/java/java/lang/reflect/Method.java b/ojluni/src/main/java/java/lang/reflect/Method.java
index ddda93d..3da75c5 100644
--- a/ojluni/src/main/java/java/lang/reflect/Method.java
+++ b/ojluni/src/main/java/java/lang/reflect/Method.java
@@ -26,6 +26,7 @@
package java.lang.reflect;
+import sun.reflect.CallerSensitive;
import dalvik.annotation.optimization.FastNative;
import java.lang.annotation.Annotation;
import java.util.Comparator;
@@ -53,6 +54,11 @@
* @author Nakul Saraiya
*/
public final class Method extends Executable {
+ // Android-changed: Extensive modifications made throughout the class for ART.
+ // Android-changed: Many fields and methods removed / modified.
+ // Android-removed: Type annotations runtime code. Not supported on Android.
+ // Android-removed: Declared vs actual parameter annotation indexes handling.
+
/**
* Orders methods by their name, parameters and return type.
*
@@ -86,7 +92,7 @@
@Override
boolean hasGenericInformation() {
- // Android-changed: Signature retrieval is handled in Executable.
+ // Android-changed: hasGenericInformation() implemented using Executable.
return super.hasGenericInformationInternal();
}
@@ -95,7 +101,7 @@
*/
@Override
public Class<?> getDeclaringClass() {
- // Android-changed: This is handled by Executable.
+ // Android-changed: getDeclaringClass() implemented using Executable.
return super.getDeclaringClassInternal();
}
@@ -105,7 +111,7 @@
*/
@Override
public String getName() {
- // Android-changed: This is handled by Executable.
+ // Android-changed: getName() implemented using Executable.
return getMethodNameInternal();
}
@@ -114,7 +120,7 @@
*/
@Override
public int getModifiers() {
- // Android-changed: This is handled by Executable.
+ // Android-changed: getModifiers() implemented using Executable.
return super.getModifiersInternal();
}
@@ -126,7 +132,7 @@
@Override
@SuppressWarnings({"rawtypes", "unchecked"})
public TypeVariable<Method>[] getTypeParameters() {
- // Android-changed: This is mostly handled by Executable.
+ // Android-changed: getTypeParameters() partly implemented using Executable.
GenericInfo info = getMethodOrConstructorGenericInfoInternal();
return (TypeVariable<Method>[]) info.formalTypeParameters.clone();
}
@@ -138,6 +144,7 @@
* @return the return type for the method this object represents
*/
public Class<?> getReturnType() {
+ // Android-changed: getReturnType() implemented using Executable.
return getMethodReturnTypeInternal();
}
@@ -166,7 +173,7 @@
* @since 1.5
*/
public Type getGenericReturnType() {
- // Android-changed: Modified implementation to use Executable.
+ // Android-changed: getGenericReturnType() partly implemented using Executable.
return Types.getType(getMethodOrConstructorGenericInfoInternal().genericReturnType);
}
@@ -175,7 +182,7 @@
*/
@Override
public Class<?>[] getParameterTypes() {
- // Android-changed: This is handled by Executable.
+ // Android-changed: getParameterTypes() partly implemented using Executable.
Class<?>[] paramTypes = super.getParameterTypesInternal();
if (paramTypes == null) {
return EmptyArray.CLASS;
@@ -189,7 +196,7 @@
* @since 1.8
*/
public int getParameterCount() {
- // Android-changed: This is handled by Executable.
+ // Android-changed: getParameterTypes() implemented using Executable.
return super.getParameterCountInternal();
}
@@ -209,6 +216,7 @@
* {@inheritDoc}
*/
@Override
+ // Android-changed: getExceptionTypes() implemented natively.
@FastNative
public native Class<?>[] getExceptionTypes();
@@ -235,9 +243,10 @@
Method other = (Method)obj;
if ((getDeclaringClass() == other.getDeclaringClass())
&& (getName() == other.getName())) {
+ // Android-changed: Use getReturnType() instead of deleted returnType field
if (!getReturnType().equals(other.getReturnType()))
return false;
- // Android-changed: Use getParameterTypes.
+ // Android-changed: Use getParameterTypes() instead of deleted parameterTypes field
return equalParamTypes(getParameterTypes(), other.getParameterTypes());
}
}
@@ -280,7 +289,7 @@
* @jls 8.4.3 Method Modifiers
*/
public String toString() {
- // Android-changed: Use getParameterTypes.
+ // Android-changed: Use getParameterTypes() / getExceptionTypes() instead of deleted fields
return sharedToString(Modifier.methodModifiers(),
isDefault(),
getParameterTypes(),
@@ -403,6 +412,8 @@
* @exception ExceptionInInitializerError if the initialization
* provoked by this method fails.
*/
+ @CallerSensitive
+ // Android-changed: invoke(Object, Object...) implemented natively.
@FastNative
public native Object invoke(Object obj, Object... args)
throws IllegalAccessException, IllegalArgumentException, InvocationTargetException;
@@ -416,7 +427,7 @@
* @since 1.5
*/
public boolean isBridge() {
- // Android-changed: This is handled by Executable.
+ // Android-changed: isBridge() implemented using Executable.
return super.isBridgeMethodInternal();
}
@@ -452,7 +463,7 @@
* @since 1.8
*/
public boolean isDefault() {
- // Android-changed: This is handled by Executable.
+ // Android-changed: isDefault() implemented using Executable.
return super.isDefaultMethodInternal();
}
@@ -470,6 +481,7 @@
* default class value.
* @since 1.5
*/
+ // Android-changed: isDefault() implemented natively.
@FastNative
public native Object getDefaultValue();
@@ -496,10 +508,11 @@
*/
@Override
public Annotation[][] getParameterAnnotations() {
- // Android-changed: This is handled by Executable.
+ // Android-changed: getParameterAnnotations() implemented using Executable.
return super.getParameterAnnotationsInternal();
}
+ // Android-added: equalNameAndParameters(Method) for Proxy support.
/**
* Returns true if this and {@code method} have the same name and the same
* parameters in the same order. Such methods can share implementation if
diff --git a/ojluni/src/main/java/java/lang/reflect/Modifier.java b/ojluni/src/main/java/java/lang/reflect/Modifier.java
index e694505..28d89bb 100644
--- a/ojluni/src/main/java/java/lang/reflect/Modifier.java
+++ b/ojluni/src/main/java/java/lang/reflect/Modifier.java
@@ -42,6 +42,20 @@
*/
public class Modifier {
+ // Android-removed: ReflectionFactory bootstrapping code not used on Android.
+ /*
+ /*
+ * Bootstrapping protocol between java.lang and java.lang.reflect
+ * packages
+ *
+ static {
+ sun.reflect.ReflectionFactory factory =
+ AccessController.doPrivileged(
+ new ReflectionFactory.GetReflectionFactoryAction());
+ factory.setLangReflectAccess(new java.lang.reflect.ReflectAccess());
+ }
+ */
+
/**
* Return {@code true} if the integer argument includes the
* {@code public} modifier, {@code false} otherwise.
@@ -126,6 +140,7 @@
return (mod & VOLATILE) != 0;
}
+ // Android-added: isConstructor(int) to support DEX-defined modifier flag.
/**
* Returns true if the given modifiers contain {@link Modifier#CONSTRUCTOR}.
* @hide
@@ -332,6 +347,7 @@
// they are not Java programming language keywords
static final int BRIDGE = 0x00000040;
static final int VARARGS = 0x00000080;
+ // Android-changed: SYNTHETIC made public for use in tests.
/**
* @hide
*/
@@ -357,6 +373,7 @@
// methods return an unchanging values for a given release, but a
// value that can potentially change over time.
+ // Android-added: CONSTRUCTOR to support DEX-defined modifier flag.
/**
* Dex addition to mark instance constructors and static class
* initializer methods.
@@ -364,6 +381,7 @@
*/
public static final int CONSTRUCTOR = 0x10000;
+ // Android-added: DEFAULT to support DEX-defined modifier flag.
/**
* Default methods are marked with a synthetic access flag
* to speed up class loading and invocation target lookup.
diff --git a/ojluni/src/main/java/java/lang/reflect/Parameter.java b/ojluni/src/main/java/java/lang/reflect/Parameter.java
index 77c26d7..4dc32b4 100644
--- a/ojluni/src/main/java/java/lang/reflect/Parameter.java
+++ b/ojluni/src/main/java/java/lang/reflect/Parameter.java
@@ -41,6 +41,9 @@
* @since 1.8
*/
public final class Parameter implements AnnotatedElement {
+ // Android-changed: Extensive modifications made throughout the class for ART.
+ // Android-removed: Type annotations runtime code. Not supported on Android.
+ // Android-removed: Annotation retrieval is implemented natively in ART.
private final String name;
private final int modifiers;
@@ -95,7 +98,7 @@
return executable.hashCode() ^ index;
}
- // Android-changed: Removed references to the class file format.
+ // Android-changed: Removed references in javadoc to the class file format.
/**
* Returns true if the parameter has a name; returns false otherwise.
* Whether a parameter has a name is determined by compiler options
@@ -271,9 +274,10 @@
*/
public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
Objects.requireNonNull(annotationClass);
- // Android-changed: Uses native code to obtain annotation information.
+ // Android-changed: getAnnotation(Class) Uses native code to obtain annotation information.
return getAnnotationNative(executable, index, annotationClass);
}
+ // Android-added: getAnnotation(Class) Uses native code to obtain annotation information.
@FastNative
private static native <A extends Annotation> A getAnnotationNative(
Executable executable, int parameterIndex, Class<A> annotationType);
@@ -284,7 +288,7 @@
*/
@Override
public <T extends Annotation> T[] getAnnotationsByType(Class<T> annotationClass) {
- // Android-changed: Uses AnnotatedElements instead.
+ // Android-changed: getAnnotationsByType(Class), Android uses AnnotatedElements instead.
return AnnotatedElements.getDirectOrIndirectAnnotationsByType(this, annotationClass);
}
@@ -322,4 +326,5 @@
public Annotation[] getAnnotations() {
return getDeclaredAnnotations();
}
+
}
diff --git a/ojluni/src/main/java/java/lang/reflect/TypeVariable.java b/ojluni/src/main/java/java/lang/reflect/TypeVariable.java
index 20372a4..07b375c 100644
--- a/ojluni/src/main/java/java/lang/reflect/TypeVariable.java
+++ b/ojluni/src/main/java/java/lang/reflect/TypeVariable.java
@@ -48,9 +48,9 @@
*
* @since 1.5
*/
-// Android-changed: Removed AnnotatedElement super-class due to excluded support
-// for runtime type annotations
-public interface TypeVariable<D extends GenericDeclaration> extends Type {
+// Android-changed: Removed support for type annotations at runtime.
+// Removed AnnotatedElement super-class.
+public interface TypeVariable<D extends GenericDeclaration> extends Type/*, AnnotatedElement*/ {
/**
* Returns an array of {@code Type} objects representing the
* upper bound(s) of this type variable. Note that if no upper bound is
@@ -100,6 +100,6 @@
* @return an array of objects representing the upper bounds of the type variable
* @since 1.8
*/
- // Android-changed: Excluded support for runtime type annotations
+ // Android-removed: getAnnotatedBounds(), no support for runtime type annotations on Android.
// AnnotatedType[] getAnnotatedBounds();
}