8376045: [lworld] Treat @NullRestricted fields as ACC_STRICT_INIT on load#1951
8376045: [lworld] Treat @NullRestricted fields as ACC_STRICT_INIT on load#1951liach wants to merge 9 commits intoopenjdk:lworldfrom
Conversation
|
👋 Welcome back liach! A progress list of the required criteria for merging this PR into |
|
@liach 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: 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 11 new commits pushed to the
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. ➡️ To integrate this PR with the above commit message to the |
Webrevs
|
|
Testing: tier1 clear on Linux. |
|
I want to confirm that this works on a non-preview class file, and that nothing downstream is going to break. (Hard to prove that second point definitively, but looking for some confirmation from a runtime expert.) |
|
Currently The non-preview class scenario is possible with users annotating a migrated value class field plus opening up jdk internals, don't know what we should do in this case - Given this annotation is expected to be revisited in bworld, wonder if it's worth adding extra checks. |
|
With this change, the double annotation @strict + @NullRestricted can be replaced by a single @NullRestricted annotation in all the tests. Is there a reason why this simplification is not part or this PR? |
|
The annotation After both #1951 and #1952 are merged, I plan to move on to to the simplification you mentioned. |
The annotation is currently parsed and processed without checking if the class file has a preview version number or not. Looks like an issue that can easily be fixed. When a field is annotated with @NullRestricted, it is automatically marked as a null-free value field, which will trigger two actions later in the loading of the declaring class:
For the JEP 401 preview, the simplest solution would be to simply reject or ignore the annotation when the class file hasn't a preview version number. |
…ture/cfp-nr-auto-strict
|
My worry is that if the annotation gets ignored in a non-preview class file, we'll have to be sure javac is setting the preview version number for the relevant tests. But Chen is right, I think, that a value-class-typed field should already trigger LoadableDescriptors and a preview version number, so maybe there's nothing to worry about here. Alternatively, we can interpret the annotation in all class file versions. That's what I thought we wanted, and I was just confirming that nothing later is going to break because of an unexpected version number. Sounds like probably not. So it seems good either way. |
|
Per Fred's suggestion I have added a filter to block NR on non-preview classes. This is experimental; Running tier 1-2 to see whether our "already preview" assumption stands. |
|
I added |
| class_name()->as_C_string(), name->as_C_string()); | ||
| } | ||
| const bool is_strict = (flags & JVM_ACC_STRICT) != 0; | ||
| if (!is_strict && !HAS_PENDING_EXCEPTION) { |
There was a problem hiding this comment.
This test should not include exception checking.
There's a bug just above, the call to Exceptions::fthrow() should be followed by a return; statement.
There was a problem hiding this comment.
I tried to add return; to both fthrow() occurrences. The problem is that they hit some weird assertions in runtime like when metaspace is being teared down. I couldn't diagnose them so I resorted to HAS_PENDING_EXCEPTION which runs successfully instead.
…ture/cfp-nr-auto-strict
|
Could you try the patch below that enabled early returns in the parse_fields() method by removing the assumption in Annotations deallocation code that the arrays are fully populated, and by ensuring the ownership transfer of field_annotations is completed before all return to prevent a double free. |
|
/contributor add @fparain |
|
@liach |
|
Ran tier 1-3 on the CI, no failure on linux-x64 platform. I think this patch is safe. |
|
Thanks for the reviews. I will integrate now to facilitate testing for the subsequent test fixes. /integrate |
|
Going to push as commit e7af4bd.
Your commit was automatically rebased without conflicts. |
This is the 2nd PR in the strict removal series. 1st PR is #1952, and 3rd PR is #1959.
Automatically inject strict for NR annotations, and remove tests that previously kept them separate. Also add behavior where NR is only accepted for preview class files.
Progress
Issue
Reviewers
Contributors
<fparain@openjdk.org>Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/valhalla.git pull/1951/head:pull/1951$ git checkout pull/1951Update a local copy of the PR:
$ git checkout pull/1951$ git pull https://git.openjdk.org/valhalla.git pull/1951/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 1951View PR using the GUI difftool:
$ git pr show -t 1951Using diff file
Download this PR as a diff file:
https://git.openjdk.org/valhalla/pull/1951.diff
Using Webrev
Link to Webrev Comment