Skip to content

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

Closed
lmesnik wants to merge 6 commits intoopenjdk:masterfrom
lmesnik:7904149
Closed

7904149: jtreg fails when test with @enablePreview is executed with driver mode#314
lmesnik wants to merge 6 commits intoopenjdk:masterfrom
lmesnik:7904149

Conversation

@lmesnik
Copy link
Member

@lmesnik lmesnik commented Feb 5, 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.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • CODETOOLS-7904149: jtreg fails when test with @enablePreview is executed with driver mode (Bug - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jtreg.git pull/314/head:pull/314
$ git checkout pull/314

Update a local copy of the PR:
$ git checkout pull/314
$ git pull https://git.openjdk.org/jtreg.git pull/314/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 314

View PR using the GUI difftool:
$ git pr show -t 314

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jtreg/pull/314.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Feb 5, 2026

👋 Welcome back lmesnik! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Feb 5, 2026

@lmesnik This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

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

Reviewed-by: cstein

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 1 new commit pushed to the master branch:

  • da8892f: 7904152: jtreg tests fail with openjdk 25

Please see this link for an up-to-date comparison between the source branch of this pull request and the master branch.
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@sormuras) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added the rfr Pull request is ready for review label Feb 5, 2026
@mlbridge
Copy link

mlbridge bot commented Feb 5, 2026

Webrevs

Copy link
Member

@sormuras sormuras left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for updating the spec and faq documents.

Please also update the dates in the copyright headers and increase the version of the spec (as suggested).

lmesnik and others added 3 commits February 20, 2026 07:34
Co-authored-by: Christian Stein <sormuras@gmail.com>
Co-authored-by: Christian Stein <sormuras@gmail.com>
Co-authored-by: Christian Stein <sormuras@gmail.com>
@openjdk openjdk bot added the ready Pull request is ready to be integrated label Mar 4, 2026
@lmesnik
Copy link
Member Author

lmesnik commented Mar 4, 2026

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Mar 4, 2026
@openjdk
Copy link

openjdk bot commented Mar 4, 2026

@lmesnik
Your change (at version fdfa925) is now ready to be sponsored by a Committer.

@sormuras
Copy link
Member

sormuras commented Mar 4, 2026

/sponsor

@openjdk
Copy link

openjdk bot commented Mar 4, 2026

Going to push as commit bab5aeb.
Since your change was applied there has been 1 commit pushed to the master branch:

  • da8892f: 7904152: jtreg tests fail with openjdk 25

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Mar 4, 2026
@openjdk openjdk bot closed this Mar 4, 2026
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review sponsor Pull request is ready to be sponsored labels Mar 4, 2026
@openjdk
Copy link

openjdk bot commented Mar 4, 2026

@sormuras @lmesnik Pushed as commit bab5aeb.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@jonathan-gibbons
Copy link
Collaborator

While it may be too late to comment, it seems wrong to execute a driver class with preview features enabled.

The original intent of "driver code" was to be able to use plain-simple-standard Java, instead of shell scripts, to properly execute the "real" test class, which should be executed on the test JVM, with any necessary options (like "enable preview") enabled.

Instead of running driver-mode classes with "enable preview" enabled, surely it would be better to ensure the relevant classes were not compiled with "enable preview".

@lmesnik
Copy link
Member Author

lmesnik commented Mar 5, 2026

Unlike shell code,, the driver code is not completely isolated from test code, and it's compiled with all the test compilation flags. So can't have combination of enablePreview + driver. It is going to fail because compiled with compilation flags and executed with not.

Another case - we need to compile and run tests with '--enable-preview'. The '--enabe-preview' compilation should be completely compatible except few non-preview tests. (Remind that '--enable-preview' for valhalla affects compilation even if class is not value class itself.)
However we can't do this now.

Also, I think that we should more care real use cases  and adopt our tools for our goals rather than change process and goals.
Do you see any real  or potential problem of running jtreg driver code with '--enable-preview'?

@jonathan-gibbons
Copy link
Collaborator

Driver code is not test code. It is intended to be code that runs in a plain stable Java environment that sets up the environment for a test in a way that is beyond the normal simple abilities of jtreg itself.

If you want to run code in the test environment, use @run main.
If you're running driver code with test options that completely nullifies the intent and purpose of @run driver.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

3 participants