From jlaskey at openjdk.org Mon May 1 12:10:55 2023
From: jlaskey at openjdk.org (Jim Laskey)
Date: Mon, 1 May 2023 12:10:55 GMT
Subject: RFR: JDK-8306112 Implementation of JEP 445: Flexible Main Methods
and Anonymous Main Classes (Preview) [v2]
In-Reply-To: <5Gfuey8swtt5kH7aGU7aQNwU80KcoCFJ2hZxxGO2tnk=.75eb7117-299b-449a-b3a2-6ef27de44ac0@github.com>
References:
<5Gfuey8swtt5kH7aGU7aQNwU80KcoCFJ2hZxxGO2tnk=.75eb7117-299b-449a-b3a2-6ef27de44ac0@github.com>
Message-ID:
On Thu, 27 Apr 2023 18:00:38 GMT, Jim Laskey wrote:
>> src/java.base/share/native/libjli/java.c line 590:
>>
>>> 588: CHECK_EXCEPTION_NULL_LEAVE(mainID);
>>> 589: (*env)->CallVoidMethod(env, mainObject, mainID);
>>> 590: break;
>>
>> This calls into LauncherHelper to get the "main type", then calls the static or new/instance method. I'm wondering if you tried have a single entry point in LauncherHelper instead. I think the only downside might be that the trampoline would show up in stack traces but @Hidden could hide that.
>
> Good idea. If @hidden doesn't work then we can eat the trace entries.
Many dependencies (ex. JDI) on main being the first frame. Will set up a separate RFE witch should include using the LauncherHelper in the source code launcher.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13689#discussion_r1181532559
From jlaskey at openjdk.org Mon May 1 13:06:24 2023
From: jlaskey at openjdk.org (Jim Laskey)
Date: Mon, 1 May 2023 13:06:24 GMT
Subject: RFR: JDK-8306112 Implementation of JEP 445: Flexible Main Methods
and Anonymous Main Classes (Preview) [v8]
In-Reply-To:
References:
Message-ID:
> Add flexible main methods and anonymous main classes to the Java language.
Jim Laskey has updated the pull request incrementally with two additional commits since the last revision:
- Anonymous main classes renamed to unnamed classes
- Add test
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/13689/files
- new: https://git.openjdk.org/jdk/pull/13689/files/a09a0a1b..ff7cd4c7
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=13689&range=07
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=13689&range=06-07
Stats: 314 lines in 14 files changed: 151 ins; 135 del; 28 mod
Patch: https://git.openjdk.org/jdk/pull/13689.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/13689/head:pull/13689
PR: https://git.openjdk.org/jdk/pull/13689
From vromero at openjdk.org Mon May 1 13:39:29 2023
From: vromero at openjdk.org (Vicente Romero)
Date: Mon, 1 May 2023 13:39:29 GMT
Subject: RFR: 8305672: Surprising definite assignment error after
JDK-8043179 [v3]
In-Reply-To:
References:
Message-ID: <_at5mqPt_PU0kSLRmgTjpKu9Ghn9qPFEn6Rhe_yuYrM=.528b271f-f14a-467a-a8f2-e8f9744fb9b6@github.com>
On Fri, 28 Apr 2023 17:12:44 GMT, Vicente Romero wrote:
>> Archie Cobbs has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains three additional commits since the last revision:
>>
>> - Merge branch 'master' into JDK-8305672
>> - Merge branch 'master' into JDK-8305672
>> - Fix failure of visitLambda() to save & restore uninitsTry bits.
>
> the fix looks good to me, running regression tests now to make sure nothing breaks, will approve if all green
> Thanks for the review @vicente-romero-oracle !
>
> /integrate
sure thanks @kevinrushforth and @neil too
-------------
PR Comment: https://git.openjdk.org/jdk/pull/13366#issuecomment-1529711388
From acobbs at openjdk.org Mon May 1 13:39:53 2023
From: acobbs at openjdk.org (Archie Cobbs)
Date: Mon, 1 May 2023 13:39:53 GMT
Subject: Integrated: 8305672: Surprising definite assignment error after
JDK-8043179
In-Reply-To:
References:
Message-ID:
On Wed, 5 Apr 2023 22:42:58 GMT, Archie Cobbs wrote:
> The fix for [JDK-8043179](https://bugs.openjdk.org/browse/JDK-8043179) is to clear the DU flags for all variables when entering a lamba. This reflects the fact that the lamba's actual execution could be arbitrarily far in the future, so we can't assume anything that is DU when the lambda is created is still DU when the lambda actually executes.
>
> However, this fix created a new bug. The problem is that `visitLambda()` does not save & restore the `uninitsTry` bits, which are used by `visitTry()` to track DU variables within `try { }` blocks. So if there is a `try { }` block outside the lambda and a `try { }` block inside the lambda, the latter can "leak" DU state up to the former via this field. As a result, a final variable that should still be DU at the completion of the outer `try { }` block can be incorrectly recorded as not DU, leading to the bogus "might already have been assigned" error.
>
> This patch fixes that by adding the necessary save & restore logic.
This pull request has now been integrated.
Changeset: d437c61f
Author: Archie Cobbs
Committer: Vicente Romero
URL: https://git.openjdk.org/jdk/commit/d437c61f5b77793606d73960eeaf98a091f14f6a
Stats: 49 lines in 2 files changed: 49 ins; 0 del; 0 mod
8305672: Surprising definite assignment error after JDK-8043179
Reviewed-by: kcr, vromero
-------------
PR: https://git.openjdk.org/jdk/pull/13366
From vromero at openjdk.org Mon May 1 16:48:53 2023
From: vromero at openjdk.org (Vicente Romero)
Date: Mon, 1 May 2023 16:48:53 GMT
Subject: RFR: 8292275: javac does not emit SYNTHETIC and MANDATED flags for
parameters by default [v8]
In-Reply-To:
References:
Message-ID:
On Sat, 29 Apr 2023 19:03:23 GMT, Hannes Greule wrote:
>> With this change, javac emits the MethodParameters attribute in cases where the JLS requires the information about synthetic and mandated parameters to be stored (see issue).
>> Parameter names are *not* emitted unless the `-parameter` flag is set.
>>
>> The relevant changes are in `ClassWriter`, where we go through the params to see if we need the attribute if the `-parameter` flag is not set (if it is set, both names and flags will be emitted).
>> For records, the mandated flag wasn't set at all, this is solved by the one line fix in `JavacParser`.
>>
>> The changes to `CreateSymbols` and `ClassReader` are needed as they weren't able to deal with missing names in the attribute.
>> I also had to update some tests as they got a new constant pool entry.
>>
>> Only the mandated flag is covered by tests at the moment, as the occurrences are well-specified in the JLS.
>> Please let me know if you want tests for specific appearances of synthetic parameters.
>
> Hannes Greule has updated the pull request incrementally with one additional commit since the last revision:
>
> Use ternary operator
>
> Co-authored-by: liach <7806504+liach at users.noreply.github.com>
good to see this one done, thanks to all!
-------------
PR Comment: https://git.openjdk.org/jdk/pull/9862#issuecomment-1529923659
From vromero at openjdk.org Mon May 1 16:48:55 2023
From: vromero at openjdk.org (Vicente Romero)
Date: Mon, 1 May 2023 16:48:55 GMT
Subject: RFR: 8292275: javac does not emit SYNTHETIC and MANDATED flags for
parameters by default [v8]
In-Reply-To: <9zxTtvwvKntdl1Cv01PD6OXwMNYInDfGlusMsVX1er8=.d6a40924-c18a-4263-9372-dbff6fc98a46@github.com>
References:
<9zxTtvwvKntdl1Cv01PD6OXwMNYInDfGlusMsVX1er8=.d6a40924-c18a-4263-9372-dbff6fc98a46@github.com>
Message-ID:
On Sun, 30 Apr 2023 08:56:10 GMT, Julian Waters wrote:
> Haha, glad to have been of help
>
> Now, if only someone would also take a look at my javac patch for the JNI header generator... :(
what's the PR for that one?
-------------
PR Comment: https://git.openjdk.org/jdk/pull/9862#issuecomment-1529924116
From jwaters at openjdk.org Mon May 1 16:48:56 2023
From: jwaters at openjdk.org (Julian Waters)
Date: Mon, 1 May 2023 16:48:56 GMT
Subject: RFR: 8292275: javac does not emit SYNTHETIC and MANDATED flags for
parameters by default [v8]
In-Reply-To:
References:
<9zxTtvwvKntdl1Cv01PD6OXwMNYInDfGlusMsVX1er8=.d6a40924-c18a-4263-9372-dbff6fc98a46@github.com>
Message-ID: <83vlAP86eh-7qkBGECeXvb2Sq8t4JdmE3w5ECtJpQK8=.0808b65a-26f4-45f5-955f-0fd72c260d1e@github.com>
On Mon, 1 May 2023 16:30:45 GMT, Vicente Romero wrote:
> > Haha, glad to have been of help
> > Now, if only someone would also take a look at my javac patch for the JNI header generator... :(
>
> what's the PR for that one?
Ah, sorry for the trouble, I was mildly joking for that one, but the corresponding PR is https://github.com/openjdk/jdk/pull/13457
-------------
PR Comment: https://git.openjdk.org/jdk/pull/9862#issuecomment-1529932401
From vromero at openjdk.org Mon May 1 17:33:59 2023
From: vromero at openjdk.org (Vicente Romero)
Date: Mon, 1 May 2023 17:33:59 GMT
Subject: RFR: 8292275: javac does not emit SYNTHETIC and MANDATED flags for
parameters by default [v8]
In-Reply-To:
References:
Message-ID:
On Sat, 29 Apr 2023 19:03:23 GMT, Hannes Greule wrote:
>> With this change, javac emits the MethodParameters attribute in cases where the JLS requires the information about synthetic and mandated parameters to be stored (see issue).
>> Parameter names are *not* emitted unless the `-parameter` flag is set.
>>
>> The relevant changes are in `ClassWriter`, where we go through the params to see if we need the attribute if the `-parameter` flag is not set (if it is set, both names and flags will be emitted).
>> For records, the mandated flag wasn't set at all, this is solved by the one line fix in `JavacParser`.
>>
>> The changes to `CreateSymbols` and `ClassReader` are needed as they weren't able to deal with missing names in the attribute.
>> I also had to update some tests as they got a new constant pool entry.
>>
>> Only the mandated flag is covered by tests at the moment, as the occurrences are well-specified in the JLS.
>> Please let me know if you want tests for specific appearances of synthetic parameters.
>
> Hannes Greule has updated the pull request incrementally with one additional commit since the last revision:
>
> Use ternary operator
>
> Co-authored-by: liach <7806504+liach at users.noreply.github.com>
> > > Haha, glad to have been of help
> > > Now, if only someone would also take a look at my javac patch for the JNI header generator... :(
> >
> >
> > what's the PR for that one?
>
> Ah, sorry for the trouble, I was mildly joking for that one, but the corresponding PR is #13457
I see, it seems like it is already being looked at
-------------
PR Comment: https://git.openjdk.org/jdk/pull/9862#issuecomment-1529968082
From abimpoudis at openjdk.org Mon May 1 22:29:27 2023
From: abimpoudis at openjdk.org (Aggelos Biboudis)
Date: Mon, 1 May 2023 22:29:27 GMT
Subject: RFR: 8302344: Compiler Implementation for Unnamed patterns and
variables (Preview) [v8]
In-Reply-To:
References:
Message-ID:
> This PR implements [JEP 443](https://openjdk.org/jeps/443), the preview feature for Unnamed Patterns and Variables in Java.
>
> Draft Spec: https://cr.openjdk.org/~abimpoudis/unnamed/latest/
Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision:
Address comments around JavacParser (remove identOrFlagUnderscore)
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/13528/files
- new: https://git.openjdk.org/jdk/pull/13528/files/e39dd6dd..47d738bb
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=13528&range=07
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=13528&range=06-07
Stats: 39 lines in 1 file changed: 12 ins; 20 del; 7 mod
Patch: https://git.openjdk.org/jdk/pull/13528.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/13528/head:pull/13528
PR: https://git.openjdk.org/jdk/pull/13528
From abimpoudis at openjdk.org Mon May 1 22:29:30 2023
From: abimpoudis at openjdk.org (Aggelos Biboudis)
Date: Mon, 1 May 2023 22:29:30 GMT
Subject: RFR: 8302344: Compiler Implementation for Unnamed patterns and
variables (Preview) [v4]
In-Reply-To:
References:
Message-ID:
On Fri, 28 Apr 2023 08:56:38 GMT, Maurizio Cimadamore wrote:
>> Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Update test files with JDK 8307007 bug id
>
> src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java line 839:
>
>> 837: }
>> 838:
>> 839: private UnnamedDetails identOrFlagUnderscore(JCModifiers mods) {
>
> I'm not 100% sure this is required - the main use seems to be in `variableDeclarator` - but in that method you already have a token to look at, and a set of modifiers that you can augment - so why not just doing everything in that method (instead of preprocessing it?)
Good point. That was an artifact of code evolution. Everything is integrated in `variableDeclarator` now.
> src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java line 3555:
>
>> 3553: */
>> 3554: JCVariableDecl variableDeclarator(JCModifiers mods, JCExpression type, boolean reqInit, Comment dc, boolean localDecl) {
>> 3555: UnnamedDetails result = identOrFlagUnderscore(mods);
>
> Why do we need to get the "unnamed details" here, instead of letting the code flow to `variableDeclaratorRest` and do it there?
Indeed. I removed it.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13528#discussion_r1181937000
PR Review Comment: https://git.openjdk.org/jdk/pull/13528#discussion_r1181937191
From abimpoudis at openjdk.org Mon May 1 22:32:31 2023
From: abimpoudis at openjdk.org (Aggelos Biboudis)
Date: Mon, 1 May 2023 22:32:31 GMT
Subject: RFR: 8302344: Compiler Implementation for Unnamed patterns and
variables (Preview) [v4]
In-Reply-To:
References:
Message-ID:
On Fri, 28 Apr 2023 09:07:22 GMT, Maurizio Cimadamore wrote:
>> Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Update test files with JDK 8307007 bug id
>
> src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java line 1777:
>
>> 1775: log.error(guard.pos(), Errors.GuardHasConstantExpressionFalse);
>> 1776: }
>> 1777: } else if (guard != null) {
>
> I guess this is caused by something like:
>
> case _ when ...
>
> If now a guard can appear regardless of how many labels there are, should be refactor this code so that if `guard != null` it is always attributed? And then we do other stuff in case `labels.tail.isEmpty()` ? Note that the code for attributing the guard is slightly different in the two cases in this patch: the original code creates a nested scope - while the new code doesn't.
Actually this is for the case where we have `case A(_), B(C _) when ... `. In that case we are sure that the only scope we can use is the switch environment (since no bindings are introduced). Hm, I don't see another way of refactoring this without depending on `labels.tail.isEmpty()`
> src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java line 826:
>
>> 824: //type test pattern:
>> 825: UnnamedDetails result = identOrFlagUnderscore(mods);
>> 826: JCVariableDecl var = toP(F.at(result.varPos()).VarDef(mods, result.name(), e, null));
>
> Do you think we can delegate to `variableDeclarator` here?
The behavior I observe is that `variableDeclarator` does not behave well when we have a `var` instead of a type in a type pattern. `variableDeclarator` is well suited for variable declarations but not for type patterns. But I can investigate further.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13528#discussion_r1181938984
PR Review Comment: https://git.openjdk.org/jdk/pull/13528#discussion_r1181938402
From jjg at openjdk.org Mon May 1 23:03:10 2023
From: jjg at openjdk.org (Jonathan Gibbons)
Date: Mon, 1 May 2023 23:03:10 GMT
Subject: RFR: JDK-8307123: Fix deprecation warnings in DPrinter
Message-ID: <6rSeWRzbI8BZ33d400uerrSxitH0s2qe0irKFzw6CRc=.e4629a3a-6f9a-4a70-a5e1-ad884a7dab2e@github.com>
Please review a trivial test clean to fix some deprecation warnings in the test/langtools DPrinter class.
-------------
Commit messages:
- JDK-8307123: Fix deprecation warnings in DPrinter
Changes: https://git.openjdk.org/jdk/pull/13747/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=13747&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8307123
Stats: 2 lines in 1 file changed: 2 ins; 0 del; 0 mod
Patch: https://git.openjdk.org/jdk/pull/13747.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/13747/head:pull/13747
PR: https://git.openjdk.org/jdk/pull/13747
From vromero at openjdk.org Tue May 2 03:23:15 2023
From: vromero at openjdk.org (Vicente Romero)
Date: Tue, 2 May 2023 03:23:15 GMT
Subject: RFR: JDK-8307123: Fix deprecation warnings in DPrinter
In-Reply-To: <6rSeWRzbI8BZ33d400uerrSxitH0s2qe0irKFzw6CRc=.e4629a3a-6f9a-4a70-a5e1-ad884a7dab2e@github.com>
References: <6rSeWRzbI8BZ33d400uerrSxitH0s2qe0irKFzw6CRc=.e4629a3a-6f9a-4a70-a5e1-ad884a7dab2e@github.com>
Message-ID:
On Mon, 1 May 2023 22:56:12 GMT, Jonathan Gibbons wrote:
> Please review a trivial test clean to fix some deprecation warnings in the test/langtools DPrinter class.
looks good
-------------
Marked as reviewed by vromero (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/13747#pullrequestreview-1408338632
From jwaters at openjdk.org Tue May 2 07:56:38 2023
From: jwaters at openjdk.org (Julian Waters)
Date: Tue, 2 May 2023 07:56:38 GMT
Subject: RFR: 8292275: javac does not emit SYNTHETIC and MANDATED flags for
parameters by default [v8]
In-Reply-To:
References:
Message-ID:
On Sat, 29 Apr 2023 19:03:23 GMT, Hannes Greule wrote:
>> With this change, javac emits the MethodParameters attribute in cases where the JLS requires the information about synthetic and mandated parameters to be stored (see issue).
>> Parameter names are *not* emitted unless the `-parameter` flag is set.
>>
>> The relevant changes are in `ClassWriter`, where we go through the params to see if we need the attribute if the `-parameter` flag is not set (if it is set, both names and flags will be emitted).
>> For records, the mandated flag wasn't set at all, this is solved by the one line fix in `JavacParser`.
>>
>> The changes to `CreateSymbols` and `ClassReader` are needed as they weren't able to deal with missing names in the attribute.
>> I also had to update some tests as they got a new constant pool entry.
>>
>> Only the mandated flag is covered by tests at the moment, as the occurrences are well-specified in the JLS.
>> Please let me know if you want tests for specific appearances of synthetic parameters.
>
> Hannes Greule has updated the pull request incrementally with one additional commit since the last revision:
>
> Use ternary operator
>
> Co-authored-by: liach <7806504+liach at users.noreply.github.com>
It was yeah, Jan hasn't come back to reviewing it in quite a while unfortunately :/
-------------
PR Comment: https://git.openjdk.org/jdk/pull/9862#issuecomment-1531037537
From abimpoudis at openjdk.org Tue May 2 08:20:19 2023
From: abimpoudis at openjdk.org (Aggelos Biboudis)
Date: Tue, 2 May 2023 08:20:19 GMT
Subject: RFR: 8302344: Compiler Implementation for Unnamed patterns and
variables (Preview) [v4]
In-Reply-To:
References:
Message-ID:
On Fri, 28 Apr 2023 08:59:35 GMT, Maurizio Cimadamore wrote:
>> Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Update test files with JDK 8307007 bug id
>
> src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java line 3660:
>
>> 3658: int pos = token.pos;
>> 3659: Name name;
>> 3660: if (allowThisIdent ||
>
> I note that now the error re. underscore on lambda is no longer given even if preview features are disabled. But I guess that's ok. (instead you will probably get an error that unnamed parameters are a preview feature)
Yes, indeed.
~/dev/jdk unnamed !1 > javac Unnamed.java
Unnamed.java:61: error: unnamed variables are a preview feature and are disabled by default.
TwoParams p1 = (_, _) -> {};
^
(use --enable-preview to enable unnamed variables)
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13528#discussion_r1182230562
From abimpoudis at openjdk.org Tue May 2 08:27:20 2023
From: abimpoudis at openjdk.org (Aggelos Biboudis)
Date: Tue, 2 May 2023 08:27:20 GMT
Subject: RFR: 8302344: Compiler Implementation for Unnamed patterns and
variables (Preview) [v4]
In-Reply-To:
References:
Message-ID:
On Fri, 28 Apr 2023 09:20:12 GMT, Maurizio Cimadamore wrote:
>> Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Update test files with JDK 8307007 bug id
>
> src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java line 746:
>
>> 744:
>> 745: sealed interface PatternDescription {
>> 746: public static PatternDescription from(Types types, Type selectorType, JCPattern pattern, Symtab syms) {
>
> Optional comment: the fact that this factory needs so much compiler state makes me think that perhaps a better place for it would be as an instance method of Flow, rather than a static method in PatternDescription.
@lahodaj WDYT? Looks like it can be easily refactored and it is used only in one place (apart from the recursive call). I can refactor it in this PR or u can do it in #13074.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13528#discussion_r1182237560
From abimpoudis at openjdk.org Tue May 2 09:49:38 2023
From: abimpoudis at openjdk.org (Aggelos Biboudis)
Date: Tue, 2 May 2023 09:49:38 GMT
Subject: RFR: 8302344: Compiler Implementation for Unnamed patterns and
variables (Preview) [v9]
In-Reply-To:
References:
Message-ID:
> This PR implements [JEP 443](https://openjdk.org/jeps/443), the preview feature for Unnamed Patterns and Variables in Java.
>
> Draft Spec: https://cr.openjdk.org/~abimpoudis/unnamed/latest/
Aggelos Biboudis has updated the pull request incrementally with two additional commits since the last revision:
- Address comments around JavacParser (reuse variableDeclaratorRest in parsePattern)
- Add new lines and revise comment in Unnamed.java
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/13528/files
- new: https://git.openjdk.org/jdk/pull/13528/files/47d738bb..3d83fa14
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=13528&range=08
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=13528&range=07-08
Stats: 49 lines in 4 files changed: 8 ins; 7 del; 34 mod
Patch: https://git.openjdk.org/jdk/pull/13528.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/13528/head:pull/13528
PR: https://git.openjdk.org/jdk/pull/13528
From abimpoudis at openjdk.org Tue May 2 09:49:42 2023
From: abimpoudis at openjdk.org (Aggelos Biboudis)
Date: Tue, 2 May 2023 09:49:42 GMT
Subject: RFR: 8302344: Compiler Implementation for Unnamed patterns and
variables (Preview) [v4]
In-Reply-To:
References:
Message-ID:
On Mon, 1 May 2023 22:28:00 GMT, Aggelos Biboudis wrote:
>> src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java line 826:
>>
>>> 824: //type test pattern:
>>> 825: UnnamedDetails result = identOrFlagUnderscore(mods);
>>> 826: JCVariableDecl var = toP(F.at(result.varPos()).VarDef(mods, result.name(), e, null));
>>
>> Do you think we can delegate to `variableDeclarator` here?
>
> The behavior I observe is that `variableDeclarator` does not behave well when we have a `var` instead of a type in a type pattern. `variableDeclarator` is well suited for variable declarations but not for type patterns. But I can investigate further.
What about reusing `variableDeclaratorRest`?
https://github.com/openjdk/jdk/pull/13528/commits/3d83fa14ae26981d5b6fc75faa0d3ba9336952b1
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13528#discussion_r1182329080
From cushon at openjdk.org Tue May 2 15:19:32 2023
From: cushon at openjdk.org (Liam Miller-Cushon)
Date: Tue, 2 May 2023 15:19:32 GMT
Subject: RFR: 8303784: no-@Target annotations should be applicable to type
parameter declarations [v6]
In-Reply-To:
References:
Message-ID:
> Please consider this fix for https://bugs.openjdk.org/browse/JDK-8303784, which make `@Target`-less annotations applicable to type parameter declarations.
>
> `@Target`-less annotations are applicable to 'all declaration contexts', which includes type parameter declarations.
Liam Miller-Cushon has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains six additional commits since the last revision:
- Merge branch 'master' into JDK-8303784
- Use Feature enum for version checks
- Add a test case with no --release flag
- Make fix contingent on --release 14
based on discussion in CSR.
- Move test under `test/langtools/tools/javac/annotations/typeAnnotations`
- 8303784: no- at Target annotations should be applicable to type parameter declarations
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/12914/files
- new: https://git.openjdk.org/jdk/pull/12914/files/749af3cc..6b03a477
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=12914&range=05
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=12914&range=04-05
Stats: 495182 lines in 4948 files changed: 389506 ins; 65649 del; 40027 mod
Patch: https://git.openjdk.org/jdk/pull/12914.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/12914/head:pull/12914
PR: https://git.openjdk.org/jdk/pull/12914
From jjg at openjdk.org Tue May 2 16:57:23 2023
From: jjg at openjdk.org (Jonathan Gibbons)
Date: Tue, 2 May 2023 16:57:23 GMT
Subject: Integrated: JDK-8307123: Fix deprecation warnings in DPrinter
In-Reply-To: <6rSeWRzbI8BZ33d400uerrSxitH0s2qe0irKFzw6CRc=.e4629a3a-6f9a-4a70-a5e1-ad884a7dab2e@github.com>
References: <6rSeWRzbI8BZ33d400uerrSxitH0s2qe0irKFzw6CRc=.e4629a3a-6f9a-4a70-a5e1-ad884a7dab2e@github.com>
Message-ID: <1Owalr1EgZuLqk5pR0_IgeOVgTm_QN1gnZVDMM2g2mw=.3a9a6080-553e-4bab-82a6-d52eb4dc0c98@github.com>
On Mon, 1 May 2023 22:56:12 GMT, Jonathan Gibbons wrote:
> Please review a trivial test clean to fix some deprecation warnings in the test/langtools DPrinter class.
This pull request has now been integrated.
Changeset: b76f320e
Author: Jonathan Gibbons
URL: https://git.openjdk.org/jdk/commit/b76f320e76f0fb58c598fdd7a5937f1b5bb1de15
Stats: 2 lines in 1 file changed: 2 ins; 0 del; 0 mod
8307123: Fix deprecation warnings in DPrinter
Reviewed-by: vromero
-------------
PR: https://git.openjdk.org/jdk/pull/13747
From cushon at openjdk.org Tue May 2 18:22:32 2023
From: cushon at openjdk.org (Liam Miller-Cushon)
Date: Tue, 2 May 2023 18:22:32 GMT
Subject: Integrated: 8303784: no-@Target annotations should be applicable to
type parameter declarations
In-Reply-To:
References:
Message-ID:
On Wed, 8 Mar 2023 00:06:41 GMT, Liam Miller-Cushon wrote:
> Please consider this fix for https://bugs.openjdk.org/browse/JDK-8303784, which make `@Target`-less annotations applicable to type parameter declarations.
>
> `@Target`-less annotations are applicable to 'all declaration contexts', which includes type parameter declarations.
This pull request has now been integrated.
Changeset: 8c106b0c
Author: Liam Miller-Cushon
URL: https://git.openjdk.org/jdk/commit/8c106b0c8e4562a44ecd1e069c0911acfc428ecf
Stats: 49 lines in 4 files changed: 48 ins; 0 del; 1 mod
8303784: no- at Target annotations should be applicable to type parameter declarations
Reviewed-by: vromero
-------------
PR: https://git.openjdk.org/jdk/pull/12914
From abimpoudis at openjdk.org Tue May 2 19:27:12 2023
From: abimpoudis at openjdk.org (Aggelos Biboudis)
Date: Tue, 2 May 2023 19:27:12 GMT
Subject: RFR: 8302344: Compiler Implementation for Unnamed patterns and
variables (Preview) [v10]
In-Reply-To:
References:
Message-ID:
> This PR implements [JEP 443](https://openjdk.org/jeps/443), the preview feature for Unnamed Patterns and Variables in Java.
>
> Draft Spec: https://cr.openjdk.org/~abimpoudis/unnamed/latest/
Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision:
Remove flag
- Fixes unnamed errors
- Fixes missing test in TestUnnamedVariableElement
- Removes scope elements from erroneous source file tests in TestGetScopeResult (names.empty is used to signify error when we mix and match implicit and explicit parameters in lambdas)
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/13528/files
- new: https://git.openjdk.org/jdk/pull/13528/files/3d83fa14..5c9314d3
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=13528&range=09
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=13528&range=08-09
Stats: 29 lines in 9 files changed: 8 ins; 11 del; 10 mod
Patch: https://git.openjdk.org/jdk/pull/13528.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/13528/head:pull/13528
PR: https://git.openjdk.org/jdk/pull/13528
From abimpoudis at openjdk.org Tue May 2 19:27:16 2023
From: abimpoudis at openjdk.org (Aggelos Biboudis)
Date: Tue, 2 May 2023 19:27:16 GMT
Subject: RFR: 8302344: Compiler Implementation for Unnamed patterns and
variables (Preview) [v9]
In-Reply-To:
References:
Message-ID:
On Tue, 2 May 2023 09:49:38 GMT, Aggelos Biboudis wrote:
>> This PR implements [JEP 443](https://openjdk.org/jeps/443), the preview feature for Unnamed Patterns and Variables in Java.
>>
>> Draft Spec: https://cr.openjdk.org/~abimpoudis/unnamed/latest/
>
> Aggelos Biboudis has updated the pull request incrementally with two additional commits since the last revision:
>
> - Address comments around JavacParser (reuse variableDeclaratorRest in parsePattern)
> - Add new lines and revise comment in Unnamed.java
@mcimadamore
@vicente-romero-oracle
Flag removed in https://github.com/openjdk/jdk/pull/13528/commits/5c9314d3f39dc0e3084c80b7f2ff06e70a363425
re-requesting review ?
cc-ing @lahodaj
-------------
PR Comment: https://git.openjdk.org/jdk/pull/13528#issuecomment-1532022476
From abimpoudis at openjdk.org Tue May 2 22:34:15 2023
From: abimpoudis at openjdk.org (Aggelos Biboudis)
Date: Tue, 2 May 2023 22:34:15 GMT
Subject: RFR: 8305582: Compiler crash when compiling record patterns with
var
In-Reply-To:
References:
Message-ID:
On Tue, 4 Apr 2023 17:34:27 GMT, Aggelos Biboudis wrote:
> While `var` is not allowed in record pattern position the compiler was not checking it. This PR address this issue, by introducing the relevant error symbols and error types.
>
> e.g., `if (o instanceof ColoredPoint(var(var x, var y), var c)) { }`
Small fix, looking for a reviewer ?
-------------
PR Comment: https://git.openjdk.org/jdk/pull/13331#issuecomment-1532237887
From jjg at openjdk.org Wed May 3 00:00:13 2023
From: jjg at openjdk.org (Jonathan Gibbons)
Date: Wed, 3 May 2023 00:00:13 GMT
Subject: RFR: JDK-8068925: Add @Override in javax.tools classes
Message-ID:
Please review a simple update to add `@Override` annotations where appropriate in the `javax.tools` API, and one other minor opportunistic cleanup to use an `instanceof` pattern.
-------------
Commit messages:
- JDK-8068925: Add @Override in javax.tools classes
Changes: https://git.openjdk.org/jdk/pull/13766/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=13766&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8068925
Stats: 21 lines in 4 files changed: 17 ins; 2 del; 2 mod
Patch: https://git.openjdk.org/jdk/pull/13766.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/13766/head:pull/13766
PR: https://git.openjdk.org/jdk/pull/13766
From darcy at openjdk.org Wed May 3 00:40:16 2023
From: darcy at openjdk.org (Joe Darcy)
Date: Wed, 3 May 2023 00:40:16 GMT
Subject: RFR: JDK-8068925: Add @Override in javax.tools classes
In-Reply-To:
References:
Message-ID: <0dOq3gH30pL3b0SlirauHQKb0m7dxKhRAko_n2bxDd4=.c99dfe0c-e033-4802-be2c-75ec067a5856@github.com>
On Tue, 2 May 2023 23:53:55 GMT, Jonathan Gibbons wrote:
> Please review a simple update to add `@Override` annotations where appropriate in the `javax.tools` API, and one other minor opportunistic cleanup to use an `instanceof` pattern.
Marked as reviewed by darcy (Reviewer).
-------------
PR Review: https://git.openjdk.org/jdk/pull/13766#pullrequestreview-1410044906
From acobbs at openjdk.org Wed May 3 01:37:19 2023
From: acobbs at openjdk.org (Archie Cobbs)
Date: Wed, 3 May 2023 01:37:19 GMT
Subject: RFR: 8278856: javac documentation does not mention use of Manifest
class-path attribute
In-Reply-To:
References:
Message-ID: <6gqOqSCzzzxD0yCWh2lId3KzuEi9yL7ljb_2H3GOR98=.68fcd605-0e49-4da6-9026-602d330f842e@github.com>
On Tue, 4 Apr 2023 17:45:12 GMT, Archie Cobbs wrote:
> JAR files appearing in `--class-path` are implicitly scanned for manifest `Class-Path` attributes, but this behavior is not documented.
>
> This patch adds a blurb to the `javac(1)` man page.
/?
-------------
PR Comment: https://git.openjdk.org/jdk/pull/13332#issuecomment-1532350855
From iris at openjdk.org Wed May 3 03:57:13 2023
From: iris at openjdk.org (Iris Clark)
Date: Wed, 3 May 2023 03:57:13 GMT
Subject: RFR: JDK-8068925: Add @Override in javax.tools classes
In-Reply-To:
References:
Message-ID:
On Tue, 2 May 2023 23:53:55 GMT, Jonathan Gibbons wrote:
> Please review a simple update to add `@Override` annotations where appropriate in the `javax.tools` API, and one other minor opportunistic cleanup to use an `instanceof` pattern.
Marked as reviewed by iris (Reviewer).
-------------
PR Review: https://git.openjdk.org/jdk/pull/13766#pullrequestreview-1410153726
From abimpoudis at openjdk.org Wed May 3 14:29:23 2023
From: abimpoudis at openjdk.org (Aggelos Biboudis)
Date: Wed, 3 May 2023 14:29:23 GMT
Subject: RFR: 8302344: Compiler Implementation for Unnamed patterns and
variables (Preview) [v11]
In-Reply-To:
References:
Message-ID:
> This PR implements [JEP 443](https://openjdk.org/jeps/443), the preview feature for Unnamed Patterns and Variables in Java.
>
> Draft Spec: https://cr.openjdk.org/~abimpoudis/unnamed/latest/
Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision:
Add guard test
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/13528/files
- new: https://git.openjdk.org/jdk/pull/13528/files/5c9314d3..e95465ed
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=13528&range=10
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=13528&range=09-10
Stats: 15 lines in 2 files changed: 14 ins; 0 del; 1 mod
Patch: https://git.openjdk.org/jdk/pull/13528.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/13528/head:pull/13528
PR: https://git.openjdk.org/jdk/pull/13528
From abimpoudis at openjdk.org Wed May 3 15:41:19 2023
From: abimpoudis at openjdk.org (Aggelos Biboudis)
Date: Wed, 3 May 2023 15:41:19 GMT
Subject: RFR: 8302344: Compiler Implementation for Unnamed patterns and
variables (Preview) [v4]
In-Reply-To:
References:
Message-ID:
On Fri, 28 Apr 2023 09:16:29 GMT, Maurizio Cimadamore wrote:
>> Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Update test files with JDK 8307007 bug id
>
> src/jdk.compiler/share/classes/com/sun/tools/javac/comp/MemberEnter.java line 295:
>
>> 293: : tree.vartype.type;
>> 294: Name name;
>> 295: if (Feature.UNNAMED_VARIABLES.allowedInSource(source) && (tree.mods.flags & UNNAMED) != 0) {
>
> Not 100% sure what this code does. E.g. shouldn't we just set the name of the variable as the name stored in the tree? It seems more economical if we could just set in the parser the name as empty (if preview features are enabled etc.) - and then all these special cases can disappear. After all, you still have the flag (and even then, do we need a flag? Can't we just see whether the name is empty to see that it's unnamed?)
This is still needed because we want to have a different name for the Tree API (_) and the symbol (empty).
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13528#discussion_r1183863324
From jjg at openjdk.org Wed May 3 17:35:21 2023
From: jjg at openjdk.org (Jonathan Gibbons)
Date: Wed, 3 May 2023 17:35:21 GMT
Subject: Integrated: JDK-8068925: Add @Override in javax.tools classes
In-Reply-To:
References:
Message-ID:
On Tue, 2 May 2023 23:53:55 GMT, Jonathan Gibbons wrote:
> Please review a simple update to add `@Override` annotations where appropriate in the `javax.tools` API, and one other minor opportunistic cleanup to use an `instanceof` pattern.
This pull request has now been integrated.
Changeset: 3930709a
Author: Jonathan Gibbons
URL: https://git.openjdk.org/jdk/commit/3930709af40c2524622f379e16b90a0226bedf2a
Stats: 21 lines in 4 files changed: 17 ins; 2 del; 2 mod
8068925: Add @Override in javax.tools classes
Reviewed-by: darcy, iris
-------------
PR: https://git.openjdk.org/jdk/pull/13766
From abimpoudis at openjdk.org Thu May 4 15:08:21 2023
From: abimpoudis at openjdk.org (Aggelos Biboudis)
Date: Thu, 4 May 2023 15:08:21 GMT
Subject: RFR: 8302344: Compiler Implementation for Unnamed patterns and
variables (Preview) [v12]
In-Reply-To:
References:
Message-ID:
> This PR implements [JEP 443](https://openjdk.org/jeps/443), the preview feature for Unnamed Patterns and Variables in Java.
>
> Draft Spec: https://cr.openjdk.org/~abimpoudis/unnamed/latest/
Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision:
8307444: java.lang.AssertionError when using unnamed patterns
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/13528/files
- new: https://git.openjdk.org/jdk/pull/13528/files/e95465ed..12ce9e19
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=13528&range=11
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=13528&range=10-11
Stats: 18 lines in 2 files changed: 15 ins; 1 del; 2 mod
Patch: https://git.openjdk.org/jdk/pull/13528.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/13528/head:pull/13528
PR: https://git.openjdk.org/jdk/pull/13528
From mcimadamore at openjdk.org Thu May 4 17:23:26 2023
From: mcimadamore at openjdk.org (Maurizio Cimadamore)
Date: Thu, 4 May 2023 17:23:26 GMT
Subject: RFR: 8302344: Compiler Implementation for Unnamed patterns and
variables (Preview) [v12]
In-Reply-To:
References:
Message-ID:
On Thu, 4 May 2023 15:08:21 GMT, Aggelos Biboudis wrote:
>> This PR implements [JEP 443](https://openjdk.org/jeps/443), the preview feature for Unnamed Patterns and Variables in Java.
>>
>> Draft Spec: https://cr.openjdk.org/~abimpoudis/unnamed/latest/
>
> Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision:
>
> 8307444: java.lang.AssertionError when using unnamed patterns
src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java line 4165:
> 4163: tree.type = tree.var.type = type;
> 4164: Name name = tree.var.name;
> 4165: if (name == names.underscore) name = names.empty;
Why isn't the parser doing this?
src/jdk.compiler/share/classes/com/sun/tools/javac/comp/MemberEnter.java line 295:
> 293: : tree.vartype.type;
> 294: Name name = tree.name;
> 295: if (Feature.UNNAMED_VARIABLES.allowedInSource(source) && name == names.underscore) name = names.empty;
Same, I believe the parser should have set the right name on this
src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java line 3591:
> 3589: }
> 3590: }
> 3591: result = toP(F.at(pos).VarDef(mods, name, type, init, declaredUsingVar));
I think this should check whether name is underscore (and feature is enabled) and, if that's the case, replace the name with an empty name, so that the rest of the compiler is already correct.
Also, related, no matter what, I think javac's Pretty class should be updated to render variables with empty name as "_" when the tree is turned back into source.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13528#discussion_r1185294832
PR Review Comment: https://git.openjdk.org/jdk/pull/13528#discussion_r1185295283
PR Review Comment: https://git.openjdk.org/jdk/pull/13528#discussion_r1185299587
From abimpoudis at openjdk.org Thu May 4 17:48:28 2023
From: abimpoudis at openjdk.org (Aggelos Biboudis)
Date: Thu, 4 May 2023 17:48:28 GMT
Subject: RFR: 8302344: Compiler Implementation for Unnamed patterns and
variables (Preview) [v13]
In-Reply-To:
References:
Message-ID: <7x1mAOBwhQdGgCaHjiOQ1O9BCmgJFKASy7yFJHsGVbI=.842ee2fe-8819-4e43-935a-120303815fd5@github.com>
> This PR implements [JEP 443](https://openjdk.org/jeps/443), the preview feature for Unnamed Patterns and Variables in Java.
>
> Draft Spec: https://cr.openjdk.org/~abimpoudis/unnamed/latest/
Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision:
Add test
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/13528/files
- new: https://git.openjdk.org/jdk/pull/13528/files/12ce9e19..ffae4e0e
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=13528&range=12
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=13528&range=11-12
Stats: 46 lines in 1 file changed: 46 ins; 0 del; 0 mod
Patch: https://git.openjdk.org/jdk/pull/13528.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/13528/head:pull/13528
PR: https://git.openjdk.org/jdk/pull/13528
From vromero at openjdk.org Thu May 4 17:51:22 2023
From: vromero at openjdk.org (Vicente Romero)
Date: Thu, 4 May 2023 17:51:22 GMT
Subject: RFR: 8302344: Compiler Implementation for Unnamed patterns and
variables (Preview) [v12]
In-Reply-To:
References:
Message-ID:
On Thu, 4 May 2023 17:20:35 GMT, Maurizio Cimadamore wrote:
>> Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision:
>>
>> 8307444: java.lang.AssertionError when using unnamed patterns
>
> src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java line 3591:
>
>> 3589: }
>> 3590: }
>> 3591: result = toP(F.at(pos).VarDef(mods, name, type, init, declaredUsingVar));
>
> I think this should check whether name is underscore (and feature is enabled) and, if that's the case, replace the name with an empty name, so that the rest of the compiler is already correct.
>
> Also, related, no matter what, I think javac's Pretty class should be updated to render variables with empty name as "_" when the tree is turned back into source.
yep I agree with this, the parser should set the right name as soon as it sees a `_`
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13528#discussion_r1185327903
From abimpoudis at openjdk.org Thu May 4 18:23:24 2023
From: abimpoudis at openjdk.org (Aggelos Biboudis)
Date: Thu, 4 May 2023 18:23:24 GMT
Subject: RFR: 8302344: Compiler Implementation for Unnamed patterns and
variables (Preview) [v12]
In-Reply-To:
References:
Message-ID:
On Thu, 4 May 2023 17:48:31 GMT, Vicente Romero wrote:
>> src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java line 3591:
>>
>>> 3589: }
>>> 3590: }
>>> 3591: result = toP(F.at(pos).VarDef(mods, name, type, init, declaredUsingVar));
>>
>> I think this should check whether name is underscore (and feature is enabled) and, if that's the case, replace the name with an empty name, so that the rest of the compiler is already correct.
>>
>> Also, related, no matter what, I think javac's Pretty class should be updated to render variables with empty name as "_" when the tree is turned back into source.
>
> yep I agree with this, the parser should set the right name as soon as it sees a `_`
We could indeed if we wanted to store `empty` everywhere. However, after some off-list discussions I updated the CSR (and the code) to include `empty` as the name at the symbol-level (for consistency with javax model) and `_` at the Tree API-level for its version of a name. This is the rationale behind what you see in Attr (for patterns) and member enter for all other cases. @jddarcy what do you think?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13528#discussion_r1185358285
From vromero at openjdk.org Thu May 4 18:55:21 2023
From: vromero at openjdk.org (Vicente Romero)
Date: Thu, 4 May 2023 18:55:21 GMT
Subject: RFR: 8302344: Compiler Implementation for Unnamed patterns and
variables (Preview) [v13]
In-Reply-To: <7x1mAOBwhQdGgCaHjiOQ1O9BCmgJFKASy7yFJHsGVbI=.842ee2fe-8819-4e43-935a-120303815fd5@github.com>
References:
<7x1mAOBwhQdGgCaHjiOQ1O9BCmgJFKASy7yFJHsGVbI=.842ee2fe-8819-4e43-935a-120303815fd5@github.com>
Message-ID:
On Thu, 4 May 2023 17:48:28 GMT, Aggelos Biboudis wrote:
>> This PR implements [JEP 443](https://openjdk.org/jeps/443), the preview feature for Unnamed Patterns and Variables in Java.
>>
>> Draft Spec: https://cr.openjdk.org/~abimpoudis/unnamed/latest/
>
> Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision:
>
> Add test
src/jdk.compiler/share/classes/com/sun/source/tree/VariableTree.java line 54:
> 52:
> 53: /**
> 54: * Returns the name of the variable being declared or `_` if the variable
I guess if we go full for the empty name then this will need to change too
src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransPatterns.java line 69:
> 67: import com.sun.tools.javac.util.Names;
> 68:
> 69: import java.util.*;
nit: I think we prefer not using star imports, this was probably done by the IDE
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13528#discussion_r1185336672
PR Review Comment: https://git.openjdk.org/jdk/pull/13528#discussion_r1185393785
From vromero at openjdk.org Thu May 4 19:33:28 2023
From: vromero at openjdk.org (Vicente Romero)
Date: Thu, 4 May 2023 19:33:28 GMT
Subject: RFR: 8302344: Compiler Implementation for Unnamed patterns and
variables (Preview) [v13]
In-Reply-To: <7x1mAOBwhQdGgCaHjiOQ1O9BCmgJFKASy7yFJHsGVbI=.842ee2fe-8819-4e43-935a-120303815fd5@github.com>
References:
<7x1mAOBwhQdGgCaHjiOQ1O9BCmgJFKASy7yFJHsGVbI=.842ee2fe-8819-4e43-935a-120303815fd5@github.com>
Message-ID:
On Thu, 4 May 2023 17:48:28 GMT, Aggelos Biboudis wrote:
>> This PR implements [JEP 443](https://openjdk.org/jeps/443), the preview feature for Unnamed Patterns and Variables in Java.
>>
>> Draft Spec: https://cr.openjdk.org/~abimpoudis/unnamed/latest/
>
> Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision:
>
> Add test
src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransPatterns.java line 535:
> 533: if (clearedPatterns.size() > 1) {
> 534: validCaseLabelList = clearedPatterns.stream().allMatch(cP -> cP.hasTag(Tag.PATTERNCASELABEL));
> 535: } else validCaseLabelList = clearedPatterns.size() == 1 && clearedPatterns.head.hasTag(Tag.PATTERNCASELABEL);
style: I would use `{}` for the code in the `else` branch here, same way as it has been done for the `then` branch. Also in the `else` branch isn't the `clearedPatterns.size() == 1` condition always true?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13528#discussion_r1185430664
From darcy at openjdk.org Thu May 4 20:01:23 2023
From: darcy at openjdk.org (Joe Darcy)
Date: Thu, 4 May 2023 20:01:23 GMT
Subject: RFR: 8302344: Compiler Implementation for Unnamed patterns and
variables (Preview) [v12]
In-Reply-To:
References:
Message-ID:
On Thu, 4 May 2023 18:20:30 GMT, Aggelos Biboudis wrote:
>> yep I agree with this, the parser should set the right name as soon as it sees a `_`
>
> We could indeed if we wanted to store `empty` everywhere. However, after some off-list discussions I updated the CSR (and the code) to include `empty` as the name at the symbol-level (for consistency with javax model) and `_` at the Tree API-level for its version of a name. This is the rationale behind what you see in Attr (for patterns) and member enter for all other cases. @jddarcy what do you think?
>
In terms of pretty printing, src/jdk.compiler/share/classes/com/sun/tools/javac/processing/PrintingProcessor.java may need to be updated too.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13528#discussion_r1185457942
From vromero at openjdk.org Thu May 4 20:07:19 2023
From: vromero at openjdk.org (Vicente Romero)
Date: Thu, 4 May 2023 20:07:19 GMT
Subject: RFR: 8302344: Compiler Implementation for Unnamed patterns and
variables (Preview) [v13]
In-Reply-To: <7x1mAOBwhQdGgCaHjiOQ1O9BCmgJFKASy7yFJHsGVbI=.842ee2fe-8819-4e43-935a-120303815fd5@github.com>
References:
<7x1mAOBwhQdGgCaHjiOQ1O9BCmgJFKASy7yFJHsGVbI=.842ee2fe-8819-4e43-935a-120303815fd5@github.com>
Message-ID:
On Thu, 4 May 2023 17:48:28 GMT, Aggelos Biboudis wrote:
>> This PR implements [JEP 443](https://openjdk.org/jeps/443), the preview feature for Unnamed Patterns and Variables in Java.
>>
>> Draft Spec: https://cr.openjdk.org/~abimpoudis/unnamed/latest/
>
> Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision:
>
> Add test
src/jdk.compiler/share/classes/com/sun/tools/javac/model/JavacElements.java line 88:
> 86: * or deletion without notice.
> 87: */
> 88: @SuppressWarnings("preview")
isn't it better to apply the annotation to the method below?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13528#discussion_r1185463034
From darcy at openjdk.org Thu May 4 20:50:28 2023
From: darcy at openjdk.org (Joe Darcy)
Date: Thu, 4 May 2023 20:50:28 GMT
Subject: RFR: 8302344: Compiler Implementation for Unnamed patterns and
variables (Preview) [v13]
In-Reply-To: <7x1mAOBwhQdGgCaHjiOQ1O9BCmgJFKASy7yFJHsGVbI=.842ee2fe-8819-4e43-935a-120303815fd5@github.com>
References:
<7x1mAOBwhQdGgCaHjiOQ1O9BCmgJFKASy7yFJHsGVbI=.842ee2fe-8819-4e43-935a-120303815fd5@github.com>
Message-ID: <2f6yNQHJy1t65PBsSelcHM2episYeYxt7gdYtQV1Zsc=.ff0f7299-3378-496d-ad92-0ed1cbdf90e8@github.com>
On Thu, 4 May 2023 17:48:28 GMT, Aggelos Biboudis wrote:
>> This PR implements [JEP 443](https://openjdk.org/jeps/443), the preview feature for Unnamed Patterns and Variables in Java.
>>
>> Draft Spec: https://cr.openjdk.org/~abimpoudis/unnamed/latest/
>
> Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision:
>
> Add test
src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java line 438:
> 436: }
> 437:
> 438: public boolean isUnnamed() {
Should this method get the '@Override @DefinedBy(Api.LANGUAGE_MODEL)' markup?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13528#discussion_r1185497754
From mcimadamore at openjdk.org Thu May 4 20:53:32 2023
From: mcimadamore at openjdk.org (Maurizio Cimadamore)
Date: Thu, 4 May 2023 20:53:32 GMT
Subject: RFR: JDK-8306112 Implementation of JEP 445: Unnamed Classes and
Instance Main Methods (Preview) [v8]
In-Reply-To:
References:
Message-ID: <2yJRhrPzbNeYBsrEdaC6xv3ng7kv5LI9IEP20zkoUgc=.b38576ed-a819-404b-9cea-b78b65e24b04@github.com>
On Mon, 1 May 2023 13:06:24 GMT, Jim Laskey wrote:
>> Add flexible main methods and anonymous main classes to the Java language.
>
> Jim Laskey has updated the pull request incrementally with two additional commits since the last revision:
>
> - Anonymous main classes renamed to unnamed classes
> - Add test
The compiler changes look good - I like howthe code got simpler by adding the main class wrapper at parser time. As I suggested elsewhere, do we want to change `Pretty` so that the AST of an unnamed class is rendered like if the unnamed class wasn't there (e.g. so that the output is like the source where the AST comes from) ?
-------------
Marked as reviewed by mcimadamore (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/13689#pullrequestreview-1413902695
From james.laskey at oracle.com Thu May 4 20:56:22 2023
From: james.laskey at oracle.com (Jim Laskey)
Date: Thu, 4 May 2023 20:56:22 +0000
Subject: RFR: JDK-8306112 Implementation of JEP 445: Unnamed Classes and
Instance Main Methods (Preview) [v8]
In-Reply-To: <2yJRhrPzbNeYBsrEdaC6xv3ng7kv5LI9IEP20zkoUgc=.b38576ed-a819-404b-9cea-b78b65e24b04@github.com>
References:
<2yJRhrPzbNeYBsrEdaC6xv3ng7kv5LI9IEP20zkoUgc=.b38576ed-a819-404b-9cea-b78b65e24b04@github.com>
Message-ID:
I suppose that?s a possibility. But is it more informative to have the class print with the synthetic flag?
?
> On May 4, 2023, at 5:54 PM, Maurizio Cimadamore wrote:
>
> ?On Mon, 1 May 2023 13:06:24 GMT, Jim Laskey wrote:
>
>>> Add flexible main methods and anonymous main classes to the Java language.
>>
>> Jim Laskey has updated the pull request incrementally with two additional commits since the last revision:
>>
>> - Anonymous main classes renamed to unnamed classes
>> - Add test
>
> The compiler changes look good - I like howthe code got simpler by adding the main class wrapper at parser time. As I suggested elsewhere, do we want to change `Pretty` so that the AST of an unnamed class is rendered like if the unnamed class wasn't there (e.g. so that the output is like the source where the AST comes from) ?
>
> -------------
>
> Marked as reviewed by mcimadamore (Reviewer).
>
> PR Review: https://git.openjdk.org/jdk/pull/13689#pullrequestreview-1413902695
From darcy at openjdk.org Thu May 4 21:00:25 2023
From: darcy at openjdk.org (Joe Darcy)
Date: Thu, 4 May 2023 21:00:25 GMT
Subject: RFR: 8302344: Compiler Implementation for Unnamed patterns and
variables (Preview) [v13]
In-Reply-To: <7x1mAOBwhQdGgCaHjiOQ1O9BCmgJFKASy7yFJHsGVbI=.842ee2fe-8819-4e43-935a-120303815fd5@github.com>
References:
<7x1mAOBwhQdGgCaHjiOQ1O9BCmgJFKASy7yFJHsGVbI=.842ee2fe-8819-4e43-935a-120303815fd5@github.com>
Message-ID:
On Thu, 4 May 2023 17:48:28 GMT, Aggelos Biboudis wrote:
>> This PR implements [JEP 443](https://openjdk.org/jeps/443), the preview feature for Unnamed Patterns and Variables in Java.
>>
>> Draft Spec: https://cr.openjdk.org/~abimpoudis/unnamed/latest/
>
> Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision:
>
> Add test
src/java.compiler/share/classes/javax/lang/model/element/VariableElement.java line 114:
> 112: */
> 113: @PreviewFeature(feature=PreviewFeature.Feature.UNNAMED, reflective = true)
> 114: default boolean isUnnamed() { return false; }
Looking at the various sources more closely, I'll revise my previous guidance and recommend the default method be defined as:
return getSimpleName().isEmpty()
which would also avoid the strict need to override the method in Symbol.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13528#discussion_r1185505824
From darcy at openjdk.org Thu May 4 21:06:23 2023
From: darcy at openjdk.org (Joe Darcy)
Date: Thu, 4 May 2023 21:06:23 GMT
Subject: RFR: 8302344: Compiler Implementation for Unnamed patterns and
variables (Preview) [v13]
In-Reply-To: <7x1mAOBwhQdGgCaHjiOQ1O9BCmgJFKASy7yFJHsGVbI=.842ee2fe-8819-4e43-935a-120303815fd5@github.com>
References:
<7x1mAOBwhQdGgCaHjiOQ1O9BCmgJFKASy7yFJHsGVbI=.842ee2fe-8819-4e43-935a-120303815fd5@github.com>
Message-ID:
On Thu, 4 May 2023 17:48:28 GMT, Aggelos Biboudis wrote:
>> This PR implements [JEP 443](https://openjdk.org/jeps/443), the preview feature for Unnamed Patterns and Variables in Java.
>>
>> Draft Spec: https://cr.openjdk.org/~abimpoudis/unnamed/latest/
>
> Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision:
>
> Add test
src/java.compiler/share/classes/javax/lang/model/util/Elements.java line 724:
> 722: @PreviewFeature(feature=PreviewFeature.Feature.UNNAMED, reflective = true)
> 723: default boolean isUnnamed(Element element) {
> 724: return false;
Analogous suggestion to switch to "return element.getSimpleName().isEmpty();"
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13528#discussion_r1185512905
From jjg at openjdk.org Thu May 4 21:29:25 2023
From: jjg at openjdk.org (Jonathan Gibbons)
Date: Thu, 4 May 2023 21:29:25 GMT
Subject: RFR: 8278856: javac documentation does not mention use of Manifest
class-path attribute
In-Reply-To: <6gqOqSCzzzxD0yCWh2lId3KzuEi9yL7ljb_2H3GOR98=.68fcd605-0e49-4da6-9026-602d330f842e@github.com>
References:
<6gqOqSCzzzxD0yCWh2lId3KzuEi9yL7ljb_2H3GOR98=.68fcd605-0e49-4da6-9026-602d330f842e@github.com>
Message-ID:
On Wed, 3 May 2023 01:34:23 GMT, Archie Cobbs wrote:
>> JAR files appearing in `--class-path` are implicitly scanned for manifest `Class-Path` attributes, but this behavior is not documented.
>>
>> This patch adds a blurb to the `javac(1)` man page.
>
> /?
@archiecobbs
Regrettably, this is *not* the way/place to document this.
The true source of the man page is upstream in an internal repo. The `.1` file here is a derived file that will get overridden.
See this hint at the top of the file:
> ." Automatically generated by Pandoc 2.19.2
The edit needs to be applied by an Oracle engineer with access to the upstream source. (Sorry about this.)
-------------
PR Comment: https://git.openjdk.org/jdk/pull/13332#issuecomment-1535433900
From acobbs at openjdk.org Thu May 4 21:40:21 2023
From: acobbs at openjdk.org (Archie Cobbs)
Date: Thu, 4 May 2023 21:40:21 GMT
Subject: RFR: 8278856: javac documentation does not mention use of Manifest
class-path attribute
In-Reply-To:
References:
<6gqOqSCzzzxD0yCWh2lId3KzuEi9yL7ljb_2H3GOR98=.68fcd605-0e49-4da6-9026-602d330f842e@github.com>
Message-ID:
On Thu, 4 May 2023 21:24:45 GMT, Jonathan Gibbons wrote:
> The true source of the man page is upstream in an internal repo.
Ah, got it - thanks for the heads-up. Not my problem then :)
-------------
PR Comment: https://git.openjdk.org/jdk/pull/13332#issuecomment-1535444786
From acobbs at openjdk.org Thu May 4 21:40:23 2023
From: acobbs at openjdk.org (Archie Cobbs)
Date: Thu, 4 May 2023 21:40:23 GMT
Subject: Withdrawn: 8278856: javac documentation does not mention use of
Manifest class-path attribute
In-Reply-To:
References:
Message-ID:
On Tue, 4 Apr 2023 17:45:12 GMT, Archie Cobbs wrote:
> JAR files appearing in `--class-path` are implicitly scanned for manifest `Class-Path` attributes, but this behavior is not documented.
>
> This patch adds a blurb to the `javac(1)` man page.
This pull request has been closed without being integrated.
-------------
PR: https://git.openjdk.org/jdk/pull/13332
From darcy at openjdk.org Thu May 4 21:43:22 2023
From: darcy at openjdk.org (Joe Darcy)
Date: Thu, 4 May 2023 21:43:22 GMT
Subject: RFR: 8302344: Compiler Implementation for Unnamed patterns and
variables (Preview) [v12]
In-Reply-To:
References:
Message-ID:
On Thu, 4 May 2023 19:58:37 GMT, Joe Darcy wrote:
>> We could indeed if we wanted to store `empty` everywhere. However, after some off-list discussions I updated the CSR (and the code) to include `empty` as the name at the symbol-level (for consistency with javax model) and `_` at the Tree API-level for its version of a name. This is the rationale behind what you see in Attr (for patterns) and member enter for all other cases. @jddarcy what do you think?
>
>>
>
> In terms of pretty printing, src/jdk.compiler/share/classes/com/sun/tools/javac/processing/PrintingProcessor.java may need to be updated too.
>
For the user-facing javax.lang.model languages, I think the current convention of "empty name means unnamed" is reasonable and is consistent with how other unnamed items are handled in that API.
I assumed for the lower-level tree API "_" would be a more appropriate choice, but I'm open to discussions alternative conventions there.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13528#discussion_r1185544462
From vromero at openjdk.org Thu May 4 22:04:20 2023
From: vromero at openjdk.org (Vicente Romero)
Date: Thu, 4 May 2023 22:04:20 GMT
Subject: RFR: 8302344: Compiler Implementation for Unnamed patterns and
variables (Preview) [v13]
In-Reply-To: <7x1mAOBwhQdGgCaHjiOQ1O9BCmgJFKASy7yFJHsGVbI=.842ee2fe-8819-4e43-935a-120303815fd5@github.com>
References:
<7x1mAOBwhQdGgCaHjiOQ1O9BCmgJFKASy7yFJHsGVbI=.842ee2fe-8819-4e43-935a-120303815fd5@github.com>
Message-ID: <4dcjzbL_QNyX1L-n4dCOlV6ZvWQBsnrlqbHhDEku8jg=.0c82bcea-6c43-45c5-9e4b-f64aa914bc59@github.com>
On Thu, 4 May 2023 17:48:28 GMT, Aggelos Biboudis wrote:
>> This PR implements [JEP 443](https://openjdk.org/jeps/443), the preview feature for Unnamed Patterns and Variables in Java.
>>
>> Draft Spec: https://cr.openjdk.org/~abimpoudis/unnamed/latest/
>
> Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision:
>
> Add test
src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeCopier.java line 496:
> 494: @DefinedBy(Api.COMPILER_TREE)
> 495: public JCTree visitAnyPattern(AnyPatternTree node, P p) {
> 496: JCBindingPattern t = (JCBindingPattern) node;
not sure this is correct, are we returning a JCBindingPattern?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13528#discussion_r1185555175
From vromero at openjdk.org Thu May 4 22:08:24 2023
From: vromero at openjdk.org (Vicente Romero)
Date: Thu, 4 May 2023 22:08:24 GMT
Subject: RFR: 8302344: Compiler Implementation for Unnamed patterns and
variables (Preview) [v13]
In-Reply-To: <7x1mAOBwhQdGgCaHjiOQ1O9BCmgJFKASy7yFJHsGVbI=.842ee2fe-8819-4e43-935a-120303815fd5@github.com>
References:
<7x1mAOBwhQdGgCaHjiOQ1O9BCmgJFKASy7yFJHsGVbI=.842ee2fe-8819-4e43-935a-120303815fd5@github.com>
Message-ID:
On Thu, 4 May 2023 17:48:28 GMT, Aggelos Biboudis wrote:
>> This PR implements [JEP 443](https://openjdk.org/jeps/443), the preview feature for Unnamed Patterns and Variables in Java.
>>
>> Draft Spec: https://cr.openjdk.org/~abimpoudis/unnamed/latest/
>
> Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision:
>
> Add test
test/langtools/tools/javac/patterns/Unnamed.java line 4:
> 2:
> 3: /**
> 4: * @test /nodynamiccopyright/
there is no golden file for this test so full copyright will be needed
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13528#discussion_r1185559074
From abimpoudis at openjdk.org Thu May 4 23:28:29 2023
From: abimpoudis at openjdk.org (Aggelos Biboudis)
Date: Thu, 4 May 2023 23:28:29 GMT
Subject: RFR: 8302344: Compiler Implementation for Unnamed patterns and
variables (Preview) [v14]
In-Reply-To:
References:
Message-ID:
> This PR implements [JEP 443](https://openjdk.org/jeps/443), the preview feature for Unnamed Patterns and Variables in Java.
>
> Draft Spec: https://cr.openjdk.org/~abimpoudis/unnamed/latest/
Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision:
8307482: Compiler should accept var _ in nested patterns in switch case
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/13528/files
- new: https://git.openjdk.org/jdk/pull/13528/files/ffae4e0e..888297ef
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=13528&range=13
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=13528&range=12-13
Stats: 49 lines in 4 files changed: 35 ins; 0 del; 14 mod
Patch: https://git.openjdk.org/jdk/pull/13528.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/13528/head:pull/13528
PR: https://git.openjdk.org/jdk/pull/13528
From abimpoudis at openjdk.org Thu May 4 23:28:29 2023
From: abimpoudis at openjdk.org (Aggelos Biboudis)
Date: Thu, 4 May 2023 23:28:29 GMT
Subject: RFR: 8302344: Compiler Implementation for Unnamed patterns and
variables (Preview) [v12]
In-Reply-To:
References:
Message-ID: <_2IbNlxLzlbXs3UkPWmrTTuMVRsvTnHnX4JqN35kbPU=.e1053192-5d69-4b31-b1d0-8bfa12adefda@github.com>
On Thu, 4 May 2023 21:40:38 GMT, Joe Darcy wrote:
>>>
>>
>> In terms of pretty printing, src/jdk.compiler/share/classes/com/sun/tools/javac/processing/PrintingProcessor.java may need to be updated too.
>
>>
>
> For the user-facing javax.lang.model languages, I think the current convention of "empty name means unnamed" is reasonable and is consistent with how other unnamed items are handled in that API.
>
> I assumed for the lower-level tree API "_" would be a more appropriate choice, but I'm open to discussions alternative conventions there.
Recently, I realized that `names.empty` also signifies an error in `variableDeclaratorId` in some occasion around lambdas: https://github.com/openjdk/jdk/blob/ffae4e0e97b19b1c1ad2865ed618ba380a861b7e/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java#L3688-L3697
I don't believe that this would be a blocker but it could pose a possible minor challenge.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13528#discussion_r1185595137
From jlahoda at openjdk.org Fri May 5 06:14:45 2023
From: jlahoda at openjdk.org (Jan Lahoda)
Date: Fri, 5 May 2023 06:14:45 GMT
Subject: RFR: 8300543 Compiler Implementation for Pattern Matching for
switch [v9]
In-Reply-To:
References:
Message-ID:
> This is the first draft of a patch for JEP 440 and JEP 441. Changes included:
>
> - the pattern matching for switch and record patterns features are made final, together with updates to tests.
> - parenthesized patterns are removed.
> - qualified enum constants are supported for case labels.
>
> This change herein also includes removal record patterns in for each loop, which may be split into a separate PR in the future.
Jan Lahoda has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 42 commits:
- Updating MatchException javadoc.
- Merge branch 'master' into JDK-8300543
- Reverting use of record patterns in enhanced for loop.
- Cleanup: reflecting review feedback.
- Merge branch 'master' into JDK-8300543
- Reflecting review changes.
- Adding test.
- Removing redundant continue, as noted on the review.
- Replacing use of mutable callsite with a mutable state.
- Reflecting review feedback.
- ... and 32 more: https://git.openjdk.org/jdk/compare/a87262ef...79bbd717
-------------
Changes: https://git.openjdk.org/jdk/pull/13074/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=13074&range=08
Stats: 4262 lines in 159 files changed: 2025 ins; 1722 del; 515 mod
Patch: https://git.openjdk.org/jdk/pull/13074.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/13074/head:pull/13074
PR: https://git.openjdk.org/jdk/pull/13074
From abimpoudis at openjdk.org Fri May 5 08:44:23 2023
From: abimpoudis at openjdk.org (Aggelos Biboudis)
Date: Fri, 5 May 2023 08:44:23 GMT
Subject: RFR: 8302344: Compiler Implementation for Unnamed patterns and
variables (Preview) [v13]
In-Reply-To:
References:
<7x1mAOBwhQdGgCaHjiOQ1O9BCmgJFKASy7yFJHsGVbI=.842ee2fe-8819-4e43-935a-120303815fd5@github.com>
Message-ID:
On Thu, 4 May 2023 20:04:49 GMT, Vicente Romero wrote:
>> Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Add test
>
> src/jdk.compiler/share/classes/com/sun/tools/javac/model/JavacElements.java line 88:
>
>> 86: * or deletion without notice.
>> 87: */
>> 88: @SuppressWarnings("preview")
>
> isn't it better to apply the annotation to the method below?
Yeap, this is what I thought at first but I was getting "warnings found and -Werror specified". So compilation was failing.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13528#discussion_r1185840546
From jlahoda at openjdk.org Fri May 5 09:29:35 2023
From: jlahoda at openjdk.org (Jan Lahoda)
Date: Fri, 5 May 2023 09:29:35 GMT
Subject: RFR: 8302344: Compiler Implementation for Unnamed patterns and
variables (Preview) [v14]
In-Reply-To:
References:
Message-ID: <3eNbxZ47pN094c130bnXzkaRcts92buDBG_EPBM4DJg=.3d354d72-17c5-4f5f-8c78-2166e56455c6@github.com>
On Thu, 4 May 2023 23:28:29 GMT, Aggelos Biboudis wrote:
>> This PR implements [JEP 443](https://openjdk.org/jeps/443), the preview feature for Unnamed Patterns and Variables in Java.
>>
>> Draft Spec: https://cr.openjdk.org/~abimpoudis/unnamed/latest/
>
> Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision:
>
> 8307482: Compiler should accept var _ in nested patterns in switch case
src/jdk.compiler/share/classes/com/sun/source/tree/AnyPatternTree.java line 32:
> 30: *
> 31: */
> 32: public interface AnyPatternTree extends PatternTree {
`@PreviewFeature` here.
src/jdk.compiler/share/classes/com/sun/source/tree/Tree.java line 227:
> 225: * @since 21
> 226: */
> 227: ANY_PATTERN(AnyPatternTree.class),
@PreviewFeature here.
src/jdk.compiler/share/classes/com/sun/source/tree/TreeVisitor.java line 267:
> 265: * @since 21
> 266: */
> 267: R visitAnyPattern(AnyPatternTree node, P p);
@PreviewFeature here.
src/jdk.compiler/share/classes/com/sun/source/util/SimpleTreeVisitor.java line 641:
> 639: */
> 640: @Override
> 641: public R visitAnyPattern(AnyPatternTree node, P p) {
`@PreviewFeature` here.
src/jdk.compiler/share/classes/com/sun/source/util/TreeScanner.java line 773:
> 771: */
> 772: @Override
> 773: public R visitAnyPattern(AnyPatternTree node, P p) {
`@PreviewFeature` here.
src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransPatterns.java line 329:
> 327: nestedBinding = nestedDesugared.primaryPattern();
> 328: allowNull = false;
> 329: } else if (nestedPattern instanceof JCAnyPattern nestedRecordPattern) {
Nit: `nestedRecordPattern` -> `nestedAnyPattern`?
test/langtools/tools/javac/patterns/Unnamed.java line 8:
> 6: * @summary Compiler Implementation for Unnamed patterns and variables
> 7: * @enablePreview
> 8: * @compile --enable-preview -source ${jdk.version} Unnamed.java
+1 on keeping the `@compile` tag, but `--enable-preview -source ${jdk.version}` shouldn't be needed when `@enablePreview` is present.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13528#discussion_r1185805923
PR Review Comment: https://git.openjdk.org/jdk/pull/13528#discussion_r1185807097
PR Review Comment: https://git.openjdk.org/jdk/pull/13528#discussion_r1185807170
PR Review Comment: https://git.openjdk.org/jdk/pull/13528#discussion_r1185807989
PR Review Comment: https://git.openjdk.org/jdk/pull/13528#discussion_r1185808102
PR Review Comment: https://git.openjdk.org/jdk/pull/13528#discussion_r1185819402
PR Review Comment: https://git.openjdk.org/jdk/pull/13528#discussion_r1185871609
From jlahoda at openjdk.org Fri May 5 09:29:40 2023
From: jlahoda at openjdk.org (Jan Lahoda)
Date: Fri, 5 May 2023 09:29:40 GMT
Subject: RFR: 8302344: Compiler Implementation for Unnamed patterns and
variables (Preview) [v13]
In-Reply-To:
References:
<7x1mAOBwhQdGgCaHjiOQ1O9BCmgJFKASy7yFJHsGVbI=.842ee2fe-8819-4e43-935a-120303815fd5@github.com>
Message-ID: <4GXVg3R1xzO-tFQenVIh_6FGWvSeXUfs5-17WDaM6m0=.ab0ae8c0-9fd0-4f2d-aade-d841f8fbece7@github.com>
On Thu, 4 May 2023 17:56:37 GMT, Vicente Romero wrote:
>> Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Add test
>
> src/jdk.compiler/share/classes/com/sun/source/tree/VariableTree.java line 54:
>
>> 52:
>> 53: /**
>> 54: * Returns the name of the variable being declared or `_` if the variable
>
> I guess if we go full for the empty name then this will need to change too
Maybe also add a mention that unnamed is a preview feature?
> src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransPatterns.java line 535:
>
>> 533: if (clearedPatterns.size() > 1) {
>> 534: validCaseLabelList = clearedPatterns.stream().allMatch(cP -> cP.hasTag(Tag.PATTERNCASELABEL));
>> 535: } else validCaseLabelList = clearedPatterns.size() == 1 && clearedPatterns.head.hasTag(Tag.PATTERNCASELABEL);
>
> style: I would use `{}` for the code in the `else` branch here, same way as it has been done for the `then` branch. Also in the `else` branch isn't the `clearedPatterns.size() == 1` condition always true?
True - if I read the code correctly, the list should never be empty at this place.
> src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeCopier.java line 496:
>
>> 494: @DefinedBy(Api.COMPILER_TREE)
>> 495: public JCTree visitAnyPattern(AnyPatternTree node, P p) {
>> 496: JCBindingPattern t = (JCBindingPattern) node;
>
> not sure this is correct, are we returning a JCBindingPattern?
+1
> test/langtools/tools/javac/patterns/Unnamed.java line 4:
>
>> 2:
>> 3: /**
>> 4: * @test /nodynamiccopyright/
>
> there is no golden file for this test so full copyright will be needed
Also, it is a custom that the comment with `@test` is before any imports, AFAIK.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13528#discussion_r1185807820
PR Review Comment: https://git.openjdk.org/jdk/pull/13528#discussion_r1185823113
PR Review Comment: https://git.openjdk.org/jdk/pull/13528#discussion_r1185870099
PR Review Comment: https://git.openjdk.org/jdk/pull/13528#discussion_r1185871058
From jlahoda at openjdk.org Fri May 5 09:29:49 2023
From: jlahoda at openjdk.org (Jan Lahoda)
Date: Fri, 5 May 2023 09:29:49 GMT
Subject: RFR: 8302344: Compiler Implementation for Unnamed patterns and
variables (Preview) [v12]
In-Reply-To: <_2IbNlxLzlbXs3UkPWmrTTuMVRsvTnHnX4JqN35kbPU=.e1053192-5d69-4b31-b1d0-8bfa12adefda@github.com>
References:
<_2IbNlxLzlbXs3UkPWmrTTuMVRsvTnHnX4JqN35kbPU=.e1053192-5d69-4b31-b1d0-8bfa12adefda@github.com>
Message-ID: <0lJobZbHgtHyGKnoyvKcj8COkObRQo448AlEJxwIzIw=.5061dc4b-0900-4e6c-a36a-93c444c3effd@github.com>
On Thu, 4 May 2023 23:19:26 GMT, Aggelos Biboudis wrote:
>>>
>>
>> For the user-facing javax.lang.model languages, I think the current convention of "empty name means unnamed" is reasonable and is consistent with how other unnamed items are handled in that API.
>>
>> I assumed for the lower-level tree API "_" would be a more appropriate choice, but I'm open to discussions alternative conventions there.
>
> Recently, I realized that `names.empty` also signifies an error in `variableDeclaratorId` in some occasion around lambdas: https://github.com/openjdk/jdk/blob/ffae4e0e97b19b1c1ad2865ed618ba380a861b7e/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java#L3688-L3697
> I don't believe that this would be a blocker but it could pose a possible minor challenge.
FWIW, I don't have a strong opinion on whether the name in the AST should be empty or underscore. (But I agree empty name is more consistent in the Language Model.) For missing names where names are expected (which is the above case), we could revisit later, there are more cases like this.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13528#discussion_r1185869588
From jlahoda at openjdk.org Fri May 5 09:29:47 2023
From: jlahoda at openjdk.org (Jan Lahoda)
Date: Fri, 5 May 2023 09:29:47 GMT
Subject: RFR: 8302344: Compiler Implementation for Unnamed patterns and
variables (Preview) [v13]
In-Reply-To:
References:
<7x1mAOBwhQdGgCaHjiOQ1O9BCmgJFKASy7yFJHsGVbI=.842ee2fe-8819-4e43-935a-120303815fd5@github.com>
Message-ID:
On Fri, 5 May 2023 08:41:08 GMT, Aggelos Biboudis wrote:
>> src/jdk.compiler/share/classes/com/sun/tools/javac/model/JavacElements.java line 88:
>>
>>> 86: * or deletion without notice.
>>> 87: */
>>> 88: @SuppressWarnings("preview")
>>
>> isn't it better to apply the annotation to the method below?
>
> Yeap, this is what I thought at first but I was getting "warnings found and -Werror specified". So compilation was failing.
IIRC the error is reported on the class level (with position on the class), so suppressing the warning on the method is not sufficient. We might want to review if the warning could have a better position, but we probably should not do it under this patch.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13528#discussion_r1185855689
From jlahoda at openjdk.org Fri May 5 09:29:42 2023
From: jlahoda at openjdk.org (Jan Lahoda)
Date: Fri, 5 May 2023 09:29:42 GMT
Subject: RFR: 8302344: Compiler Implementation for Unnamed patterns and
variables (Preview) [v13]
In-Reply-To: <2f6yNQHJy1t65PBsSelcHM2episYeYxt7gdYtQV1Zsc=.ff0f7299-3378-496d-ad92-0ed1cbdf90e8@github.com>
References:
<7x1mAOBwhQdGgCaHjiOQ1O9BCmgJFKASy7yFJHsGVbI=.842ee2fe-8819-4e43-935a-120303815fd5@github.com>
<2f6yNQHJy1t65PBsSelcHM2episYeYxt7gdYtQV1Zsc=.ff0f7299-3378-496d-ad92-0ed1cbdf90e8@github.com>
Message-ID: <8fbux7W7kkd8KYN9Z6ks6IHYdtrFIPhQPTZ6lI816tw=.156e8b6d-0b18-4690-9f5a-21bbbca30bc5@github.com>
On Thu, 4 May 2023 20:47:54 GMT, Joe Darcy wrote:
>> Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Add test
>
> src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java line 438:
>
>> 436: }
>> 437:
>> 438: public boolean isUnnamed() {
>
> Should this method get the '@Override @DefinedBy(Api.LANGUAGE_MODEL)' markup?
+1 (I am a bit surprised the tests don't complain, that might be something to look at as well)
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13528#discussion_r1185809422
From jlahoda at openjdk.org Fri May 5 09:29:44 2023
From: jlahoda at openjdk.org (Jan Lahoda)
Date: Fri, 5 May 2023 09:29:44 GMT
Subject: RFR: 8302344: Compiler Implementation for Unnamed patterns and
variables (Preview) [v4]
In-Reply-To:
References:
Message-ID:
On Mon, 1 May 2023 22:29:21 GMT, Aggelos Biboudis wrote:
>> src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java line 1777:
>>
>>> 1775: log.error(guard.pos(), Errors.GuardHasConstantExpressionFalse);
>>> 1776: }
>>> 1777: } else if (guard != null) {
>>
>> I guess this is caused by something like:
>>
>> case _ when ...
>>
>> If now a guard can appear regardless of how many labels there are, should be refactor this code so that if `guard != null` it is always attributed? And then we do other stuff in case `labels.tail.isEmpty()` ? Note that the code for attributing the guard is slightly different in the two cases in this patch: the original code creates a nested scope - while the new code doesn't.
>
> Actually this is for the case where we have `case A(_), B(C _) when ... `. In that case we are sure that the only scope we can use is the switch environment (since no bindings are introduced). Hm, I don't see another way of refactoring this without depending on `labels.tail.isEmpty()`
I was looking into this again, and I am afraid this is not quite correct. One of the issues is that this attrib will place any binding variables from the guard into the current `matchBindings`, and when the guard is attributed again, the variables in the `matchBindings` will collide. For example:
String unnamedGuardAddsBindings(Object o1, Object o2) {
return switch (o1) {
case String _, Object _ when o2 instanceof String s: yield s;
case Object _: yield "any";
};
}
My current proposal would be to (try to):
- attribute the guard when handling the first pattern (so that we can detect whether or not it is constant)
- but, do not merge the bindings from the guard immediately, but only after all the patterns are handled
It could look like this:
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java
index e9c3ca27f1c..bade6b530eb 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java
@@ -1688,7 +1688,7 @@ public class Attr extends JCTree.Visitor {
wasError = true;
}
MatchBindings currentBindings = null;
- boolean wasUnconditionalPattern = hasUnconditionalPattern;
+ MatchBindings guardBindings = null;
for (List labels = c.labels; labels.nonEmpty(); labels = labels.tail) {
JCCaseLabel label = labels.head;
if (label instanceof JCConstantCaseLabel constLabel) {
@@ -1761,7 +1761,7 @@ public class Attr extends JCTree.Visitor {
checkCastablePattern(pat.pos(), seltype, primaryType);
Type patternType = types.erasure(primaryType);
JCExpression guard = c.guard;
- if (labels.tail.isEmpty() && guard != null) {
+ if (labels == c.labels && guard != null) {
MatchBindings afterPattern = matchBindings;
Env bodyEnv = bindingEnv(switchEnv, matchBindings.bindingsWhenTrue);
try {
@@ -1769,14 +1769,13 @@ public class Attr extends JCTree.Visitor {
} finally {
bodyEnv.info.scope.leave();
}
- matchBindings = matchBindingsComputer.caseGuard(c, afterPattern, matchBindings);
+
+ guardBindings = matchBindings;
+ matchBindings = afterPattern;
if (TreeInfo.isBooleanWithValue(guard, 0)) {
log.error(guard.pos(), Errors.GuardHasConstantExpressionFalse);
}
- } else if (guard != null) {
- // if the label has multiple patterns and a guard (with binding from the switch environment)
- attribExpr(guard, switchEnv, syms.booleanType);
}
boolean unguarded = TreeInfo.unguardedCase(c) && !pat.hasTag(RECORDPATTERN);
boolean unconditional =
@@ -1799,6 +1798,10 @@ public class Attr extends JCTree.Visitor {
currentBindings = matchBindingsComputer.switchCase(label, currentBindings, matchBindings);
}
+ if (guardBindings != null) {
+ currentBindings = matchBindingsComputer.caseGuard(c, currentBindings, guardBindings);
+ }
+
Env caseEnv =
bindingEnv(switchEnv, c, currentBindings.bindingsWhenTrue);
try {
(I didn't run tests on this, though.)
>> src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java line 746:
>>
>>> 744:
>>> 745: sealed interface PatternDescription {
>>> 746: public static PatternDescription from(Types types, Type selectorType, JCPattern pattern, Symtab syms) {
>>
>> Optional comment: the fact that this factory needs so much compiler state makes me think that perhaps a better place for it would be as an instance method of Flow, rather than a static method in PatternDescription.
>
> @lahodaj WDYT? Looks like it can be easily refactored and it is used only in one place (apart from the recursive call). I can refactor it in this PR or u can do it in #13074.
I somewhat liked the "factory method" aspect to this, but I admit the parameter list is getting longer. So, up to you, I think.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13528#discussion_r1185881273
PR Review Comment: https://git.openjdk.org/jdk/pull/13528#discussion_r1185817955
From jpai at openjdk.org Fri May 5 09:33:22 2023
From: jpai at openjdk.org (Jaikiran Pai)
Date: Fri, 5 May 2023 09:33:22 GMT
Subject: RFR: JDK-8306112 Implementation of JEP 445: Unnamed Classes and
Instance Main Methods (Preview) [v8]
In-Reply-To:
References:
Message-ID:
On Mon, 1 May 2023 13:06:24 GMT, Jim Laskey wrote:
>> Add flexible main methods and anonymous main classes to the Java language.
>
> Jim Laskey has updated the pull request incrementally with two additional commits since the last revision:
>
> - Anonymous main classes renamed to unnamed classes
> - Add test
src/java.base/share/classes/jdk/internal/misc/MainMethodFinder.java line 139:
> 137: public static Method findMainMethod(Class> mainClass) throws NoSuchMethodException {
> 138: try {
> 139: Method mainMethod = mainClass.getMethod("main", String[].class);
Hello Jim, I think this specific line is trying to find a `public static void main(String[])` method from the launched class. In the current form of this implementation, this has the potential of returning a non-static `public void main(String[])` from here. I think a `isStatic(mainMethod)` would be needed here before returning this method as the found method.
src/java.base/share/classes/jdk/internal/misc/MainMethodFinder.java line 142:
> 140:
> 141: if (mainMethod.getDeclaringClass() != mainClass) {
> 142: System.err.println("WARNING: static main in super class will be deprecated.");
Similarly, this warning would have to be logged only if the method is `static`. Furthermore, do you think we should include the declaring class in the log message to provide some context on what's causing this warning? Something like:
> WARNING: static main(String[]) in super class foo.bar.Parent will be deprecated.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13689#discussion_r1185882851
PR Review Comment: https://git.openjdk.org/jdk/pull/13689#discussion_r1185885497
From jpai at openjdk.org Fri May 5 09:42:23 2023
From: jpai at openjdk.org (Jaikiran Pai)
Date: Fri, 5 May 2023 09:42:23 GMT
Subject: RFR: JDK-8306112 Implementation of JEP 445: Unnamed Classes and
Instance Main Methods (Preview) [v8]
In-Reply-To:
References:
Message-ID:
On Mon, 1 May 2023 13:06:24 GMT, Jim Laskey wrote:
>> Add flexible main methods and anonymous main classes to the Java language.
>
> Jim Laskey has updated the pull request incrementally with two additional commits since the last revision:
>
> - Anonymous main classes renamed to unnamed classes
> - Add test
src/java.base/share/classes/jdk/internal/misc/MainMethodFinder.java line 152:
> 150:
> 151: List mains = new ArrayList<>();
> 152: gatherMains(mainClass, mainClass, mains);
The `try` block above is there to find `public static void main(String[])` in the launched class. When it's not found, then we gather the potential main methods (as listed in the JEP). The implementation of `gatherMains(...)`, in its current form starts gathering the main methods from `refc.getSuperclass()`, where `refc` in this case is the `mainClass`, which is the launched class.
So if I'm reading this correctly, then I think it's going to completely skip the launched class for looking any potential main methods and instead start looking for them in the launched class' super hierarchy.
src/java.base/share/classes/jdk/internal/misc/MainMethodFinder.java line 158:
> 156: }
> 157:
> 158: mains.sort(MainMethodFinder::compareMethods);
Perhaps skip the call to `sort` and just return the found main method if `mains.size() == 1`?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13689#discussion_r1185890136
PR Review Comment: https://git.openjdk.org/jdk/pull/13689#discussion_r1185892782
From jpai at openjdk.org Fri May 5 09:48:24 2023
From: jpai at openjdk.org (Jaikiran Pai)
Date: Fri, 5 May 2023 09:48:24 GMT
Subject: RFR: JDK-8306112 Implementation of JEP 445: Unnamed Classes and
Instance Main Methods (Preview) [v8]
In-Reply-To:
References:
Message-ID:
On Mon, 1 May 2023 13:06:24 GMT, Jim Laskey wrote:
>> Add flexible main methods and anonymous main classes to the Java language.
>
> Jim Laskey has updated the pull request incrementally with two additional commits since the last revision:
>
> - Anonymous main classes renamed to unnamed classes
> - Add test
src/java.base/share/classes/jdk/internal/misc/MainMethodFinder.java line 70:
> 68: correctArgs(method) &&
> 69: // Only statics in the declaring class
> 70: (!isStatic(method) || declc == refc)
Should this also exclude `abstract` and `native` methods named `main`?
src/java.base/share/classes/jdk/internal/misc/MainMethodFinder.java line 134:
> 132:
> 133: /**
> 134: * {@return priority main method or null if none found}
I think this javadoc is perhaps outdated? The current implementation of this method throws a `NoSuchMethodException` when it can't find any eligible main method.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13689#discussion_r1185896198
PR Review Comment: https://git.openjdk.org/jdk/pull/13689#discussion_r1185898281
From jpai at openjdk.org Fri May 5 09:55:23 2023
From: jpai at openjdk.org (Jaikiran Pai)
Date: Fri, 5 May 2023 09:55:23 GMT
Subject: RFR: JDK-8306112 Implementation of JEP 445: Unnamed Classes and
Instance Main Methods (Preview) [v8]
In-Reply-To:
References:
Message-ID:
On Mon, 1 May 2023 13:06:24 GMT, Jim Laskey wrote:
>> Add flexible main methods and anonymous main classes to the Java language.
>
> Jim Laskey has updated the pull request incrementally with two additional commits since the last revision:
>
> - Anonymous main classes renamed to unnamed classes
> - Add test
src/java.base/share/classes/sun/launcher/LauncherHelper.java line 872:
> 870: Method mainMethod = null;
> 871: try {
> 872: mainMethod = MainMethodFinder.findMainMethod(mainClass);
The `MainMethodFinder.findMainMethod(...)` throws a `NoSuchMethodException` when it can't find the regular `public static void main(String[])` or, when preview is enabled, any other eligible main methods. That will now mean that the next line here which catches a `NoSuchMethodException` can potentially end up aborting with a (very confusing) error message about JavaFX application. We should perhaps change that catch block to something like:
} catch (NoSuchMethodException nsme) {
if (!PreviewFeatures.isEnabled()) {
// invalid main or not FX application, abort with an error
abort(null, "java.launcher.cls.error4", mainClass.getName(),
JAVAFX_APPLICATION_CLASS_NAME);
} else {
// abort with something more clear error?
}
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13689#discussion_r1185905158
From jpai at openjdk.org Fri May 5 10:00:41 2023
From: jpai at openjdk.org (Jaikiran Pai)
Date: Fri, 5 May 2023 10:00:41 GMT
Subject: RFR: JDK-8306112 Implementation of JEP 445: Unnamed Classes and
Instance Main Methods (Preview) [v8]
In-Reply-To:
References:
Message-ID:
On Mon, 1 May 2023 13:06:24 GMT, Jim Laskey wrote:
>> Add flexible main methods and anonymous main classes to the Java language.
>
> Jim Laskey has updated the pull request incrementally with two additional commits since the last revision:
>
> - Anonymous main classes renamed to unnamed classes
> - Add test
src/java.base/share/classes/sun/launcher/LauncherHelper.java line 893:
> 891: * findMainMethod (above) will choose the correct method, based
> 892: * on its name and parameter type, however, we still have to
> 893: * ensure that the method is static (non-preview) and returns a void.
I think it's probably going to be easier to read and maintain if we moved these checks for `static` and `void` return type into the `MainMethodFinder.findMainMethod(...)` itself.
What I mean is once we return from the `findMainMethod(...)`, I think the callers, like this code here, shouldn't have to do additional checks to know if this main method is valid and can be used.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13689#discussion_r1185908021
From jpai at openjdk.org Fri May 5 10:10:24 2023
From: jpai at openjdk.org (Jaikiran Pai)
Date: Fri, 5 May 2023 10:10:24 GMT
Subject: RFR: JDK-8306112 Implementation of JEP 445: Unnamed Classes and
Instance Main Methods (Preview) [v8]
In-Reply-To:
References:
Message-ID: <0IFuexmcfMhpT8nlQ02H-NNhUWzOvzdyMaklwlMR93k=.c674102a-00f1-4a26-ac87-8cd121ceb10f@github.com>
On Mon, 1 May 2023 13:06:24 GMT, Jim Laskey wrote:
>> Add flexible main methods and anonymous main classes to the Java language.
>
> Jim Laskey has updated the pull request incrementally with two additional commits since the last revision:
>
> - Anonymous main classes renamed to unnamed classes
> - Add test
src/jdk.compiler/share/classes/com/sun/tools/javac/launcher/Main.java line 419:
> 417: private static boolean isStatic(Method method) {
> 418: return method != null && Modifier.isStatic(method.getModifiers());
> 419: }
It looks like these new methods aren't being used.
src/jdk.compiler/share/classes/com/sun/tools/javac/launcher/Main.java line 440:
> 438: int mods = mainMethod.getModifiers();
> 439: boolean isStatic = Modifier.isStatic(mods);
> 440: boolean isPublic = Modifier.isStatic(mods);
This looks like a typo. This should have been `Modifier.isPublic(mods);`
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13689#discussion_r1185918190
PR Review Comment: https://git.openjdk.org/jdk/pull/13689#discussion_r1185917271
From jpai at openjdk.org Fri May 5 10:18:23 2023
From: jpai at openjdk.org (Jaikiran Pai)
Date: Fri, 5 May 2023 10:18:23 GMT
Subject: RFR: JDK-8306112 Implementation of JEP 445: Unnamed Classes and
Instance Main Methods (Preview) [v8]
In-Reply-To:
References:
Message-ID:
On Mon, 1 May 2023 13:06:24 GMT, Jim Laskey wrote:
>> Add flexible main methods and anonymous main classes to the Java language.
>
> Jim Laskey has updated the pull request incrementally with two additional commits since the last revision:
>
> - Anonymous main classes renamed to unnamed classes
> - Add test
src/jdk.compiler/share/classes/com/sun/tools/javac/launcher/Main.java line 457:
> 455: if (isStatic) {
> 456: if (noArgs) {
> 457: mainMethod.invoke(appClass);
Given that `Method.invoke(...)` on a static method ignores the `obj` param that's passed to it, perhaps pass `null`?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13689#discussion_r1185924903
From jpai at openjdk.org Fri May 5 10:25:21 2023
From: jpai at openjdk.org (Jaikiran Pai)
Date: Fri, 5 May 2023 10:25:21 GMT
Subject: RFR: JDK-8306112 Implementation of JEP 445: Unnamed Classes and
Instance Main Methods (Preview) [v8]
In-Reply-To:
References:
Message-ID: <8Q_VdzphUbJgaiyTigSlBztROntOa5lz0oeMhrMcvRU=.2ce70574-d520-49be-91de-e2059c6062ce@github.com>
On Mon, 1 May 2023 13:06:24 GMT, Jim Laskey wrote:
>> Add flexible main methods and anonymous main classes to the Java language.
>
> Jim Laskey has updated the pull request incrementally with two additional commits since the last revision:
>
> - Anonymous main classes renamed to unnamed classes
> - Add test
test/jdk/tools/launcher/InstanceMainTest.java line 33:
> 31: public class InstanceMainTest extends TestHelper {
> 32:
> 33: @Test
Does this compile? I don't see imports for this annotation and this is launched as a `@run main ....`
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13689#discussion_r1185930904
From abimpoudis at openjdk.org Fri May 5 10:41:24 2023
From: abimpoudis at openjdk.org (Aggelos Biboudis)
Date: Fri, 5 May 2023 10:41:24 GMT
Subject: RFR: 8302344: Compiler Implementation for Unnamed patterns and
variables (Preview) [v13]
In-Reply-To: <8fbux7W7kkd8KYN9Z6ks6IHYdtrFIPhQPTZ6lI816tw=.156e8b6d-0b18-4690-9f5a-21bbbca30bc5@github.com>
References:
<7x1mAOBwhQdGgCaHjiOQ1O9BCmgJFKASy7yFJHsGVbI=.842ee2fe-8819-4e43-935a-120303815fd5@github.com>
<2f6yNQHJy1t65PBsSelcHM2episYeYxt7gdYtQV1Zsc=.ff0f7299-3378-496d-ad92-0ed1cbdf90e8@github.com>
<8fbux7W7kkd8KYN9Z6ks6IHYdtrFIPhQPTZ6lI816tw=.156e8b6d-0b18-4690-9f5a-21bbbca30bc5@github.com>
Message-ID:
On Fri, 5 May 2023 08:06:19 GMT, Jan Lahoda wrote:
>> src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java line 438:
>>
>>> 436: }
>>> 437:
>>> 438: public boolean isUnnamed() {
>>
>> Should this method get the '@Override @DefinedBy(Api.LANGUAGE_MODEL)' markup?
>
> +1 (I am a bit surprised the tests don't complain, that might be something to look at as well)
Note that `Element` does not declare `isUnnamed`.
`isUnnamed` overrides method in `VariableElement` (javax.lang.model.element) via subclass `VarSymbol` in `Symbol`.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13528#discussion_r1185944024
From jlaskey at openjdk.org Fri May 5 11:56:23 2023
From: jlaskey at openjdk.org (Jim Laskey)
Date: Fri, 5 May 2023 11:56:23 GMT
Subject: RFR: JDK-8306112 Implementation of JEP 445: Unnamed Classes and
Instance Main Methods (Preview) [v3]
In-Reply-To:
References:
<_6xSHusevGR4RDMupHM5YlVpM1X2CgcHmc-jtLGE3uA=.6f8f53ab-86d3-4556-a551-7530074dffc0@github.com>
Message-ID:
On Thu, 27 Apr 2023 20:51:53 GMT, Maurizio Cimadamore wrote:
>> Jim Laskey has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 14 commits:
>>
>> - Merge branch 'master' into 8306112
>> - PreviewFeatures.isEnabled()
>> - Clean up isPreview
>> - Missing exception
>> - Corrections
>> - Update VM.java
>> - Clean up testing
>> - Update TestJavacTaskScanner.java
>> - Merge branch 'master' into 8306112
>> - Clean up
>> - ... and 4 more: https://git.openjdk.org/jdk/compare/96cdf93b...53a5321d
>
> test/jdk/tools/launcher/OnrampMainTest.java line 31:
>
>> 29: * @run main OnrampMainTest
>> 30: */
>> 31: public class OnrampMainTest extends TestHelper {
>
> Should more tests be added for inherited methods?
Test added
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13689#discussion_r1186003544
From jlaskey at openjdk.org Fri May 5 15:17:23 2023
From: jlaskey at openjdk.org (Jim Laskey)
Date: Fri, 5 May 2023 15:17:23 GMT
Subject: RFR: JDK-8306112 Implementation of JEP 445: Unnamed Classes and
Instance Main Methods (Preview) [v8]
In-Reply-To:
References:
Message-ID:
On Fri, 5 May 2023 09:28:04 GMT, Jaikiran Pai wrote:
>> Jim Laskey has updated the pull request incrementally with two additional commits since the last revision:
>>
>> - Anonymous main classes renamed to unnamed classes
>> - Add test
>
> src/java.base/share/classes/jdk/internal/misc/MainMethodFinder.java line 139:
>
>> 137: public static Method findMainMethod(Class> mainClass) throws NoSuchMethodException {
>> 138: try {
>> 139: Method mainMethod = mainClass.getMethod("main", String[].class);
>
> Hello Jim, I think this specific line is trying to find a `public static void main(String[])` method from the launched class. In the current form of this implementation, this has the potential of returning a non-static `public void main(String[])` from here. I think a `isStatic(mainMethod)` would be needed here before returning this method as the found method.
The problem with modifying behaviour that has existed since JDK 1.0 is that it has to be compatible in unexpected ways. If you look at the code modification:
- mainMethod = mainClass.getMethod("main", String[].class);
+ mainMethod = MainMethodFinder.findMainMethod(mainClass);
you can see that nothing has really changed. The mainMethod was always possibly non-static and the caller produced an appropriate error message if that was the case. There is the rub. If I didn't do it the way I have, I would also have to modify 130+ tests that expect to fail with a "method is not static" message as oppose to a "method not found" error message (there are other related issues to args and return types). After spending several days wading through a handful of these ancient tests, I realized I did not have time to complete the modifications necessary before targeting. And, there is also the issue of what happens to tests and expectations downstream. For a preview feature, behaviour has to remain the same when preview is not enabled.
I was also hopeful to be able to unify the _java launcher_ and the _source code launcher_. Similar problem with error messaging, though the tests for the source code launcher are fewer and newer.
Unifying the launchers would also introduce another downstream issue. Since launching would occur from Java code, addition frames appear on the stack. Seems there are a several tests, tools and debuggers that rely on "main" being the first frame (even if hidden by printStackTrace). Ugh.
Before the next cycle, I hope to unify the messaging, have someone clean up the tests and figure out a scheme that unifies the launching.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13689#discussion_r1186216248
From jlaskey at openjdk.org Fri May 5 15:24:50 2023
From: jlaskey at openjdk.org (Jim Laskey)
Date: Fri, 5 May 2023 15:24:50 GMT
Subject: RFR: JDK-8306112 Implementation of JEP 445: Unnamed Classes and
Instance Main Methods (Preview) [v8]
In-Reply-To:
References:
Message-ID: <6Rr-jSur-o5l60DNHYg-1GoZS7LO9Fc8S9d83Zs4Q7g=.58c21be6-a3b0-48be-9fff-74ad1c1f43dd@github.com>
On Fri, 5 May 2023 09:30:54 GMT, Jaikiran Pai wrote:
>> Jim Laskey has updated the pull request incrementally with two additional commits since the last revision:
>>
>> - Anonymous main classes renamed to unnamed classes
>> - Add test
>
> src/java.base/share/classes/jdk/internal/misc/MainMethodFinder.java line 142:
>
>> 140:
>> 141: if (mainMethod.getDeclaringClass() != mainClass) {
>> 142: System.err.println("WARNING: static main in super class will be deprecated.");
>
> Similarly, this warning would have to be logged only if the method is `static`. Furthermore, do you think we should include the declaring class in the log message to provide some context on what's causing this warning? Something like:
>> WARNING: static main(String[]) in super class foo.bar.Parent will be deprecated.
Yes this is an oversight on my part.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13689#discussion_r1186223626
From jlaskey at openjdk.org Fri May 5 15:28:23 2023
From: jlaskey at openjdk.org (Jim Laskey)
Date: Fri, 5 May 2023 15:28:23 GMT
Subject: RFR: JDK-8306112 Implementation of JEP 445: Unnamed Classes and
Instance Main Methods (Preview) [v8]
In-Reply-To:
References:
Message-ID:
On Fri, 5 May 2023 09:39:07 GMT, Jaikiran Pai wrote:
>> Jim Laskey has updated the pull request incrementally with two additional commits since the last revision:
>>
>> - Anonymous main classes renamed to unnamed classes
>> - Add test
>
> src/java.base/share/classes/jdk/internal/misc/MainMethodFinder.java line 158:
>
>> 156: }
>> 157:
>> 158: mains.sort(MainMethodFinder::compareMethods);
>
> Perhaps skip the call to `sort` and just return the found main method if `mains.size() == 1`?
Likely negligible difference since it's interpreted code, but what the hey.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13689#discussion_r1186227774
From jlaskey at openjdk.org Fri May 5 15:50:26 2023
From: jlaskey at openjdk.org (Jim Laskey)
Date: Fri, 5 May 2023 15:50:26 GMT
Subject: RFR: JDK-8306112 Implementation of JEP 445: Unnamed Classes and
Instance Main Methods (Preview) [v8]
In-Reply-To:
References:
Message-ID:
On Fri, 5 May 2023 09:43:04 GMT, Jaikiran Pai wrote:
>> Jim Laskey has updated the pull request incrementally with two additional commits since the last revision:
>>
>> - Anonymous main classes renamed to unnamed classes
>> - Add test
>
> src/java.base/share/classes/jdk/internal/misc/MainMethodFinder.java line 70:
>
>> 68: correctArgs(method) &&
>> 69: // Only statics in the declaring class
>> 70: (!isStatic(method) || declc == refc)
>
> Should this also exclude `abstract` and `native` methods named `main`?
abstract would be overshadowed by its implementation and native is fair game.
> src/java.base/share/classes/jdk/internal/misc/MainMethodFinder.java line 134:
>
>> 132:
>> 133: /**
>> 134: * {@return priority main method or null if none found}
>
> I think this javadoc is perhaps outdated? The current implementation of this method throws a `NoSuchMethodException` when it can't find any eligible main method.
Changing
> src/java.base/share/classes/jdk/internal/misc/MainMethodFinder.java line 152:
>
>> 150:
>> 151: List mains = new ArrayList<>();
>> 152: gatherMains(mainClass, mainClass, mains);
>
> The `try` block above is there to find `public static void main(String[])` in the launched class. When it's not found, then we gather the potential main methods (as listed in the JEP). The implementation of `gatherMains(...)`, in its current form starts gathering the main methods from `refc.getSuperclass()`, where `refc` in this case is the `mainClass`, which is the launched class.
>
> So if I'm reading this correctly, then I think it's going to completely skip the launched class for looking any potential main methods and instead start looking for them in the launched class' super hierarchy.
It doesn't skip, it just adds the super members first. However, I should move the `gatherMains` to the end since the sort pushes the best candidate to the top and (was originally taking the last one with an opposite sort order). The sort order is
- static trumps non-static
- public trumps protected/package-protected
- arguments trumps no arguments
- depth in hierarchy
Let's say we have a hierarchy of `B` inherits from `A`. If `B` contains `public void main()` and `A` contains `public void main(String... args)`, `A`'s `main` trumps `B` `main` since it has arguments.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13689#discussion_r1186247702
PR Review Comment: https://git.openjdk.org/jdk/pull/13689#discussion_r1186249703
PR Review Comment: https://git.openjdk.org/jdk/pull/13689#discussion_r1186245072
From abimpoudis at openjdk.org Fri May 5 16:01:00 2023
From: abimpoudis at openjdk.org (Aggelos Biboudis)
Date: Fri, 5 May 2023 16:01:00 GMT
Subject: RFR: 8302344: Compiler Implementation for Unnamed patterns and
variables (Preview) [v15]
In-Reply-To:
References:
Message-ID:
> This PR implements [JEP 443](https://openjdk.org/jeps/443), the preview feature for Unnamed Patterns and Variables in Java.
>
> Draft Spec: https://cr.openjdk.org/~abimpoudis/unnamed/latest/
Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision:
Address comments
- Annotate with Preview
- Fix isUnnamed hierarchy
- Flow names.empty for underscore in both model and API
- Adjust pretty printing and annotation pretty printing
- Fix guard bindings (great catch and thx @lahodaj!)
- Fix TreeVisitor
- Remove test with lambda which has a parse error from VarTree (names.empty is used to signal error)
- Various adjustments
Co-authored-by: Jan Lahoda
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/13528/files
- new: https://git.openjdk.org/jdk/pull/13528/files/888297ef..5d9a1ba7
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=13528&range=14
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=13528&range=13-14
Stats: 348 lines in 25 files changed: 189 ins; 102 del; 57 mod
Patch: https://git.openjdk.org/jdk/pull/13528.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/13528/head:pull/13528
PR: https://git.openjdk.org/jdk/pull/13528
From jlaskey at openjdk.org Fri May 5 16:02:39 2023
From: jlaskey at openjdk.org (Jim Laskey)
Date: Fri, 5 May 2023 16:02:39 GMT
Subject: RFR: JDK-8306112 Implementation of JEP 445: Unnamed Classes and
Instance Main Methods (Preview) [v8]
In-Reply-To:
References:
Message-ID:
On Fri, 5 May 2023 09:52:37 GMT, Jaikiran Pai wrote:
>> Jim Laskey has updated the pull request incrementally with two additional commits since the last revision:
>>
>> - Anonymous main classes renamed to unnamed classes
>> - Add test
>
> src/java.base/share/classes/sun/launcher/LauncherHelper.java line 872:
>
>> 870: Method mainMethod = null;
>> 871: try {
>> 872: mainMethod = MainMethodFinder.findMainMethod(mainClass);
>
> The `MainMethodFinder.findMainMethod(...)` throws a `NoSuchMethodException` when it can't find the regular `public static void main(String[])` or, when preview is enabled, any other eligible main methods. That will now mean that the next line here which catches a `NoSuchMethodException` can potentially end up aborting with a (very confusing) error message about JavaFX application. We should perhaps change that catch block to something like:
>
> } catch (NoSuchMethodException nsme) {
> if (!PreviewFeatures.isEnabled()) {
> // invalid main or not FX application, abort with an error
> abort(null, "java.launcher.cls.error4", mainClass.getName(),
> JAVAFX_APPLICATION_CLASS_NAME);
> } else {
> // abort with something more clear error?
> }
Not convinced that anything has changed or that the message is confusing.
> src/java.base/share/classes/sun/launcher/LauncherHelper.java line 893:
>
>> 891: * findMainMethod (above) will choose the correct method, based
>> 892: * on its name and parameter type, however, we still have to
>> 893: * ensure that the method is static (non-preview) and returns a void.
>
> I think it's probably going to be easier to read and maintain if we moved these checks for `static` and `void` return type into the `MainMethodFinder.findMainMethod(...)` itself.
> What I mean is once we return from the `findMainMethod(...)`, I think the callers, like this code here, shouldn't have to do additional checks to know if this main method is valid and can be used.
I agree, but from my early commentary we have to hold off until later.
> src/jdk.compiler/share/classes/com/sun/tools/javac/launcher/Main.java line 419:
>
>> 417: private static boolean isStatic(Method method) {
>> 418: return method != null && Modifier.isStatic(method.getModifiers());
>> 419: }
>
> It looks like these new methods aren't being used.
Remnants - removing
> src/jdk.compiler/share/classes/com/sun/tools/javac/launcher/Main.java line 440:
>
>> 438: int mods = mainMethod.getModifiers();
>> 439: boolean isStatic = Modifier.isStatic(mods);
>> 440: boolean isPublic = Modifier.isStatic(mods);
>
> This looks like a typo. This should have been `Modifier.isPublic(mods);`
Changing
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13689#discussion_r1186258290
PR Review Comment: https://git.openjdk.org/jdk/pull/13689#discussion_r1186259446
PR Review Comment: https://git.openjdk.org/jdk/pull/13689#discussion_r1186261107
PR Review Comment: https://git.openjdk.org/jdk/pull/13689#discussion_r1186259830
From abimpoudis at openjdk.org Fri May 5 16:07:24 2023
From: abimpoudis at openjdk.org (Aggelos Biboudis)
Date: Fri, 5 May 2023 16:07:24 GMT
Subject: RFR: 8302344: Compiler Implementation for Unnamed patterns and
variables (Preview) [v15]
In-Reply-To:
References:
Message-ID:
On Fri, 5 May 2023 16:01:00 GMT, Aggelos Biboudis wrote:
>> This PR implements [JEP 443](https://openjdk.org/jeps/443), the preview feature for Unnamed Patterns and Variables in Java.
>>
>> Draft Spec: https://cr.openjdk.org/~abimpoudis/unnamed/latest/
>
> Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision:
>
> Address comments
>
> - Annotate with Preview
> - Fix isUnnamed hierarchy
> - Flow names.empty for underscore in both model and API
> - Adjust pretty printing and annotation pretty printing
> - Fix guard bindings (great catch and thx @lahodaj!)
> - Fix TreeVisitor
> - Remove test with lambda which has a parse error from VarTree (names.empty is used to signal error)
> - Various adjustments
>
> Co-authored-by: Jan Lahoda
Addressed all comments in https://github.com/openjdk/jdk/pull/13528/commits/5d9a1ba74aad4ee95dad6892d40e0aa68e04af18
Thx @lahodaj, @vicente-romero-oracle, @mcimadamore, @jddarcy ???
-------------
PR Comment: https://git.openjdk.org/jdk/pull/13528#issuecomment-1536469342
From jlaskey at openjdk.org Fri May 5 16:08:22 2023
From: jlaskey at openjdk.org (Jim Laskey)
Date: Fri, 5 May 2023 16:08:22 GMT
Subject: RFR: JDK-8306112 Implementation of JEP 445: Unnamed Classes and
Instance Main Methods (Preview) [v8]
In-Reply-To:
References:
Message-ID:
On Fri, 5 May 2023 10:15:02 GMT, Jaikiran Pai wrote:
>> Jim Laskey has updated the pull request incrementally with two additional commits since the last revision:
>>
>> - Anonymous main classes renamed to unnamed classes
>> - Add test
>
> src/jdk.compiler/share/classes/com/sun/tools/javac/launcher/Main.java line 457:
>
>> 455: if (isStatic) {
>> 456: if (noArgs) {
>> 457: mainMethod.invoke(appClass);
>
> Given that `Method.invoke(...)` on a static method ignores the `obj` param that's passed to it, perhaps pass `null`?
Nostalgia and a useful reminder.
> test/jdk/tools/launcher/InstanceMainTest.java line 33:
>
>> 31: public class InstanceMainTest extends TestHelper {
>> 32:
>> 33: @Test
>
> Does this compile? I don't see imports for this annotation and this is launched as a `@run main ....`
Same package
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13689#discussion_r1186263733
PR Review Comment: https://git.openjdk.org/jdk/pull/13689#discussion_r1186265984
From jlaskey at openjdk.org Fri May 5 16:18:42 2023
From: jlaskey at openjdk.org (Jim Laskey)
Date: Fri, 5 May 2023 16:18:42 GMT
Subject: RFR: JDK-8306112 Implementation of JEP 445: Unnamed Classes and
Instance Main Methods (Preview) [v9]
In-Reply-To:
References:
Message-ID:
> Add flexible main methods and anonymous main classes to the Java language.
Jim Laskey has updated the pull request incrementally with one additional commit since the last revision:
Recommended changes #2
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/13689/files
- new: https://git.openjdk.org/jdk/pull/13689/files/ff7cd4c7..788b4e5a
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=13689&range=08
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=13689&range=07-08
Stats: 22 lines in 2 files changed: 9 ins; 10 del; 3 mod
Patch: https://git.openjdk.org/jdk/pull/13689.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/13689/head:pull/13689
PR: https://git.openjdk.org/jdk/pull/13689
From vromero at openjdk.org Fri May 5 17:11:28 2023
From: vromero at openjdk.org (Vicente Romero)
Date: Fri, 5 May 2023 17:11:28 GMT
Subject: RFR: JDK-8306112 Implementation of JEP 445: Unnamed Classes and
Instance Main Methods (Preview) [v9]
In-Reply-To:
References:
Message-ID:
On Fri, 5 May 2023 16:18:42 GMT, Jim Laskey wrote:
>> Add flexible main methods and anonymous main classes to the Java language.
>
> Jim Laskey has updated the pull request incrementally with one additional commit since the last revision:
>
> Recommended changes #2
src/java.base/share/classes/jdk/internal/misc/MainMethodFinder.java line 138:
> 136: * @param mainClass main class
> 137: *
> 138: * @throws NoSuchMethodException when not and preview and no method found
wording here? `when not and preview`?
src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java line 3999:
> 3997: Name name = names.fromString(simplename);
> 3998: JCModifiers anonMods = F.at(primaryPos)
> 3999: .Modifiers(Flags.FINAL|Flags.MANDATED|Flags.SYNTHETIC|Flags.UNNAMED_CLASS, List.nil());
I wonder if testing if a class has flags: `Flags.FINAL|Flags.MANDATED|Flags.SYNTHETIC` should be enough to know if it is unnamed or not and we don't need to use the new `UNNAMED_CLASS` flag
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13689#discussion_r1186299301
PR Review Comment: https://git.openjdk.org/jdk/pull/13689#discussion_r1186323116
From jlaskey at openjdk.org Fri May 5 17:31:27 2023
From: jlaskey at openjdk.org (Jim Laskey)
Date: Fri, 5 May 2023 17:31:27 GMT
Subject: RFR: JDK-8306112 Implementation of JEP 445: Unnamed Classes and
Instance Main Methods (Preview) [v10]
In-Reply-To:
References:
Message-ID:
> Add flexible main methods and anonymous main classes to the Java language.
Jim Laskey has updated the pull request incrementally with one additional commit since the last revision:
Typo
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/13689/files
- new: https://git.openjdk.org/jdk/pull/13689/files/788b4e5a..0c8add65
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=13689&range=09
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=13689&range=08-09
Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod
Patch: https://git.openjdk.org/jdk/pull/13689.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/13689/head:pull/13689
PR: https://git.openjdk.org/jdk/pull/13689
From jlaskey at openjdk.org Fri May 5 17:31:30 2023
From: jlaskey at openjdk.org (Jim Laskey)
Date: Fri, 5 May 2023 17:31:30 GMT
Subject: RFR: JDK-8306112 Implementation of JEP 445: Unnamed Classes and
Instance Main Methods (Preview) [v9]
In-Reply-To:
References:
Message-ID:
On Fri, 5 May 2023 16:42:43 GMT, Vicente Romero wrote:
>> Jim Laskey has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Recommended changes #2
>
> src/java.base/share/classes/jdk/internal/misc/MainMethodFinder.java line 138:
>
>> 136: * @param mainClass main class
>> 137: *
>> 138: * @throws NoSuchMethodException when not and preview and no method found
>
> wording here? `when not and preview`?
oops - never on a Friday
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13689#discussion_r1186337652
From forax at openjdk.org Fri May 5 17:31:31 2023
From: forax at openjdk.org (=?UTF-8?B?UsOpbWk=?= Forax)
Date: Fri, 5 May 2023 17:31:31 GMT
Subject: RFR: JDK-8306112 Implementation of JEP 445: Unnamed Classes and
Instance Main Methods (Preview) [v9]
In-Reply-To:
References:
Message-ID:
On Fri, 5 May 2023 17:08:35 GMT, Vicente Romero wrote:
>> Jim Laskey has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Recommended changes #2
>
> src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java line 3999:
>
>> 3997: Name name = names.fromString(simplename);
>> 3998: JCModifiers anonMods = F.at(primaryPos)
>> 3999: .Modifiers(Flags.FINAL|Flags.MANDATED|Flags.SYNTHETIC|Flags.UNNAMED_CLASS, List.nil());
>
> I wonder if testing if a class has flags: `Flags.FINAL|Flags.MANDATED|Flags.SYNTHETIC` should be enough to know if it is unnamed or not and we don't need to use the new `UNNAMED_CLASS` flag
`Flags.MANDATED` on a class is currently enough to know if it's a unnamed class or not, but it's not enough for classes not produced by javac.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13689#discussion_r1186335538
From vromero at openjdk.org Fri May 5 17:38:25 2023
From: vromero at openjdk.org (Vicente Romero)
Date: Fri, 5 May 2023 17:38:25 GMT
Subject: RFR: JDK-8306112 Implementation of JEP 445: Unnamed Classes and
Instance Main Methods (Preview) [v9]
In-Reply-To:
References:
Message-ID:
On Fri, 5 May 2023 17:22:03 GMT, R?mi Forax wrote:
>> src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java line 3999:
>>
>>> 3997: Name name = names.fromString(simplename);
>>> 3998: JCModifiers anonMods = F.at(primaryPos)
>>> 3999: .Modifiers(Flags.FINAL|Flags.MANDATED|Flags.SYNTHETIC|Flags.UNNAMED_CLASS, List.nil());
>>
>> I wonder if testing if a class has flags: `Flags.FINAL|Flags.MANDATED|Flags.SYNTHETIC` should be enough to know if it is unnamed or not and we don't need to use the new `UNNAMED_CLASS` flag
>
> `Flags.MANDATED` on a class is currently enough to know if it's a unnamed class or not, but it's not enough for classes not produced by javac.
good point
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13689#discussion_r1186346149
From forax at openjdk.org Fri May 5 17:50:21 2023
From: forax at openjdk.org (=?UTF-8?B?UsOpbWk=?= Forax)
Date: Fri, 5 May 2023 17:50:21 GMT
Subject: RFR: JDK-8306112 Implementation of JEP 445: Unnamed Classes and
Instance Main Methods (Preview) [v9]
In-Reply-To:
References:
Message-ID:
On Fri, 5 May 2023 17:35:33 GMT, Vicente Romero wrote:
>> `Flags.MANDATED` on a class is currently enough to know if it's a unnamed class or not, but it's not enough for classes not produced by javac.
>
> good point
Just to be clear, here, Flags.UNNAMED_CLASS is needed because an an unnamed class must have a main(), which is tested later.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13689#discussion_r1186357338
From vromero at openjdk.org Fri May 5 18:18:24 2023
From: vromero at openjdk.org (Vicente Romero)
Date: Fri, 5 May 2023 18:18:24 GMT
Subject: RFR: JDK-8306112 Implementation of JEP 445: Unnamed Classes and
Instance Main Methods (Preview) [v10]
In-Reply-To:
References:
Message-ID:
On Fri, 5 May 2023 17:31:27 GMT, Jim Laskey wrote:
>> Add flexible main methods and anonymous main classes to the Java language.
>
> Jim Laskey has updated the pull request incrementally with one additional commit since the last revision:
>
> Typo
src/jdk.compiler/share/classes/com/sun/tools/javac/launcher/Main.java line 466:
> 464: } catch (ClassNotFoundException e) {
> 465: throw new Fault(Errors.CantFindClass(mainClassName));
> 466: } catch (NoSuchMethodException e) {
`getDeclaredConstructor` can also throw a NSME but this error message would still say that the main method couldn't be found unless at this point we are sure that the class must have a no-args constructor
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13689#discussion_r1186379230
From jlaskey at openjdk.org Fri May 5 18:32:30 2023
From: jlaskey at openjdk.org (Jim Laskey)
Date: Fri, 5 May 2023 18:32:30 GMT
Subject: RFR: JDK-8306112 Implementation of JEP 445: Unnamed Classes and
Instance Main Methods (Preview) [v10]
In-Reply-To:
References:
Message-ID:
On Fri, 5 May 2023 18:15:20 GMT, Vicente Romero wrote:
>> Jim Laskey has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Typo
>
> src/jdk.compiler/share/classes/com/sun/tools/javac/launcher/Main.java line 466:
>
>> 464: } catch (ClassNotFoundException e) {
>> 465: throw new Fault(Errors.CantFindClass(mainClassName));
>> 466: } catch (NoSuchMethodException e) {
>
> `getDeclaredConstructor` can also throw a NSME but this error message would still say that the main method couldn't be found unless at this point we are sure that the class must have a no-args constructor
I was avoiding moving things so not to change behaviour when not in preview, but I think I really need to break it down into separate try blocks; get method, get constructor, execute method. Let me attempt.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13689#discussion_r1186390633
From jlaskey at openjdk.org Fri May 5 19:17:53 2023
From: jlaskey at openjdk.org (Jim Laskey)
Date: Fri, 5 May 2023 19:17:53 GMT
Subject: RFR: JDK-8306112 Implementation of JEP 445: Unnamed Classes and
Instance Main Methods (Preview) [v11]
In-Reply-To:
References:
Message-ID:
> Add flexible main methods and anonymous main classes to the Java language.
Jim Laskey has updated the pull request incrementally with one additional commit since the last revision:
Refactor source code launcher
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/13689/files
- new: https://git.openjdk.org/jdk/pull/13689/files/0c8add65..b91e75aa
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=13689&range=10
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=13689&range=09-10
Stats: 76 lines in 2 files changed: 43 ins; 22 del; 11 mod
Patch: https://git.openjdk.org/jdk/pull/13689.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/13689/head:pull/13689
PR: https://git.openjdk.org/jdk/pull/13689
From vromero at openjdk.org Fri May 5 20:16:26 2023
From: vromero at openjdk.org (Vicente Romero)
Date: Fri, 5 May 2023 20:16:26 GMT
Subject: RFR: JDK-8306112 Implementation of JEP 445: Unnamed Classes and
Instance Main Methods (Preview) [v11]
In-Reply-To:
References:
Message-ID:
On Fri, 5 May 2023 19:17:53 GMT, Jim Laskey wrote:
>> Add flexible main methods and anonymous main classes to the Java language.
>
> Jim Laskey has updated the pull request incrementally with one additional commit since the last revision:
>
> Refactor source code launcher
looks good
-------------
Marked as reviewed by vromero (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/13689#pullrequestreview-1415400703
From darcy at openjdk.org Fri May 5 21:25:23 2023
From: darcy at openjdk.org (Joe Darcy)
Date: Fri, 5 May 2023 21:25:23 GMT
Subject: RFR: 8302344: Compiler Implementation for Unnamed patterns and
variables (Preview) [v15]
In-Reply-To:
References:
Message-ID:
On Fri, 5 May 2023 16:01:00 GMT, Aggelos Biboudis wrote:
>> This PR implements [JEP 443](https://openjdk.org/jeps/443), the preview feature for Unnamed Patterns and Variables in Java.
>>
>> Draft Spec: https://cr.openjdk.org/~abimpoudis/unnamed/latest/
>
> Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision:
>
> Address comments
>
> - Annotate with Preview
> - Fix isUnnamed hierarchy
> - Flow names.empty for underscore in both model and API
> - Adjust pretty printing and annotation pretty printing
> - Fix guard bindings (great catch and thx @lahodaj!)
> - Fix TreeVisitor
> - Remove test with lambda which has a parse error from VarTree (names.empty is used to signal error)
> - Various adjustments
>
> Co-authored-by: Jan Lahoda
src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java line 1788:
> 1786: }
> 1787:
> 1788: @Override @DefinedBy(Api.LANGUAGE_MODEL)
It's not incorrect to have this override, but I don't think it is necessary now either with the update to the default method.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13528#discussion_r1186509423
From jjg at openjdk.org Sat May 6 01:22:40 2023
From: jjg at openjdk.org (Jonathan Gibbons)
Date: Sat, 6 May 2023 01:22:40 GMT
Subject: RFR: JDK-8307563: make most fields final in `JavacTrees`
Message-ID: