On Fri, 27 Mar 2026 18:45:46 GMT, Bill Huang <[email protected]> wrote:

>> test/jdk/java/util/Collections/AddAll.java line 36:
>> 
>>> 34: 
>>> 35: /*
>>> 36:  * @test id=Preview
>> 
>> I think that is going to fail if test is executed with
>> jtreg -jdk:<jdk> -test ....
>> 
>> I think that is better to support 
>> make JTREG_VALUE_CLASS=true run-test 
>> TEST=test/jdk/java/util/Collections/AddAll.java
>> and in this mode test is  compiled with this plugin.
>> 
>> So we are not executing the preview mode by default, but can run all our 
>> test compiling and executing with `--enable-preview`. So all JDK build in 
>> value classes and these ValueClass marked classes are value classes.
>
> You're right that plain jtreg without cpa will fail with "plugin not found". 
> But this is temporary solution that goes away when value classes graduate 
> from preview - so the failure being loud and obvious is a feature, not a bug. 
> Anyone running these tests without the plugin jar is misconfigured rather 
> than silently getting results that don't test value class behavior.
> 
> On the other hand, `make test` already handles it properly - the plugin jar 
> is built as part of the test image and cpa is added automatically.

I understand your intentions, but not sure it is achievable. 
We can't break plain jtreg execution for testing preview features.  We should 
be able to run the default test without any additional requirements.  The 
change of default behavior requires much wider discussion and documentation 
changes that doesn't worth for temporary solution.

It still think that it should be controlled in the make files. Like adding (the 
actual options might be updated)


+  ifneq ($$(JTREG_ENABLE_VALUE_CLASS), )
+    $1_JTREG_BASIC_OPTIONS += \
+        -vmoption:'-Djtreg.value.class=true' \
+        -vmoption:'--enable-preview' \
+        -javacoption:'-XDaccessInternalAPI' \
+        -javacoption:'--source' \
+        -javacoption:'27' \
+        -javacoption:'--enable-preview' \
+        -javacoption:'-cp' \
+        -javacoption:'...../public-plugin.jar' \
+        -javacoption:'-Xplugin:VallhallaPlugin'
+
+    $1_JTREG_BASIC_OPTIONS += $$(addprefix $$(JTREG_PROBLEM_LIST_PREFIX), 
$$(wildcard \
+        $$(addprefix $$($1_TEST_ROOT)/, ProblemList-enable-preview.txt) \
+    ))
+  endif


So we have this mode JTREG_ENABLE_VALUE_CLASS and use it instead of 
'--enable-preview' to test value classes. Instead of just running test with 
value classes enabled, we compile and use test classes as value classes here.

And test should just pass when executed with jtreg -test:...

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

PR Review Comment: 
https://git.openjdk.org/valhalla/pull/2253#discussion_r3003058639

Reply via email to