8361570: Incorrect 'sealed is not allowed here' compile-time error#26181
8361570: Incorrect 'sealed is not allowed here' compile-time error#26181lahodaj wants to merge 2 commits intoopenjdk:masterfrom
Conversation
|
👋 Welcome back jlahoda! A progress list of the required criteria for merging this PR into |
|
@lahodaj 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 13 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
|
| RECORD(Flags.RECORD), | ||
| RECOVERABLE(Flags.RECOVERABLE), | ||
| SEALED(Flags.SEALED), | ||
| RESTRICTED(Flags.RESTRICTED), |
There was a problem hiding this comment.
Why do we need to add RESTRCITED this time?
There was a problem hiding this comment.
For every long value, the needs to be a enum Flag constant (which is weak, of course, as there are conceptually multiple flags using the same value, so the mapping to the enum would need to include the Symbol kind). As sealed now has a different number than RESTRICTED, RESTRICTED needs its own constant.
| continue; | ||
| } | ||
| long flag = ((Number) f.get(null)).longValue(); | ||
| value2FlagFields.computeIfAbsent(flag, _ -> new ArrayList<>()) |
There was a problem hiding this comment.
If we are performing general flag checks, I recommend including checks to ensure there is exactly one bit set (like Long.lowestOneBit(flag) == flag)
So we no longer need a map, but can use a Field[64] and use Long.numberOfTrailingZeros to map to the array index.
There was a problem hiding this comment.
I don't think this check is very general, it is more like a test checking one corner that is apparently problematic. Maurizio proposed a more general test below. There are constants in Flags that have multiple bits set (like ExtendedStandardFlags). We could filter those out, but having the map allows to collect all flags with the same value, not only 1+1.
mcimadamore
left a comment
There was a problem hiding this comment.
Fix looks good -- and thanks for the test.
I think we might be able to take the test a step further (in a separate PR) by introducing annotations to all flags, to denote whether a non-standard flag applies to:
- everything (such as extended standard flags)
- var-only (e.g. HAS_INIT)
- method-only (e.g. BRIDGE)
- type-only (e.g. ACYCLIC)
If we do this work, then we can write a test to make sure non-standard flags are truly disjoint. The test could also report an error when it finds any flag that doesn't have the associated annotation.
|
kudos to @lahodaj and colleagues who are working on the fixes - you guys are super fast. This PR appeared ~10h after the Apache NetBeans smoke test found it, the CCE issue (JDK-8361445) before that is also already fixed. |
|
/integrate |
|
Going to push as commit 8533194.
Your commit was automatically rebased without conflicts. |
|
/backport :jdk25 |
|
@lahodaj the backport was successfully created on the branch backport-lahodaj-85331943-jdk25 in my personal fork of openjdk/jdk. To create a pull request with this backport targeting openjdk/jdk:jdk25, just click the following link: The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:
If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk: |
Consider code like this:
Compiling this with JDK 25/26 leads to:
Which does not make much sense.
The reason for this is as follows:
WeakReferenceis marked with@jdk.internal.RequiresIdentity, and theWeakReference's constructor has a parameter whose type is this type parameter.REQUIRES_IDENTITY. Note this flag has currently the samelongvalue asSEALED, as the value is reused to mean different things for different Symbol kinds.REQUIRES_IDENTITYtogether with the constructor's parameterSEALEDis set, and reports the errorUltimately, I don't think we can reuse the value of
SEALEDto mean different things (and the same for all other similar cases). This PR assigns a different value forSEALED, and tries to add a test that strives to hopefully prevent similar cases in the future by saying that noFlagsinExtendedStandardFlagscan be reused.Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/26181/head:pull/26181$ git checkout pull/26181Update a local copy of the PR:
$ git checkout pull/26181$ git pull https://git.openjdk.org/jdk.git pull/26181/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 26181View PR using the GUI difftool:
$ git pr show -t 26181Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/26181.diff
Using Webrev
Link to Webrev Comment