RFR: 8372253: Improve logging to show why a class was excluded form AOT Cache
Ioi Lam
iklam at openjdk.org
Thu Nov 20 20:36:56 UTC 2025
On Thu, 20 Nov 2025 09:20:11 GMT, María Arias de Reyna Domínguez <duke at openjdk.org> wrote:
> Fixes: https://bugs.openjdk.org/browse/JDK-8372253
>
> When dumping the AOT Cache file, some classes throw a verification error and are excluded from the cache:
>
>
> [warning][aot] Preload Warning: Verification failed for io.netty.handler.ssl.OpenSslClientContext
> [warning][aot] Skipping io/netty/handler/ssl/OpenSslClientContext: Failed verification
>
>
> This PR improves the log message by adding the cause of this failure:
>
>
> [warning][aot] Preload Warning: Verification failed for io.netty.handler.ssl.OpenSslClientContext because a java.lang.NoClassDefFoundError was thrown: io/netty/internal/tcnative/SSLPrivateKeyMethod
Marked as reviewed by iklam (Reviewer).
Thanks for making the changes. I have a written a test case.
class ExclusionTest {
public void main() {
System.out.println("I am not calling getFoo()");
}
// The verification of this method adds a verification constraint:
// Bar must be a subclass of Foo
//
// Note that the verification of this class only loads Bar and Foo
// to check that Bar is a subclass of Foo. It does not cause
// Bar and Foo to be immediately verified.
//
// Bar and Foo are verified only when the app uses them, or
// in the case of AOT training, they are verified after the app
// has exited but before we write the AOT config file.
Foo getFoo() {
return new Bar();
}
}
// Foo is verified at the end of the training run in AOTMetaspace::link_all_loaded_classes().
// This is AFTER the app has exited.
class Foo {}
// Bar is also verified at end of the training run. The verification will fail
// because Baz cannot be loaded,
//
// As a result, Bar is excluded from the AOT config.
// ExclusionTest is also excluded, because its verification depended on Bar.
class Bar extends Foo {
Bar getBar() {
return new Baz(); // Bar cannot be verified if Baz class cannot be loaded,
}
}
// Do NOT put this class in the classpath
class Baz extends Bar {}
With the new log added by this PR, we can now understand why `Bar` and `ExclusionTest` are excluded:
$ rm -rf tmpclasses
$ mkdir -p tmpclasses
$ javac -d tmpclasses ExclusionTest.java
$ rm tmpclasses/Baz.class
$ jar cvf ExclusionTest.jar -C tmpclasses .
$ java -XX:AOTMode=record -XX:AOTConfiguration=test.aotconf \
-cp ExclusionTest.jar ExclusionTest | egrep '(Skip)|(Preload)'
[0.125s][warning][aot] Preload Warning: Verification failed for Bar because a
java.lang.NoClassDefFoundError was thrown: Baz
[...]
[0.242s][warning][aot] Skipping Bar: Failed verification
[0.242s][info ][aot] Skipping ExclusionTest: verification constraint Bar is excluded
-------------
PR Review: https://git.openjdk.org/jdk/pull/28413#pullrequestreview-3489831233
PR Comment: https://git.openjdk.org/jdk/pull/28413#issuecomment-3559947611
More information about the hotspot-runtime-dev
mailing list