From github.com+741251+turbanoff at openjdk.java.net Sat Sep 25 11:00:04 2021 From: github.com+741251+turbanoff at openjdk.java.net (Andrey Turbanov) Date: Sat, 25 Sep 2021 11:00:04 GMT Subject: jmx-dev RFR: 8274318: Replace 'for' cycles with iterator with enhanced-for in java.management Message-ID: There are a few places in code, where manual `for` loop is used with Iterator to iterate over Collection. Instead of manual `for` cycles, it's preferred to use enhanced-for cycle instead: it's less verbose, makes code easier to read and it's less error-prone. It doesn't have any performance impact: javac compiler generates similar code when compiling enhanced-for cycle. Similar cleanups: 1. [JDK-8274016](https://bugs.openjdk.java.net/browse/JDK-8274016) java.desktop 2. [JDK-8274237](https://bugs.openjdk.java.net/browse/JDK-8274237) java.base 3. [JDK-8274261](https://bugs.openjdk.java.net/browse/JDK-8274261) jdk.jcmd ------------- Commit messages: - [PATCH] Use enhanced-for instead of plain 'for' in java.management Changes: https://git.openjdk.java.net/jdk/pull/5695/files Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=5695&range=00 Issue: https://bugs.openjdk.java.net/browse/JDK-8274318 Stats: 16 lines in 3 files changed: 0 ins; 7 del; 9 mod Patch: https://git.openjdk.java.net/jdk/pull/5695.diff Fetch: git fetch https://git.openjdk.java.net/jdk pull/5695/head:pull/5695 PR: https://git.openjdk.java.net/jdk/pull/5695 From darcy at openjdk.java.net Mon Sep 27 09:29:09 2021 From: darcy at openjdk.java.net (Joe Darcy) Date: Mon, 27 Sep 2021 09:29:09 GMT Subject: jmx-dev RFR: 8202056: Expand serial warning to check for bad overloads of serial-related methods and ineffectual fields Message-ID: <6FKZsPgQFbL8ZEFh0EiVXy9QN7o__qNpjvlt4cIJA-I=.2a74a3a6-2a67-425d-bb73-7984b18fc3a4@github.com> This is an initial PR for expanded lint warnings done under two bugs: 8202056: Expand serial warning to check for bad overloads of serial-related methods and ineffectual fields 8160675: Issue lint warning for non-serializable non-transient instance fields in serializable type to get feedback on the general approach and test strategy before further polishing the implementation. The implementation initially started as an annotation processor I wrote several years ago. The refined version being incorporated into Attr has been refactored, had its checks expanded, and been partially ported to idiomatic javac coding style rather than using the javax.lang.model API from annotation processing. Subsequent versions of this PR are expected to move the implementation closer to idiomatic javac, in particular to use javac flags rather than javax.lang.model.Modifier's. Additional resources keys will be defined for the serialization-related fields and methods not having the expected modifiers, types, etc. The resource keys for the existing checks related to serialVersionUID and reused. Please also review the corresponding CSRs: https://bugs.openjdk.java.net/browse/JDK-8274335 https://bugs.openjdk.java.net/browse/JDK-8274336 Informative serialization-related warning messages must take into account whether a class, interface, annotation, record, and enum is being analyzed. Enum classes and record classes have special handling in serialization. This implementation under review has been augmented with checks for interface types recommended by Chris Hegarty in an attachment on 8202056. The JDK build has the Xlint:serial check enabled. The build did not pass with the augmented checks. For most modules, this PR contains the library changes necessary for the build to pass. I will start separate PRs in those library areas to get the needed SuppressWarning("serial") or other changes in place. For one module, I temporarily disabled the Xlint:serial check. In terms of performance, I have not done benchmarks of the JDK build with and without these changes, but informally the build seems to take about as long as before. ------------- Commit messages: - Appease jcheck - Implement checks chegar recommended for interfaces. - Update comment. - Add tests for instance field checks. - Clean build with instance field checks in place. - Merge branch 'master' into JDK-8202056 - Put Externalizable checks last. - Add checks for constructor access in Serializable classes. - Add no-arg ctor check for Externalizable classes. - Improve Externalization warnings. - ... and 19 more: https://git.openjdk.java.net/jdk/compare/5756385c...d498ff5f Changes: https://git.openjdk.java.net/jdk/pull/5709/files Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=5709&range=00 Issue: https://bugs.openjdk.java.net/browse/JDK-8202056 Stats: 1519 lines in 79 files changed: 1511 ins; 1 del; 7 mod Patch: https://git.openjdk.java.net/jdk/pull/5709.diff Fetch: git fetch https://git.openjdk.java.net/jdk pull/5709/head:pull/5709 PR: https://git.openjdk.java.net/jdk/pull/5709 From erikj at openjdk.java.net Mon Sep 27 13:01:58 2021 From: erikj at openjdk.java.net (Erik Joelsson) Date: Mon, 27 Sep 2021 13:01:58 GMT Subject: jmx-dev RFR: 8202056: Expand serial warning to check for bad overloads of serial-related methods and ineffectual fields In-Reply-To: <6FKZsPgQFbL8ZEFh0EiVXy9QN7o__qNpjvlt4cIJA-I=.2a74a3a6-2a67-425d-bb73-7984b18fc3a4@github.com> References: <6FKZsPgQFbL8ZEFh0EiVXy9QN7o__qNpjvlt4cIJA-I=.2a74a3a6-2a67-425d-bb73-7984b18fc3a4@github.com> Message-ID: On Mon, 27 Sep 2021 01:00:18 GMT, Joe Darcy wrote: > This is an initial PR for expanded lint warnings done under two bugs: > > 8202056: Expand serial warning to check for bad overloads of serial-related methods and ineffectual fields > 8160675: Issue lint warning for non-serializable non-transient instance fields in serializable type > > to get feedback on the general approach and test strategy before further polishing the implementation. > > The implementation initially started as an annotation processor I wrote several years ago. The refined version being incorporated into Attr has been refactored, had its checks expanded, and been partially ported to idiomatic javac coding style rather than using the javax.lang.model API from annotation processing. > > Subsequent versions of this PR are expected to move the implementation closer to idiomatic javac, in particular to use javac flags rather than javax.lang.model.Modifier's. Additional resources keys will be defined for the serialization-related fields and methods not having the expected modifiers, types, etc. The resource keys for the existing checks related to serialVersionUID and reused. > > Please also review the corresponding CSRs: > > https://bugs.openjdk.java.net/browse/JDK-8274335 > https://bugs.openjdk.java.net/browse/JDK-8274336 > > Informative serialization-related warning messages must take into account whether a class, interface, annotation, record, and enum is being analyzed. Enum classes and record classes have special handling in serialization. This implementation under review has been augmented with checks for interface types recommended by Chris Hegarty in an attachment on 8202056. > > The JDK build has the Xlint:serial check enabled. The build did not pass with the augmented checks. For most modules, this PR contains the library changes necessary for the build to pass. I will start separate PRs in those library areas to get the needed SuppressWarning("serial") or other changes in place. For one module, I temporarily disabled the Xlint:serial check. > > In terms of performance, I have not done benchmarks of the JDK build with and without these changes, but informally the build seems to take about as long as before. Build change looks ok. ------------- Marked as reviewed by erikj (Reviewer). PR: https://git.openjdk.java.net/jdk/pull/5709 From cjplummer at openjdk.java.net Mon Sep 27 21:51:11 2021 From: cjplummer at openjdk.java.net (Chris Plummer) Date: Mon, 27 Sep 2021 21:51:11 GMT Subject: jmx-dev RFR: 8274318: Replace 'for' cycles with iterator with enhanced-for in java.management In-Reply-To: References: Message-ID: On Sat, 25 Sep 2021 10:51:12 GMT, Andrey Turbanov wrote: > There are a few places in code, where manual `for` loop is used with Iterator to iterate over Collection. > Instead of manual `for` cycles, it's preferred to use enhanced-for cycle instead: it's less verbose, makes code easier to read and it's less error-prone. > It doesn't have any performance impact: javac compiler generates similar code when compiling enhanced-for cycle. > Similar cleanups: > 1. [JDK-8274016](https://bugs.openjdk.java.net/browse/JDK-8274016) java.desktop > 2. [JDK-8274237](https://bugs.openjdk.java.net/browse/JDK-8274237) java.base > 3. [JDK-8274261](https://bugs.openjdk.java.net/browse/JDK-8274261) jdk.jcmd Marked as reviewed by cjplummer (Reviewer). ------------- PR: https://git.openjdk.java.net/jdk/pull/5695 From darcy at openjdk.java.net Mon Sep 27 22:10:27 2021 From: darcy at openjdk.java.net (Joe Darcy) Date: Mon, 27 Sep 2021 22:10:27 GMT Subject: jmx-dev RFR: 8274398: Suppress more warnings on non-serializable non-transient instance fields in management libs Message-ID: Follow-up change to JDK-8232442, augmentations to javac's Xlint:serial checking are out for review (#5709) and various management libraries would need some changes to pass under the expanded checks. The changes are to suppress warnings where non-transient fields in serializable types are not declared with a type statically known to be serializable. That isn't necessarily a correctness issues, but it does merit further scrutiny. I'll run a script to update copyright years before a push. ------------- Commit messages: - 8274398: Suppress more warnings on non-serializable non-transient instance fields in management libs Changes: https://git.openjdk.java.net/jdk/pull/5726/files Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=5726&range=00 Issue: https://bugs.openjdk.java.net/browse/JDK-8274398 Stats: 12 lines in 8 files changed: 12 ins; 0 del; 0 mod Patch: https://git.openjdk.java.net/jdk/pull/5726.diff Fetch: git fetch https://git.openjdk.java.net/jdk pull/5726/head:pull/5726 PR: https://git.openjdk.java.net/jdk/pull/5726 From github.com+741251+turbanoff at openjdk.java.net Tue Sep 28 21:18:43 2021 From: github.com+741251+turbanoff at openjdk.java.net (Andrey Turbanov) Date: Tue, 28 Sep 2021 21:18:43 GMT Subject: jmx-dev RFR: 8274464: Remove redundant stream() call before forEach in java.* modules Message-ID: 8274464: Remove redundant stream() call before forEach in java.* modules ------------- Commit messages: - [PATCH] Remove redundant stream() call before forEach in java.* modules Changes: https://git.openjdk.java.net/jdk/pull/5520/files Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=5520&range=00 Issue: https://bugs.openjdk.java.net/browse/JDK-8274464 Stats: 8 lines in 4 files changed: 0 ins; 3 del; 5 mod Patch: https://git.openjdk.java.net/jdk/pull/5520.diff Fetch: git fetch https://git.openjdk.java.net/jdk pull/5520/head:pull/5520 PR: https://git.openjdk.java.net/jdk/pull/5520 From dfuchs at openjdk.java.net Wed Sep 29 10:08:34 2021 From: dfuchs at openjdk.java.net (Daniel Fuchs) Date: Wed, 29 Sep 2021 10:08:34 GMT Subject: jmx-dev RFR: 8274464: Remove redundant stream() call before forEach in java.* modules In-Reply-To: References: Message-ID: On Wed, 15 Sep 2021 07:12:25 GMT, Andrey Turbanov wrote: > 8274464: Remove redundant stream() call before forEach in java.* modules LGTM ------------- Marked as reviewed by dfuchs (Reviewer). PR: https://git.openjdk.java.net/jdk/pull/5520 From amenkov at openjdk.java.net Wed Sep 29 19:02:35 2021 From: amenkov at openjdk.java.net (Alex Menkov) Date: Wed, 29 Sep 2021 19:02:35 GMT Subject: jmx-dev RFR: 8274464: Remove redundant stream() call before forEach in java.* modules In-Reply-To: References: Message-ID: On Wed, 15 Sep 2021 07:12:25 GMT, Andrey Turbanov wrote: > 8274464: Remove redundant stream() call before forEach in java.* modules Marked as reviewed by amenkov (Reviewer). ------------- PR: https://git.openjdk.java.net/jdk/pull/5520 From vtewari at openjdk.java.net Thu Sep 30 05:01:33 2021 From: vtewari at openjdk.java.net (Vyom Tewari) Date: Thu, 30 Sep 2021 05:01:33 GMT Subject: jmx-dev RFR: 8274464: Remove redundant stream() call before forEach in java.* modules In-Reply-To: References: Message-ID: <4Dr78xXY2h3mNV3-y__VcjZ5QmnA03mx1EHJ7HT3gsE=.a2f96a23-7c12-4f52-94a2-e57f401a75d6@github.com> On Wed, 15 Sep 2021 07:12:25 GMT, Andrey Turbanov wrote: > 8274464: Remove redundant stream() call before forEach in java.* modules Looks good to me. ------------- Marked as reviewed by vtewari (Committer). PR: https://git.openjdk.java.net/jdk/pull/5520 From sspitsyn at openjdk.java.net Thu Sep 30 09:48:33 2021 From: sspitsyn at openjdk.java.net (Serguei Spitsyn) Date: Thu, 30 Sep 2021 09:48:33 GMT Subject: jmx-dev RFR: 8274318: Replace 'for' cycles with iterator with enhanced-for in java.management In-Reply-To: References: Message-ID: On Sat, 25 Sep 2021 10:51:12 GMT, Andrey Turbanov wrote: > There are a few places in code, where manual `for` loop is used with Iterator to iterate over Collection. > Instead of manual `for` cycles, it's preferred to use enhanced-for cycle instead: it's less verbose, makes code easier to read and it's less error-prone. > It doesn't have any performance impact: javac compiler generates similar code when compiling enhanced-for cycle. > Similar cleanups: > 1. [JDK-8274016](https://bugs.openjdk.java.net/browse/JDK-8274016) java.desktop > 2. [JDK-8274237](https://bugs.openjdk.java.net/browse/JDK-8274237) java.base > 3. [JDK-8274261](https://bugs.openjdk.java.net/browse/JDK-8274261) jdk.jcmd Andrey, I've inlined one formatting nit. Other than that it looks good. Thanks, Serguei src/java.management/share/classes/javax/management/relation/RoleResult.java line 200: > 198: RoleUnresolved currRoleUnres = (RoleUnresolved) o; > 199: unresolvedRoleList.add((RoleUnresolved) currRoleUnres.clone()); > 200: } Space is not needed after casts above at lines: 176-177, 198-199. ------------- Marked as reviewed by sspitsyn (Reviewer). PR: https://git.openjdk.java.net/jdk/pull/5695 From sspitsyn at openjdk.java.net Thu Sep 30 09:59:40 2021 From: sspitsyn at openjdk.java.net (Serguei Spitsyn) Date: Thu, 30 Sep 2021 09:59:40 GMT Subject: jmx-dev RFR: 8274398: Suppress more warnings on non-serializable non-transient instance fields in management libs In-Reply-To: References: Message-ID: On Mon, 27 Sep 2021 21:49:06 GMT, Joe Darcy wrote: > Follow-up change to JDK-8232442, augmentations to javac's Xlint:serial checking are out for review (#5709) and various management libraries would need some changes to pass under the expanded checks. > > The changes are to suppress warnings where non-transient fields in serializable types are not declared with a type statically known to be serializable. That isn't necessarily a correctness issues, but it does merit further scrutiny. > > I'll run a script to update copyright years before a push. Looks good. Thanks, Serguei ------------- Marked as reviewed by sspitsyn (Reviewer). PR: https://git.openjdk.java.net/jdk/pull/5726 From darcy at openjdk.java.net Thu Sep 30 16:23:34 2021 From: darcy at openjdk.java.net (Joe Darcy) Date: Thu, 30 Sep 2021 16:23:34 GMT Subject: jmx-dev RFR: 8274398: Suppress more warnings on non-serializable non-transient instance fields in management libs In-Reply-To: References: Message-ID: On Thu, 30 Sep 2021 09:56:45 GMT, Serguei Spitsyn wrote: > > > Looks good. Thanks, Serguei Thanks Serguei, I'll add some explanatory comments and check for any needed copyright updates before pushing. ------------- PR: https://git.openjdk.java.net/jdk/pull/5726 From darcy at openjdk.java.net Thu Sep 30 17:00:24 2021 From: darcy at openjdk.java.net (Joe Darcy) Date: Thu, 30 Sep 2021 17:00:24 GMT Subject: jmx-dev RFR: 8274398: Suppress more warnings on non-serializable non-transient instance fields in management libs [v2] In-Reply-To: References: Message-ID: > Follow-up change to JDK-8232442, augmentations to javac's Xlint:serial checking are out for review (#5709) and various management libraries would need some changes to pass under the expanded checks. > > The changes are to suppress warnings where non-transient fields in serializable types are not declared with a type statically known to be serializable. That isn't necessarily a correctness issues, but it does merit further scrutiny. > > I'll run a script to update copyright years before a push. Joe Darcy 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: - Add comments and update copyrights. - Merge branch 'master' into JDK-8274398 - 8274398: Suppress more warnings on non-serializable non-transient instance fields in management libs ------------- Changes: - all: https://git.openjdk.java.net/jdk/pull/5726/files - new: https://git.openjdk.java.net/jdk/pull/5726/files/bc8dde4f..a6f37fa5 Webrevs: - full: https://webrevs.openjdk.java.net/?repo=jdk&pr=5726&range=01 - incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=5726&range=00-01 Stats: 5574 lines in 212 files changed: 3989 ins; 1022 del; 563 mod Patch: https://git.openjdk.java.net/jdk/pull/5726.diff Fetch: git fetch https://git.openjdk.java.net/jdk pull/5726/head:pull/5726 PR: https://git.openjdk.java.net/jdk/pull/5726 From darcy at openjdk.java.net Thu Sep 30 17:03:36 2021 From: darcy at openjdk.java.net (Joe Darcy) Date: Thu, 30 Sep 2021 17:03:36 GMT Subject: jmx-dev Integrated: 8274398: Suppress more warnings on non-serializable non-transient instance fields in management libs In-Reply-To: References: Message-ID: On Mon, 27 Sep 2021 21:49:06 GMT, Joe Darcy wrote: > Follow-up change to JDK-8232442, augmentations to javac's Xlint:serial checking are out for review (#5709) and various management libraries would need some changes to pass under the expanded checks. > > The changes are to suppress warnings where non-transient fields in serializable types are not declared with a type statically known to be serializable. That isn't necessarily a correctness issues, but it does merit further scrutiny. > > I'll run a script to update copyright years before a push. This pull request has now been integrated. Changeset: 8215b2eb Author: Joe Darcy URL: https://git.openjdk.java.net/jdk/commit/8215b2eb61bd89c4041420e1c5c673603d6b2119 Stats: 17 lines in 8 files changed: 12 ins; 0 del; 5 mod 8274398: Suppress more warnings on non-serializable non-transient instance fields in management libs Reviewed-by: sspitsyn ------------- PR: https://git.openjdk.java.net/jdk/pull/5726