Search in sources :

Example 1 with KeepOriginal

use of com.oracle.svm.core.annotate.KeepOriginal in project graal by oracle.

the class AnnotationSubstitutionProcessor method handleAnnotatedMethodInSubstitutionClass.

private void handleAnnotatedMethodInSubstitutionClass(Executable annotatedMethod, Class<?> originalClass) {
    Substitute substituteAnnotation = lookupAnnotation(annotatedMethod, Substitute.class);
    KeepOriginal keepOriginalAnnotation = lookupAnnotation(annotatedMethod, KeepOriginal.class);
    int numAnnotations = (substituteAnnotation != null ? 1 : 0) + (keepOriginalAnnotation != null ? 1 : 0);
    if (numAnnotations == 0) {
        /* Unannotated method in substitution class: a regular method, nothing to do. */
        return;
    }
    guarantee(numAnnotations == 1, "only one of @Substitute or @KeepOriginal 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 (substituteAnnotation != null) {
        register(methodSubstitutions, annotated, original, annotated);
    } else if (keepOriginalAnnotation != null) {
        register(methodSubstitutions, annotated, original, original);
    }
}
Also used : KeepOriginal(com.oracle.svm.core.annotate.KeepOriginal) Substitute(com.oracle.svm.core.annotate.Substitute) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Aggregations

KeepOriginal (com.oracle.svm.core.annotate.KeepOriginal)1 Substitute (com.oracle.svm.core.annotate.Substitute)1 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)1