graalvm / native-build-tools

Native-image plugins for various build tools
https://graalvm.github.io/native-build-tools/
Other
366 stars 57 forks source link

JUnit class initialization error #598

Closed sdeleuze closed 4 months ago

sdeleuze commented 4 months ago

When building the Spring data-jdbc-h2-kotlin AOT smoke test (sources available here), we observe the following error:

Error: An object of type 'org.junit.platform.launcher.core.SessionPerRequestLauncher' was found in the image heap. This type, however, is marked for initialization at image run time for the following reason: classes are initialized at run time by default.

This class is configured to be initialized at build time here but recent version of GraalVM were expected to solve this kind of issue by reinitializing classes at runtime as far as I understand, so I am not sure why we see that blocking error. I am using 22.0.1-graalce from SDKman.

To reproduce:

sdk install java 22.0.1-graalce
git clone https://github.com/spring-projects/spring-aot-smoke-tests.git
sdk env install
sdk env
GRAALVM_HOME=/ADAPT-TO-YOUR-LOCAL-ENV/.sdkman/candidates/java/22.0.1-graalce ./gradlew :data:data-jdbc-h2-kotlin:nativeTestCompile

Fail as well with 23.ea.9-graal from SDKman.

fniephaus commented 4 months ago

Thanks for the report, @sdeleuze. I just reproduced this and the problem seems to be that the AOT smoke test runs with NBTs 0.9.25. The missing JUnit registrations for --strict-image-heap were added in 0.10.1, and with that, I can build the test just fine.

Can the NBT version be bumped in the AOT smoke test suite or is that a problem?

sdeleuze commented 4 months ago

Good catch, this was indeed related to using an old version of NBT, will upgrade.