raphw / byte-buddy

Runtime code generation for the Java virtual machine.
https://bytebuddy.net
Apache License 2.0
6.22k stars 803 forks source link

Is junixsocket-native-common dependency still possible to use? #1398

Closed adam-bialas closed 1 year ago

adam-bialas commented 1 year ago

I am trying to use ReactorDebugAgent by attaching it to running JVM with init() method. On the Reactor page it is mentioned there are some ByteBuddy limitation. I checked them here https://github.com/raphw/byte-buddy/blob/master/byte-buddy-agent/src/main/java/net/bytebuddy/agent/ByteBuddyAgent.java#L523 and I added dependency mentioned in my build.gradle:

implementation 'com.kohlschutter.junixsocket:junixsocket-native-common:2.6.1'

However, my app does not start an exception is:

Exception in thread "main" java.lang.IllegalStateException: No compatible attachment provider is available at reactor.tools.shaded.net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:627) at reactor.tools.shaded.net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:611) at reactor.tools.shaded.net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:563) at reactor.tools.shaded.net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:540) at reactor.tools.agent.ReactorDebugAgent.init(ReactorDebugAgent.java:56) at com.motobloq.MotobloqRestApplication.main(MotobloqRestApplication.java:18)

I looked at the byte-buddy-agent pom.xml and I see junixsocket-native-common as provided in older versions. Newer ones have net.java.dev.jna.jna. When I include jna in my project all works fine - the app starts without problem.

Questions I have:

Thanks for help

raphw commented 1 year ago

If ReactorDebugAgent is usibg a current Byte Buddy, it will need JNA. There's no performance difference.

The change was made quite a while ago to dupport other platforms, including Mac and Windows. That was not possible before where only Linux was supported.

adam-bialas commented 1 year ago

It runs fine on JDK. Does it mean jdk has JNA included?

raphw commented 1 year ago

no, but it includes APIs that implement the attach API.