RFR: 7904149: jtreg fails when test with @enablePreview is executed with driver mode

Leonid Mesnik lmesnik at openjdk.org
Thu Feb 5 08:06:13 UTC 2026


The test like this



/*
 * @test
 * @enablePreview
 * @run driver ${test.main.class}
 */



public class PreviewDriverTest {
    Integer i;
    public static void main(String[] args) throws Exception {
    }
}


fails in valhalla repo because class is compiled with enable-preview while executed without this option.

Test fails with:
java.lang.UnsupportedClassVersionError: Preview features are not enabled for PreviewDriverTest (class file version 71.65535). Try running with '--enable-preview'

It doesn't use any Valhalla feature directly but has a field Integer and javac generates additional attributes because of this.

Fix is just to pass --enable-preview to driver code.
The workaround is to don't run driver tests with enable preview.

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

Commit messages:
 - 7904149: jtreg fails when test with @enablePreview is executed with driver mode

Changes: https://git.openjdk.org/jtreg/pull/314/files
  Webrev: https://webrevs.openjdk.org/?repo=jtreg&pr=314&range=00
  Issue: https://bugs.openjdk.org/browse/CODETOOLS-7904149
  Stats: 3 lines in 1 file changed: 2 ins; 0 del; 1 mod
  Patch: https://git.openjdk.org/jtreg/pull/314.diff
  Fetch: git fetch https://git.openjdk.org/jtreg.git pull/314/head:pull/314

PR: https://git.openjdk.org/jtreg/pull/314


More information about the jtreg-dev mailing list