use of com.oracle.svm.core.annotate.AnnotateOriginal in project graal by oracle.
the class AnnotationSubstitutionProcessor method handleMethodInAliasClass.
private void handleMethodInAliasClass(Executable annotatedMethod, Class<?> originalClass) {
if (!NativeImageGenerator.includedIn(ImageSingletons.lookup(Platform.class), lookupAnnotation(annotatedMethod, Platforms.class))) {
return;
}
Delete deleteAnnotation = lookupAnnotation(annotatedMethod, Delete.class);
Substitute substituteAnnotation = lookupAnnotation(annotatedMethod, Substitute.class);
AnnotateOriginal annotateOriginalAnnotation = lookupAnnotation(annotatedMethod, AnnotateOriginal.class);
Alias aliasAnnotation = lookupAnnotation(annotatedMethod, Alias.class);
int numAnnotations = (deleteAnnotation != null ? 1 : 0) + (substituteAnnotation != null ? 1 : 0) + (annotateOriginalAnnotation != null ? 1 : 0) + (aliasAnnotation != null ? 1 : 0);
if (numAnnotations == 0) {
guarantee(annotatedMethod instanceof Constructor, "One of @Delete, @Substitute, @AnnotateOriginal, or @Alias must be used: %s", annotatedMethod);
return;
}
guarantee(numAnnotations == 1, "Only one of @Delete, @Substitute, @AnnotateOriginal, or @Alias can be used: %s", annotatedMethod);
ResolvedJavaMethod annotated = metaAccess.lookupJavaMethod(annotatedMethod);
ResolvedJavaMethod original = findOriginalMethod(annotatedMethod, originalClass);
if (original == null) {
/* Optional target that is not present, so nothing to do. */
} else if (deleteAnnotation != null) {
registerAsDeleted(annotated, original, deleteAnnotation);
} else if (substituteAnnotation != null) {
SubstitutionMethod substitution = new SubstitutionMethod(original, annotated);
register(methodSubstitutions, annotated, original, substitution);
} else if (annotateOriginalAnnotation != null) {
AnnotatedMethod substitution = new AnnotatedMethod(original, annotated);
register(methodSubstitutions, annotated, original, substitution);
} else if (aliasAnnotation != null) {
register(methodSubstitutions, annotated, original, original);
}
}
Aggregations