use of com.oracle.svm.core.annotate.Delete in project graal by oracle.
the class AnnotationSubstitutionProcessor method handleClass.
private void handleClass(Class<?> annotatedClass) {
guarantee(Modifier.isFinal(annotatedClass.getModifiers()) || annotatedClass.isInterface(), "Annotated class must be final: %s", annotatedClass);
guarantee(annotatedClass.getSuperclass() == Object.class || annotatedClass.isInterface(), "Annotated class must inherit directly from Object: %s", annotatedClass);
if (!NativeImageGenerator.includedIn(ImageSingletons.lookup(Platform.class), lookupAnnotation(annotatedClass, Platforms.class))) {
return;
}
TargetClass targetClassAnnotation = lookupAnnotation(annotatedClass, TargetClass.class);
Class<?> originalClass = findTargetClass(annotatedClass, targetClassAnnotation);
if (originalClass == null) {
return;
}
Delete deleteAnnotation = lookupAnnotation(annotatedClass, Delete.class);
Substitute substituteAnnotation = lookupAnnotation(annotatedClass, Substitute.class);
int numAnnotations = (deleteAnnotation != null ? 1 : 0) + (substituteAnnotation != null ? 1 : 0);
guarantee(numAnnotations <= 1, "Only one of @Delete or @Substitute can be used: %s", annotatedClass);
if (deleteAnnotation != null) {
handleDeletedClass(originalClass, deleteAnnotation);
} else if (substituteAnnotation != null) {
handleSubstitutionClass(annotatedClass, originalClass);
} else {
handleAliasClass(annotatedClass, originalClass);
}
}
use of com.oracle.svm.core.annotate.Delete 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