Mercurial > hg > graal-jvmci-8
changeset 23376:ae27c683c128
Make ResolvedJava* types extend AnnotatedElement.
Contributed-by: Vojin Jovanovic <vojin.jovanovic@oracle.com>
author | Roland Schatz <roland.schatz@oracle.com> |
---|---|
date | Fri, 06 May 2016 13:21:20 +0200 |
parents | 3f70efb8f473 |
children | 3039c53c72d3 |
files | jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaFieldImpl.java jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl.java jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl.java jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedPrimitiveType.java jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/ResolvedJavaField.java jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/ResolvedJavaMethod.java jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/ResolvedJavaType.java |
diffstat | 7 files changed, 31 insertions(+), 53 deletions(-) [+] |
line wrap: on
line diff
--- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaFieldImpl.java Wed May 04 12:06:51 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaFieldImpl.java Fri May 06 13:21:20 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/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl.java Wed May 04 12:06:51 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl.java Fri May 06 13:21:20 2016 +0200 @@ -477,6 +477,12 @@ } @Override + public Annotation[] getDeclaredAnnotations() { + Executable javaMethod = toJava(); + return javaMethod == null ? null : javaMethod.getDeclaredAnnotations(); + } + + @Override public <T extends Annotation> T getAnnotation(Class<T> annotationClass) { Executable javaMethod = toJava(); return javaMethod == null ? null : javaMethod.getAnnotation(annotationClass);
--- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl.java Wed May 04 12:06:51 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl.java Fri May 06 13:21:20 2016 +0200 @@ -768,6 +768,11 @@ } @Override + public Annotation[] getDeclaredAnnotations() { + return mirror().getDeclaredAnnotations(); + } + + @Override public <T extends Annotation> T getAnnotation(Class<T> annotationClass) { return mirror().getAnnotation(annotationClass); }
--- a/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedPrimitiveType.java Wed May 04 12:06:51 2016 +0200 +++ b/jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedPrimitiveType.java Fri May 06 13:21:20 2016 +0200 @@ -199,6 +199,11 @@ } @Override + public Annotation[] getDeclaredAnnotations() { + return new Annotation[0]; + } + + @Override public <T extends Annotation> T getAnnotation(Class<T> annotationClass) { return null; }
--- a/jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/ResolvedJavaField.java Wed May 04 12:06:51 2016 +0200 +++ b/jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/ResolvedJavaField.java Fri May 06 13:21:20 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/jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/ResolvedJavaMethod.java Wed May 04 12:06:51 2016 +0200 +++ b/jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/ResolvedJavaMethod.java Fri May 06 13:21:20 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/jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/ResolvedJavaType.java Wed May 04 12:06:51 2016 +0200 +++ b/jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/ResolvedJavaType.java Fri May 06 13:21:20 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. * @@ -276,22 +276,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. *