From jlahoda at openjdk.org Tue Jan 2 15:05:57 2024 From: jlahoda at openjdk.org (Jan Lahoda) Date: Tue, 2 Jan 2024 15:05:57 GMT Subject: RFR: 8322003: JShell - Incorrect type inference in lists of records implementing interfaces Message-ID: Consider JShell snippet like: var v = List.of("", 0); The type of `v` is along the lines of `List&java.lang.constant.Constable&java.lang.constant.ConstantDesc>&java.lang.constant.Constable&java.lang.constant.ConstantDesc>` - i.e. a List with an intersection type as a type argument. The problem is that JShell compiles snippets separately in separate classes. And hence `v` is upgraded to a field. But, the field cannot have the above non-denotable type, so its type is demoted to `List`. When the field is read when a subsequent snippet is processed, JShell tries to reconstitute the type, but a type with an intersection type as a type argument cannot be parsed by the parser. As a consequence, continuing with the example above: jshell> List l = v; | Error: | incompatible types: java.util.List cannot be converted to java.util.List | List l = v; | ^ The proposed solution here is to enhance the parser used by JShell so that it can parse intersection types at any position. JShell then can reconstitute the type, and the above snippets work: jshell> var v = List.of("", 0); v ==> [, 0] jshell> List l = v; l ==> [, 0] ------------- Commit messages: - 8322003: JShell - Incorrect type inference in lists of records implementing interfaces Changes: https://git.openjdk.org/jdk/pull/17223/files Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=17223&range=00 Issue: https://bugs.openjdk.org/browse/JDK-8322003 Stats: 121 lines in 3 files changed: 87 ins; 11 del; 23 mod Patch: https://git.openjdk.org/jdk/pull/17223.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/17223/head:pull/17223 PR: https://git.openjdk.org/jdk/pull/17223 From jlahoda at openjdk.org Tue Jan 2 15:21:06 2024 From: jlahoda at openjdk.org (Jan Lahoda) Date: Tue, 2 Jan 2024 15:21:06 GMT Subject: RFR: 8322532: JShell : Unnamed variable issue Message-ID: The parser that estimates the type and completeness of snippets categorizes tokens to several categories. Underscore is currently not considered to be a token that may appear in an expression, and hence: Func f = _ -> 0; is not recognized as a full valid variable declaration snippet, leading to further problems with splitting input into snippets, like: jshell> interface Func { public void t(int i); } ...> Func f = _ -> {}; ...> System.err.println("This should be printed, but is not!"); ...> | created interface Func f ==> $Lambda/0x00000000b3099000 at 2833cc44 jshell> Note the output `This should be printed, but is not!` is missing. The proposed change here is to mark underscore as an expression token, which then allows JShell to split the snippets correctly: jshell> interface Func { public void t(int i); } ...> Func f = _ -> {}; ...> System.err.println("This should be printed, but is not!"); | created interface Func f ==> $Lambda/0x0000000084099000 at 2833cc44 This should be printed, but is not! ------------- Commit messages: - 8322532: JShell : Unnamed variable issue Changes: https://git.openjdk.org/jdk/pull/17225/files Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=17225&range=00 Issue: https://bugs.openjdk.org/browse/JDK-8322532 Stats: 8 lines in 2 files changed: 6 ins; 0 del; 2 mod Patch: https://git.openjdk.org/jdk/pull/17225.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/17225/head:pull/17225 PR: https://git.openjdk.org/jdk/pull/17225 From asotona at openjdk.org Wed Jan 3 13:33:39 2024 From: asotona at openjdk.org (Adam Sotona) Date: Wed, 3 Jan 2024 13:33:39 GMT Subject: RFR: 8322532: JShell : Unnamed variable issue In-Reply-To: References: Message-ID: On Tue, 2 Jan 2024 15:16:41 GMT, Jan Lahoda wrote: > The parser that estimates the type and completeness of snippets categorizes tokens to several categories. Underscore is currently not considered to be a token that may appear in an expression, and hence: > > Func f = _ -> 0; > > > is not recognized as a full valid variable declaration snippet, leading to further problems with splitting input into snippets, like: > > jshell> interface Func { public void t(int i); } > ...> Func f = _ -> {}; > ...> System.err.println("This should be printed, but is not!"); > ...> > | created interface Func > f ==> $Lambda/0x00000000b3099000 at 2833cc44 > > jshell> > > > Note the output `This should be printed, but is not!` is missing. > > The proposed change here is to mark underscore as an expression token, which then allows JShell to split the snippets correctly: > > jshell> interface Func { public void t(int i); } > ...> Func f = _ -> {}; > ...> System.err.println("This should be printed, but is not!"); > | created interface Func > f ==> $Lambda/0x0000000084099000 at 2833cc44 > This should be printed, but is not! It looks good. ------------- Marked as reviewed by asotona (Reviewer). PR Review: https://git.openjdk.org/jdk/pull/17225#pullrequestreview-1802067800 From jlahoda at openjdk.org Fri Jan 5 11:37:32 2024 From: jlahoda at openjdk.org (Jan Lahoda) Date: Fri, 5 Jan 2024 11:37:32 GMT Subject: Integrated: 8322532: JShell : Unnamed variable issue In-Reply-To: References: Message-ID: <0AWVg_9MXMQfAfS9iakxKg9NKlt71OwgJ--4bjYCRIU=.69afdca0-8a47-4ff6-9758-0272b0b93b31@github.com> On Tue, 2 Jan 2024 15:16:41 GMT, Jan Lahoda wrote: > The parser that estimates the type and completeness of snippets categorizes tokens to several categories. Underscore is currently not considered to be a token that may appear in an expression, and hence: > > Func f = _ -> 0; > > > is not recognized as a full valid variable declaration snippet, leading to further problems with splitting input into snippets, like: > > jshell> interface Func { public void t(int i); } > ...> Func f = _ -> {}; > ...> System.err.println("This should be printed, but is not!"); > ...> > | created interface Func > f ==> $Lambda/0x00000000b3099000 at 2833cc44 > > jshell> > > > Note the output `This should be printed, but is not!` is missing. > > The proposed change here is to mark underscore as an expression token, which then allows JShell to split the snippets correctly: > > jshell> interface Func { public void t(int i); } > ...> Func f = _ -> {}; > ...> System.err.println("This should be printed, but is not!"); > | created interface Func > f ==> $Lambda/0x0000000084099000 at 2833cc44 > This should be printed, but is not! This pull request has now been integrated. Changeset: f0cfd361 Author: Jan Lahoda URL: https://git.openjdk.org/jdk/commit/f0cfd361bd6a98dc1192dab2116fdd3904f130f8 Stats: 8 lines in 2 files changed: 6 ins; 0 del; 2 mod 8322532: JShell : Unnamed variable issue Reviewed-by: asotona ------------- PR: https://git.openjdk.org/jdk/pull/17225 From jlahoda at openjdk.org Fri Jan 5 19:58:43 2024 From: jlahoda at openjdk.org (Jan Lahoda) Date: Fri, 5 Jan 2024 19:58:43 GMT Subject: [jdk22] RFR: 8322532: JShell : Unnamed variable issue Message-ID: <2B3duICJGAcVZTDPldFNv3m0q6XfJrqAWXNbccJChIE=.e01830e4-d608-4c23-811e-542ce4dcde80@github.com> Hi all, This pull request contains a backport of commit [f0cfd361](https://github.com/openjdk/jdk/commit/f0cfd361bd6a98dc1192dab2116fdd3904f130f8) from the [openjdk/jdk](https://git.openjdk.org/jdk) repository. The commit being backported was authored by Jan Lahoda on 5 Jan 2024 and was reviewed by Adam Sotona. Thanks! ------------- Commit messages: - Backport f0cfd361bd6a98dc1192dab2116fdd3904f130f8 Changes: https://git.openjdk.org/jdk22/pull/36/files Webrev: https://webrevs.openjdk.org/?repo=jdk22&pr=36&range=00 Issue: https://bugs.openjdk.org/browse/JDK-8322532 Stats: 8 lines in 2 files changed: 6 ins; 0 del; 2 mod Patch: https://git.openjdk.org/jdk22/pull/36.diff Fetch: git fetch https://git.openjdk.org/jdk22.git pull/36/head:pull/36 PR: https://git.openjdk.org/jdk22/pull/36 From jlahoda at openjdk.org Fri Jan 5 20:00:57 2024 From: jlahoda at openjdk.org (Jan Lahoda) Date: Fri, 5 Jan 2024 20:00:57 GMT Subject: RFR: 8322003: JShell - Incorrect type inference in lists of records implementing interfaces [v2] In-Reply-To: References: Message-ID: > Consider JShell snippet like: > > var v = List.of("", 0); > > > The type of `v` is along the lines of `List&java.lang.constant.Constable&java.lang.constant.ConstantDesc>&java.lang.constant.Constable&java.lang.constant.ConstantDesc>` - i.e. a List with an intersection type as a type argument. > > The problem is that JShell compiles snippets separately in separate classes. And hence `v` is upgraded to a field. But, the field cannot have the above non-denotable type, so its type is demoted to `List`. When the field is read when a subsequent snippet is processed, JShell tries to reconstitute the type, but a type with an intersection type as a type argument cannot be parsed by the parser. As a consequence, continuing with the example above: > > jshell> List l = v; > | Error: > | incompatible types: java.util.List cannot be converted to java.util.List > | List l = v; > | ^ > > > The proposed solution here is to enhance the parser used by JShell so that it can parse intersection types at any position. JShell then can reconstitute the type, and the above snippets work: > > jshell> var v = List.of("", 0); > v ==> [, 0] > > jshell> List l = v; > l ==> [, 0] Jan Lahoda has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains two commits: - Merge branch 'master' into JDK-8322003 - 8322003: JShell - Incorrect type inference in lists of records implementing interfaces ------------- Changes: https://git.openjdk.org/jdk/pull/17223/files Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=17223&range=01 Stats: 121 lines in 3 files changed: 87 ins; 11 del; 23 mod Patch: https://git.openjdk.org/jdk/pull/17223.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/17223/head:pull/17223 PR: https://git.openjdk.org/jdk/pull/17223 From vromero at openjdk.org Fri Jan 5 21:01:24 2024 From: vromero at openjdk.org (Vicente Romero) Date: Fri, 5 Jan 2024 21:01:24 GMT Subject: RFR: 8322003: JShell - Incorrect type inference in lists of records implementing interfaces [v2] In-Reply-To: References: Message-ID: On Fri, 5 Jan 2024 20:00:57 GMT, Jan Lahoda wrote: >> Consider JShell snippet like: >> >> var v = List.of("", 0); >> >> >> The type of `v` is along the lines of `List&java.lang.constant.Constable&java.lang.constant.ConstantDesc>&java.lang.constant.Constable&java.lang.constant.ConstantDesc>` - i.e. a List with an intersection type as a type argument. >> >> The problem is that JShell compiles snippets separately in separate classes. And hence `v` is upgraded to a field. But, the field cannot have the above non-denotable type, so its type is demoted to `List`. When the field is read when a subsequent snippet is processed, JShell tries to reconstitute the type, but a type with an intersection type as a type argument cannot be parsed by the parser. As a consequence, continuing with the example above: >> >> jshell> List l = v; >> | Error: >> | incompatible types: java.util.List cannot be converted to java.util.List >> | List l = v; >> | ^ >> >> >> The proposed solution here is to enhance the parser used by JShell so that it can parse intersection types at any position. JShell then can reconstitute the type, and the above snippets work: >> >> jshell> var v = List.of("", 0); >> v ==> [, 0] >> >> jshell> List l = v; >> l ==> [, 0] > > Jan Lahoda has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains two commits: > > - Merge branch 'master' into JDK-8322003 > - 8322003: JShell - Incorrect type inference in lists of records implementing interfaces lgtm ------------- Marked as reviewed by vromero (Reviewer). PR Review: https://git.openjdk.org/jdk/pull/17223#pullrequestreview-1806836651 From kcr at openjdk.org Fri Jan 5 23:09:26 2024 From: kcr at openjdk.org (Kevin Rushforth) Date: Fri, 5 Jan 2024 23:09:26 GMT Subject: [jdk22] RFR: 8322532: JShell : Unnamed variable issue In-Reply-To: <2B3duICJGAcVZTDPldFNv3m0q6XfJrqAWXNbccJChIE=.e01830e4-d608-4c23-811e-542ce4dcde80@github.com> References: <2B3duICJGAcVZTDPldFNv3m0q6XfJrqAWXNbccJChIE=.e01830e4-d608-4c23-811e-542ce4dcde80@github.com> Message-ID: <5AYPWYZJvT8StN3rY7FO59iEYmlVpELusfsimNvIPVY=.23a01ce8-ef93-4113-a84c-4d5fca50dea3@github.com> On Fri, 5 Jan 2024 19:52:16 GMT, Jan Lahoda wrote: > Hi all, > > This pull request contains a backport of commit [f0cfd361](https://github.com/openjdk/jdk/commit/f0cfd361bd6a98dc1192dab2116fdd3904f130f8) from the [openjdk/jdk](https://git.openjdk.org/jdk) repository. > > The commit being backported was authored by Jan Lahoda on 5 Jan 2024 and was reviewed by Adam Sotona. > > Thanks! If the bug priority is correct, it doesn't seem to meet the criteria for JDK 22 backports during RDP1. ------------- PR Comment: https://git.openjdk.org/jdk22/pull/36#issuecomment-1879363340 From jlahoda at openjdk.org Mon Jan 8 08:18:24 2024 From: jlahoda at openjdk.org (Jan Lahoda) Date: Mon, 8 Jan 2024 08:18:24 GMT Subject: [jdk22] RFR: 8322532: JShell : Unnamed variable issue In-Reply-To: <5AYPWYZJvT8StN3rY7FO59iEYmlVpELusfsimNvIPVY=.23a01ce8-ef93-4113-a84c-4d5fca50dea3@github.com> References: <2B3duICJGAcVZTDPldFNv3m0q6XfJrqAWXNbccJChIE=.e01830e4-d608-4c23-811e-542ce4dcde80@github.com> <5AYPWYZJvT8StN3rY7FO59iEYmlVpELusfsimNvIPVY=.23a01ce8-ef93-4113-a84c-4d5fca50dea3@github.com> Message-ID: On Fri, 5 Jan 2024 23:06:52 GMT, Kevin Rushforth wrote: > If the bug priority is correct, it doesn't seem to meet the criteria for JDK 22 backports during RDP1. Oops, sorry, I thought I've update the priority, but apparently I didn't. Fixed now, including ILW. Thanks! ------------- PR Comment: https://git.openjdk.org/jdk22/pull/36#issuecomment-1880545402 From asotona at openjdk.org Mon Jan 8 13:46:26 2024 From: asotona at openjdk.org (Adam Sotona) Date: Mon, 8 Jan 2024 13:46:26 GMT Subject: [jdk22] RFR: 8322532: JShell : Unnamed variable issue In-Reply-To: <2B3duICJGAcVZTDPldFNv3m0q6XfJrqAWXNbccJChIE=.e01830e4-d608-4c23-811e-542ce4dcde80@github.com> References: <2B3duICJGAcVZTDPldFNv3m0q6XfJrqAWXNbccJChIE=.e01830e4-d608-4c23-811e-542ce4dcde80@github.com> Message-ID: On Fri, 5 Jan 2024 19:52:16 GMT, Jan Lahoda wrote: > Hi all, > > This pull request contains a backport of commit [f0cfd361](https://github.com/openjdk/jdk/commit/f0cfd361bd6a98dc1192dab2116fdd3904f130f8) from the [openjdk/jdk](https://git.openjdk.org/jdk) repository. > > The commit being backported was authored by Jan Lahoda on 5 Jan 2024 and was reviewed by Adam Sotona. > > Thanks! Marked as reviewed by asotona (Reviewer). ------------- PR Review: https://git.openjdk.org/jdk22/pull/36#pullrequestreview-1809133706 From jlahoda at openjdk.org Mon Jan 8 14:05:30 2024 From: jlahoda at openjdk.org (Jan Lahoda) Date: Mon, 8 Jan 2024 14:05:30 GMT Subject: [jdk22] Integrated: 8322532: JShell : Unnamed variable issue In-Reply-To: <2B3duICJGAcVZTDPldFNv3m0q6XfJrqAWXNbccJChIE=.e01830e4-d608-4c23-811e-542ce4dcde80@github.com> References: <2B3duICJGAcVZTDPldFNv3m0q6XfJrqAWXNbccJChIE=.e01830e4-d608-4c23-811e-542ce4dcde80@github.com> Message-ID: On Fri, 5 Jan 2024 19:52:16 GMT, Jan Lahoda wrote: > Hi all, > > This pull request contains a backport of commit [f0cfd361](https://github.com/openjdk/jdk/commit/f0cfd361bd6a98dc1192dab2116fdd3904f130f8) from the [openjdk/jdk](https://git.openjdk.org/jdk) repository. > > The commit being backported was authored by Jan Lahoda on 5 Jan 2024 and was reviewed by Adam Sotona. > > Thanks! This pull request has now been integrated. Changeset: 29ed3878 Author: Jan Lahoda URL: https://git.openjdk.org/jdk22/commit/29ed3878cc51fadccc0023795e056195d108a9a2 Stats: 8 lines in 2 files changed: 6 ins; 0 del; 2 mod 8322532: JShell : Unnamed variable issue Reviewed-by: asotona Backport-of: f0cfd361bd6a98dc1192dab2116fdd3904f130f8 ------------- PR: https://git.openjdk.org/jdk22/pull/36 From jlahoda at openjdk.org Mon Jan 8 14:12:30 2024 From: jlahoda at openjdk.org (Jan Lahoda) Date: Mon, 8 Jan 2024 14:12:30 GMT Subject: Integrated: 8322003: JShell - Incorrect type inference in lists of records implementing interfaces In-Reply-To: References: Message-ID: On Tue, 2 Jan 2024 15:00:46 GMT, Jan Lahoda wrote: > Consider JShell snippet like: > > var v = List.of("", 0); > > > The type of `v` is along the lines of `List&java.lang.constant.Constable&java.lang.constant.ConstantDesc>&java.lang.constant.Constable&java.lang.constant.ConstantDesc>` - i.e. a List with an intersection type as a type argument. > > The problem is that JShell compiles snippets separately in separate classes. And hence `v` is upgraded to a field. But, the field cannot have the above non-denotable type, so its type is demoted to `List`. When the field is read when a subsequent snippet is processed, JShell tries to reconstitute the type, but a type with an intersection type as a type argument cannot be parsed by the parser. As a consequence, continuing with the example above: > > jshell> List l = v; > | Error: > | incompatible types: java.util.List cannot be converted to java.util.List > | List l = v; > | ^ > > > The proposed solution here is to enhance the parser used by JShell so that it can parse intersection types at any position. JShell then can reconstitute the type, and the above snippets work: > > jshell> var v = List.of("", 0); > v ==> [, 0] > > jshell> List l = v; > l ==> [, 0] This pull request has now been integrated. Changeset: 57a65fe4 Author: Jan Lahoda URL: https://git.openjdk.org/jdk/commit/57a65fe436a3617d64bbf0b02d4c7f7c2551448f Stats: 121 lines in 3 files changed: 87 ins; 11 del; 23 mod 8322003: JShell - Incorrect type inference in lists of records implementing interfaces Reviewed-by: vromero ------------- PR: https://git.openjdk.org/jdk/pull/17223 From jlahoda at openjdk.org Mon Jan 8 14:27:47 2024 From: jlahoda at openjdk.org (Jan Lahoda) Date: Mon, 8 Jan 2024 14:27:47 GMT Subject: [jdk22] RFR: 8322003: JShell - Incorrect type inference in lists of records implementing interfaces Message-ID: Hi all, This pull request contains a backport of commit [57a65fe4](https://github.com/openjdk/jdk/commit/57a65fe436a3617d64bbf0b02d4c7f7c2551448f) from the [openjdk/jdk](https://git.openjdk.org/jdk) repository. The commit being backported was authored by Jan Lahoda on 8 Jan 2024 and was reviewed by Vicente Romero. Thanks! ------------- Commit messages: - Backport 57a65fe436a3617d64bbf0b02d4c7f7c2551448f Changes: https://git.openjdk.org/jdk22/pull/40/files Webrev: https://webrevs.openjdk.org/?repo=jdk22&pr=40&range=00 Issue: https://bugs.openjdk.org/browse/JDK-8322003 Stats: 121 lines in 3 files changed: 87 ins; 11 del; 23 mod Patch: https://git.openjdk.org/jdk22/pull/40.diff Fetch: git fetch https://git.openjdk.org/jdk22.git pull/40/head:pull/40 PR: https://git.openjdk.org/jdk22/pull/40 From abimpoudis at openjdk.org Thu Jan 11 11:51:30 2024 From: abimpoudis at openjdk.org (Aggelos Biboudis) Date: Thu, 11 Jan 2024 11:51:30 GMT Subject: RFR: 8303374: Compiler Implementation for Primitive types in patterns, instanceof, and switch (Preview) [v38] In-Reply-To: <3JvLQvkIPnCIy1JtnD6hKyVg2GvDUDvUqog8R7gbGJc=.21d55c1c-1476-4eea-8720-5424eda66678@github.com> References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> <3JvLQvkIPnCIy1JtnD6hKyVg2GvDUDvUqog8R7gbGJc=.21d55c1c-1476-4eea-8720-5424eda66678@github.com> Message-ID: On Thu, 14 Dec 2023 11:04:09 GMT, Aggelos Biboudis wrote: >> This is the proposed patch for Primitive types in patterns, instanceof, and switch (Preview). >> >> Draft spec here: https://cr.openjdk.org/~abimpoudis/instanceof/latest/ > > Aggelos Biboudis has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 54 commits: > > - Merge branch 'master' into primitive-patterns > - Cleanup > - Merge branch 'master' into primitive-patterns > - Remove trailing spaces > - Merge branch 'primitive-patterns-and-generating-dispatch' into primitive-patterns > - Fixed switch in the cases of unboxing and widening > - Merge branch 'JDK-8319220' into primitive-patterns > - Merge branch 'master' into JDK-8319220 > - reflecting review comment: fixing letter case. > - Reflecting review feedback. > - ... and 44 more: https://git.openjdk.org/jdk/compare/d2ba3b1e...a03fea7c Keep open ??? ------------- PR Comment: https://git.openjdk.org/jdk/pull/15638#issuecomment-1886978935 From vromero at openjdk.org Thu Jan 11 18:06:25 2024 From: vromero at openjdk.org (Vicente Romero) Date: Thu, 11 Jan 2024 18:06:25 GMT Subject: [jdk22] RFR: 8322003: JShell - Incorrect type inference in lists of records implementing interfaces In-Reply-To: References: Message-ID: On Mon, 8 Jan 2024 14:21:24 GMT, Jan Lahoda wrote: > Hi all, > > This pull request contains a backport of commit [57a65fe4](https://github.com/openjdk/jdk/commit/57a65fe436a3617d64bbf0b02d4c7f7c2551448f) from the [openjdk/jdk](https://git.openjdk.org/jdk) repository. > > The commit being backported was authored by Jan Lahoda on 8 Jan 2024 and was reviewed by Vicente Romero. > > Thanks! looks good ------------- Marked as reviewed by vromero (Reviewer). PR Review: https://git.openjdk.org/jdk22/pull/40#pullrequestreview-1816186760 From jlahoda at openjdk.org Fri Jan 12 10:04:22 2024 From: jlahoda at openjdk.org (Jan Lahoda) Date: Fri, 12 Jan 2024 10:04:22 GMT Subject: [jdk22] Integrated: 8322003: JShell - Incorrect type inference in lists of records implementing interfaces In-Reply-To: References: Message-ID: On Mon, 8 Jan 2024 14:21:24 GMT, Jan Lahoda wrote: > Hi all, > > This pull request contains a backport of commit [57a65fe4](https://github.com/openjdk/jdk/commit/57a65fe436a3617d64bbf0b02d4c7f7c2551448f) from the [openjdk/jdk](https://git.openjdk.org/jdk) repository. > > The commit being backported was authored by Jan Lahoda on 8 Jan 2024 and was reviewed by Vicente Romero. > > Thanks! This pull request has now been integrated. Changeset: 07a8911c Author: Jan Lahoda URL: https://git.openjdk.org/jdk22/commit/07a8911ce8d6c0e791544c0fd38e04d9a5ca2cd5 Stats: 121 lines in 3 files changed: 87 ins; 11 del; 23 mod 8322003: JShell - Incorrect type inference in lists of records implementing interfaces Reviewed-by: vromero Backport-of: 57a65fe436a3617d64bbf0b02d4c7f7c2551448f ------------- PR: https://git.openjdk.org/jdk22/pull/40 From abimpoudis at openjdk.org Mon Jan 22 09:41:50 2024 From: abimpoudis at openjdk.org (Aggelos Biboudis) Date: Mon, 22 Jan 2024 09:41:50 GMT Subject: RFR: 8303374: Compiler Implementation for Primitive types in patterns, instanceof, and switch (Preview) [v39] In-Reply-To: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> Message-ID: > This is the proposed patch for Primitive types in patterns, instanceof, and switch (Preview). > > Draft spec here: https://cr.openjdk.org/~abimpoudis/instanceof/latest/ Aggelos Biboudis has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 56 commits: - Update copyright year, javadoc, JDK version - Merge branch 'master' into primitive-patterns - Merge branch 'master' into primitive-patterns - Cleanup - Merge branch 'master' into primitive-patterns - Remove trailing spaces - Merge branch 'primitive-patterns-and-generating-dispatch' into primitive-patterns - Fixed switch in the cases of unboxing and widening - Merge branch 'JDK-8319220' into primitive-patterns - Merge branch 'master' into JDK-8319220 - ... and 46 more: https://git.openjdk.org/jdk/compare/9049402a...676af9de ------------- Changes: https://git.openjdk.org/jdk/pull/15638/files Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=15638&range=38 Stats: 3281 lines in 41 files changed: 3000 ins; 110 del; 171 mod Patch: https://git.openjdk.org/jdk/pull/15638.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/15638/head:pull/15638 PR: https://git.openjdk.org/jdk/pull/15638 From abimpoudis at openjdk.org Mon Jan 22 10:48:05 2024 From: abimpoudis at openjdk.org (Aggelos Biboudis) Date: Mon, 22 Jan 2024 10:48:05 GMT Subject: RFR: 8303374: Compiler Implementation for Primitive types in patterns, instanceof, and switch (Preview) [v40] In-Reply-To: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> Message-ID: <3q3UXhPplqk5X8E0rnHuEyUFY-HiAIQSYPgBJeIXzEE=.bcc70cff-e2da-471b-abea-7ed23d168e18@github.com> > This is the proposed patch for Primitive types in patterns, instanceof, and switch (Preview). > > Draft spec here: https://cr.openjdk.org/~abimpoudis/instanceof/latest/ Aggelos Biboudis has updated the pull request incrementally with two additional commits since the last revision: - Update ExactConversionsSupport Javadoc and JDK version - Revert "Update copyright year, javadoc, JDK version" This reverts commit 676af9de90d946f64f34762a6df94dbd91bce41b. ------------- Changes: - all: https://git.openjdk.org/jdk/pull/15638/files - new: https://git.openjdk.org/jdk/pull/15638/files/676af9de..ed61d5fd Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk&pr=15638&range=39 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=15638&range=38-39 Stats: 27 lines in 27 files changed: 0 ins; 0 del; 27 mod Patch: https://git.openjdk.org/jdk/pull/15638.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/15638/head:pull/15638 PR: https://git.openjdk.org/jdk/pull/15638 From abimpoudis at openjdk.org Mon Jan 22 18:42:56 2024 From: abimpoudis at openjdk.org (Aggelos Biboudis) Date: Mon, 22 Jan 2024 18:42:56 GMT Subject: RFR: 8303374: Compiler Implementation for Primitive types in patterns, instanceof, and switch (Preview) [v41] In-Reply-To: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> Message-ID: > This is the proposed patch for Primitive types in patterns, instanceof, and switch (Preview). > > Draft spec here: https://cr.openjdk.org/~abimpoudis/instanceof/latest/ Aggelos Biboudis has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 60 commits: - Improve Javadoc of ExactConversionsSupport - Merge branch 'master' into primitive-patterns - Update ExactConversionsSupport Javadoc and JDK version - Revert "Update copyright year, javadoc, JDK version" This reverts commit 676af9de90d946f64f34762a6df94dbd91bce41b. - Update copyright year, javadoc, JDK version - Merge branch 'master' into primitive-patterns - Merge branch 'master' into primitive-patterns - Cleanup - Merge branch 'master' into primitive-patterns - Remove trailing spaces - ... and 50 more: https://git.openjdk.org/jdk/compare/c9cacfb2...50cb9832 ------------- Changes: https://git.openjdk.org/jdk/pull/15638/files Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=15638&range=40 Stats: 3272 lines in 41 files changed: 3008 ins; 110 del; 154 mod Patch: https://git.openjdk.org/jdk/pull/15638.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/15638/head:pull/15638 PR: https://git.openjdk.org/jdk/pull/15638 From vromero at openjdk.org Wed Jan 24 04:00:37 2024 From: vromero at openjdk.org (Vicente Romero) Date: Wed, 24 Jan 2024 04:00:37 GMT Subject: RFR: 8303374: Compiler Implementation for Primitive types in patterns, instanceof, and switch (Preview) [v41] In-Reply-To: References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> Message-ID: On Mon, 22 Jan 2024 18:42:56 GMT, Aggelos Biboudis wrote: >> This is the proposed patch for Primitive types in patterns, instanceof, and switch (Preview). >> >> Draft spec here: https://cr.openjdk.org/~abimpoudis/instanceof/latest/ > > Aggelos Biboudis has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 60 commits: > > - Improve Javadoc of ExactConversionsSupport > - Merge branch 'master' into primitive-patterns > - Update ExactConversionsSupport Javadoc and JDK version > - Revert "Update copyright year, javadoc, JDK version" > > This reverts commit 676af9de90d946f64f34762a6df94dbd91bce41b. > - Update copyright year, javadoc, JDK version > - Merge branch 'master' into primitive-patterns > - Merge branch 'master' into primitive-patterns > - Cleanup > - Merge branch 'master' into primitive-patterns > - Remove trailing spaces > - ... and 50 more: https://git.openjdk.org/jdk/compare/c9cacfb2...50cb9832 src/java.base/share/classes/java/lang/runtime/SwitchBootstraps.java line 72: > 70: private static final Object SENTINEL = new Object(); > 71: private static final MethodHandles.Lookup LOOKUP = MethodHandles.lookup(); > 72: private static final boolean previewEnabled = true; not sure about the use of this constant, do we really need it? ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1464262036 From jlahoda at openjdk.org Wed Jan 24 10:29:35 2024 From: jlahoda at openjdk.org (Jan Lahoda) Date: Wed, 24 Jan 2024 10:29:35 GMT Subject: RFR: 8303374: Compiler Implementation for Primitive types in patterns, instanceof, and switch (Preview) [v41] In-Reply-To: References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> Message-ID: <01zQgnrUk9UigmTRH4Zijckme2pKW4gUsKMzhlGorsc=.2bb5c607-644b-457d-b8d6-e1f9b6a84025@github.com> On Wed, 24 Jan 2024 03:47:06 GMT, Vicente Romero wrote: >> Aggelos Biboudis has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 60 commits: >> >> - Improve Javadoc of ExactConversionsSupport >> - Merge branch 'master' into primitive-patterns >> - Update ExactConversionsSupport Javadoc and JDK version >> - Revert "Update copyright year, javadoc, JDK version" >> >> This reverts commit 676af9de90d946f64f34762a6df94dbd91bce41b. >> - Update copyright year, javadoc, JDK version >> - Merge branch 'master' into primitive-patterns >> - Merge branch 'master' into primitive-patterns >> - Cleanup >> - Merge branch 'master' into primitive-patterns >> - Remove trailing spaces >> - ... and 50 more: https://git.openjdk.org/jdk/compare/c9cacfb2...50cb9832 > > src/java.base/share/classes/java/lang/runtime/SwitchBootstraps.java line 72: > >> 70: private static final Object SENTINEL = new Object(); >> 71: private static final MethodHandles.Lookup LOOKUP = MethodHandles.lookup(); >> 72: private static final boolean previewEnabled = true; > > not sure about the use of this constant, do we really need it? Uh, I think this is a good catch. I am not completely sure what the policy is, but here we are enhancing a non-preview method with some preview-based behavior. I would feel better if the method would refuse to work in the preview way when preview is not enabled. I.e. my opinion is that this should either be initialized to `jdk.internal.misc.PreviewFeatures.isEnabled()`, or `jdk.internal.misc.PreviewFeatures.ensureEnabled()` should be used appropriately. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1464693259 From abimpoudis at openjdk.org Wed Jan 24 11:53:52 2024 From: abimpoudis at openjdk.org (Aggelos Biboudis) Date: Wed, 24 Jan 2024 11:53:52 GMT Subject: RFR: 8303374: Compiler Implementation for Primitive types in patterns, instanceof, and switch (Preview) [v42] In-Reply-To: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> Message-ID: > This is the proposed patch for Primitive types in patterns, instanceof, and switch (Preview). > > Draft spec here: https://cr.openjdk.org/~abimpoudis/instanceof/latest/ Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision: Set previewEnabled properly in SwitchBootstraps ------------- Changes: - all: https://git.openjdk.org/jdk/pull/15638/files - new: https://git.openjdk.org/jdk/pull/15638/files/50cb9832..663c7a54 Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk&pr=15638&range=41 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=15638&range=40-41 Stats: 3 lines in 1 file changed: 1 ins; 1 del; 1 mod Patch: https://git.openjdk.org/jdk/pull/15638.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/15638/head:pull/15638 PR: https://git.openjdk.org/jdk/pull/15638 From abimpoudis at openjdk.org Wed Jan 24 11:53:54 2024 From: abimpoudis at openjdk.org (Aggelos Biboudis) Date: Wed, 24 Jan 2024 11:53:54 GMT Subject: RFR: 8303374: Compiler Implementation for Primitive types in patterns, instanceof, and switch (Preview) [v41] In-Reply-To: <01zQgnrUk9UigmTRH4Zijckme2pKW4gUsKMzhlGorsc=.2bb5c607-644b-457d-b8d6-e1f9b6a84025@github.com> References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> <01zQgnrUk9UigmTRH4Zijckme2pKW4gUsKMzhlGorsc=.2bb5c607-644b-457d-b8d6-e1f9b6a84025@github.com> Message-ID: On Wed, 24 Jan 2024 10:26:18 GMT, Jan Lahoda wrote: >> src/java.base/share/classes/java/lang/runtime/SwitchBootstraps.java line 72: >> >>> 70: private static final Object SENTINEL = new Object(); >>> 71: private static final MethodHandles.Lookup LOOKUP = MethodHandles.lookup(); >>> 72: private static final boolean previewEnabled = true; >> >> not sure about the use of this constant, do we really need it? > > Uh, I think this is a good catch. > > I am not completely sure what the policy is, but here we are enhancing a non-preview method with some preview-based behavior. I would feel better if the method would refuse to work in the preview way when preview is not enabled. I.e. my opinion is that this should either be initialized to `jdk.internal.misc.PreviewFeatures.isEnabled()`, or `jdk.internal.misc.PreviewFeatures.ensureEnabled()` should be used appropriately. Used the `jdk.internal.misc.PreviewFeatures.isEnabled()` and remove an erroneous check in `typeSwitch`. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1464801847 From mcimadamore at openjdk.org Wed Jan 24 12:25:34 2024 From: mcimadamore at openjdk.org (Maurizio Cimadamore) Date: Wed, 24 Jan 2024 12:25:34 GMT Subject: RFR: 8303374: Compiler Implementation for Primitive types in patterns, instanceof, and switch (Preview) [v42] In-Reply-To: References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> Message-ID: On Wed, 24 Jan 2024 11:53:52 GMT, Aggelos Biboudis wrote: >> This is the proposed patch for Primitive types in patterns, instanceof, and switch (Preview). >> >> Draft spec here: https://cr.openjdk.org/~abimpoudis/instanceof/latest/ > > Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision: > > Set previewEnabled properly in SwitchBootstraps src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java line 5046: > 5044: > 5045: if (target.isPrimitive()) { > 5046: return (source.isReference() && isSubtype(source, target)) || I'm a bit confused here - in here we have: * `target.isPrimitive()` * `source.isReference()` So, isn't it the case that `isSubtype(source, target)` is always false? src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java line 1924: > 1922: } > 1923: // where > 1924: static final Set nonIntegralPrimitiveTypes = Set.of( This feels like a method on TypeTag? ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1464835145 PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1464836721 From mcimadamore at openjdk.org Wed Jan 24 12:34:35 2024 From: mcimadamore at openjdk.org (Maurizio Cimadamore) Date: Wed, 24 Jan 2024 12:34:35 GMT Subject: RFR: 8303374: Compiler Implementation for Primitive types in patterns, instanceof, and switch (Preview) [v42] In-Reply-To: References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> Message-ID: On Wed, 24 Jan 2024 11:53:52 GMT, Aggelos Biboudis wrote: >> This is the proposed patch for Primitive types in patterns, instanceof, and switch (Preview). >> >> Draft spec here: https://cr.openjdk.org/~abimpoudis/instanceof/latest/ > > Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision: > > Set previewEnabled properly in SwitchBootstraps src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java line 4147: > 4145: } > 4146: if (clazztype.isPrimitive()) { > 4147: preview.checkSourceLevel(tree.pattern.pos(), Feature.PRIMITIVE_PATTERNS); So, if I have a primitive instanceof, I get two preview warnings, one for the expression, and one for the pattern type? Shouldn't one be enough? ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1464846948 From mcimadamore at openjdk.org Wed Jan 24 12:17:38 2024 From: mcimadamore at openjdk.org (Maurizio Cimadamore) Date: Wed, 24 Jan 2024 12:17:38 GMT Subject: RFR: 8303374: Compiler Implementation for Primitive types in patterns, instanceof, and switch (Preview) [v42] In-Reply-To: References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> Message-ID: <_hlWjNWAiPgvNTpwVWsBKURLCwySlIt5GoWiWKTJLRs=.3f069a48-2a82-408a-ba40-84d2b75b8ed3@github.com> On Wed, 24 Jan 2024 11:53:52 GMT, Aggelos Biboudis wrote: >> This is the proposed patch for Primitive types in patterns, instanceof, and switch (Preview). >> >> Draft spec here: https://cr.openjdk.org/~abimpoudis/instanceof/latest/ > > Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision: > > Set previewEnabled properly in SwitchBootstraps src/java.base/share/classes/java/lang/runtime/ExactConversionsSupport.java line 34: > 32: * may be used, for example, by Java compiler implementations to implement > 33: * checks for {@code instanceof} and pattern matching runtime implementations. > 34: * Unconditionally exact testing conversions do not require a corresponding "... do not require a corresponding action at runtime" ... and, for this reason, method corresponding to these conversions are omitted here src/java.base/share/classes/java/lang/runtime/ExactConversionsSupport.java line 37: > 35: * action at run time. > 36: *

> 37: * The run time conversion checks examine whether loss of information would You provide examples for runtime conversions - it would be useful, before this para, to also have examples of an inexact conversion, an exact conversion and an unconditionally exact conversion (before diving into the details of how the runtime check is performed for floating points). ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1464828250 PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1464826696 From mcimadamore at openjdk.org Wed Jan 24 12:43:36 2024 From: mcimadamore at openjdk.org (Maurizio Cimadamore) Date: Wed, 24 Jan 2024 12:43:36 GMT Subject: RFR: 8303374: Compiler Implementation for Primitive types in patterns, instanceof, and switch (Preview) [v42] In-Reply-To: References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> Message-ID: <7L1Al1Y3JbKk3Xw624IOvM1ESmoRmmzkHRPbs-Wy4J0=.f9d0acee-0f06-41ea-889e-a035208d38aa@github.com> On Wed, 24 Jan 2024 11:53:52 GMT, Aggelos Biboudis wrote: >> This is the proposed patch for Primitive types in patterns, instanceof, and switch (Preview). >> >> Draft spec here: https://cr.openjdk.org/~abimpoudis/instanceof/latest/ > > Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision: > > Set previewEnabled properly in SwitchBootstraps src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java line 2962: > 2960: * More rewritings: > 2961: * > 2962: * - If the `instanceof` check is unconditionally exact rewrite to true. Note: the same effect can be obtained, w/o rewriting (and perhaps more simply) by detecting the case of an unconditionally exact "instanceof" test, and giving the instanceof expression a constant boolean type (with value "true"). This can be done in Attr. Then, `Gen` will shortcircuit the expression, as required. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1464857684 From abimpoudis at openjdk.org Wed Jan 24 14:58:55 2024 From: abimpoudis at openjdk.org (Aggelos Biboudis) Date: Wed, 24 Jan 2024 14:58:55 GMT Subject: RFR: 8303374: Implement JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview) [v43] In-Reply-To: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> Message-ID: > This is the proposed patch for Primitive types in patterns, instanceof, and switch (Preview). > > Draft spec here: https://cr.openjdk.org/~abimpoudis/instanceof/latest/ Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision: Check the range of the new types of switch through TypeTag.isInSuperClassesOf ------------- Changes: - all: https://git.openjdk.org/jdk/pull/15638/files - new: https://git.openjdk.org/jdk/pull/15638/files/663c7a54..9b7fb7fc Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk&pr=15638&range=42 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=15638&range=41-42 Stats: 12 lines in 2 files changed: 4 ins; 7 del; 1 mod Patch: https://git.openjdk.org/jdk/pull/15638.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/15638/head:pull/15638 PR: https://git.openjdk.org/jdk/pull/15638 From abimpoudis at openjdk.org Wed Jan 24 14:58:57 2024 From: abimpoudis at openjdk.org (Aggelos Biboudis) Date: Wed, 24 Jan 2024 14:58:57 GMT Subject: RFR: 8303374: Implement JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview) [v41] In-Reply-To: References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> <01zQgnrUk9UigmTRH4Zijckme2pKW4gUsKMzhlGorsc=.2bb5c607-644b-457d-b8d6-e1f9b6a84025@github.com> Message-ID: On Wed, 24 Jan 2024 11:50:05 GMT, Aggelos Biboudis wrote: >> Uh, I think this is a good catch. >> >> I am not completely sure what the policy is, but here we are enhancing a non-preview method with some preview-based behavior. I would feel better if the method would refuse to work in the preview way when preview is not enabled. I.e. my opinion is that this should either be initialized to `jdk.internal.misc.PreviewFeatures.isEnabled()`, or `jdk.internal.misc.PreviewFeatures.ensureEnabled()` should be used appropriately. > > Used the `jdk.internal.misc.PreviewFeatures.isEnabled()` and remove an erroneous check in `typeSwitch`. Addressed in https://github.com/openjdk/jdk/pull/15638/commits/663c7a54cec9ffd6ca468080f4d084e5fa4c9c3d ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1465039116 From abimpoudis at openjdk.org Wed Jan 24 14:59:01 2024 From: abimpoudis at openjdk.org (Aggelos Biboudis) Date: Wed, 24 Jan 2024 14:59:01 GMT Subject: RFR: 8303374: Implement JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview) [v42] In-Reply-To: References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> Message-ID: <2d_xzWvSpAAcu_RvESs8LipQDSvPL5A5N12t2VL6FMo=.b16e42ce-632a-4b1f-a7ab-a417ea39f86d@github.com> On Wed, 24 Jan 2024 12:22:20 GMT, Maurizio Cimadamore wrote: >> Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision: >> >> Set previewEnabled properly in SwitchBootstraps > > src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java line 1924: > >> 1922: } >> 1923: // where >> 1924: static final Set nonIntegralPrimitiveTypes = Set.of( > > This feels like a method on TypeTag? Addressed in https://github.com/openjdk/jdk/pull/15638/commits/9b7fb7fcdd2b393425267313622970ba709c645e > src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java line 4147: > >> 4145: } >> 4146: if (clazztype.isPrimitive()) { >> 4147: preview.checkSourceLevel(tree.pattern.pos(), Feature.PRIMITIVE_PATTERNS); > > So, if I have a primitive instanceof, I get two preview warnings, one for the expression, and one for the pattern type? Shouldn't one be enough? Meaning the `compiler.err.preview.feature.disabled.plural: (compiler.misc.feature.primitive.patterns)` error due to the two `if (clazztype.isPrimitive()) { preview.checkSourceLevel(tree.pattern.pos(), Feature.PRIMITIVE_PATTERNS);` ifs? Isn't it better to keep both, for better error reporting regarding the position? (i.e., which position do we report?) ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1465034738 PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1465033188 From abimpoudis at openjdk.org Wed Jan 24 15:26:57 2024 From: abimpoudis at openjdk.org (Aggelos Biboudis) Date: Wed, 24 Jan 2024 15:26:57 GMT Subject: RFR: 8303374: Implement JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview) [v42] In-Reply-To: <_hlWjNWAiPgvNTpwVWsBKURLCwySlIt5GoWiWKTJLRs=.3f069a48-2a82-408a-ba40-84d2b75b8ed3@github.com> References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> <_hlWjNWAiPgvNTpwVWsBKURLCwySlIt5GoWiWKTJLRs=.3f069a48-2a82-408a-ba40-84d2b75b8ed3@github.com> Message-ID: On Wed, 24 Jan 2024 12:13:23 GMT, Maurizio Cimadamore wrote: >> Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision: >> >> Set previewEnabled properly in SwitchBootstraps > > src/java.base/share/classes/java/lang/runtime/ExactConversionsSupport.java line 37: > >> 35: * action at run time. >> 36: *

>> 37: * The run time conversion checks examine whether loss of information would > > You provide examples for runtime conversions - it would be useful, before this para, to also have examples of an inexact conversion, an exact conversion and an unconditionally exact conversion (before diving into the details of how the runtime check is performed for floating points). Addressed in https://github.com/openjdk/jdk/pull/15638/commits/5e48ea253bb7d8ae6fcc15a1ae7adb30475ff4ac Good point! ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1465080703 From abimpoudis at openjdk.org Wed Jan 24 15:26:54 2024 From: abimpoudis at openjdk.org (Aggelos Biboudis) Date: Wed, 24 Jan 2024 15:26:54 GMT Subject: RFR: 8303374: Implement JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview) [v44] In-Reply-To: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> Message-ID: > This is the proposed patch for Primitive types in patterns, instanceof, and switch (Preview). > > Draft spec here: https://cr.openjdk.org/~abimpoudis/instanceof/latest/ Aggelos Biboudis has updated the pull request incrementally with two additional commits since the last revision: - Enhance Javadoc of ExactConversionsSupport (2) - Enhance Javadoc of ExactConversionsSupport ------------- Changes: - all: https://git.openjdk.org/jdk/pull/15638/files - new: https://git.openjdk.org/jdk/pull/15638/files/9b7fb7fc..aa9b2fcd Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk&pr=15638&range=43 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=15638&range=42-43 Stats: 33 lines in 1 file changed: 15 ins; 3 del; 15 mod Patch: https://git.openjdk.org/jdk/pull/15638.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/15638/head:pull/15638 PR: https://git.openjdk.org/jdk/pull/15638 From vromero at openjdk.org Wed Jan 24 15:37:38 2024 From: vromero at openjdk.org (Vicente Romero) Date: Wed, 24 Jan 2024 15:37:38 GMT Subject: RFR: 8303374: Implement JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview) [v44] In-Reply-To: References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> Message-ID: <0g1L6FBda3O8Wz02hDrLEIXzUDdRh4or6H3N-szm5Lg=.e5ec4739-577e-4833-b71d-848c26978d4d@github.com> On Wed, 24 Jan 2024 15:26:54 GMT, Aggelos Biboudis wrote: >> This is the proposed patch for Primitive types in patterns, instanceof, and switch (Preview). >> >> Draft spec here: https://cr.openjdk.org/~abimpoudis/instanceof/latest/ > > Aggelos Biboudis has updated the pull request incrementally with two additional commits since the last revision: > > - Enhance Javadoc of ExactConversionsSupport (2) > - Enhance Javadoc of ExactConversionsSupport src/java.base/share/classes/java/lang/runtime/SwitchBootstraps.java line 461: > 459: // Object o = ... > 460: // o instanceof Wrapped(float) > 461: cb.aload(0); probably just a matter of style so up to you, but I don't like the mixing of low level code generation here with higher level logic. I would prefer to see the code generation be extracted if possible to helper methods and or a separate helper class. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1465102870 From vromero at openjdk.org Wed Jan 24 15:40:37 2024 From: vromero at openjdk.org (Vicente Romero) Date: Wed, 24 Jan 2024 15:40:37 GMT Subject: RFR: 8303374: Implement JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview) [v44] In-Reply-To: References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> Message-ID: <98Xa1dqszc0IzREHFRDihwUi8_Y-NZ0i47NP-4pcfGc=.fbff61cf-f0ec-49e2-910f-19baa8c68565@github.com> On Wed, 24 Jan 2024 15:26:54 GMT, Aggelos Biboudis wrote: >> This is the proposed patch for Primitive types in patterns, instanceof, and switch (Preview). >> >> Draft spec here: https://cr.openjdk.org/~abimpoudis/instanceof/latest/ > > Aggelos Biboudis has updated the pull request incrementally with two additional commits since the last revision: > > - Enhance Javadoc of ExactConversionsSupport (2) > - Enhance Javadoc of ExactConversionsSupport src/java.base/share/classes/java/lang/runtime/SwitchBootstraps.java line 471: > 469: // o instanceof float > 470: Label notNumber = cb.newLabel(); > 471: cb.aload(0); we are wiring constants into code generation: `0`, `3` etc, probably those won't change but I would prefer using static final fields or enums, that can be documented and changed easily in the future if needed ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1465107903 From abimpoudis at openjdk.org Wed Jan 24 15:55:51 2024 From: abimpoudis at openjdk.org (Aggelos Biboudis) Date: Wed, 24 Jan 2024 15:55:51 GMT Subject: RFR: 8303374: Implement JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview) [v45] In-Reply-To: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> Message-ID: > This is the proposed patch for Primitive types in patterns, instanceof, and switch (Preview). > > Draft spec here: https://cr.openjdk.org/~abimpoudis/instanceof/latest/ Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision: Remove redundant test from checkUnconditionallyExact ------------- Changes: - all: https://git.openjdk.org/jdk/pull/15638/files - new: https://git.openjdk.org/jdk/pull/15638/files/aa9b2fcd..0fcdca82 Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk&pr=15638&range=44 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=15638&range=43-44 Stats: 2 lines in 1 file changed: 0 ins; 1 del; 1 mod Patch: https://git.openjdk.org/jdk/pull/15638.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/15638/head:pull/15638 PR: https://git.openjdk.org/jdk/pull/15638 From abimpoudis at openjdk.org Wed Jan 24 15:55:55 2024 From: abimpoudis at openjdk.org (Aggelos Biboudis) Date: Wed, 24 Jan 2024 15:55:55 GMT Subject: RFR: 8303374: Implement JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview) [v42] In-Reply-To: References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> Message-ID: <9CCAFcGWzoHFi_4SaMN9i5KxnV3tSPnJAHvjQnZLE6I=.3db99d55-ded7-4a1a-a66e-fc6841af85fa@github.com> On Wed, 24 Jan 2024 12:20:55 GMT, Maurizio Cimadamore wrote: >> Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision: >> >> Set previewEnabled properly in SwitchBootstraps > > src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java line 5046: > >> 5044: >> 5045: if (target.isPrimitive()) { >> 5046: return (source.isReference() && isSubtype(source, target)) || > > I'm a bit confused here - in here we have: > * `target.isPrimitive()` > * `source.isReference()` > > So, isn't it the case that `isSubtype(source, target)` is always false? Yes! Thanks for spotting. https://github.com/openjdk/jdk/pull/15638/commits/0fcdca8229c0db81fe3503770ed155a6aaa4f250 ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1465139800 From vromero at openjdk.org Wed Jan 24 17:32:38 2024 From: vromero at openjdk.org (Vicente Romero) Date: Wed, 24 Jan 2024 17:32:38 GMT Subject: RFR: 8303374: Implement JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview) [v45] In-Reply-To: References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> Message-ID: On Wed, 24 Jan 2024 15:55:51 GMT, Aggelos Biboudis wrote: >> This is the proposed patch for Primitive types in patterns, instanceof, and switch (Preview). >> >> Draft spec here: https://cr.openjdk.org/~abimpoudis/instanceof/latest/ > > Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision: > > Remove redundant test from checkUnconditionallyExact src/java.base/share/classes/java/lang/runtime/SwitchBootstraps.java line 168: > 166: requireNonNull(labels); > 167: > 168: labels = labels.clone(); just curious, why do we need to clone this array? src/java.base/share/classes/java/lang/runtime/SwitchBootstraps.java line 405: > 403: */ > 404: @SuppressWarnings("removal") > 405: private static MethodHandle generateInnerClass(MethodHandles.Lookup caller, Class selectorType, Object[] labels) { again a matter of style but it seems to me that the huge lambda inside of this method, starting in line 409, really wants to be a separate helper method. That will probably be a better refactoring as we won't be mixing byte code generation with method handles manipulation. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1465292275 PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1465308346 From vromero at openjdk.org Wed Jan 24 17:32:41 2024 From: vromero at openjdk.org (Vicente Romero) Date: Wed, 24 Jan 2024 17:32:41 GMT Subject: RFR: 8303374: Implement JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview) [v44] In-Reply-To: <0g1L6FBda3O8Wz02hDrLEIXzUDdRh4or6H3N-szm5Lg=.e5ec4739-577e-4833-b71d-848c26978d4d@github.com> References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> <0g1L6FBda3O8Wz02hDrLEIXzUDdRh4or6H3N-szm5Lg=.e5ec4739-577e-4833-b71d-848c26978d4d@github.com> Message-ID: On Wed, 24 Jan 2024 15:34:33 GMT, Vicente Romero wrote: >> Aggelos Biboudis has updated the pull request incrementally with two additional commits since the last revision: >> >> - Enhance Javadoc of ExactConversionsSupport (2) >> - Enhance Javadoc of ExactConversionsSupport > > src/java.base/share/classes/java/lang/runtime/SwitchBootstraps.java line 461: > >> 459: // Object o = ... >> 460: // o instanceof Wrapped(float) >> 461: cb.aload(0); > > probably just a matter of style so up to you, but I don't like the mixing of low level code generation here with higher level logic. I would prefer to see the code generation be extracted if possible to helper methods and or a separate helper class. see my other comment above that I think supersedes this one ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1465309941 From darcy at openjdk.org Wed Jan 24 18:17:35 2024 From: darcy at openjdk.org (Joe Darcy) Date: Wed, 24 Jan 2024 18:17:35 GMT Subject: RFR: 8303374: Implement JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview) [v45] In-Reply-To: References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> Message-ID: <_1NOO9WJQnrGflaFyaId1xfkeiijY6BAvtoIdwLhAiE=.1e6acede-f0bb-47c5-9745-f34cc82f25ed@github.com> On Wed, 24 Jan 2024 15:55:51 GMT, Aggelos Biboudis wrote: >> This is the proposed patch for Primitive types in patterns, instanceof, and switch (Preview). >> >> Draft spec here: https://cr.openjdk.org/~abimpoudis/instanceof/latest/ > > Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision: > > Remove redundant test from checkUnconditionallyExact test/micro/org/openjdk/bench/jdk/preview/patterns/Exactness.java line 1: > 1: /* The exactness predicates should have regression tests on their correct operation in addition to any performance testing. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1465361951 From abimpoudis at openjdk.org Wed Jan 24 18:17:35 2024 From: abimpoudis at openjdk.org (Aggelos Biboudis) Date: Wed, 24 Jan 2024 18:17:35 GMT Subject: RFR: 8303374: Implement JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview) [v45] In-Reply-To: <_1NOO9WJQnrGflaFyaId1xfkeiijY6BAvtoIdwLhAiE=.1e6acede-f0bb-47c5-9745-f34cc82f25ed@github.com> References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> <_1NOO9WJQnrGflaFyaId1xfkeiijY6BAvtoIdwLhAiE=.1e6acede-f0bb-47c5-9745-f34cc82f25ed@github.com> Message-ID: On Wed, 24 Jan 2024 18:12:35 GMT, Joe Darcy wrote: >> Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision: >> >> Remove redundant test from checkUnconditionallyExact > > test/micro/org/openjdk/bench/jdk/preview/patterns/Exactness.java line 1: > >> 1: /* > > The exactness predicates should have regression tests on their correct operation in addition to any performance testing. I have this regarding numeric values [test/langtools/tools/javac/patterns/PrimitiveInstanceOfNumericValueTests.java](https://github.com/openjdk/jdk/pull/15638/files#diff-0c7b37309d920b4c1af93789aed337c9eb259ad31977b9ef395e7b8c4b47a6d6) ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1465363618 From darcy at openjdk.org Wed Jan 24 18:23:38 2024 From: darcy at openjdk.org (Joe Darcy) Date: Wed, 24 Jan 2024 18:23:38 GMT Subject: RFR: 8303374: Implement JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview) [v45] In-Reply-To: References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> <_1NOO9WJQnrGflaFyaId1xfkeiijY6BAvtoIdwLhAiE=.1e6acede-f0bb-47c5-9745-f34cc82f25ed@github.com> Message-ID: <_UoKEsRH6GvJlMfK10Q486qghFcXnD-MgBjEIAONvZI=.d9bde165-4546-48b2-aed8-a601a11fe044@github.com> On Wed, 24 Jan 2024 18:14:11 GMT, Aggelos Biboudis wrote: > I have this regarding numeric values. Is it the kind of test you have in mind? > > [test/langtools/tools/javac/patterns/PrimitiveInstanceOfNumericValueTests.java](https://github.com/openjdk/jdk/pull/15638/files#diff-0c7b37309d920b4c1af93789aed337c9eb259ad31977b9ef395e7b8c4b47a6d6) IMO, the library methods merit some of their own dedicated direct testing (since an end user could in principle call them too) in addition to indirect tests of their operation via javac's code generation. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1465371034 From vromero at openjdk.org Wed Jan 24 18:28:35 2024 From: vromero at openjdk.org (Vicente Romero) Date: Wed, 24 Jan 2024 18:28:35 GMT Subject: RFR: 8303374: Implement JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview) [v45] In-Reply-To: References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> Message-ID: On Wed, 24 Jan 2024 15:55:51 GMT, Aggelos Biboudis wrote: >> This is the proposed patch for Primitive types in patterns, instanceof, and switch (Preview). >> >> Draft spec here: https://cr.openjdk.org/~abimpoudis/instanceof/latest/ > > Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision: > > Remove redundant test from checkUnconditionallyExact test/langtools/tools/javac/patterns/CastConversionMatch.java line 6: > 4: * @summary Match which involves a cast conversion > 5: * @compile/fail/ref=CastConversionMatch.out -XDrawDiagnostics CastConversionMatch.java > 6: * @compile --enable-preview --source ${jdk.version} CastConversionMatch.java */ @enablePreview? ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1465374452 From abimpoudis at openjdk.org Wed Jan 24 18:28:36 2024 From: abimpoudis at openjdk.org (Aggelos Biboudis) Date: Wed, 24 Jan 2024 18:28:36 GMT Subject: RFR: 8303374: Implement JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview) [v45] In-Reply-To: References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> Message-ID: On Wed, 24 Jan 2024 18:24:34 GMT, Vicente Romero wrote: >> Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision: >> >> Remove redundant test from checkUnconditionallyExact > > test/langtools/tools/javac/patterns/CastConversionMatch.java line 6: > >> 4: * @summary Match which involves a cast conversion >> 5: * @compile/fail/ref=CastConversionMatch.out -XDrawDiagnostics CastConversionMatch.java >> 6: * @compile --enable-preview --source ${jdk.version} CastConversionMatch.java */ > > @enablePreview? I have two compile commands. Wanted to test one with and one without preview. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1465376180 From vromero at openjdk.org Wed Jan 24 18:31:43 2024 From: vromero at openjdk.org (Vicente Romero) Date: Wed, 24 Jan 2024 18:31:43 GMT Subject: RFR: 8303374: Implement JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview) [v45] In-Reply-To: References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> Message-ID: On Wed, 24 Jan 2024 15:55:51 GMT, Aggelos Biboudis wrote: >> This is the proposed patch for Primitive types in patterns, instanceof, and switch (Preview). >> >> Draft spec here: https://cr.openjdk.org/~abimpoudis/instanceof/latest/ > > Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision: > > Remove redundant test from checkUnconditionallyExact test/langtools/tools/javac/patterns/PrimitiveInstanceOfPatternOpWithRecordPatterns.java line 28: > 26: * @bug 8304487 > 27: * @summary Compiler Implementation for Primitive types in patterns, instanceof, and switch (Preview) > 28: * @compile -g --enable-preview -source ${jdk.version} PrimitiveInstanceOfPatternOpWithRecordPatterns.java not sure why you need `-g` here test/langtools/tools/javac/patterns/PrimitiveInstanceOfTypeComparisonOp.java line 28: > 26: * @bug 8304487 > 27: * @summary Compiler Implementation for Primitive types in patterns, instanceof, and switch (Preview) > 28: * @compile -g --enable-preview -source ${jdk.version} PrimitiveInstanceOfTypeComparisonOp.java `-g`? ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1465376609 PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1465378575 From abimpoudis at openjdk.org Wed Jan 24 18:41:54 2024 From: abimpoudis at openjdk.org (Aggelos Biboudis) Date: Wed, 24 Jan 2024 18:41:54 GMT Subject: RFR: 8303374: Implement JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview) [v46] In-Reply-To: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> Message-ID: > This is the proposed patch for Primitive types in patterns, instanceof, and switch (Preview). > > Draft spec here: https://cr.openjdk.org/~abimpoudis/instanceof/latest/ Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision: Cleanup test parameters ------------- Changes: - all: https://git.openjdk.org/jdk/pull/15638/files - new: https://git.openjdk.org/jdk/pull/15638/files/0fcdca82..ea31a804 Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk&pr=15638&range=45 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=15638&range=44-45 Stats: 53 lines in 7 files changed: 5 ins; 0 del; 48 mod Patch: https://git.openjdk.org/jdk/pull/15638.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/15638/head:pull/15638 PR: https://git.openjdk.org/jdk/pull/15638 From abimpoudis at openjdk.org Wed Jan 24 19:33:52 2024 From: abimpoudis at openjdk.org (Aggelos Biboudis) Date: Wed, 24 Jan 2024 19:33:52 GMT Subject: RFR: 8303374: Implement JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview) [v47] In-Reply-To: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> Message-ID: > This is the proposed patch for Primitive types in patterns, instanceof, and switch (Preview). > > Draft spec here: https://cr.openjdk.org/~abimpoudis/instanceof/latest/ Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision: Introduce ExactnessConversionsSupportTest ------------- Changes: - all: https://git.openjdk.org/jdk/pull/15638/files - new: https://git.openjdk.org/jdk/pull/15638/files/ea31a804..4e5ac772 Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk&pr=15638&range=46 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=15638&range=45-46 Stats: 243 lines in 2 files changed: 236 ins; 0 del; 7 mod Patch: https://git.openjdk.org/jdk/pull/15638.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/15638/head:pull/15638 PR: https://git.openjdk.org/jdk/pull/15638 From abimpoudis at openjdk.org Wed Jan 24 19:36:33 2024 From: abimpoudis at openjdk.org (Aggelos Biboudis) Date: Wed, 24 Jan 2024 19:36:33 GMT Subject: RFR: 8303374: Implement JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview) [v45] In-Reply-To: <_UoKEsRH6GvJlMfK10Q486qghFcXnD-MgBjEIAONvZI=.d9bde165-4546-48b2-aed8-a601a11fe044@github.com> References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> <_1NOO9WJQnrGflaFyaId1xfkeiijY6BAvtoIdwLhAiE=.1e6acede-f0bb-47c5-9745-f34cc82f25ed@github.com> <_UoKEsRH6GvJlMfK10Q486qghFcXnD-MgBjEIAONvZI=.d9bde165-4546-48b2-aed8-a601a11fe044@github.com> Message-ID: On Wed, 24 Jan 2024 18:21:11 GMT, Joe Darcy wrote: >> I have this regarding numeric values. Is it the kind of test you have in mind? >> >> [test/langtools/tools/javac/patterns/PrimitiveInstanceOfNumericValueTests.java](https://github.com/openjdk/jdk/pull/15638/files#diff-0c7b37309d920b4c1af93789aed337c9eb259ad31977b9ef395e7b8c4b47a6d6) > >> I have this regarding numeric values. Is it the kind of test you have in mind? >> >> [test/langtools/tools/javac/patterns/PrimitiveInstanceOfNumericValueTests.java](https://github.com/openjdk/jdk/pull/15638/files#diff-0c7b37309d920b4c1af93789aed337c9eb259ad31977b9ef395e7b8c4b47a6d6) > > IMO, the library methods merit some of their own dedicated direct testing (since an end user could in principle call them too) in addition to indirect tests of their operation via javac's code generation. I did a translation of that file into [ExactnessConversionsSupportTest.java](https://github.com/openjdk/jdk/pull/15638/commits/4e5ac772417a2e50d47fd6fa8feb363a6bffa88c#diff-c24740028b9956d2dd2947907713f5e2d8681e8762f6d8e26e4faf2ded3979a8). What else could I add? ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1465445954 From vromero at openjdk.org Wed Jan 24 20:31:34 2024 From: vromero at openjdk.org (Vicente Romero) Date: Wed, 24 Jan 2024 20:31:34 GMT Subject: RFR: 8303374: Implement JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview) [v45] In-Reply-To: References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> Message-ID: On Wed, 24 Jan 2024 18:26:08 GMT, Aggelos Biboudis wrote: >> test/langtools/tools/javac/patterns/CastConversionMatch.java line 6: >> >>> 4: * @summary Match which involves a cast conversion >>> 5: * @compile/fail/ref=CastConversionMatch.out -XDrawDiagnostics CastConversionMatch.java >>> 6: * @compile --enable-preview --source ${jdk.version} CastConversionMatch.java */ >> >> @enablePreview? > > I have two compile commands. Wanted to test one with and one without preview. right missed that sorry ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1465499180 From mcimadamore at openjdk.org Wed Jan 24 21:37:34 2024 From: mcimadamore at openjdk.org (Maurizio Cimadamore) Date: Wed, 24 Jan 2024 21:37:34 GMT Subject: RFR: 8303374: Implement JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview) [v42] In-Reply-To: <2d_xzWvSpAAcu_RvESs8LipQDSvPL5A5N12t2VL6FMo=.b16e42ce-632a-4b1f-a7ab-a417ea39f86d@github.com> References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> <2d_xzWvSpAAcu_RvESs8LipQDSvPL5A5N12t2VL6FMo=.b16e42ce-632a-4b1f-a7ab-a417ea39f86d@github.com> Message-ID: On Wed, 24 Jan 2024 14:53:19 GMT, Aggelos Biboudis wrote: >> src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java line 4147: >> >>> 4145: } >>> 4146: if (clazztype.isPrimitive()) { >>> 4147: preview.checkSourceLevel(tree.pattern.pos(), Feature.PRIMITIVE_PATTERNS); >> >> So, if I have a primitive instanceof, I get two preview warnings, one for the expression, and one for the pattern type? Shouldn't one be enough? > > Meaning the `compiler.err.preview.feature.disabled.plural: (compiler.misc.feature.primitive.patterns)` error due to the two `if (clazztype.isPrimitive()) { preview.checkSourceLevel(tree.pattern.pos(), Feature.PRIMITIVE_PATTERNS);` ifs? Isn't it better to keep both, for better error reporting regarding the position? (i.e., which position do we report?) What I mean is that, looking at the code, it seems like: int x; if (x instanceof int y) ... will generate two warnings. Perhaps that's what we want, but it seems a bit on the heavy-side, subjectively. Anyway, no need to take any action. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1465569066 From mcimadamore at openjdk.org Wed Jan 24 21:50:34 2024 From: mcimadamore at openjdk.org (Maurizio Cimadamore) Date: Wed, 24 Jan 2024 21:50:34 GMT Subject: RFR: 8303374: Implement JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview) [v47] In-Reply-To: References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> Message-ID: On Wed, 24 Jan 2024 19:33:52 GMT, Aggelos Biboudis wrote: >> This is the proposed patch for Primitive types in patterns, instanceof, and switch (Preview). >> >> Draft spec here: https://cr.openjdk.org/~abimpoudis/instanceof/latest/ > > Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision: > > Introduce ExactnessConversionsSupportTest src/java.base/share/classes/java/lang/runtime/ExactConversionsSupport.java line 33: > 31: * said to be unconditionally exact. > 32: *

> 33: * For example, a conversion from {@code int} to {@code byte} for the value 10 Very nice text! src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java line 5045: > 5043: } > 5044: > 5045: if (target.isPrimitive()) { nit: maybe now a ternary expression can be used ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1465579085 PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1465580461 From abimpoudis at openjdk.org Wed Jan 24 23:25:00 2024 From: abimpoudis at openjdk.org (Aggelos Biboudis) Date: Wed, 24 Jan 2024 23:25:00 GMT Subject: RFR: 8303374: Implement JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview) [v48] In-Reply-To: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> Message-ID: > This is the proposed patch for Primitive types in patterns, instanceof, and switch (Preview). > > Draft spec here: https://cr.openjdk.org/~abimpoudis/instanceof/latest/ Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision: Simplify checkUnconditionallyExact ------------- Changes: - all: https://git.openjdk.org/jdk/pull/15638/files - new: https://git.openjdk.org/jdk/pull/15638/files/4e5ac772..4ed60e9d Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk&pr=15638&range=47 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=15638&range=46-47 Stats: 5 lines in 1 file changed: 0 ins; 2 del; 3 mod Patch: https://git.openjdk.org/jdk/pull/15638.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/15638/head:pull/15638 PR: https://git.openjdk.org/jdk/pull/15638 From abimpoudis at openjdk.org Wed Jan 24 23:25:03 2024 From: abimpoudis at openjdk.org (Aggelos Biboudis) Date: Wed, 24 Jan 2024 23:25:03 GMT Subject: RFR: 8303374: Implement JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview) [v47] In-Reply-To: References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> Message-ID: On Wed, 24 Jan 2024 21:47:19 GMT, Maurizio Cimadamore wrote: >> Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision: >> >> Introduce ExactnessConversionsSupportTest > > src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java line 5045: > >> 5043: } >> 5044: >> 5045: if (target.isPrimitive()) { > > nit: maybe now a ternary expression can be used Done! ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1465656376 From abimpoudis at openjdk.org Wed Jan 24 23:42:48 2024 From: abimpoudis at openjdk.org (Aggelos Biboudis) Date: Wed, 24 Jan 2024 23:42:48 GMT Subject: RFR: 8303374: Implement JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview) [v49] In-Reply-To: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> Message-ID: > This is the proposed patch for Primitive types in patterns, instanceof, and switch (Preview). > > Draft spec here: https://cr.openjdk.org/~abimpoudis/instanceof/latest/ Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision: Cleanup redundant clone ------------- Changes: - all: https://git.openjdk.org/jdk/pull/15638/files - new: https://git.openjdk.org/jdk/pull/15638/files/4ed60e9d..80cfc06c Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk&pr=15638&range=48 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=15638&range=47-48 Stats: 1 line in 1 file changed: 0 ins; 1 del; 0 mod Patch: https://git.openjdk.org/jdk/pull/15638.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/15638/head:pull/15638 PR: https://git.openjdk.org/jdk/pull/15638 From abimpoudis at openjdk.org Wed Jan 24 23:42:51 2024 From: abimpoudis at openjdk.org (Aggelos Biboudis) Date: Wed, 24 Jan 2024 23:42:51 GMT Subject: RFR: 8303374: Implement JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview) [v45] In-Reply-To: References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> Message-ID: On Wed, 24 Jan 2024 17:15:06 GMT, Vicente Romero wrote: >> Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision: >> >> Remove redundant test from checkUnconditionallyExact > > src/java.base/share/classes/java/lang/runtime/SwitchBootstraps.java line 168: > >> 166: requireNonNull(labels); >> 167: >> 168: labels = labels.clone(); > > just curious, why do we need to clone this array? No need. Remainings of a previous approach. Thanks for spotting ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1465672119 From abimpoudis at openjdk.org Wed Jan 24 23:50:51 2024 From: abimpoudis at openjdk.org (Aggelos Biboudis) Date: Wed, 24 Jan 2024 23:50:51 GMT Subject: RFR: 8303374: Implement JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview) [v50] In-Reply-To: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> Message-ID: > This is the proposed patch for Primitive types in patterns, instanceof, and switch (Preview). > > Draft spec here: https://cr.openjdk.org/~abimpoudis/instanceof/latest/ Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision: Update year ------------- Changes: - all: https://git.openjdk.org/jdk/pull/15638/files - new: https://git.openjdk.org/jdk/pull/15638/files/80cfc06c..2af70ba2 Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk&pr=15638&range=49 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=15638&range=48-49 Stats: 3 lines in 3 files changed: 0 ins; 0 del; 3 mod Patch: https://git.openjdk.org/jdk/pull/15638.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/15638/head:pull/15638 PR: https://git.openjdk.org/jdk/pull/15638 From mcimadamore at openjdk.org Thu Jan 25 10:00:47 2024 From: mcimadamore at openjdk.org (Maurizio Cimadamore) Date: Thu, 25 Jan 2024 10:00:47 GMT Subject: RFR: 8303374: Implement JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview) [v50] In-Reply-To: References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> Message-ID: On Wed, 24 Jan 2024 23:50:51 GMT, Aggelos Biboudis wrote: >> This is the proposed patch for Primitive types in patterns, instanceof, and switch (Preview). >> >> Draft spec here: https://cr.openjdk.org/~abimpoudis/instanceof/latest/ > > Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision: > > Update year src/java.base/share/classes/java/lang/runtime/SwitchBootstraps.java line 148: > 146: * @throws NullPointerException if any argument is {@code null} > 147: * @throws IllegalArgumentException if any element in the labels array is null, if the > 148: * invocation type is not a method type of first parameter of a reference type, One thing we did often in the FFM API was to break up long `@throws` and split them into two or three `@throws` (javadoc allows the same exception to appear multiple times). Not saying you have to change this, just a possible suggestion (as I didn't know this!) ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1466119276 From mcimadamore at openjdk.org Thu Jan 25 10:15:45 2024 From: mcimadamore at openjdk.org (Maurizio Cimadamore) Date: Thu, 25 Jan 2024 10:15:45 GMT Subject: RFR: 8303374: Implement JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview) [v44] In-Reply-To: <98Xa1dqszc0IzREHFRDihwUi8_Y-NZ0i47NP-4pcfGc=.fbff61cf-f0ec-49e2-910f-19baa8c68565@github.com> References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> <98Xa1dqszc0IzREHFRDihwUi8_Y-NZ0i47NP-4pcfGc=.fbff61cf-f0ec-49e2-910f-19baa8c68565@github.com> Message-ID: On Wed, 24 Jan 2024 15:37:58 GMT, Vicente Romero wrote: >> Aggelos Biboudis has updated the pull request incrementally with two additional commits since the last revision: >> >> - Enhance Javadoc of ExactConversionsSupport (2) >> - Enhance Javadoc of ExactConversionsSupport > > src/java.base/share/classes/java/lang/runtime/SwitchBootstraps.java line 471: > >> 469: // o instanceof float >> 470: Label notNumber = cb.newLabel(); >> 471: cb.aload(0); > > we are wiring constants into code generation: `0`, `3` etc, probably those won't change but I would prefer using static final fields or enums, that can be documented and changed easily in the future if needed Note also that the classfile API supports an higher-level construct to access method parameters, which supports _logical_ indexes (see CodeBuilder::parameterSlot). This would make the indices more robust against changes in types (e.g. int vs. long, where the latter would require two local variable slots) ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1466139675 From mcimadamore at openjdk.org Thu Jan 25 10:18:39 2024 From: mcimadamore at openjdk.org (Maurizio Cimadamore) Date: Thu, 25 Jan 2024 10:18:39 GMT Subject: RFR: 8303374: Implement JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview) [v50] In-Reply-To: References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> Message-ID: <6ca0VuWfm7LeOOW5RZ818DP2zSafC87fdBt3LS2ZxPo=.7d7d6285-63a0-4982-95c3-891a9ff86dd2@github.com> On Wed, 24 Jan 2024 23:50:51 GMT, Aggelos Biboudis wrote: >> This is the proposed patch for Primitive types in patterns, instanceof, and switch (Preview). >> >> Draft spec here: https://cr.openjdk.org/~abimpoudis/instanceof/latest/ > > Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision: > > Update year src/java.base/share/classes/java/lang/runtime/SwitchBootstraps.java line 592: > 590: element.caseLabel() instanceof Double || > 591: element.caseLabel() instanceof Boolean)) { > 592: //TODO: should call equals on the constant, not on the selector, check Looking at the code, it seems like we're already calling equals on the constant? (I assume that's to avoid spurious NPEs?) ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1466143827 From mcimadamore at openjdk.org Thu Jan 25 10:25:38 2024 From: mcimadamore at openjdk.org (Maurizio Cimadamore) Date: Thu, 25 Jan 2024 10:25:38 GMT Subject: RFR: 8303374: Implement JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview) [v50] In-Reply-To: References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> Message-ID: On Wed, 24 Jan 2024 23:50:51 GMT, Aggelos Biboudis wrote: >> This is the proposed patch for Primitive types in patterns, instanceof, and switch (Preview). >> >> Draft spec here: https://cr.openjdk.org/~abimpoudis/instanceof/latest/ > > Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision: > > Update year src/java.base/share/classes/java/lang/runtime/SwitchBootstraps.java line 404: > 402: */ > 403: @SuppressWarnings("removal") > 404: private static MethodHandle generateInnerClass(MethodHandles.Lookup caller, Class selectorType, Object[] labels) { I think the name "labels" for the array here is unfortunate, because the code generation also contains "labels" which mean really "jump targets". Maybe `constants` or `labelConstants` or `caseConstants` ? src/java.base/share/classes/java/lang/runtime/SwitchBootstraps.java line 517: > 515: } > 516: } else { > 517: Optional classLabelConstableOpt = classLabel.describeConstable(); One comment (for future work): we have a bunch of constants that are known by the time we generate this code (at runtime). But we're still serializing them into the constant pool, and then deserialize them at runtime, which is needless work. Hidden classes support injection of already resolved constants into the constant pool - see: https://download.java.net/java/early_access/jdk22/docs/api/java.base/java/lang/invoke/MethodHandles.Lookup.html#defineHiddenClassWithClassData(byte%5B%5D,java.lang.Object,boolean,java.lang.invoke.MethodHandles.Lookup.ClassOption...) Basically, the idea is that you can pass the entire `labels` array as a "constant data" which is stored in the constant pool as a pre-resolved constant. You can then load elements from this array using ready-made method handles: https://download.java.net/java/early_access/jdk22/docs/api/java.base/java/lang/invoke/MethodHandles.html#classDataAt(java.lang.invoke.MethodHandles.Lookup,java.lang.String,java.lang.Class,int) ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1466151276 PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1466149901 From mcimadamore at openjdk.org Thu Jan 25 10:25:40 2024 From: mcimadamore at openjdk.org (Maurizio Cimadamore) Date: Thu, 25 Jan 2024 10:25:40 GMT Subject: RFR: 8303374: Implement JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview) [v44] In-Reply-To: References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> <0g1L6FBda3O8Wz02hDrLEIXzUDdRh4or6H3N-szm5Lg=.e5ec4739-577e-4833-b71d-848c26978d4d@github.com> Message-ID: On Wed, 24 Jan 2024 17:30:34 GMT, Vicente Romero wrote: >> src/java.base/share/classes/java/lang/runtime/SwitchBootstraps.java line 461: >> >>> 459: // Object o = ... >>> 460: // o instanceof Wrapped(float) >>> 461: cb.aload(0); >> >> probably just a matter of style so up to you, but I don't like the mixing of low level code generation here with higher level logic. I would prefer to see the code generation be extracted if possible to helper methods and or a separate helper class. > > see my other comment above that I think supersedes this one I see what you mean, that said, I think having some high-level checks driving low-level classfile generation is pretty standard for code generators (e.g. lambda metafactory, invoke bytecode generator, binding specializer). I agree on the fact that the lambda should probably moved onto a separate method. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1466153248 From jlahoda at openjdk.org Thu Jan 25 10:54:33 2024 From: jlahoda at openjdk.org (Jan Lahoda) Date: Thu, 25 Jan 2024 10:54:33 GMT Subject: RFR: 8303374: Implement JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview) [v44] In-Reply-To: References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> <98Xa1dqszc0IzREHFRDihwUi8_Y-NZ0i47NP-4pcfGc=.fbff61cf-f0ec-49e2-910f-19baa8c68565@github.com> Message-ID: On Thu, 25 Jan 2024 10:12:31 GMT, Maurizio Cimadamore wrote: >> src/java.base/share/classes/java/lang/runtime/SwitchBootstraps.java line 471: >> >>> 469: // o instanceof float >>> 470: Label notNumber = cb.newLabel(); >>> 471: cb.aload(0); >> >> we are wiring constants into code generation: `0`, `3` etc, probably those won't change but I would prefer using static final fields or enums, that can be documented and changed easily in the future if needed > > Note also that the classfile API supports an higher-level construct to access method parameters, which supports _logical_ indexes (see CodeBuilder::parameterSlot). This would make the indices more robust against changes in types (e.g. int vs. long, where the latter would require two local variable slots) This code is intentionally using low-level primitives, as Classfile API is using pattern matching, and using some higher-level primitives is not possible due to the bootstrap issues. `parameterSlot` would probably work, but it does not seem too significant - we know the parameter types that are send to the method, and it is a static method. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1466187756 From jlahoda at openjdk.org Thu Jan 25 10:54:36 2024 From: jlahoda at openjdk.org (Jan Lahoda) Date: Thu, 25 Jan 2024 10:54:36 GMT Subject: RFR: 8303374: Implement JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview) [v50] In-Reply-To: <6ca0VuWfm7LeOOW5RZ818DP2zSafC87fdBt3LS2ZxPo=.7d7d6285-63a0-4982-95c3-891a9ff86dd2@github.com> References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> <6ca0VuWfm7LeOOW5RZ818DP2zSafC87fdBt3LS2ZxPo=.7d7d6285-63a0-4982-95c3-891a9ff86dd2@github.com> Message-ID: On Thu, 25 Jan 2024 10:15:48 GMT, Maurizio Cimadamore wrote: >> Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision: >> >> Update year > > src/java.base/share/classes/java/lang/runtime/SwitchBootstraps.java line 592: > >> 590: element.caseLabel() instanceof Double || >> 591: element.caseLabel() instanceof Boolean)) { >> 592: //TODO: should call equals on the constant, not on the selector, check > > Looking at the code, it seems like we're already calling equals on the constant? (I assume that's to avoid spurious NPEs?) The note there was to double-check that for selector `s` and constant `l`, we do something like `Long.valueOf(l).equals(s)`, not `s.equals(Long.valueOf(l))`, as the latter does not have the proper semantics. I believe Angelos is adding a test checking this is (and remains) the case. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1466189962 From abimpoudis at openjdk.org Thu Jan 25 11:21:12 2024 From: abimpoudis at openjdk.org (Aggelos Biboudis) Date: Thu, 25 Jan 2024 11:21:12 GMT Subject: RFR: 8303374: Implement JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview) [v51] In-Reply-To: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> Message-ID: > This is the proposed patch for Primitive types in patterns, instanceof, and switch (Preview). > > Draft spec here: https://cr.openjdk.org/~abimpoudis/instanceof/latest/ Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision: Improve readability in SwitchBootstraps ------------- Changes: - all: https://git.openjdk.org/jdk/pull/15638/files - new: https://git.openjdk.org/jdk/pull/15638/files/2af70ba2..13bfc436 Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk&pr=15638&range=50 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=15638&range=49-50 Stats: 347 lines in 2 files changed: 138 ins; 115 del; 94 mod Patch: https://git.openjdk.org/jdk/pull/15638.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/15638/head:pull/15638 PR: https://git.openjdk.org/jdk/pull/15638 From abimpoudis at openjdk.org Thu Jan 25 11:21:12 2024 From: abimpoudis at openjdk.org (Aggelos Biboudis) Date: Thu, 25 Jan 2024 11:21:12 GMT Subject: RFR: 8303374: Implement JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview) [v50] In-Reply-To: References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> Message-ID: On Thu, 25 Jan 2024 10:21:26 GMT, Maurizio Cimadamore wrote: >> Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision: >> >> Update year > > src/java.base/share/classes/java/lang/runtime/SwitchBootstraps.java line 404: > >> 402: */ >> 403: @SuppressWarnings("removal") >> 404: private static MethodHandle generateInnerClass(MethodHandles.Lookup caller, Class selectorType, Object[] labels) { > > I think the name "labels" for the array here is unfortunate, because the code generation also contains "labels" which mean really "jump targets". Maybe `constants` or `labelConstants` or `caseConstants` ? Done ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1466217507 From abimpoudis at openjdk.org Thu Jan 25 11:21:13 2024 From: abimpoudis at openjdk.org (Aggelos Biboudis) Date: Thu, 25 Jan 2024 11:21:13 GMT Subject: RFR: 8303374: Implement JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview) [v45] In-Reply-To: References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> Message-ID: On Wed, 24 Jan 2024 17:29:09 GMT, Vicente Romero wrote: >> Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision: >> >> Remove redundant test from checkUnconditionallyExact > > src/java.base/share/classes/java/lang/runtime/SwitchBootstraps.java line 405: > >> 403: */ >> 404: @SuppressWarnings("removal") >> 405: private static MethodHandle generateInnerClass(MethodHandles.Lookup caller, Class selectorType, Object[] labels) { > > again a matter of style but it seems to me that the huge lambda inside of this method, starting in line 409, really wants to be a separate helper method. That will probably be a better refactoring as we won't be mixing byte code generation with method handles manipulation. Done ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1466217863 From abimpoudis at openjdk.org Thu Jan 25 11:21:13 2024 From: abimpoudis at openjdk.org (Aggelos Biboudis) Date: Thu, 25 Jan 2024 11:21:13 GMT Subject: RFR: 8303374: Implement JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview) [v44] In-Reply-To: References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> <0g1L6FBda3O8Wz02hDrLEIXzUDdRh4or6H3N-szm5Lg=.e5ec4739-577e-4833-b71d-848c26978d4d@github.com> Message-ID: On Thu, 25 Jan 2024 10:22:52 GMT, Maurizio Cimadamore wrote: >> see my other comment above that I think supersedes this one > > I see what you mean, that said, I think having some high-level checks driving low-level classfile generation is pretty standard for code generators (e.g. lambda metafactory, invoke bytecode generator, binding specializer). I agree on the fact that the lambda should probably moved onto a separate method. Done in https://github.com/openjdk/jdk/pull/15638/commits/13bfc43654f23f842ac71c1971de32da209d64d3 ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1466219133 From abimpoudis at openjdk.org Thu Jan 25 13:53:04 2024 From: abimpoudis at openjdk.org (Aggelos Biboudis) Date: Thu, 25 Jan 2024 13:53:04 GMT Subject: RFR: 8303374: Implement JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview) [v52] In-Reply-To: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> Message-ID: > This is the proposed patch for Primitive types in patterns, instanceof, and switch (Preview). > > Draft spec here: https://cr.openjdk.org/~abimpoudis/instanceof/latest/ Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision: Tidy up Javadoc of IllegalArgumentException in typeSwitch ------------- Changes: - all: https://git.openjdk.org/jdk/pull/15638/files - new: https://git.openjdk.org/jdk/pull/15638/files/13bfc436..b77d2316 Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk&pr=15638&range=51 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=15638&range=50-51 Stats: 9 lines in 1 file changed: 1 ins; 0 del; 8 mod Patch: https://git.openjdk.org/jdk/pull/15638.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/15638/head:pull/15638 PR: https://git.openjdk.org/jdk/pull/15638 From abimpoudis at openjdk.org Thu Jan 25 13:53:06 2024 From: abimpoudis at openjdk.org (Aggelos Biboudis) Date: Thu, 25 Jan 2024 13:53:06 GMT Subject: RFR: 8303374: Implement JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview) [v50] In-Reply-To: References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> Message-ID: On Thu, 25 Jan 2024 09:57:13 GMT, Maurizio Cimadamore wrote: >> Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision: >> >> Update year > > src/java.base/share/classes/java/lang/runtime/SwitchBootstraps.java line 148: > >> 146: * @throws NullPointerException if any argument is {@code null} >> 147: * @throws IllegalArgumentException if any element in the labels array is null, if the >> 148: * invocation type is not a method type of first parameter of a reference type, > > One thing we did often in the FFM API was to break up long `@throws` and split them into two or three `@throws` (javadoc allows the same exception to appear multiple times). Not saying you have to change this, just a possible suggestion (as I didn't know this!) Indeed it looks better: Screenshot 2024-01-25 at 14 49 07 ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1466406565 From abimpoudis at openjdk.org Thu Jan 25 17:33:14 2024 From: abimpoudis at openjdk.org (Aggelos Biboudis) Date: Thu, 25 Jan 2024 17:33:14 GMT Subject: RFR: 8303374: Implement JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview) [v53] In-Reply-To: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> Message-ID: > This is the proposed patch for Primitive types in patterns, instanceof, and switch (Preview). > > Draft spec here: https://cr.openjdk.org/~abimpoudis/instanceof/latest/ Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision: Tidy up Javadoc of Lower.visitTypeTest ------------- Changes: - all: https://git.openjdk.org/jdk/pull/15638/files - new: https://git.openjdk.org/jdk/pull/15638/files/b77d2316..44634684 Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk&pr=15638&range=52 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=15638&range=51-52 Stats: 28 lines in 1 file changed: 9 ins; 5 del; 14 mod Patch: https://git.openjdk.org/jdk/pull/15638.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/15638/head:pull/15638 PR: https://git.openjdk.org/jdk/pull/15638 From abimpoudis at openjdk.org Thu Jan 25 17:46:07 2024 From: abimpoudis at openjdk.org (Aggelos Biboudis) Date: Thu, 25 Jan 2024 17:46:07 GMT Subject: RFR: 8303374: Implement JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview) [v54] In-Reply-To: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> Message-ID: <0P6DMz53NNbzFireeMjPkayWCA93kTUGv0yAH9j-yP0=.27ec38d2-aa91-4aba-9d88-d94978d42abb@github.com> > This is the proposed patch for Primitive types in patterns, instanceof, and switch (Preview). > > Draft spec here: https://cr.openjdk.org/~abimpoudis/instanceof/latest/ Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision: Small fix in Javadoc ------------- Changes: - all: https://git.openjdk.org/jdk/pull/15638/files - new: https://git.openjdk.org/jdk/pull/15638/files/44634684..854c20a1 Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk&pr=15638&range=53 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=15638&range=52-53 Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod Patch: https://git.openjdk.org/jdk/pull/15638.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/15638/head:pull/15638 PR: https://git.openjdk.org/jdk/pull/15638 From abimpoudis at openjdk.org Fri Jan 26 18:02:58 2024 From: abimpoudis at openjdk.org (Aggelos Biboudis) Date: Fri, 26 Jan 2024 18:02:58 GMT Subject: RFR: 8303374: Implement JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview) [v55] In-Reply-To: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> Message-ID: > This is the proposed patch for Primitive types in patterns, instanceof, and switch (Preview). > > Draft spec here: https://cr.openjdk.org/~abimpoudis/instanceof/latest/ Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision: Remove redundant null check and introduce a const boolean for unconditionally exact pairs ------------- Changes: - all: https://git.openjdk.org/jdk/pull/15638/files - new: https://git.openjdk.org/jdk/pull/15638/files/854c20a1..e466cfba Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk&pr=15638&range=54 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=15638&range=53-54 Stats: 12 lines in 1 file changed: 0 ins; 9 del; 3 mod Patch: https://git.openjdk.org/jdk/pull/15638.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/15638/head:pull/15638 PR: https://git.openjdk.org/jdk/pull/15638 From jlahoda at openjdk.org Mon Jan 29 16:18:53 2024 From: jlahoda at openjdk.org (Jan Lahoda) Date: Mon, 29 Jan 2024 16:18:53 GMT Subject: RFR: 8303374: Implement JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview) [v55] In-Reply-To: References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> Message-ID: <8lRWOKmFWcWkgP5XCyXZGacvbtPRdco7AyVyJ4aVhNs=.afbba2a2-6757-4129-965e-f6c4609e8304@github.com> On Fri, 26 Jan 2024 18:02:58 GMT, Aggelos Biboudis wrote: >> This is the proposed patch for Primitive types in patterns, instanceof, and switch (Preview). >> >> Draft spec here: https://cr.openjdk.org/~abimpoudis/instanceof/latest/ > > Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision: > > Remove redundant null check and introduce a const boolean for unconditionally exact pairs javac changes look sensible to me - some minor comments inline. src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java line 5040: > 5038: * @param target Target primitive or reference type > 5039: */ > 5040: public boolean checkUnconditionallyExact(Type source, Type target) { Maybe something like `isUnconditionallyExact`? src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java line 5060: > 5058: * @param targetType Target type > 5059: */ > 5060: public boolean checkUnconditionallyExactPrimitives(Type selectorType, Type targetType) { Maybe something like `isUnconditionallyExactPrimitives`? src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java line 1799: > 1797: log.error(label.pos(), Errors.UnconditionalPatternAndDefault); > 1798: } else if (booleanSwitch && constants.containsAll(Set.of(0, 1))) { > 1799: log.error(label.pos(), Errors.UnconditionalPatternAndDefault); // TODO improve error Maybe file a follow-up to improve the error? src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java line 3079: > 3077: > 3078: // Resolve the exactness method > 3079: Symbol ecsym = rs.resolveQualifiedMethod(null, Minor: better use `rs.resolveInternalMethod` or `this.lookupMethod`, so that the compilation fails more obviously if the method cannot be found. test/langtools/tools/javac/diags/examples/NotApplicableTypes.java line 21: > 19: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA > 20: * or visit www.oracle.com if you need additional information or have any > 21: * questions. The key does not exist any, per my understanding. I would suggest to simply delete the file. test/langtools/tools/javac/diags/examples/SelectorTypeNotAllowed.java line 24: > 22: */ > 23: > 24: // key: compiler.err.preview.feature.disabled.plural The key does not exist any, per my understanding. I would suggest to simply delete the file. ------------- Marked as reviewed by jlahoda (Reviewer). PR Review: https://git.openjdk.org/jdk/pull/15638#pullrequestreview-1848712425 PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1469805646 PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1469806136 PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1469614384 PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1469811642 PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1469838360 PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1469838529 From vromero at openjdk.org Mon Jan 29 20:27:46 2024 From: vromero at openjdk.org (Vicente Romero) Date: Mon, 29 Jan 2024 20:27:46 GMT Subject: RFR: 8303374: Implement JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview) [v55] In-Reply-To: References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> Message-ID: <7kcOKMS7ryi8yOLlyzjgRW7cK0aJzFIQHpqoRsV_sB4=.1caaf2cc-860a-44c3-9180-79b7df7ab7f2@github.com> On Fri, 26 Jan 2024 18:02:58 GMT, Aggelos Biboudis wrote: >> This is the proposed patch for Primitive types in patterns, instanceof, and switch (Preview). >> >> Draft spec here: https://cr.openjdk.org/~abimpoudis/instanceof/latest/ > > Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision: > > Remove redundant null check and introduce a const boolean for unconditionally exact pairs lgtm ------------- Marked as reviewed by vromero (Reviewer). PR Review: https://git.openjdk.org/jdk/pull/15638#pullrequestreview-1849695360 From abimpoudis at openjdk.org Mon Jan 29 23:53:08 2024 From: abimpoudis at openjdk.org (Aggelos Biboudis) Date: Mon, 29 Jan 2024 23:53:08 GMT Subject: RFR: 8303374: Implement JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview) [v56] In-Reply-To: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> Message-ID: > This is the proposed patch for Primitive types in patterns, instanceof, and switch (Preview). > > Draft spec here: https://cr.openjdk.org/~abimpoudis/instanceof/latest/ Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision: Address review by Jan ------------- Changes: - all: https://git.openjdk.org/jdk/pull/15638/files - new: https://git.openjdk.org/jdk/pull/15638/files/e466cfba..8c27c5c0 Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk&pr=15638&range=55 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=15638&range=54-55 Stats: 165 lines in 12 files changed: 78 ins; 68 del; 19 mod Patch: https://git.openjdk.org/jdk/pull/15638.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/15638/head:pull/15638 PR: https://git.openjdk.org/jdk/pull/15638 From abimpoudis at openjdk.org Tue Jan 30 08:33:49 2024 From: abimpoudis at openjdk.org (Aggelos Biboudis) Date: Tue, 30 Jan 2024 08:33:49 GMT Subject: RFR: 8303374: Implement JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview) [v55] In-Reply-To: <8lRWOKmFWcWkgP5XCyXZGacvbtPRdco7AyVyJ4aVhNs=.afbba2a2-6757-4129-965e-f6c4609e8304@github.com> References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> <8lRWOKmFWcWkgP5XCyXZGacvbtPRdco7AyVyJ4aVhNs=.afbba2a2-6757-4129-965e-f6c4609e8304@github.com> Message-ID: On Mon, 29 Jan 2024 16:16:00 GMT, Jan Lahoda wrote: >> Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision: >> >> Remove redundant null check and introduce a const boolean for unconditionally exact pairs > > javac changes look sensible to me - some minor comments inline. Thx for all the comments @lahodaj @mcimadamore @vicente-romero-oracle @rgiulietti @jddarcy ? Addressed all @lahodaj ------------- PR Comment: https://git.openjdk.org/jdk/pull/15638#issuecomment-1916314623 From jlahoda at openjdk.org Tue Jan 30 10:07:28 2024 From: jlahoda at openjdk.org (Jan Lahoda) Date: Tue, 30 Jan 2024 10:07:28 GMT Subject: RFR: 8303374: Implement JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview) [v56] In-Reply-To: References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> Message-ID: On Mon, 29 Jan 2024 23:53:08 GMT, Aggelos Biboudis wrote: >> This is the proposed patch for Primitive types in patterns, instanceof, and switch (Preview). >> >> Draft spec here: https://cr.openjdk.org/~abimpoudis/instanceof/latest/ > > Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision: > > Address review by Jan lgtm ------------- Marked as reviewed by jlahoda (Reviewer). PR Review: https://git.openjdk.org/jdk/pull/15638#pullrequestreview-1850754613 From darcy at openjdk.org Tue Jan 30 21:15:36 2024 From: darcy at openjdk.org (Joe Darcy) Date: Tue, 30 Jan 2024 21:15:36 GMT Subject: RFR: 8303374: Implement JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview) [v56] In-Reply-To: References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> Message-ID: On Mon, 29 Jan 2024 23:53:08 GMT, Aggelos Biboudis wrote: >> This is the proposed patch for Primitive types in patterns, instanceof, and switch (Preview). >> >> Draft spec here: https://cr.openjdk.org/~abimpoudis/instanceof/latest/ > > Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision: > > Address review by Jan test/jdk/java/lang/runtime/ExactnessConversionsSupportTest.java line 46: > 44: * @test > 45: * @bug 8304487 > 46: * @summary Compiler Implementation for Primitive types in patterns, instanceof, and switch (Preview) While the bug synopsis isn't off-topic for the summary, the summary could be more informative, something like: "Verify boundary and special cases of exact conversion predicates", etc. test/jdk/java/lang/runtime/ExactnessConversionsSupportTest.java line 65: > 63: } > 64: > 65: public static void testByte() { If this test had the likelihood of needing to be updated, I would recommend some kind of refactoring so that the implicit loops ("for each of these boundary values in type T..") were explicit, but given that the test should not need to be updated often, I think the current approach is fine. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1471963476 PR Review Comment: https://git.openjdk.org/jdk/pull/15638#discussion_r1471968497 From abimpoudis at openjdk.org Wed Jan 31 10:03:23 2024 From: abimpoudis at openjdk.org (Aggelos Biboudis) Date: Wed, 31 Jan 2024 10:03:23 GMT Subject: RFR: 8303374: Implement JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview) [v57] In-Reply-To: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> Message-ID: > This is the proposed patch for Primitive types in patterns, instanceof, and switch (Preview). > > Draft spec here: https://cr.openjdk.org/~abimpoudis/instanceof/latest/ Aggelos Biboudis has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 78 commits: - Merge branch 'master' into primitive-patterns - Update summary in ExactnessConversionsSupportTest - Address review by Jan - Remove redundant null check and introduce a const boolean for unconditionally exact pairs - Small fix in Javadoc - Tidy up Javadoc of Lower.visitTypeTest - Tidy up Javadoc of IllegalArgumentException in typeSwitch - Improve readability in SwitchBootstraps - Update year - Cleanup redundant clone - ... and 68 more: https://git.openjdk.org/jdk/compare/ec56c72b...f68748b1 ------------- Changes: https://git.openjdk.org/jdk/pull/15638/files Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=15638&range=56 Stats: 3818 lines in 45 files changed: 3385 ins; 212 del; 221 mod Patch: https://git.openjdk.org/jdk/pull/15638.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/15638/head:pull/15638 PR: https://git.openjdk.org/jdk/pull/15638 From abimpoudis at openjdk.org Wed Jan 31 14:21:14 2024 From: abimpoudis at openjdk.org (Aggelos Biboudis) Date: Wed, 31 Jan 2024 14:21:14 GMT Subject: Integrated: 8303374: Implement JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview) In-Reply-To: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> References: <4GCkSMggtYI8KnM-kELHez3Nd42WIrfd6jOF1bbK5PA=.12aec6f3-669b-4675-ad34-ffe28cb23459@github.com> Message-ID: <7MBpFjawIZA1YtjJ8_wP_6UeqG7n7wXF6N1yehtb150=.c8531d10-e969-4cac-bd95-d4e8748bfc49@github.com> On Fri, 8 Sep 2023 14:17:29 GMT, Aggelos Biboudis wrote: > This is the proposed patch for Primitive types in patterns, instanceof, and switch (Preview). > > Draft spec here: https://cr.openjdk.org/~abimpoudis/instanceof/latest/ This pull request has now been integrated. Changeset: 1733d2ea Author: Aggelos Biboudis URL: https://git.openjdk.org/jdk/commit/1733d2ea244756238c302d802511eb1557cd46ac Stats: 3818 lines in 45 files changed: 3385 ins; 212 del; 221 mod 8303374: Implement JEP 455: Primitive Types in Patterns, instanceof, and switch (Preview) Co-authored-by: Jan Lahoda Co-authored-by: Maurizio Cimadamore Co-authored-by: Gavin Bierman Co-authored-by: Brian Goetz Co-authored-by: Raffaello Giulietti Co-authored-by: Aggelos Biboudis Reviewed-by: vromero, jlahoda ------------- PR: https://git.openjdk.org/jdk/pull/15638