Skip to content

Question about how java.net.http.HttpClient#sendAsync instrumentation works #6780

Answered by laurit
fmterrorf asked this question in Q&A
Discussion options

You must be logged in to vote

You need to ensure that the class you instrument (in this case jdk.internal.net.http.HttpClientImpl) has access to the class that you use in your advice (lets call it ResponseConsumer). The first hurdle is that the javaagent is loaded with app class loader (system class loader in jdk8) and HttpClientImpl is loaded with platform class loader (it is not present in jdk8, but on jdk8 jdk classes are loaded by boot loader). Platform loader is parent of app loader so HttpClientImpl won't have access to classes in agent jar. The way you get around this is adding your agent to boot loader with Instrumentation.appendToBootstrapClassLoaderSearch. Typically you'd do this as the verify first thing in…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by fmterrorf
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants