8156211: [JVMCI] ResolvedJava* interfaces should extend AnnotatedElement
Reviewed-by: twisti
Contributed-by: Vojin Jovanovic <vojin.jovanovic@oracle.com>
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaFieldImpl.java Tue May 10 12:18:22 2016 +0200
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaFieldImpl.java Tue May 10 11:18:40 2016 +0200
@@ -210,6 +210,15 @@
}
@Override
+ public Annotation[] getDeclaredAnnotations() {
+ Field javaField = toJava();
+ if (javaField != null) {
+ return javaField.getDeclaredAnnotations();
+ }
+ return new Annotation[0];
+ }
+
+ @Override
public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
Field javaField = toJava();
if (javaField != null) {
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl.java Tue May 10 12:18:22 2016 +0200
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl.java Tue May 10 11:18:40 2016 +0200
@@ -472,7 +472,19 @@
@Override
public Annotation[] getAnnotations() {
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
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl.java Tue May 10 12:18:22 2016 +0200
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl.java Tue May 10 11:18:40 2016 +0200
@@ -744,6 +744,11 @@
}
@Override
+ public Annotation[] getDeclaredAnnotations() {
+ return mirror().getDeclaredAnnotations();
+ }
+
+ @Override
public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
return mirror().getAnnotation(annotationClass);
}
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedPrimitiveType.java Tue May 10 12:18:22 2016 +0200
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedPrimitiveType.java Tue May 10 11:18:40 2016 +0200
@@ -204,6 +204,11 @@
}
@Override
+ public Annotation[] getDeclaredAnnotations() {
+ return new Annotation[0];
+ }
+
+ @Override
public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
return null;
}
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/ResolvedJavaField.java Tue May 10 12:18:22 2016 +0200
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/ResolvedJavaField.java Tue May 10 11:18:40 2016 +0200
@@ -22,14 +22,14 @@
*/
package jdk.vm.ci.meta;
-import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Modifier;
/**
* Represents a reference to a resolved Java field. Fields, like methods and types, are resolved
* through {@link ConstantPool constant pools}.
*/
-public interface ResolvedJavaField extends JavaField, ModifiersProvider {
+public interface ResolvedJavaField extends JavaField, ModifiersProvider, AnnotatedElement {
/**
* {@inheritDoc}
@@ -61,22 +61,6 @@
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.
*
* @return the location identity of the field
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/ResolvedJavaMethod.java Tue May 10 12:18:22 2016 +0200
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/ResolvedJavaMethod.java Tue May 10 11:18:40 2016 +0200
@@ -24,6 +24,7 @@
import java.lang.annotation.Annotation;
import java.lang.invoke.MethodHandle;
+import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Array;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
@@ -33,7 +34,7 @@
* Represents a resolved Java method. Methods, like fields and types, are resolved through
* {@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
@@ -189,22 +190,6 @@
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
* declaration order, of this method.
*
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/ResolvedJavaType.java Tue May 10 12:18:22 2016 +0200
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/ResolvedJavaType.java Tue May 10 11:18:40 2016 +0200
@@ -22,7 +22,7 @@
*/
package jdk.vm.ci.meta;
-import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
import jdk.vm.ci.meta.Assumptions.AssumptionResult;
@@ -31,7 +31,7 @@
* 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.
*
@@ -284,22 +284,6 @@
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,
* or {@code null} if there is no such field.
*