summaryrefslogtreecommitdiffstats
path: root/libart
diff options
context:
space:
mode:
authorIan Rogers <irogers@google.com>2013-09-23 18:55:07 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2013-09-23 18:55:07 -0700
commitbbf99fd5471f46d0aedd01a9d5961fb3e40ac700 (patch)
tree15df52e3aa05c52a43b5d4af06b6ee21c2c74f9a /libart
parentd5757c5f3f27e65ea6d53d2ecb04185225a4ade6 (diff)
parent3f1ad69ef4655901cbf71c4c1fbae074bc320585 (diff)
downloadlibcore-bbf99fd5471f46d0aedd01a9d5961fb3e40ac700.zip
libcore-bbf99fd5471f46d0aedd01a9d5961fb3e40ac700.tar.gz
libcore-bbf99fd5471f46d0aedd01a9d5961fb3e40ac700.tar.bz2
am 3f1ad69e: Merge commit \'d4ec55c4\' into manualmerge
* commit '3f1ad69ef4655901cbf71c4c1fbae074bc320585': Lazier annotation signature parsing.
Diffstat (limited to 'libart')
-rw-r--r--libart/src/main/java/java/lang/Class.java31
-rw-r--r--libart/src/main/java/java/lang/reflect/AbstractMethod.java6
-rw-r--r--libart/src/main/java/java/lang/reflect/Method.java4
3 files changed, 27 insertions, 14 deletions
diff --git a/libart/src/main/java/java/lang/Class.java b/libart/src/main/java/java/lang/Class.java
index cb504ca..f950982 100644
--- a/libart/src/main/java/java/lang/Class.java
+++ b/libart/src/main/java/java/lang/Class.java
@@ -1101,9 +1101,13 @@ public final class Class<T> implements Serializable, AnnotatedElement, GenericDe
* void} then an empty array is returned.
*/
public Type[] getGenericInterfaces() {
+ String annotationSignature = AnnotationAccess.getSignature(this);
+ if (annotationSignature == null) {
+ return EmptyArray.TYPE;
+ }
GenericSignatureParser parser = new GenericSignatureParser(getClassLoader());
- parser.parseForClass(this, AnnotationAccess.getSignature(this));
- return Types.getClonedTypeArray(parser.interfaceTypes);
+ parser.parseForClass(this, annotationSignature);
+ return Types.getTypeArray(parser.interfaceTypes, false);
}
/**
@@ -1111,9 +1115,14 @@ public final class Class<T> implements Serializable, AnnotatedElement, GenericDe
* class}.
*/
public Type getGenericSuperclass() {
- GenericSignatureParser parser = new GenericSignatureParser(getClassLoader());
- parser.parseForClass(this, AnnotationAccess.getSignature(this));
- return Types.getType(parser.superclassType);
+ Type genericSuperclass = getSuperclass();
+ String annotationSignature = AnnotationAccess.getSignature(this);
+ if (annotationSignature != null) {
+ GenericSignatureParser parser = new GenericSignatureParser(getClassLoader());
+ parser.parseForClass(this, annotationSignature);
+ genericSuperclass = parser.superclassType;
+ }
+ return Types.getType(genericSuperclass);
}
/**
@@ -1132,9 +1141,8 @@ public final class Class<T> implements Serializable, AnnotatedElement, GenericDe
return new Class<?>[] { Cloneable.class, Serializable.class };
} else if (isProxy()) {
return getProxyInterfaces();
- } else {
- return AnnotationAccess.typeIndexToInterfaces(this, getDex(), getTypeIndex());
}
+ return AnnotationAccess.typeIndexToInterfaces(this, getDex(), getTypeIndex());
}
// Returns the interfaces that this proxy class directly implements.
@@ -1319,9 +1327,13 @@ public final class Class<T> implements Serializable, AnnotatedElement, GenericDe
*/
@SuppressWarnings("unchecked")
@Override public synchronized TypeVariable<Class<T>>[] getTypeParameters() {
+ String annotationSignature = AnnotationAccess.getSignature(this);
+ if (annotationSignature == null) {
+ return EmptyArray.TYPE_VARIABLE;
+ }
GenericSignatureParser parser = new GenericSignatureParser(getClassLoader());
- parser.parseForClass(this, AnnotationAccess.getSignature(this));
- return parser.formalTypeParameters.clone();
+ parser.parseForClass(this, annotationSignature);
+ return parser.formalTypeParameters;
}
/**
@@ -1673,4 +1685,5 @@ public final class Class<T> implements Serializable, AnnotatedElement, GenericDe
// return AnnotationAccess.typeIndexToAnnotationDirectoryOffset(getDex(), getTypeIndex());
// as native code has access to fast maps between type indices and class
// defs. Move fast maps to managed code.
+
}
diff --git a/libart/src/main/java/java/lang/reflect/AbstractMethod.java b/libart/src/main/java/java/lang/reflect/AbstractMethod.java
index cacf057..ff52b41 100644
--- a/libart/src/main/java/java/lang/reflect/AbstractMethod.java
+++ b/libart/src/main/java/java/lang/reflect/AbstractMethod.java
@@ -156,11 +156,11 @@ public abstract class AbstractMethod extends AccessibleObject {
}
Type[] getGenericParameterTypes() {
- return Types.getClonedTypeArray(getMethodOrConstructorGenericInfo().genericParameterTypes);
+ return Types.getTypeArray(getMethodOrConstructorGenericInfo().genericParameterTypes, false);
}
Type[] getGenericExceptionTypes() {
- return Types.getClonedTypeArray(getMethodOrConstructorGenericInfo().genericExceptionTypes);
+ return Types.getTypeArray(getMethodOrConstructorGenericInfo().genericExceptionTypes, false);
}
@Override public Annotation[] getDeclaredAnnotations() {
@@ -284,7 +284,7 @@ public abstract class AbstractMethod extends AccessibleObject {
sb.append(')');
// append exceptions if any
Type[] genericExceptionTypeArray =
- Types.getClonedTypeArray(info.genericExceptionTypes);
+ Types.getTypeArray(info.genericExceptionTypes, false);
if (genericExceptionTypeArray.length > 0) {
sb.append(" throws ");
Types.appendArrayGenericType(sb, genericExceptionTypeArray);
diff --git a/libart/src/main/java/java/lang/reflect/Method.java b/libart/src/main/java/java/lang/reflect/Method.java
index 1a0d5c5..3089932 100644
--- a/libart/src/main/java/java/lang/reflect/Method.java
+++ b/libart/src/main/java/java/lang/reflect/Method.java
@@ -244,7 +244,7 @@ public final class Method extends AbstractMethod implements GenericDeclaration,
* instantiated for some reason
*/
public Type[] getGenericParameterTypes() {
- return Types.getClonedTypeArray(getMethodOrConstructorGenericInfo().genericParameterTypes);
+ return Types.getTypeArray(getMethodOrConstructorGenericInfo().genericParameterTypes, false);
}
@Override public boolean isAnnotationPresent(Class<? extends Annotation> annotationType) {
@@ -269,7 +269,7 @@ public final class Method extends AbstractMethod implements GenericDeclaration,
* instantiated for some reason
*/
public Type[] getGenericExceptionTypes() {
- return Types.getClonedTypeArray(getMethodOrConstructorGenericInfo().genericExceptionTypes);
+ return Types.getTypeArray(getMethodOrConstructorGenericInfo().genericExceptionTypes, false);
}
/**