On Sat, 8 Aug 2026 05:41:32 GMT, Yasumasa Suenaga <[email protected]> wrote:

> We can see following errors when we run `make test` with 
> `JTREG="VALUE_CLASS_PLUGIN=true;VM_OPTIONS=--enable-preview"`:
> 
> TestInstanceKlassSize
> 
>  stderr: [Exception in thread "main" java.lang.UnsupportedClassVersionError:
>  Preview features are not enabled for jdk/test/whitebox/WhiteBox (class file
>  version 72.65535). Try running with '--enable-preview'
>         at java.base/java.lang.ClassLoader.findBootstrapClass(Native Method)
>         at java.base/java.lang.ClassLoader.findBootstrapClassOrNull(ClassLoa
> der.java:1244)
>         at java.base/java.lang.System$1.findBootstrapClassOrNull(System.java
> :2068)
>         at java.base/jdk.internal.loader.ClassLoaders$BootClassLoader.loadCl
> assOrNull(ClassLoaders.java:138)
>         at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(
> BuiltinClassLoader.java:639)
>         at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(
> BuiltinClassLoader.java:615)
>         at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(
> BuiltinClassLoader.java:639)
>         at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(
> BuiltinClassLoader.java:615)
>         at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Builti
> nClassLoader.java:578)
>         at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:502)
>         at TestInstanceKlassSize.<clinit>(TestInstanceKlassSize.java:65)
> ]
>  exitValue = 1
> 
> java.lang.RuntimeException: Expected to get exit value of [0], exit value is
> : [1]
>         at jdk.test.lib.process.OutputAnalyzer.shouldHaveExitValue(OutputAna
> lyzer.java:602)
>         at TestInstanceKlassSize.startMeWithArgs(TestInstanceKlassSize.java:
> 100)
>         at TestInstanceKlassSize.main(TestInstanceKlassSize.java:152)
>         at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(
> DirectMethodHandleAccessor.java:104)
>         at java.base/java.lang.reflect.Method.invoke(Method.java:583)
>         at com.sun.javatest.regtest.agent.MainMethodHelper.executeModernMain
> Class(MainMethodHelper.java:55)
>         at com.sun.javatest.regtest.agent.MainWrapper$MainTask.run(MainWrapp
> er.java:138)
>         at java.base/java.lang.Thread.run(Thread.java:1527)
> 
> 
> TestInstanceKlassSizeForInterface
> 
>  stderr: [Exception in thread "main" java.lang.UnsupportedClassVersionError: 
> Preview features are not enabled for jdk/test/whitebox/WhiteBox (class file 
> version 72.65535). Try running with '--enable-preview'
>         at java.base/java.lang.ClassLoader.findBootstrapClass(Native Method)
> ...

I think the reason for using `createLimitedTestJavaProcessBuilder` is because 
the launched SA process should normally not require, and probably doesn't want, 
all the other flags that the test was asked to be run with. For SA those are 
mainly of concern for the debuggee process. We have plenty of other SA tests 
that also launch SA tools in this manner, although I'm not so sure it is 
consistent.

The reason for the preview complaint seems to be related to the SA test process 
using a class that was compiled with preview when the main test was compiled. 
In particular the WhiteBox class. I think WhiteBox is being built with preview 
due to a combination of the `@build jdk.test.whitebox.WhiteBox` and the use of 
`VALUE_CLASS_PLUGIN=true`. I think perhaps WhiteBox is not built with preview 
if not using `VALUE_CLASS_PLUGIN=true`, but I'm not 100% sure what build flag 
`@build` commands pick up, if any. It seems that just using 
`VM_OPTIONS=--enable-preview` does not trigger it being compiled with preview 
since we don't see a problem in this case.

Regarding all the other tests using `createLimitedTestJavaProcessBuilder` not 
having this issue, it is probably because they don't use `@build`. I checked, 
and these are the only two classes using both `@build` and 
`createLimitedTestJavaProcessBuilder`.

I'm not sure of the suggestion that `createLimitedTestJavaProcessBuilder` is 
probably the better place to be adding `--eanble-preview`. If for some reason 
the user didn't want it, it's hard to remove. Given the limited affected test 
cases, perhaps just fixing them directly is best.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/32262#issuecomment-5247568042

Reply via email to