JDK-8373622 : [lworld] Enabling jimage changes break tests with inMemoryJavaCompiler
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: test
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2025-12-12
  • Updated: 2025-12-15
  • Resolved: 2025-12-15
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
repo-valhallaFixed
Related Reports
Causes :  
Description
The InMemoryJavaCompiler test library doesn't pass --enable-preview to the compilation line. This isn't a problem unless jimage is used with --enable-preview instead of --patch-module.
Then we get this failure.

error: class file for /modules/java.base/java/lang/Byte.class uses preview features of Java SE 26.
  (use --enable-preview to allow loading of class files which contain preview features)
1 error
java.lang.ExceptionInInitializerError
        at java.base/jdk.internal.misc.Unsafe.ensureClassInitialized0(Native Method)
        at java.base/jdk.internal.misc.Unsafe.ensureClassInitialized(Unsafe.java:1397)
        at java.base/jdk.internal.reflect.MethodHandleAccessorFactory.ensureClassInitialized(MethodHandleAccessorFactory.java:341)
        at java.base/jdk.internal.reflect.MethodHandleAccessorFactory.newMethodAccessor(MethodHandleAccessorFactory.java:72)
        at java.base/jdk.internal.reflect.ReflectionFactory.newMethodAccessor(ReflectionFactory.java:119)
        at java.base/java.lang.reflect.Method.acquireMethodAccessor(Method.java:711)
        at java.base/java.lang.reflect.Method.invoke(Method.java:562)
        at com.sun.javatest.regtest.agent.MainWrapper$MainTask.run(MainWrapper.java:138)
        at java.base/java.lang.Thread.run(Thread.java:1474)
Caused by: java.lang.RuntimeException: Could not compile TestClass with source code public class TestClass {     public static void concat(String one, String two) throws Throwable {         System.out.println(one + two); } } 
        at jdk.test.lib.compiler.InMemoryJavaCompiler.compile(InMemoryJavaCompiler.java:264)
        at HiddenGetModule.<clinit>(HiddenGetModule.java:62)
        ... 9 more
STATUS:Failed.`main' threw exception: java.lang.ExceptionInInitializerError

Running tests like:

make test TEST=hotspot:tier1 JTREG="VERBOSE=summary;JAVA_OPTIONS=--enable-preview"

FAILED: runtime/HiddenClasses/CastToParentTest.java
FAILED: runtime/HiddenClasses/NestedHidden.java
FAILED: runtime/HiddenClasses/InstantiateHiddenClass.java
FAILED: runtime/HiddenClasses/HiddenGetModule.java
FAILED: serviceability/jvmti/RedefineClasses/RedefineAddLambdaExpression.java
FAILED: serviceability/jvmti/RedefineClasses/TestMultipleClasses.java
Comments
I linked JDK-8370904 as causal but any change that turns on the jimage code will fail these tests when run with JTREG=JAVA_OPTIONS=--enable-preview.
15-12-2025

A pull request was submitted for review. Branch: lworld URL: https://git.openjdk.org/valhalla/pull/1797 Date: 2025-12-12 20:53:03 +0000
12-12-2025