Skip to content

Commit

Permalink
[GR-15002] Support TypeVariableImpl.getAnnotations().
Browse files Browse the repository at this point in the history
PullRequest: graal/3448
  • Loading branch information
cstancu committed Apr 24, 2019
2 parents 4bb8cf9 + 2e13b31 commit 556bed6
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

//Checkstyle: allow reflection

import java.lang.annotation.Annotation;
import java.lang.reflect.GenericDeclaration;
import java.lang.reflect.MalformedParameterizedTypeException;
import java.lang.reflect.Type;
Expand All @@ -35,7 +36,9 @@

import com.oracle.svm.core.annotate.Alias;
import com.oracle.svm.core.annotate.Delete;
import com.oracle.svm.core.annotate.Inject;
import com.oracle.svm.core.annotate.RecomputeFieldValue;
import com.oracle.svm.core.annotate.RecomputeFieldValue.CustomFieldValueComputer;
import com.oracle.svm.core.annotate.RecomputeFieldValue.Kind;
import com.oracle.svm.core.annotate.Substitute;
import com.oracle.svm.core.annotate.TargetClass;
Expand Down Expand Up @@ -79,6 +82,9 @@ final class Target_sun_reflect_generics_reflectiveObjects_TypeVariableImpl {

@Alias GenericDeclaration genericDeclaration;

@Inject @RecomputeFieldValue(kind = Kind.Custom, declClass = TypeVariableAnnotationsComputer.class) //
Annotation[] annotations;

@Substitute
@SuppressWarnings("unused")
private Target_sun_reflect_generics_reflectiveObjects_TypeVariableImpl(GenericDeclaration decl, String n, FieldTypeSignature[] bs, GenericsFactory f) {
Expand Down Expand Up @@ -109,6 +115,11 @@ public Type[] getBounds() {
public GenericDeclaration getGenericDeclaration() {
return genericDeclaration;
}

@Substitute
public Annotation[] getAnnotations() {
return annotations;
}
}

final class Util_sun_reflect_generics_reflectiveObjects_TypeVariableImpl {
Expand Down Expand Up @@ -141,6 +152,14 @@ public Object compute(MetaAccessProvider metaAccess, ResolvedJavaField original,
}
}

class TypeVariableAnnotationsComputer implements CustomFieldValueComputer {

@Override
public Object compute(MetaAccessProvider metaAccess, ResolvedJavaField original, ResolvedJavaField annotated, Object receiver) {
return ((TypeVariableImpl<?>) receiver).getAnnotations();
}
}

@TargetClass(sun.reflect.generics.reflectiveObjects.WildcardTypeImpl.class)
final class Target_sun_reflect_generics_reflectiveObjects_WildcardTypeImpl {

Expand Down

0 comments on commit 556bed6

Please sign in to comment.