Skip to content

8352068: [lworld] test StrictFinalInstanceFieldsTest.java needs to be updated after fix for JDK-8351951 #1449

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: lworld
Choose a base branch
from

Conversation

matias9927
Copy link
Contributor

@matias9927 matias9927 commented May 1, 2025

Updates to javac prevent it from creating classes with improper uses of strict fields. Additionally, non-final strict fields are now allowed so StrictFinalInstanceFieldsTest.java needs to updated with new test cases. This patch adds new cases for final and non-final stricts as well as negative test cases using asmtools that check improper use of strict fields and early larval stack map frames.

During testing, it was revealed that the new verify errors added in JDK-8354694 do not work properly so a fix is included in this patch.

Note: This cannot be integrated until jtreg is updated with a recent build of asmtools which can handle strict fields and can generate early_larval frames.


Progress

  • Change must not contain extraneous whitespace

Issue

  • JDK-8352068: [lworld] test StrictFinalInstanceFieldsTest.java needs to be updated after fix for JDK-8351951 (Bug - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 1449

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/valhalla/pull/1449.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented May 1, 2025

👋 Welcome back matsaave! A progress list of the required criteria for merging this PR into lworld 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 May 1, 2025

@matias9927 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:

8352068: [lworld] test StrictFinalInstanceFieldsTest.java needs to be updated after fix for JDK-8351951

Reviewed-by: liach, heidinga

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 no new commits pushed to the lworld branch. If another commit should be pushed before you perform the /integrate command, your PR will be automatically rebased. If you prefer to avoid any potential automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the lworld branch, type /integrate in a new comment.

@matias9927 matias9927 marked this pull request as ready for review May 1, 2025 17:42
@mlbridge
Copy link

mlbridge bot commented May 1, 2025

Webrevs

@@ -139,6 +139,7 @@ runtime/AccModule/ConstModule.java 8294051 generic-all
runtime/valhalla/inlinetypes/CircularityTest.java 8349037 generic-all
runtime/valhalla/inlinetypes/PreloadCircularityTest.java 8349631 linux-aarch64-debug
runtime/valhalla/inlinetypes/ValuePreloadTest.java 8349630 linux-aarch64-debug
runtime/valhalla/inlinetypes/verifier/StrictInstanceFieldsTest.java generic-all
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this require a bug number?

Copy link
Contributor

@coleenp coleenp May 8, 2025

Choose a reason for hiding this comment

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

Maybe CODETOOLS-7903081 will work.

@liach
Copy link
Member

liach commented May 9, 2025

For jasm tests, do we usually include a Xxx.test which includes the source to generate the basic jasm with asmtools, and then include comments in jasm to indicate where the class is modified from the original?

Copy link
Member

@liach liach left a comment

Choose a reason for hiding this comment

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

Just noticed these jasm and jcod are from StrictInstanceFieldsTest. Should be all good.

@openjdk
Copy link

openjdk bot commented May 21, 2025

@matias9927 this pull request can not be integrated into lworld due to one or more merge conflicts. To resolve these merge conflicts and update this pull request you can run the following commands in the local repository for your personal fork:

git checkout new_strict_tests_8352068
git fetch https://git.openjdk.org/valhalla.git lworld
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge lworld"
git push

@openjdk openjdk bot added merge-conflict and removed ready labels May 21, 2025
@openjdk openjdk bot added ready and removed merge-conflict labels May 21, 2025
Copy link
Contributor

@DanHeidinga DanHeidinga left a comment

Choose a reason for hiding this comment

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

Maintaining jasm and jcod files can be a pain. The less those files contain, the better as it is less classfile / bytecode to try to build in your head while debugging.

One option for set of common tests like this that all have x & y fields, as well as getter methods and a complicated toString, is to use an abstract parent class:

abstract JasmParent extends Parent {
  abstract int get_x();
  abstract int get_y();
  
  public String toString() {
          return "x: " + get_x() + "\n" + "y: " + get_y() + "\n" + super.toString();
    }
}

and have all the .jasm file class extend this class instead of using Parent directly. This will move all the bootstrap methods & indy related code out of jasm files and hopefully result in something simpler to look at.

Another option is to keep Parent as it is, but have its toString() use Reflection like: this.getClass().getDeclaredFeilds() to find all the fields and print them. Any solution that moves code out of jasm / jcod files makes the code easier to maintain and understand longterm

@matias9927
Copy link
Contributor Author

matias9927 commented May 29, 2025

Maintaining jasm and jcod files can be a pain. The less those files contain, the better as it is less classfile / bytecode to try to build in your head while debugging.

One option for set of common tests like this that all have x & y fields, as well as getter methods and a complicated toString, is to use an abstract parent class:

abstract JasmParent extends Parent {
  abstract int get_x();
  abstract int get_y();
  
  public String toString() {
          return "x: " + get_x() + "\n" + "y: " + get_y() + "\n" + super.toString();
    }
}

and have all the .jasm file class extend this class instead of using Parent directly. This will move all the bootstrap methods & indy related code out of jasm files and hopefully result in something simpler to look at.

Another option is to keep Parent as it is, but have its toString() use Reflection like: this.getClass().getDeclaredFeilds() to find all the fields and print them. Any solution that moves code out of jasm / jcod files makes the code easier to maintain and understand longterm

Thanks for this suggestion! I've opted to use reflection for toString() so I can get rid of get_x() and get_y(). The jasm and jcod files have been cleaned up and now include the equivalent java source code as a comment to better illustrate what is being tested. I snuck in a logging improvement as well.

Copy link
Contributor

@DanHeidinga DanHeidinga left a comment

Choose a reason for hiding this comment

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

lgtm

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

Successfully merging this pull request may close these issues.

4 participants