Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove IntrinsicCandidate annotation on non-native delegate methods. (#…
…393) Since JDK16, a new @IntrinsicCandidate annotation has been introduced; It indicates that an annotated method may be (but is not guaranteed to be) intrinsified. For example, the native Unsafe.park method is annotated with it: @IntrinsicCandidate public native void park(boolean isAbsolute, long time); So, when BlockHound is instrumenting a native method, it first renames the native method using a prefix. For example, Unsafe.park is renamed to Unsafe.$$BlockHound$$_park And then the origin method (Unsafe.park) is rewritten in order to delegate the call to the renamed method, but the origin method is also rewritten to be non-native, so we end up with something like this after instrumentation: class Unsafe { ... public native void $$BlockHound$$_park(boolean isAbsolute, long time); @IntrinsicCandidate public void park(boolean isAbsolute, long time) { // delegates the call to $$BlockHound$$_park } Now, in JDK16 and JDK17, when CheckIntrinsicsflag is enabled (true by default), the "native" keyword was optional, but in this JDK 18 change, now, a warning message is logged in case a method annotated with @IntrinsicCandidate is not native, while it's present in internal JDK list of the native methods that can be intrinsified. The warning seems to be not harmful, but this PR just tries to avoid it by removing the @IntrinsicCandidate annotation from the proxy/delegate method (from public void park non-native method). Fixes #392
- Loading branch information