-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
8332463: Byte conditional pattern case element dominates short constant case element #19301
Conversation
👋 Welcome back abimpoudis! A progress list of the required criteria for merging this PR into |
@biboudis 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 88 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 |
Mailing list message from David Alayachew on compiler-dev: I understand the first 2 cases, but not the third. How is byte -> Integer On Mon, May 20, 2024, 4:31?AM Aggelos Biboudis <abimpoudis at openjdk.org> -------------- next part -------------- |
Mailing list message from Angelos Bimpoudis on compiler-dev: The reason is that according to Casting Contexts/Section 5.5 (or Testing Contexts in JDK 23/Section 5.7 which is very similar to casting contexts) not only it is not unconditionally exact but there is no conversion at all that can support byte to Integer. If there were one, we would see a bullet that says: a widening primitive conversion followed by boxing. The permitted conversions are the ones listed in Chapter 5.5 or 5.7 in the accompanying spec diff ? https://cr.openjdk.org/~abimpoudis/instanceof/jep455-20240424/specs/instanceof-jls.html#jls-5.7. This is also evident by trying to do the cast in JShell: jshell> byte b = (byte) 42 jshell> (Integer) b Note, that while dominance checks the relation between two case labels, those two case labels can be independently applicable to the selector type. I understand the first 2 cases, but not the third. How is byte -> Integer not unconditionally exact? What possible scenario could occur where one would lose data? On Mon, May 20, 2024, 4:31?AM Aggelos Biboudis <abimpoudis at openjdk.org<mailto:abimpoudis at openjdk.org>> wrote: public static int test() { Similarly for primitive type patterns: public static int test() { public static int test() { ------------- Commit messages: Changes: https://git.openjdk.org/jdk/pull/19301/files PR: https://git.openjdk.org/jdk/pull/19301 |
Mailing list message from David Alayachew on compiler-dev: Then maybe I am not following along here. The link you sent says this.
<https://docs.oracle.com/javase/specs/jls/se22/html/jls-5.html#jls-5.1.5>) Isn't what I described just an abbreviated version of this casting context? Namely, byte --> Byte --> Integer And even if not (I would like to know why not), my other question wasn't Specifically, I cannot imagine a single value of byte that could not be I guess, what does this lack of ability grant us that we would lose if we On Tue, May 21, 2024, 5:10?AM Angelos Bimpoudis < -------------- next part -------------- |
While
and
The two reference types in the second conversion are disjoint. Evident that you cannot even ask if a Byte is instanceof Integer.
What you are really asking is whether or not |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
/integrate |
Going to push as commit c4557a7.
Your commit was automatically rebased without conflicts. |
Mailing list message from David Alayachew on compiler-dev: Got it, ty vm. I had assumed that Byte to Integer was already implemented logic. I had Ok, makes perfect sense now. So, when Valhalla reevaluates the relationship On Wed, May 22, 2024 at 5:41?AM Aggelos Biboudis <abimpoudis at openjdk.org> -------------- next part -------------- |
It seems that the compiler introduced a rule that does not exist in the spec. The fix is simple, and it will fix the behaviour of JDK 23 according to the spec. For example the following is accepted by JDK 22 and needs to continue to be accepted by JDK 23:
Similarly for primitive type patterns:
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/19301/head:pull/19301
$ git checkout pull/19301
Update a local copy of the PR:
$ git checkout pull/19301
$ git pull https://git.openjdk.org/jdk.git pull/19301/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 19301
View PR using the GUI difftool:
$ git pr show -t 19301
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/19301.diff
Webrev
Link to Webrev Comment