8156211: [JVMCI] ResolvedJava* interfaces should extend AnnotatedElement

Reviewed-by: twisti
This commit is contained in:
Vojin Jovanovic 2016-05-10 11:18:40 +02:00 committed by Roland Schatz
parent aab69bdeb5
commit 79fa047585
7 changed files with 38 additions and 54 deletions

View File

@ -209,6 +209,15 @@ class HotSpotResolvedJavaFieldImpl implements HotSpotResolvedJavaField, HotSpotP
return new Annotation[0]; return new Annotation[0];
} }
@Override
public Annotation[] getDeclaredAnnotations() {
Field javaField = toJava();
if (javaField != null) {
return javaField.getDeclaredAnnotations();
}
return new Annotation[0];
}
@Override @Override
public <T extends Annotation> T getAnnotation(Class<T> annotationClass) { public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
Field javaField = toJava(); Field javaField = toJava();

View File

@ -472,7 +472,19 @@ final class HotSpotResolvedJavaMethodImpl extends HotSpotMethod implements HotSp
@Override @Override
public Annotation[] getAnnotations() { public Annotation[] getAnnotations() {
Executable javaMethod = toJava(); Executable javaMethod = toJava();
return javaMethod == null ? new Annotation[0] : javaMethod.getAnnotations(); if (javaMethod != null) {
return javaMethod.getAnnotations();
}
return new Annotation[0];
}
@Override
public Annotation[] getDeclaredAnnotations() {
Executable javaMethod = toJava();
if (javaMethod != null) {
return javaMethod.getDeclaredAnnotations();
}
return new Annotation[0];
} }
@Override @Override

View File

@ -743,6 +743,11 @@ final class HotSpotResolvedObjectTypeImpl extends HotSpotResolvedJavaType implem
return mirror().getAnnotations(); return mirror().getAnnotations();
} }
@Override
public Annotation[] getDeclaredAnnotations() {
return mirror().getDeclaredAnnotations();
}
@Override @Override
public <T extends Annotation> T getAnnotation(Class<T> annotationClass) { public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
return mirror().getAnnotation(annotationClass); return mirror().getAnnotation(annotationClass);

View File

@ -203,6 +203,11 @@ public final class HotSpotResolvedPrimitiveType extends HotSpotResolvedJavaType
return new Annotation[0]; return new Annotation[0];
} }
@Override
public Annotation[] getDeclaredAnnotations() {
return new Annotation[0];
}
@Override @Override
public <T extends Annotation> T getAnnotation(Class<T> annotationClass) { public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
return null; return null;

View File

@ -22,14 +22,14 @@
*/ */
package jdk.vm.ci.meta; package jdk.vm.ci.meta;
import java.lang.annotation.Annotation; import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
/** /**
* Represents a reference to a resolved Java field. Fields, like methods and types, are resolved * Represents a reference to a resolved Java field. Fields, like methods and types, are resolved
* through {@link ConstantPool constant pools}. * through {@link ConstantPool constant pools}.
*/ */
public interface ResolvedJavaField extends JavaField, ModifiersProvider { public interface ResolvedJavaField extends JavaField, ModifiersProvider, AnnotatedElement {
/** /**
* {@inheritDoc} * {@inheritDoc}
@ -60,22 +60,6 @@ public interface ResolvedJavaField extends JavaField, ModifiersProvider {
*/ */
ResolvedJavaType getDeclaringClass(); ResolvedJavaType getDeclaringClass();
/**
* Returns all annotations of this field. If no annotations are present, an array of length 0 is
* returned.
*/
Annotation[] getAnnotations();
/**
* Returns the annotation for the specified type of this field, if such an annotation is
* present.
*
* @param annotationClass the Class object corresponding to the annotation type
* @return this element's annotation for the specified annotation type if present on this field,
* else {@code null}
*/
<T extends Annotation> T getAnnotation(Class<T> annotationClass);
/** /**
* Returns an object representing the unique location identity of this resolved Java field. * Returns an object representing the unique location identity of this resolved Java field.
* *

View File

@ -24,6 +24,7 @@ package jdk.vm.ci.meta;
import java.lang.annotation.Annotation; import java.lang.annotation.Annotation;
import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandle;
import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Array; import java.lang.reflect.Array;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
@ -33,7 +34,7 @@ import java.lang.reflect.Type;
* Represents a resolved Java method. Methods, like fields and types, are resolved through * Represents a resolved Java method. Methods, like fields and types, are resolved through
* {@link ConstantPool constant pools}. * {@link ConstantPool constant pools}.
*/ */
public interface ResolvedJavaMethod extends JavaMethod, InvokeTarget, ModifiersProvider { public interface ResolvedJavaMethod extends JavaMethod, InvokeTarget, ModifiersProvider, AnnotatedElement {
/** /**
* Returns the bytecode of this method, if the method has code. The returned byte array does not * Returns the bytecode of this method, if the method has code. The returned byte array does not
@ -188,22 +189,6 @@ public interface ResolvedJavaMethod extends JavaMethod, InvokeTarget, ModifiersP
*/ */
ConstantPool getConstantPool(); ConstantPool getConstantPool();
/**
* Returns all annotations of this method. If no annotations are present, an array of length 0
* is returned.
*/
Annotation[] getAnnotations();
/**
* Returns the annotation for the specified type of this method, if such an annotation is
* present.
*
* @param annotationClass the Class object corresponding to the annotation type
* @return this element's annotation for the specified annotation type if present on this
* method, else {@code null}
*/
<T extends Annotation> T getAnnotation(Class<T> annotationClass);
/** /**
* Returns an array of arrays that represent the annotations on the formal parameters, in * Returns an array of arrays that represent the annotations on the formal parameters, in
* declaration order, of this method. * declaration order, of this method.

View File

@ -22,7 +22,7 @@
*/ */
package jdk.vm.ci.meta; package jdk.vm.ci.meta;
import java.lang.annotation.Annotation; import java.lang.reflect.AnnotatedElement;
import jdk.vm.ci.meta.Assumptions.AssumptionResult; import jdk.vm.ci.meta.Assumptions.AssumptionResult;
@ -31,7 +31,7 @@ import jdk.vm.ci.meta.Assumptions.AssumptionResult;
* thereof. Types, like fields and methods, are resolved through {@link ConstantPool constant pools} * thereof. Types, like fields and methods, are resolved through {@link ConstantPool constant pools}
* . * .
*/ */
public interface ResolvedJavaType extends JavaType, ModifiersProvider { public interface ResolvedJavaType extends JavaType, ModifiersProvider, AnnotatedElement {
/** /**
* Checks whether this type has a finalizer method. * Checks whether this type has a finalizer method.
* *
@ -283,22 +283,6 @@ public interface ResolvedJavaType extends JavaType, ModifiersProvider {
*/ */
ResolvedJavaField[] getStaticFields(); ResolvedJavaField[] getStaticFields();
/**
* Returns all annotations of this class. If no annotations are present, an array of length 0 is
* returned.
*/
Annotation[] getAnnotations();
/**
* Returns the annotation for the specified type of this class, if such an annotation is
* present.
*
* @param annotationClass the Class object corresponding to the annotation type
* @return this element's annotation for the specified annotation type if present on this class,
* else {@code null}
*/
<T extends Annotation> T getAnnotation(Class<T> annotationClass);
/** /**
* Returns the instance field of this class (or one of its super classes) at the given offset, * Returns the instance field of this class (or one of its super classes) at the given offset,
* or {@code null} if there is no such field. * or {@code null} if there is no such field.