Search in sources :

Example 1 with AnnotateOriginal

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);
    }
}
Also used : Delete(com.oracle.svm.core.annotate.Delete) AnnotateOriginal(com.oracle.svm.core.annotate.AnnotateOriginal) CustomSubstitutionMethod(com.oracle.svm.hosted.annotation.CustomSubstitutionMethod) Alias(com.oracle.svm.core.annotate.Alias) Constructor(java.lang.reflect.Constructor) Substitute(com.oracle.svm.core.annotate.Substitute) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Aggregations

Alias (com.oracle.svm.core.annotate.Alias)1 AnnotateOriginal (com.oracle.svm.core.annotate.AnnotateOriginal)1 Delete (com.oracle.svm.core.annotate.Delete)1 Substitute (com.oracle.svm.core.annotate.Substitute)1 CustomSubstitutionMethod (com.oracle.svm.hosted.annotation.CustomSubstitutionMethod)1 Constructor (java.lang.reflect.Constructor)1 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)1