From tvaleev at openjdk.java.net Thu Apr 1 06:05:25 2021 From: tvaleev at openjdk.java.net (Tagir F.Valeev) Date: Thu, 1 Apr 2021 06:05:25 GMT Subject: Integrated: JDK-8264222: Use switch expression in jshell where possible In-Reply-To: References: Message-ID: On Fri, 26 Mar 2021 00:43:44 GMT, Tagir F. Valeev wrote: > This change is powered by IntelliJ IDEA quick-fix. > I also took the liberty to fix C-style arrays in changed files. > > In SourceCodeAnalysisImpl.java:501, I left case PARAMETERIZED_TYPE -> FALSE as a separate switch case, because it had a comment. Better formatting ideas are welcome. > > If you like this, I can provide similar PR in other components as well (e.g. in javac) This pull request has now been integrated. Changeset: 3997c99e Author: Tagir F. Valeev URL: https://git.openjdk.java.net/jdk/commit/3997c99e Stats: 163 lines in 5 files changed: 0 ins; 76 del; 87 mod 8264222: Use switch expression in jshell where possible Reviewed-by: briangoetz ------------- PR: https://git.openjdk.java.net/jdk/pull/3210 From jlahoda at openjdk.java.net Thu Apr 1 06:37:48 2021 From: jlahoda at openjdk.java.net (Jan Lahoda) Date: Thu, 1 Apr 2021 06:37:48 GMT Subject: RFR: 8262900: ToolBasicTest fails to access HTTP server it starts Message-ID: Trying to use `getLoopbackAddress()` instead of `getLocalHost()`, to start the HTTP server. It will hopefully be better accessible. Inspired by: https://github.com/openjdk/jdk/pull/3137 ------------- Commit messages: - 8262900: ToolBasicTest fails to access HTTP server it starts Changes: https://git.openjdk.java.net/jdk/pull/3301/files Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=3301&range=00 Issue: https://bugs.openjdk.java.net/browse/JDK-8262900 Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod Patch: https://git.openjdk.java.net/jdk/pull/3301.diff Fetch: git fetch https://git.openjdk.java.net/jdk pull/3301/head:pull/3301 PR: https://git.openjdk.java.net/jdk/pull/3301 From tvaleev at openjdk.java.net Sat Apr 10 04:27:20 2021 From: tvaleev at openjdk.java.net (Tagir F.Valeev) Date: Sat, 10 Apr 2021 04:27:20 GMT Subject: RFR: JDK-8263411: Convert jshell tool to use Stream.toList() [v3] In-Reply-To: References: Message-ID: <8wB1_MNFcYrioBK0d67AzGVpPl3eZlreYkVuFOUxtgE=.dc09afbe-6538-48de-a787-bb1421c6dc62@github.com> On Thu, 25 Mar 2021 14:44:19 GMT, Ian Graves wrote: >> Sorry to be late but the change in SnippetMaps.java looks really confusing to me: >> >> return Stream.concat(Stream.of("java.lang"), pkgs) >> .filter(ipkg -> !ipkg.isEmpty() && ipkg.equals(pkg)) >> .map(ipkg -> full.substring(pkg.length() + 1)) >> .findFirst() >> .orElse(full); >> The elements in the stream after `map` do not depend on the previous stream content. To me, it looks a misuse of stream API. Here, `anyMatch` scenario would look better: >> return Stream.concat(Stream.of("java.lang"), pkgs) >> .anyMatch(ipkg -> !ipkg.isEmpty() && ipkg.equals(pkg)) >> ? full.substring(pkg.length() + 1) : full; >> >> Also, it looks like the emptiness check could be applied to `pkg` variable, rather than to every stream element (as we require equality of `ipkg` and `pkg` after that: >> >> return !pkg.isEmpty() && Stream.concat(Stream.of("java.lang"), pkgs).anyMatch(pkg::equals) >> ? full.substring(pkg.length() + 1) : full; >> >> Sorry if I'm missing something. > > @amaembo Since the issue is now closed and these suggestions don't have to do with correctness, I'd suggest creating a new issue and PR to put these proposed improvements forward. Thanks! @igraves could you please take a look? https://github.com/openjdk/jdk/pull/3209 Thanks! ------------- PR: https://git.openjdk.java.net/jdk/pull/2979 From sundar at openjdk.java.net Mon Apr 12 12:15:53 2021 From: sundar at openjdk.java.net (Athijegannathan Sundararajan) Date: Mon, 12 Apr 2021 12:15:53 GMT Subject: RFR: 8262900: ToolBasicTest fails to access HTTP server it starts In-Reply-To: References: Message-ID: On Thu, 1 Apr 2021 06:31:55 GMT, Jan Lahoda wrote: > Trying to use `getLoopbackAddress()` instead of `getLocalHost()`, to start the HTTP server. It will hopefully be better accessible. Inspired by: > https://github.com/openjdk/jdk/pull/3137 LGTM ------------- Marked as reviewed by sundar (Reviewer). PR: https://git.openjdk.java.net/jdk/pull/3301 From vromero at openjdk.java.net Mon Apr 12 20:51:57 2021 From: vromero at openjdk.java.net (Vicente Romero) Date: Mon, 12 Apr 2021 20:51:57 GMT Subject: RFR: 8262900: ToolBasicTest fails to access HTTP server it starts In-Reply-To: References: Message-ID: On Thu, 1 Apr 2021 06:31:55 GMT, Jan Lahoda wrote: > Trying to use `getLoopbackAddress()` instead of `getLocalHost()`, to start the HTTP server. It will hopefully be better accessible. Inspired by: > https://github.com/openjdk/jdk/pull/3137 looks good ------------- Marked as reviewed by vromero (Reviewer). PR: https://git.openjdk.java.net/jdk/pull/3301 From igraves at openjdk.java.net Mon Apr 12 20:52:26 2021 From: igraves at openjdk.java.net (Ian Graves) Date: Mon, 12 Apr 2021 20:52:26 GMT Subject: RFR: JDK-8264221: Rewrite confusing stream API chain in SnippetMaps In-Reply-To: References: Message-ID: <14j6ky62VfcpQSatTw7zQ2YHAnEYxZyBlfS-bVjbEgA=.29b36924-fa9d-4776-aec5-c214bdc17ea7@github.com> On Fri, 26 Mar 2021 00:28:15 GMT, Tagir F. Valeev wrote: > I also simplified a couple of other places: replaced `stream().forEach()` with just `forEach()` and removed redundant `length()` argument in `substring()` call. This is related to a conversation we had on a [different PR](https://github.com/openjdk/jdk/pull/2979#issuecomment-817075524) where this fix was slightly out of band for the rest of the bug. Changes look good to me, though I am not yet a reviewer. Thanks for pulling this together here @amaembo ! ------------- PR: https://git.openjdk.java.net/jdk/pull/3209 From vromero at openjdk.java.net Mon Apr 12 20:52:47 2021 From: vromero at openjdk.java.net (Vicente Romero) Date: Mon, 12 Apr 2021 20:52:47 GMT Subject: RFR: 8238173: jshell - switch statement with a single default not return cause syntax error In-Reply-To: References: Message-ID: On Wed, 24 Mar 2021 11:43:19 GMT, Jan Lahoda wrote: > Improving disambiguation between switch expressions and switch statements: switches that do not yield a value from any arm should not be considered switch expressions; switches in source levels that don't support switch expressions should always be considered switch statements. looks good ------------- Marked as reviewed by vromero (Reviewer). PR: https://git.openjdk.java.net/jdk/pull/3173 From vromero at openjdk.java.net Mon Apr 12 20:57:38 2021 From: vromero at openjdk.java.net (Vicente Romero) Date: Mon, 12 Apr 2021 20:57:38 GMT Subject: RFR: 8247403: JShell: No custom input (e.g. from GUI) possible with JavaShellToolBuilder In-Reply-To: References: Message-ID: On Wed, 10 Feb 2021 13:55:24 GMT, Jan Lahoda wrote: > Basically, JShell's ConsoleIOContext always uses the JLine's default terminal, which uses System.in, or equivalent, for input. But, if the JShell tool has been created using JavaShellToolBuilder, a different input might have been provided. The proposed solution is to use a different JLine's terminal in this case, based on the provided input. LGTM ------------- Marked as reviewed by vromero (Reviewer). PR: https://git.openjdk.java.net/jdk/pull/2509 From vromero at openjdk.java.net Mon Apr 12 21:01:37 2021 From: vromero at openjdk.java.net (Vicente Romero) Date: Mon, 12 Apr 2021 21:01:37 GMT Subject: RFR: 8255273: jshell crashes with UnsupportedOperationException: Should not get here. In-Reply-To: References: Message-ID: On Fri, 26 Mar 2021 16:45:34 GMT, Jan Lahoda wrote: > Consider JShell interaction like: > > > jshell> import java.time.*; > > jshell> new Instant > > > This will crash the JShell with an `UnsupportedOperationException`. The ultimately reason is that: > -completions are computed, and are `InstantiationError(` and `InstantiationException(`, with a common prefix `InstantiationE` > -documentation is computed, and is for java.time.Instant > > The completion state machine then gets into a state where it fills in the common prefix, and then it would like say something along the lines of "Press tab once more to see signature/documentation.", but that does not make much sense (as the documentation is computed for a wrong input - the new input is `new InstantiationE`, not `Instant`, so the documentation is already invalid for that. > > (The `UnsupportedOperationException` is in place where the "Press tab once more to see signature/documentation." should happen, because the code should not get into a state like this.) > > The proposed solution is to cancel the documentation if a prefix is (to be) filled. looks sensible ------------- Marked as reviewed by vromero (Reviewer). PR: https://git.openjdk.java.net/jdk/pull/3220 From jlahoda at openjdk.java.net Thu Apr 15 15:19:39 2021 From: jlahoda at openjdk.java.net (Jan Lahoda) Date: Thu, 15 Apr 2021 15:19:39 GMT Subject: Integrated: 8262900: ToolBasicTest fails to access HTTP server it starts In-Reply-To: References: Message-ID: <1A63u9e7QDmlcmjSTrDvSzBPDd797xxL5ocEZBtTDQE=.cb0ab195-7cfc-450b-b2ba-79e0766c57a8@github.com> On Thu, 1 Apr 2021 06:31:55 GMT, Jan Lahoda wrote: > Trying to use `getLoopbackAddress()` instead of `getLocalHost()`, to start the HTTP server. It will hopefully be better accessible. Inspired by: > https://github.com/openjdk/jdk/pull/3137 This pull request has now been integrated. Changeset: e43aee58 Author: Jan Lahoda URL: https://git.openjdk.java.net/jdk/commit/e43aee58 Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod 8262900: ToolBasicTest fails to access HTTP server it starts Reviewed-by: sundar, vromero ------------- PR: https://git.openjdk.java.net/jdk/pull/3301 From jlahoda at openjdk.java.net Thu Apr 15 16:20:38 2021 From: jlahoda at openjdk.java.net (Jan Lahoda) Date: Thu, 15 Apr 2021 16:20:38 GMT Subject: Integrated: 8255273: jshell crashes with UnsupportedOperationException: Should not get here. In-Reply-To: References: Message-ID: On Fri, 26 Mar 2021 16:45:34 GMT, Jan Lahoda wrote: > Consider JShell interaction like: > > > jshell> import java.time.*; > > jshell> new Instant > > > This will crash the JShell with an `UnsupportedOperationException`. The ultimately reason is that: > -completions are computed, and are `InstantiationError(` and `InstantiationException(`, with a common prefix `InstantiationE` > -documentation is computed, and is for java.time.Instant > > The completion state machine then gets into a state where it fills in the common prefix, and then it would like say something along the lines of "Press tab once more to see signature/documentation.", but that does not make much sense (as the documentation is computed for a wrong input - the new input is `new InstantiationE`, not `Instant`, so the documentation is already invalid for that. > > (The `UnsupportedOperationException` is in place where the "Press tab once more to see signature/documentation." should happen, because the code should not get into a state like this.) > > The proposed solution is to cancel the documentation if a prefix is (to be) filled. This pull request has now been integrated. Changeset: 325eecbc Author: Jan Lahoda URL: https://git.openjdk.java.net/jdk/commit/325eecbc Stats: 101 lines in 2 files changed: 60 ins; 27 del; 14 mod 8255273: jshell crashes with UnsupportedOperationException: Should not get here. Reviewed-by: vromero ------------- PR: https://git.openjdk.java.net/jdk/pull/3220 From tvaleev at openjdk.java.net Sat Apr 17 09:01:35 2021 From: tvaleev at openjdk.java.net (Tagir F.Valeev) Date: Sat, 17 Apr 2021 09:01:35 GMT Subject: RFR: JDK-8264221: Rewrite confusing stream API chain in SnippetMaps In-Reply-To: References: Message-ID: On Fri, 26 Mar 2021 00:28:15 GMT, Tagir F. Valeev wrote: > I also simplified a couple of other places: replaced `stream().forEach()` with just `forEach()` and removed redundant `length()` argument in `substring()` call. @lahodaj could you please review this? Thanks! ------------- PR: https://git.openjdk.java.net/jdk/pull/3209 From jlahoda at openjdk.java.net Mon Apr 19 15:32:36 2021 From: jlahoda at openjdk.java.net (Jan Lahoda) Date: Mon, 19 Apr 2021 15:32:36 GMT Subject: RFR: JDK-8264221: Rewrite confusing stream API chain in SnippetMaps In-Reply-To: References: Message-ID: On Fri, 26 Mar 2021 00:28:15 GMT, Tagir F. Valeev wrote: > I also simplified a couple of other places: replaced `stream().forEach()` with just `forEach()` and removed redundant `length()` argument in `substring()` call. OK. ------------- Marked as reviewed by jlahoda (Reviewer). PR: https://git.openjdk.java.net/jdk/pull/3209 From tvaleev at openjdk.java.net Tue Apr 20 01:47:05 2021 From: tvaleev at openjdk.java.net (Tagir F.Valeev) Date: Tue, 20 Apr 2021 01:47:05 GMT Subject: Integrated: JDK-8264221: Rewrite confusing stream API chain in SnippetMaps In-Reply-To: References: Message-ID: <7Y05J1eDE93mdz7OG_LllcwVeSn1LebJEEHmfrsCMCg=.8d718762-bbec-4020-827f-e3573b80dd30@github.com> On Fri, 26 Mar 2021 00:28:15 GMT, Tagir F. Valeev wrote: > I also simplified a couple of other places: replaced `stream().forEach()` with just `forEach()` and removed redundant `length()` argument in `substring()` call. This pull request has now been integrated. Changeset: 787908c7 Author: Tagir F. Valeev URL: https://git.openjdk.java.net/jdk/commit/787908c7 Stats: 12 lines in 1 file changed: 3 ins; 3 del; 6 mod 8264221: Rewrite confusing stream API chain in SnippetMaps Reviewed-by: jlahoda ------------- PR: https://git.openjdk.java.net/jdk/pull/3209 From jlahoda at openjdk.java.net Mon Apr 26 11:28:05 2021 From: jlahoda at openjdk.java.net (Jan Lahoda) Date: Mon, 26 Apr 2021 11:28:05 GMT Subject: RFR: 8247403: JShell: No custom input (e.g. from GUI) possible with JavaShellToolBuilder [v2] In-Reply-To: References: Message-ID: > Basically, JShell's ConsoleIOContext always uses the JLine's default terminal, which uses System.in, or equivalent, for input. But, if the JShell tool has been created using JavaShellToolBuilder, a different input might have been provided. The proposed solution is to use a different JLine's terminal in this case, based on the provided input. Jan Lahoda 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 eight additional commits since the last revision: - Restoring timeout. - Improving test. - Cleanup. - Adding an experimental API to select the JavaShell output format and the output terminal size. - Merge branch 'master' into JDK-8247404 - When using JavaShellToolBuilder programmatically, make the characters sent to the output stream more consistent with the legacy behavior. - Merge branch 'master' into JDK-8247404 - 8247403: JShell: No custom input (e.g. from GUI) possible with JavaShellToolBuilder ------------- Changes: - all: https://git.openjdk.java.net/jdk/pull/2509/files - new: https://git.openjdk.java.net/jdk/pull/2509/files/96c44308..d7eacd6a Webrevs: - full: https://webrevs.openjdk.java.net/?repo=jdk&pr=2509&range=01 - incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=2509&range=00-01 Stats: 177373 lines in 5587 files changed: 113750 ins; 40125 del; 23498 mod Patch: https://git.openjdk.java.net/jdk/pull/2509.diff Fetch: git fetch https://git.openjdk.java.net/jdk pull/2509/head:pull/2509 PR: https://git.openjdk.java.net/jdk/pull/2509 From jlahoda at openjdk.java.net Mon Apr 26 11:44:45 2021 From: jlahoda at openjdk.java.net (Jan Lahoda) Date: Mon, 26 Apr 2021 11:44:45 GMT Subject: RFR: 8247403: JShell: No custom input (e.g. from GUI) possible with JavaShellToolBuilder [v2] In-Reply-To: References: Message-ID: On Mon, 26 Apr 2021 11:28:05 GMT, Jan Lahoda wrote: >> Basically, JShell's ConsoleIOContext always uses the JLine's default terminal, which uses System.in, or equivalent, for input. But, if the JShell tool has been created using JavaShellToolBuilder, a different input might have been provided. The proposed solution is to use a different JLine's terminal in this case, based on the provided input. > > Jan Lahoda 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 eight additional commits since the last revision: > > - Restoring timeout. > - Improving test. > - Cleanup. > - Adding an experimental API to select the JavaShell output format and the output terminal size. > - Merge branch 'master' into JDK-8247404 > - When using JavaShellToolBuilder programmatically, make the characters sent to the output stream more consistent with the legacy behavior. > - Merge branch 'master' into JDK-8247404 > - 8247403: JShell: No custom input (e.g. from GUI) possible with JavaShellToolBuilder It turned out some users/clients of JavaShellToolBuilder do not attach a full terminal to it, but rather parse the output, and since we have changed the output by using a newer JLine, this became more complicated. So the new iteration of the patch supports two modes: a (default) simpler mode, which does not use escape sequences much, and a more for real terminals, where JShell will use escape sequences to provide a good experiment to a user reading on the terminal. Please also see the associated CSR: https://bugs.openjdk.java.net/browse/JDK-8265966 ------------- PR: https://git.openjdk.java.net/jdk/pull/2509 From jlahoda at openjdk.java.net Thu Apr 29 14:58:02 2021 From: jlahoda at openjdk.java.net (Jan Lahoda) Date: Thu, 29 Apr 2021 14:58:02 GMT Subject: Integrated: 8238173: jshell - switch statement with a single default not return cause syntax error In-Reply-To: References: Message-ID: <-Jb5bRnSkwepI1Sm999W-5H4KxmKT0P56F6QJqsGHOI=.4de36643-4806-460a-8019-c1cffd5b7543@github.com> On Wed, 24 Mar 2021 11:43:19 GMT, Jan Lahoda wrote: > Improving disambiguation between switch expressions and switch statements: switches that do not yield a value from any arm should not be considered switch expressions; switches in source levels that don't support switch expressions should always be considered switch statements. This pull request has now been integrated. Changeset: 8072ea56 Author: Jan Lahoda URL: https://git.openjdk.java.net/jdk/commit/8072ea56283ecac0d8bf486cdc4e1ff649bf7927 Stats: 56 lines in 5 files changed: 32 ins; 22 del; 2 mod 8238173: jshell - switch statement with a single default not return cause syntax error Reviewed-by: vromero ------------- PR: https://git.openjdk.java.net/jdk/pull/3173