raphw / raphw/byte-buddy

[Agent] Allow applying advices to the native methods

Open
#716 3 comments 0 reactions 1 assignee View on GitHub

@raphw is already working on this.

Since Aug 30, 2019.

enhancement
Dominant language
Java
Stars
6.9k
Forks
855
PR merge metrics
No merged PRs in 30d

Description

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 :)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.