Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Agent] Allow applying advices to the native methods #716

Open
bsideup opened this issue Aug 29, 2019 · 3 comments
Open

[Agent] Allow applying advices to the native methods #716

bsideup opened this issue Aug 29, 2019 · 3 comments
Assignees
Milestone

Comments

@bsideup
Copy link

bsideup commented Aug 29, 2019

Unlike in Open J9, Hotspot was allowing to instrument native methods (including the JVM's) by renaming + marking private/final until Java 13.

Here is an example ASM code in BlockHound:
https://github.com/reactor/BlockHound/blob/312fc5f30370640f69b3c1d6659f1e9eabf32738/agent/src/main/java/reactor/blockhound/NativeWrappingClassFileTransformer.java#L96

We run it before ByteBuddy, so that ByteBuddy sees the methods as non-native and applies advices to them. It also forces us to customize the DescriptionStrategy (see #713) which isn't great for performance.

It would be nice tho if this functionality is added directly to ByteBuddy, so that we can avoid running ASM code before BB.

I understand that it does not work on Open J9, plus requires -XX:+AllowRedefinitionToAddDeleteMethods flag on Hotspot 13+, so it can be an optional mode. Yet, given that the majority of Java versions are distributed between 6-8, this mode will remain helpful for at least a few years :)

@raphw raphw self-assigned this Aug 30, 2019
@raphw raphw added this to the 1.10.1 milestone Aug 30, 2019
@raphw
Copy link
Owner

raphw commented Aug 30, 2019

This would indeed be a valuable addition but I will need to see how easily I can fit it in. I do not think this will become a high priority issue, especially as the value decreases over time but I will definetly have a look!

@alexey-anufriev
Copy link

hi @raphw, I have just stumbled upon the same problem in my project. Do you think this functionality will be added in some foreseeable future?

@raphw
Copy link
Owner

raphw commented May 13, 2023

I did not yet have time to prioritize this, unfortunately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants