Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8336108

[lworld] Test libraries compiled with --enable-preview are causing tests failures

    XMLWordPrintable

Details

    Description

      The problem occurs when the classes of test libraries (WhiteBox, ModuleUtils) are compiled with --enable-preview but the test itself is run in non-preview mode. Valhalla's preview mode is generating class files with a new format and new features that are not recognized by javac or the JVM is they are run without the preview mode. The error message generated in such situation looks like this:

      error: class file for [...]/testoutput/test-support/jtreg_open_test_hotspot_jtreg_hotspot_tier2_runtime/classes/0/test/lib/jdk/test/whitebox/WhiteBox.class uses preview features of Java SE 23.
        (use --enable-preview to allow loading of class files which contain preview features)

      AFAICT, those test libraries are compiled on demand and shared across all tests. So, the first or last test to write those libraries class files can impact other tests. Because most tests are run concurrently, and because Valhalla has a mix of tests, some of them with @enablePreview and some of them without, it creates unpredictable failures in the CI.

      So, here are two solutions that could be considered:
        1 - always compile those test libraries with enable preview disabled, so their class files can be used by all tests
        2 - have two separate versions of those libraries, in different directories, one compiled with --enable-preview, and the other without

      Option 2 looks better, as it provides a better test coverage, but option 1 might be simpler to implement,

      Attachments

        Issue Links

          Activity

            People

              dsimms David Simms
              fparain Frederic Parain
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated: