Skip to content

Skip JvmDowngrader stubs that cannot load on Java 9+ - #34

Merged
shenxianpeng merged 1 commit into
mainfrom
jvmdg-httpclient-warning
Nov 2, 2026
Merged

shenxianpeng merged 1 commit into
mainfrom
jvmdg-httpclient-warning

Conversation

@shenxianpeng

@shenxianpeng shenxianpeng commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

Before: on Java 11 and 17 agents, every start logs one to three [ClassDowngrader/...] WARN: failed to resolve methods for xyz.wagyourtail.jvmdg.j21.stub.java_net_http.J_N_H_HttpClient warnings with a NoClassDefFoundError: java/net/http/HttpClient stack trace (reported in #32). Java 8 agents don't log it.

After: no such warning. Behaviour is unchanged.

JvmDowngrader loads its stubs with the bootstrap class loader, which on Java 9+ cannot see the java.net.http and jdk.httpserver modules. Its stubs for methods those modules gained in Java 16, 17, 21 and 25 (for example HttpClient.close()) never load there; JvmDowngrader logs the error and goes on without them. Checked on Temurin 17 with a class compiled for Java 21: calling HttpClient.close() fails with NoSuchMethodError with or without this change, and the warning is gone with it.

How: on Java 9+, Main passes -Djvmdg.debug.skipStub= with those stub classes to the child JVM, unless the option is already set. Also: the premain unit test now restores System.out, so the output of the tests after it is printed again (since #33 only the first 5 of the 42 results were printed; they all ran and passed).

Refs #32

JvmDowngrader loads its stubs with the bootstrap class loader, which on
Java 9+ cannot see the java.net.http and jdk.httpserver modules. Its
stubs for methods those modules gained in Java 16, 17, 21 and 25 never
load there, and each one logged a NoClassDefFoundError on every agent
start. Main now passes -Djvmdg.debug.skipStub for them to the child JVM
on Java 9+ (unless set already); behaviour is unchanged.

Unit tests: restore System.out after the premain test, so the output of
the tests after it is printed again (hidden since the #32 fix).
@shenxianpeng
shenxianpeng merged commit cefb391 into main Nov 2, 2026
18 checks passed
@shenxianpeng
shenxianpeng deleted the jvmdg-httpclient-warning branch November 2, 2026 16:30
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.

1 participant