Remove IntrinsicCandidate annotation on non-native delegate methods. #393
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
So, when BlockHound is instrumenting a native method, it first renames the native method using a prefix.
For example,
Unsafe.park
is renamed toUnsafe.$$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:
now, in JDK16 and JDK17, when
CheckIntrinsics
flag 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