Skip to content

Commit

Permalink
Remove IntrinsicCandidate annotation on non-native delegate methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
pderop committed Jan 29, 2024
1 parent ba4cedb commit 1635f2a
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ class NativeWrappingClassFileTransformer implements ClassFileTransformer {

private final Map<String, Map<String, Set<String>>> blockingMethods;

public static final boolean IS_JDK_18_OR_NEWER;

static {
String javaVersion = System.getProperty("java.specification.version");
double version = Double.parseDouble(javaVersion);
IS_JDK_18_OR_NEWER = version >= 18.0;
}

NativeWrappingClassFileTransformer(final Map<String, Map<String, Set<String>>> blockingMethods) {
this.blockingMethods = blockingMethods;
}
Expand Down Expand Up @@ -105,6 +113,14 @@ public MethodVisitor visitMethod(int access, String name, String descriptor, Str
delegatingMethodVisitor.visitCode();

return new MethodVisitor(ASM7, delegatingMethodVisitor) {
@Override
public AnnotationVisitor visitAnnotation(String descriptor, boolean visible) {
// See #392
if (IS_JDK_18_OR_NEWER && descriptor.equals("Ljdk/internal/vm/annotation/IntrinsicCandidate;")) {
return null; // remove the intrinsic annotation
}
return super.visitAnnotation(descriptor, visible);
}

@Override
public void visitEnd() {
Expand Down

0 comments on commit 1635f2a

Please sign in to comment.