Skip to content

Conversation

@kamko
Copy link
Contributor

@kamko kamko commented Dec 21, 2021

No description provided.

@kamko
Copy link
Contributor Author

kamko commented Dec 21, 2021

Newest version of Byte Buddy which works with the r8 modified distJar out of box (with JNA) is: 1.11.2

After that it starts failing during Agent initialization with:

IntegrationTests > Launching directly and attaching later should eventually intercept all clients FAILED
    org.opentest4j.AssertionFailedError at IntegrationTests.kt:120
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:564)
	at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:513)
	at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndCallAgentmain(InstrumentationImpl.java:535)
Caused by: java.lang.ExceptionInInitializerError
	at tech.httptoolkit.relocated.net.bytebuddy.agent.builder.AgentBuilder$Default.<clinit>(AgentBuilder.java:2)
	at tech.httptoolkit.javaagent.HttpProxyAgent.interceptAllHttps(AgentMain.kt:17)
	at tech.httptoolkit.javaagent.HttpProxyAgent.agentmain(AgentMain.kt:13)
	... 6 more
Caused by: java.lang.NegativeArraySizeException: -1
	at tech.httptoolkit.relocated.net.bytebuddy.utility.dispatcher.JavaDispatcher$DynamicClassLoader.invoker(JavaDispatcher.java:34)
	at tech.httptoolkit.relocated.net.bytebuddy.utility.dispatcher.JavaDispatcher$InvokerCreationAction.run(JavaDispatcher.java:1)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:312)
	at tech.httptoolkit.relocated.net.bytebuddy.utility.dispatcher.JavaDispatcher.doPrivileged(JavaDispatcher.java)
	at tech.httptoolkit.relocated.net.bytebuddy.utility.dispatcher.JavaDispatcher.<clinit>(JavaDispatcher.java:17)
	... 9 more
Agent failed to start!
Error: Exception in thread "main" com.sun.tools.attach.AgentInitializationException: Agent JAR loaded but agent failed to initialize
	at jdk.attach/sun.tools.attach.HotSpotVirtualMachine.loadAgent(HotSpotVirtualMachine.java:165)
	at tech.httptoolkit.javaagent.AttachMain.attachAgent(AttachMain.kt:12)
	at tech.httptoolkit.javaagent.AttachMain.main(AttachMain.kt:95)

Java 17 is supported since Byte Buddy 1.10.21 so that would fix our java 17 problem but we're stuck here. Test step quickTest works as that is using pre-r8 sources.

What should we do?

@pimterry
Copy link
Member

Thanks for this, we're getting closer! I was just doing the same investigation 😃

From the trace I think this comes from somewhere here raphw/byte-buddy@506e4af. Needs some proper debugging into the minified bytebuddy bytecode to check the root cause there though, and see how we can fix it. The quickTest build works just fine, so this must be something to do with the minification somewhere...

For now, I think it's sensible to just update to 1.11.2 and merge that as a working fix once the tests pass.

I'll try to find some time to investigate the issues with later versions early in the new year (or you're welcome to, if you're interested!) but I'm off for a Christmas break soon and I'm not going to have much time to dig into this before then I think.

@kamko
Copy link
Contributor Author

kamko commented Dec 21, 2021

Yeah, I agree with bumping the version to 1.11.2 and then doing some investigation later on :)

@kamko kamko changed the title Update Byte Buddy to 1.12.6 (fixes #3) Update Byte Buddy to 1.11.2 (fixes #3) Dec 21, 2021
@pimterry pimterry merged commit a8bf9a1 into httptoolkit:main Dec 21, 2021
@kamko kamko deleted the issue/3-p2 branch December 21, 2021 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants