From asotona at openjdk.org Thu Jun 1 10:15:06 2023 From: asotona at openjdk.org (Adam Sotona) Date: Thu, 1 Jun 2023 10:15:06 GMT Subject: RFR: 8308943: jdk.internal.le build fails on AIX [v2] In-Reply-To: References: Message-ID: On Wed, 31 May 2023 17:15:24 GMT, Jan Lahoda wrote: >> A simpler alternative to https://github.com/openjdk/jdk/pull/14176 - it only creates a stub of `JDKNativePty` for AIX, throwing `UnsupportedOperationException`. JLine will then either use the next provider (i.e. "exec", for JShell), or dumb terminal. > > Jan Lahoda has updated the pull request incrementally with one additional commit since the last revision: > > Removing unnecessary import of a class that does not exist for this system. The code builds for me in simulated AIX profile and it works as expected. ------------- Marked as reviewed by asotona (Reviewer). PR Review: https://git.openjdk.org/jdk/pull/14247#pullrequestreview-1455088942 From jlahoda at openjdk.org Thu Jun 1 11:16:15 2023 From: jlahoda at openjdk.org (Jan Lahoda) Date: Thu, 1 Jun 2023 11:16:15 GMT Subject: RFR: 8308943: jdk.internal.le build fails on AIX In-Reply-To: References: Message-ID: <7v8Lo9whO5Cdv-_YvrRidaxr4gCXi2cOFQcUSewvkOA=.864fd9f7-3ae2-486b-83eb-0a4dbfddb19c@github.com> On Fri, 26 May 2023 11:49:34 GMT, Jan Lahoda wrote: > Build of `jdk.internal.le` fails on AIX, because code in the `unix` directory expects `jdk.internal.org.jline.terminal.impl.jna.JDKNativePty` for each platform (unix-like), but it does not for AIX. > > We could add a stub of this class into the `aix` directory (methods could throw an exception, which would automatically switch JLine into the "external executable" mode, if enabled). But, it might be better to use the `ServiceLoader`, and simply register a platform-specific provider as a service. This patch is attempting to do the latter. In the end, I've used a simpler version that was done under https://github.com/openjdk/jdk/pull/14247. Thanks for the review/efforts anyway! ------------- PR Comment: https://git.openjdk.org/jdk/pull/14176#issuecomment-1571852225 From jlahoda at openjdk.org Thu Jun 1 11:16:16 2023 From: jlahoda at openjdk.org (Jan Lahoda) Date: Thu, 1 Jun 2023 11:16:16 GMT Subject: Withdrawn: 8308943: jdk.internal.le build fails on AIX In-Reply-To: References: Message-ID: On Fri, 26 May 2023 11:49:34 GMT, Jan Lahoda wrote: > Build of `jdk.internal.le` fails on AIX, because code in the `unix` directory expects `jdk.internal.org.jline.terminal.impl.jna.JDKNativePty` for each platform (unix-like), but it does not for AIX. > > We could add a stub of this class into the `aix` directory (methods could throw an exception, which would automatically switch JLine into the "external executable" mode, if enabled). But, it might be better to use the `ServiceLoader`, and simply register a platform-specific provider as a service. This patch is attempting to do the latter. This pull request has been closed without being integrated. ------------- PR: https://git.openjdk.org/jdk/pull/14176 From jlahoda at openjdk.org Thu Jun 1 11:17:18 2023 From: jlahoda at openjdk.org (Jan Lahoda) Date: Thu, 1 Jun 2023 11:17:18 GMT Subject: Integrated: 8308943: jdk.internal.le build fails on AIX In-Reply-To: References: Message-ID: On Wed, 31 May 2023 13:12:23 GMT, Jan Lahoda wrote: > A simpler alternative to https://github.com/openjdk/jdk/pull/14176 - it only creates a stub of `JDKNativePty` for AIX, throwing `UnsupportedOperationException`. JLine will then either use the next provider (i.e. "exec", for JShell), or dumb terminal. This pull request has now been integrated. Changeset: 6adc242c Author: Jan Lahoda URL: https://git.openjdk.org/jdk/commit/6adc242cf33941f1cbaa1f9e920c8700fd59aefc Stats: 50 lines in 1 file changed: 50 ins; 0 del; 0 mod 8308943: jdk.internal.le build fails on AIX Reviewed-by: asotona ------------- PR: https://git.openjdk.org/jdk/pull/14247 From asotona at openjdk.org Thu Jun 1 14:49:25 2023 From: asotona at openjdk.org (Adam Sotona) Date: Thu, 1 Jun 2023 14:49:25 GMT Subject: RFR: 8308899: Introduce Classfile.Context and improve Classfile.Option(s) Message-ID: Classfile context object and multi-state options have been discussed at https://mail.openjdk.org/pipermail/classfile-api-dev/2023-May/000321.html This patch implements the proposed changes in Classfile API and fixes all affected code across JDK sources and tests. Please review. Thanks, Adam ------------- Commit messages: - fixed snippets and added SnippetsTest - fixed javadoc - added Classfile context parameter to ClasRemapper::remapClass - records and methods implementations moved from Classfile to ClassfileImpl - added Classfile::buildTo override - implementation of Classfile::withOptions(Option... options) - added test for StackMapsOption.ALWAYS_GENERATE_STACK_MAPS - fixed tests - fixed options and jdk/classfile tests - fixed jdk/classfile tests - ... and 9 more: https://git.openjdk.org/jdk/compare/7d2a7ce2...bcdf0f11 Changes: https://git.openjdk.org/jdk/pull/14180/files Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=14180&range=00 Issue: https://bugs.openjdk.org/browse/JDK-8308899 Stats: 1579 lines in 106 files changed: 478 ins; 195 del; 906 mod Patch: https://git.openjdk.org/jdk/pull/14180.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/14180/head:pull/14180 PR: https://git.openjdk.org/jdk/pull/14180 From liach at openjdk.org Thu Jun 1 14:49:29 2023 From: liach at openjdk.org (Chen Liang) Date: Thu, 1 Jun 2023 14:49:29 GMT Subject: RFR: 8308899: Introduce Classfile.Context and improve Classfile.Option(s) In-Reply-To: References: Message-ID: On Fri, 26 May 2023 14:56:57 GMT, Adam Sotona wrote: > Classfile context object and multi-state options have been discussed at https://mail.openjdk.org/pipermail/classfile-api-dev/2023-May/000321.html > This patch implements the proposed changes in Classfile API and fixes all affected code across JDK sources and tests. > > Please review. > > Thanks, > Adam A side comment about the API changes: I think we should recommend users to store Classfile instances in static final variables if sharing is reasonable, like in Module and BindingSpecializer; this way, we can cache class hierarchy resolution information across builds. src/java.base/share/classes/jdk/internal/classfile/Classfile.java line 87: > 85: * @param r a function mapping attribute names to attribute mappers > 86: */ > 87: record AttributeMapperOption(Function> attributeMapper) implements Option { We might want to convert these options into interfaces and move the implementation records into ClassfileImpl, like Brian suggested about ClassHierarchyInfo. src/java.base/share/classes/jdk/internal/classfile/Classfile.java line 208: > 206: */ > 207: default ClassModel parse(byte[] bytes) { > 208: return new ClassImpl(bytes, (ClassfileImpl)this); Should we implement this in ClassfileImpl to avoid the redundant cast? src/java.base/share/classes/jdk/internal/classfile/components/ClassRemapper.java line 102: > 100: * @return re-mapped class file bytes > 101: */ > 102: default byte[] remapClass(ClassModel clm) { This api should ask for a Classfile object instead. Thankfully, the new Classfile object actually allows us to find potentially bugs in our code (say if the remapped class refer to declared types outside of system class loader) ------------- PR Review: https://git.openjdk.org/jdk/pull/14180#pullrequestreview-1452244549 PR Review Comment: https://git.openjdk.org/jdk/pull/14180#discussion_r1211113876 PR Review Comment: https://git.openjdk.org/jdk/pull/14180#discussion_r1211114779 PR Review Comment: https://git.openjdk.org/jdk/pull/14180#discussion_r1211116312 From asotona at openjdk.org Thu Jun 1 14:49:30 2023 From: asotona at openjdk.org (Adam Sotona) Date: Thu, 1 Jun 2023 14:49:30 GMT Subject: RFR: 8308899: Introduce Classfile.Context and improve Classfile.Option(s) In-Reply-To: References: Message-ID: On Wed, 31 May 2023 05:42:58 GMT, Chen Liang wrote: >> Classfile context object and multi-state options have been discussed at https://mail.openjdk.org/pipermail/classfile-api-dev/2023-May/000321.html >> This patch implements the proposed changes in Classfile API and fixes all affected code across JDK sources and tests. >> >> Please review. >> >> Thanks, >> Adam > > src/java.base/share/classes/jdk/internal/classfile/Classfile.java line 87: > >> 85: * @param r a function mapping attribute names to attribute mappers >> 86: */ >> 87: record AttributeMapperOption(Function> attributeMapper) implements Option { > > We might want to convert these options into interfaces and move the implementation records into ClassfileImpl, like Brian suggested about ClassHierarchyInfo. Will fix it, thanks. > src/java.base/share/classes/jdk/internal/classfile/Classfile.java line 208: > >> 206: */ >> 207: default ClassModel parse(byte[] bytes) { >> 208: return new ClassImpl(bytes, (ClassfileImpl)this); > > Should we implement this in ClassfileImpl to avoid the redundant cast? yes, several methods should move to ClassfileImpl, thanks. > src/java.base/share/classes/jdk/internal/classfile/components/ClassRemapper.java line 102: > >> 100: * @return re-mapped class file bytes >> 101: */ >> 102: default byte[] remapClass(ClassModel clm) { > > This api should ask for a Classfile object instead. Thankfully, the new Classfile object actually allows us to find potentially bugs in our code (say if the remapped class refer to declared types outside of system class loader) yes, I'll add the parameter, thanks. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/14180#discussion_r1212084790 PR Review Comment: https://git.openjdk.org/jdk/pull/14180#discussion_r1212094893 PR Review Comment: https://git.openjdk.org/jdk/pull/14180#discussion_r1212117128 From asotona at openjdk.org Thu Jun 1 15:20:27 2023 From: asotona at openjdk.org (Adam Sotona) Date: Thu, 1 Jun 2023 15:20:27 GMT Subject: RFR: 8308899: Introduce Classfile.Context and improve Classfile.Option(s) [v2] In-Reply-To: References: Message-ID: > Classfile context object and multi-state options have been discussed at https://mail.openjdk.org/pipermail/classfile-api-dev/2023-May/000321.html > This patch implements the proposed changes in Classfile API and fixes all affected code across JDK sources and tests. > > Please review. > > Thanks, > Adam Adam Sotona has updated the pull request incrementally with one additional commit since the last revision: fixed benchmarks ------------- Changes: - all: https://git.openjdk.org/jdk/pull/14180/files - new: https://git.openjdk.org/jdk/pull/14180/files/bcdf0f11..eae9bed3 Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk&pr=14180&range=01 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=14180&range=00-01 Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod Patch: https://git.openjdk.org/jdk/pull/14180.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/14180/head:pull/14180 PR: https://git.openjdk.org/jdk/pull/14180 From liach at openjdk.org Thu Jun 1 15:25:12 2023 From: liach at openjdk.org (Chen Liang) Date: Thu, 1 Jun 2023 15:25:12 GMT Subject: RFR: 8308899: Introduce Classfile.Context and improve Classfile.Option(s) [v2] In-Reply-To: References: Message-ID: On Thu, 1 Jun 2023 15:20:27 GMT, Adam Sotona wrote: >> Classfile context object and multi-state options have been discussed at https://mail.openjdk.org/pipermail/classfile-api-dev/2023-May/000321.html >> This patch implements the proposed changes in Classfile API and fixes all affected code across JDK sources and tests. >> >> Please review. >> >> Thanks, >> Adam > > Adam Sotona has updated the pull request incrementally with one additional commit since the last revision: > > fixed benchmarks In fact, I think we can probably mark Classfile as value-based. Then, whether it's created from a factory at every call or if it's cached (my first 2 review comments) no longer matters as much; the caching behavior will be handled by individual option instances (such as class hierarchy caching in the class hierarchy option's resolver) src/java.base/share/classes/java/lang/Module.java line 1593: > 1591: private Class loadModuleInfoClass(InputStream in) throws IOException { > 1592: final String MODULE_INFO = "module-info"; > 1593: var cc = Classfile.of(Classfile.ConstantPoolSharingOption.DO_NOT_SHARE_CONSTANT_POOL); This `cc` can be stored in a static final field instead. src/java.base/share/classes/jdk/internal/classfile/Classfile.java line 55: > 53: > 54: static Classfile of() { > 55: return new ClassfileImpl(); We can create a static final field in `ClassfileImpl` holding a default instance equivalent to that created by `new ClassfileImpl()` and have the `of()` factory return that instance instead. src/java.base/share/classes/jdk/internal/classfile/impl/StackMapGenerator.java line 840: > 838: try { > 839: //clone SplitConstantPool with alternate context > 840: var cc = Classfile.of(Classfile.StackMapsOption.DO_NOT_GENERATE_STACK_MAPS); This should set the Class hierarchy resolver, patch dead code, and filter dead labels options from the original context. ------------- PR Comment: https://git.openjdk.org/jdk/pull/14180#issuecomment-1572260124 PR Review Comment: https://git.openjdk.org/jdk/pull/14180#discussion_r1213300095 PR Review Comment: https://git.openjdk.org/jdk/pull/14180#discussion_r1213302665 PR Review Comment: https://git.openjdk.org/jdk/pull/14180#discussion_r1213314212 From asotona at openjdk.org Thu Jun 1 19:28:11 2023 From: asotona at openjdk.org (Adam Sotona) Date: Thu, 1 Jun 2023 19:28:11 GMT Subject: RFR: 8308899: Introduce Classfile.Context and improve Classfile.Option(s) [v2] In-Reply-To: References: Message-ID: <_QQg36e2Gem1E01bN6A6jJXC9x3AfInwMOF3j2kknqQ=.0ebd8190-306f-4e5d-9f32-4c37196e5aec@github.com> On Thu, 1 Jun 2023 15:04:00 GMT, Chen Liang wrote: >> Adam Sotona has updated the pull request incrementally with one additional commit since the last revision: >> >> fixed benchmarks > > src/java.base/share/classes/java/lang/Module.java line 1593: > >> 1591: private Class loadModuleInfoClass(InputStream in) throws IOException { >> 1592: final String MODULE_INFO = "module-info"; >> 1593: var cc = Classfile.of(Classfile.ConstantPoolSharingOption.DO_NOT_SHARE_CONSTANT_POOL); > > This `cc` can be stored in a static final field instead. Yes, we can avoid repeated construction of default class hierarchy resolver here. > src/java.base/share/classes/jdk/internal/classfile/Classfile.java line 55: > >> 53: >> 54: static Classfile of() { >> 55: return new ClassfileImpl(); > > We can create a static final field in `ClassfileImpl` holding a default instance equivalent to that created by `new ClassfileImpl()` and have the `of()` factory return that instance instead. Global static default context will hold global shared cached class hierarchy resolver and that we want to avoid. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/14180#discussion_r1213583268 PR Review Comment: https://git.openjdk.org/jdk/pull/14180#discussion_r1213585474 From asotona at openjdk.org Thu Jun 1 19:39:12 2023 From: asotona at openjdk.org (Adam Sotona) Date: Thu, 1 Jun 2023 19:39:12 GMT Subject: RFR: 8308899: Introduce Classfile.Context and improve Classfile.Option(s) [v2] In-Reply-To: References: Message-ID: On Thu, 1 Jun 2023 15:14:52 GMT, Chen Liang wrote: >> Adam Sotona has updated the pull request incrementally with one additional commit since the last revision: >> >> fixed benchmarks > > src/java.base/share/classes/jdk/internal/classfile/impl/StackMapGenerator.java line 840: > >> 838: try { >> 839: //clone SplitConstantPool with alternate context >> 840: var cc = Classfile.of(Classfile.StackMapsOption.DO_NOT_GENERATE_STACK_MAPS); > > This should set the Class hierarchy resolver, patch dead code, and filter dead labels options from the original context. Here the other options are irrelevant. The error report wraps already generated incomplete code attribute into a fake class to be able to print details to the error. I think even the stack map generation suppression is irrelevant here, will double check. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/14180#discussion_r1213598996 From asotona at openjdk.org Fri Jun 2 10:47:06 2023 From: asotona at openjdk.org (Adam Sotona) Date: Fri, 2 Jun 2023 10:47:06 GMT Subject: RFR: 8308899: Introduce Classfile.Context and improve Classfile.Option(s) [v2] In-Reply-To: <_QQg36e2Gem1E01bN6A6jJXC9x3AfInwMOF3j2kknqQ=.0ebd8190-306f-4e5d-9f32-4c37196e5aec@github.com> References: <_QQg36e2Gem1E01bN6A6jJXC9x3AfInwMOF3j2kknqQ=.0ebd8190-306f-4e5d-9f32-4c37196e5aec@github.com> Message-ID: On Thu, 1 Jun 2023 19:23:05 GMT, Adam Sotona wrote: >> src/java.base/share/classes/java/lang/Module.java line 1593: >> >>> 1591: private Class loadModuleInfoClass(InputStream in) throws IOException { >>> 1592: final String MODULE_INFO = "module-info"; >>> 1593: var cc = Classfile.of(Classfile.ConstantPoolSharingOption.DO_NOT_SHARE_CONSTANT_POOL); >> >> This `cc` can be stored in a static final field instead. > > Yes, we can avoid repeated construction of default class hierarchy resolver here. In this situation the ClassHierarchyResolver is never used and have no caching function. Adding static field with initializer does not make much sense here. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/14180#discussion_r1214214987 From asotona at openjdk.org Fri Jun 2 11:24:20 2023 From: asotona at openjdk.org (Adam Sotona) Date: Fri, 2 Jun 2023 11:24:20 GMT Subject: RFR: 8308899: Introduce Classfile.Context and improve Classfile.Option(s) [v3] In-Reply-To: References: Message-ID: > Classfile context object and multi-state options have been discussed at https://mail.openjdk.org/pipermail/classfile-api-dev/2023-May/000321.html > This patch implements the proposed changes in Classfile API and fixes all affected code across JDK sources and tests. > > Please review. > > Thanks, > Adam Adam Sotona 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 22 additional commits since the last revision: - fixed StackMapGenerator::generatorError and removed obsolete SplitConstantPool clone constructor - Merge branch 'master' into JDK-8308899-context - fixed benchmarks - fixed snippets and added SnippetsTest - fixed javadoc - added Classfile context parameter to ClasRemapper::remapClass - records and methods implementations moved from Classfile to ClassfileImpl - added Classfile::buildTo override - implementation of Classfile::withOptions(Option... options) ClassfileImpl made immutable "options" use across implementation renamed to "context" - added test for StackMapsOption.ALWAYS_GENERATE_STACK_MAPS fixed DirectCodeBuilder and added fast bypass when stack map is not needed - ... and 12 more: https://git.openjdk.org/jdk/compare/0945a741...f8915f91 ------------- Changes: - all: https://git.openjdk.org/jdk/pull/14180/files - new: https://git.openjdk.org/jdk/pull/14180/files/eae9bed3..f8915f91 Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk&pr=14180&range=02 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=14180&range=01-02 Stats: 20638 lines in 447 files changed: 15729 ins; 1904 del; 3005 mod Patch: https://git.openjdk.org/jdk/pull/14180.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/14180/head:pull/14180 PR: https://git.openjdk.org/jdk/pull/14180 From asotona at openjdk.org Mon Jun 5 14:31:46 2023 From: asotona at openjdk.org (Adam Sotona) Date: Mon, 5 Jun 2023 14:31:46 GMT Subject: RFR: 8308899: Introduce Classfile.Context and improve Classfile.Option(s) [v4] In-Reply-To: References: Message-ID: > Classfile context object and multi-state options have been discussed at https://mail.openjdk.org/pipermail/classfile-api-dev/2023-May/000321.html > This patch implements the proposed changes in Classfile API and fixes all affected code across JDK sources and tests. > > Please review. > > Thanks, > Adam Adam Sotona 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 23 additional commits since the last revision: - Merge branch 'master' into JDK-8308899-context - fixed StackMapGenerator::generatorError and removed obsolete SplitConstantPool clone constructor - Merge branch 'master' into JDK-8308899-context - fixed benchmarks - fixed snippets and added SnippetsTest - fixed javadoc - added Classfile context parameter to ClasRemapper::remapClass - records and methods implementations moved from Classfile to ClassfileImpl - added Classfile::buildTo override - implementation of Classfile::withOptions(Option... options) ClassfileImpl made immutable "options" use across implementation renamed to "context" - ... and 13 more: https://git.openjdk.org/jdk/compare/7990f646...7d431af9 ------------- Changes: - all: https://git.openjdk.org/jdk/pull/14180/files - new: https://git.openjdk.org/jdk/pull/14180/files/f8915f91..7d431af9 Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk&pr=14180&range=03 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=14180&range=02-03 Stats: 6081 lines in 122 files changed: 4664 ins; 863 del; 554 mod Patch: https://git.openjdk.org/jdk/pull/14180.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/14180/head:pull/14180 PR: https://git.openjdk.org/jdk/pull/14180 From asotona at openjdk.org Mon Jun 5 14:42:32 2023 From: asotona at openjdk.org (Adam Sotona) Date: Mon, 5 Jun 2023 14:42:32 GMT Subject: RFR: 8308899: Introduce Classfile.Context and improve Classfile.Option(s) [v5] In-Reply-To: References: Message-ID: > Classfile context object and multi-state options have been discussed at https://mail.openjdk.org/pipermail/classfile-api-dev/2023-May/000321.html > This patch implements the proposed changes in Classfile API and fixes all affected code across JDK sources and tests. > > Please review. > > Thanks, > Adam Adam Sotona has updated the pull request incrementally with one additional commit since the last revision: fixed copyright header ------------- Changes: - all: https://git.openjdk.org/jdk/pull/14180/files - new: https://git.openjdk.org/jdk/pull/14180/files/7d431af9..965dcba8 Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk&pr=14180&range=04 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=14180&range=03-04 Stats: 2 lines in 1 file changed: 1 ins; 0 del; 1 mod Patch: https://git.openjdk.org/jdk/pull/14180.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/14180/head:pull/14180 PR: https://git.openjdk.org/jdk/pull/14180 From briangoetz at openjdk.org Mon Jun 5 16:38:20 2023 From: briangoetz at openjdk.org (Brian Goetz) Date: Mon, 5 Jun 2023 16:38:20 GMT Subject: RFR: 8308899: Introduce Classfile.Context and improve Classfile.Option(s) [v5] In-Reply-To: References: Message-ID: On Mon, 5 Jun 2023 14:42:32 GMT, Adam Sotona wrote: >> Classfile context object and multi-state options have been discussed at https://mail.openjdk.org/pipermail/classfile-api-dev/2023-May/000321.html >> This patch implements the proposed changes in Classfile API and fixes all affected code across JDK sources and tests. >> >> Please review. >> >> Thanks, >> Adam > > Adam Sotona has updated the pull request incrementally with one additional commit since the last revision: > > fixed copyright header Overall this looks pretty clean. I like how simply it flows through the implementation classes. There are a number of methods and classes, especially in Classfile, which need some more spec. src/java.base/share/classes/jdk/internal/classfile/Classfile.java line 50: > 48: /** > 49: * Main entry points for parsing, transforming, and generating classfiles. > 50: */ Now that this is not just a bag of static methods any more, we need to have some spec text about what a Classfile is. Something like: Represents a context for parsing, transforming, and generating classfiles. A `Classfile` has a set of options that condition how parsing and generation is done. src/java.base/share/classes/jdk/internal/classfile/Classfile.java line 54: > 52: permits ClassfileImpl { > 53: > 54: static Classfile of() { Classfile::of needs specification src/java.base/share/classes/jdk/internal/classfile/Classfile.java line 63: > 61: > 62: Classfile withOptions(Option... options); > 63: Classfile::withOptions needs specification src/java.base/share/classes/jdk/internal/classfile/Classfile.java line 66: > 64: /** > 65: * An option that affects the writing of classfiles. > 66: */ Options affect parsing as well as writing now src/java.base/share/classes/jdk/internal/classfile/constantpool/ConstantPoolBuilder.java line 82: > 80: static ConstantPoolBuilder of() { > 81: return new SplitConstantPool(); > 82: } The old ctors here were (ClassModel) and (Options), where the ClassModel version had a trail of breadcrumbs back to options. The new ctors are (ClassModel) and no-args, which is a slight departure. What use did CPB make of options in the first place, if any? ------------- PR Review: https://git.openjdk.org/jdk/pull/14180#pullrequestreview-1462788383 PR Review Comment: https://git.openjdk.org/jdk/pull/14180#discussion_r1218222043 PR Review Comment: https://git.openjdk.org/jdk/pull/14180#discussion_r1218223437 PR Review Comment: https://git.openjdk.org/jdk/pull/14180#discussion_r1218223102 PR Review Comment: https://git.openjdk.org/jdk/pull/14180#discussion_r1218223991 PR Review Comment: https://git.openjdk.org/jdk/pull/14180#discussion_r1218316864 From asotona at openjdk.org Mon Jun 5 17:42:07 2023 From: asotona at openjdk.org (Adam Sotona) Date: Mon, 5 Jun 2023 17:42:07 GMT Subject: RFR: 8308899: Introduce Classfile.Context and improve Classfile.Option(s) [v5] In-Reply-To: References: Message-ID: On Mon, 5 Jun 2023 16:30:16 GMT, Brian Goetz wrote: >> Adam Sotona has updated the pull request incrementally with one additional commit since the last revision: >> >> fixed copyright header > > src/java.base/share/classes/jdk/internal/classfile/constantpool/ConstantPoolBuilder.java line 82: > >> 80: static ConstantPoolBuilder of() { >> 81: return new SplitConstantPool(); >> 82: } > > The old ctors here were (ClassModel) and (Options), where the ClassModel version had a trail of breadcrumbs back to options. The new ctors are (ClassModel) and no-args, which is a slight departure. What use did CPB make of options in the first place, if any? CPB was only holder of options and others took the options from CPB. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/14180#discussion_r1218391052 From asotona at openjdk.org Mon Jun 5 18:23:52 2023 From: asotona at openjdk.org (Adam Sotona) Date: Mon, 5 Jun 2023 18:23:52 GMT Subject: RFR: 8308899: Introduce Classfile.Context and improve Classfile.Option(s) [v6] In-Reply-To: References: Message-ID: > Classfile context object and multi-state options have been discussed at https://mail.openjdk.org/pipermail/classfile-api-dev/2023-May/000321.html > This patch implements the proposed changes in Classfile API and fixes all affected code across JDK sources and tests. > > Please review. > > Thanks, > Adam Adam Sotona has updated the pull request incrementally with two additional commits since the last revision: - added missing javadoc - simplified options names ------------- Changes: - all: https://git.openjdk.org/jdk/pull/14180/files - new: https://git.openjdk.org/jdk/pull/14180/files/965dcba8..9c20d929 Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk&pr=14180&range=05 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=14180&range=04-05 Stats: 81 lines in 20 files changed: 13 ins; 5 del; 63 mod Patch: https://git.openjdk.org/jdk/pull/14180.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/14180/head:pull/14180 PR: https://git.openjdk.org/jdk/pull/14180 From asotona at openjdk.org Mon Jun 5 18:23:58 2023 From: asotona at openjdk.org (Adam Sotona) Date: Mon, 5 Jun 2023 18:23:58 GMT Subject: RFR: 8308899: Introduce Classfile.Context and improve Classfile.Option(s) [v5] In-Reply-To: References: Message-ID: On Mon, 5 Jun 2023 15:14:35 GMT, Brian Goetz wrote: >> Adam Sotona has updated the pull request incrementally with one additional commit since the last revision: >> >> fixed copyright header > > src/java.base/share/classes/jdk/internal/classfile/Classfile.java line 50: > >> 48: /** >> 49: * Main entry points for parsing, transforming, and generating classfiles. >> 50: */ > > Now that this is not just a bag of static methods any more, we need to have some spec text about what a Classfile is. Something like: > > Represents a context for parsing, transforming, and generating classfiles. A `Classfile` has a set of options that condition how parsing and generation is done. Fixed, thanks. > src/java.base/share/classes/jdk/internal/classfile/Classfile.java line 54: > >> 52: permits ClassfileImpl { >> 53: >> 54: static Classfile of() { > > Classfile::of needs specification Fixed, thanks. > src/java.base/share/classes/jdk/internal/classfile/Classfile.java line 63: > >> 61: >> 62: Classfile withOptions(Option... options); >> 63: > > Classfile::withOptions needs specification Fixed, thanks. > src/java.base/share/classes/jdk/internal/classfile/Classfile.java line 66: > >> 64: /** >> 65: * An option that affects the writing of classfiles. >> 66: */ > > Options affect parsing as well as writing now Fixed, thanks. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/14180#discussion_r1218431266 PR Review Comment: https://git.openjdk.org/jdk/pull/14180#discussion_r1218431345 PR Review Comment: https://git.openjdk.org/jdk/pull/14180#discussion_r1218431300 PR Review Comment: https://git.openjdk.org/jdk/pull/14180#discussion_r1218431386 From asotona at openjdk.org Mon Jun 5 18:59:07 2023 From: asotona at openjdk.org (Adam Sotona) Date: Mon, 5 Jun 2023 18:59:07 GMT Subject: RFR: 8308899: Introduce Classfile.Context and improve Classfile.Option(s) [v7] In-Reply-To: References: Message-ID: > Classfile context object and multi-state options have been discussed at https://mail.openjdk.org/pipermail/classfile-api-dev/2023-May/000321.html > This patch implements the proposed changes in Classfile API and fixes all affected code across JDK sources and tests. > > Please review. > > Thanks, > Adam Adam Sotona has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 27 commits: - Merge branch 'master' into JDK-8308899-context # Conflicts: # src/java.base/share/classes/jdk/internal/classfile/Classfile.java # src/java.base/share/classes/jdk/internal/classfile/impl/DirectCodeBuilder.java # test/jdk/jdk/classfile/DiscontinuedInstructionsTest.java # test/jdk/jdk/classfile/FilterDeadLabelsTest.java # test/jdk/jdk/classfile/ShortJumpsFixTest.java # test/jdk/jdk/classfile/StackMapsTest.java - added missing javadoc - simplified options names - fixed copyright header - Merge branch 'master' into JDK-8308899-context - fixed StackMapGenerator::generatorError and removed obsolete SplitConstantPool clone constructor - Merge branch 'master' into JDK-8308899-context - fixed benchmarks - fixed snippets and added SnippetsTest - fixed javadoc - ... and 17 more: https://git.openjdk.org/jdk/compare/4b8922f5...0c3c1913 ------------- Changes: https://git.openjdk.org/jdk/pull/14180/files Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=14180&range=06 Stats: 1603 lines in 106 files changed: 491 ins; 212 del; 900 mod Patch: https://git.openjdk.org/jdk/pull/14180.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/14180/head:pull/14180 PR: https://git.openjdk.org/jdk/pull/14180 From abimpoudis at openjdk.org Tue Jun 6 15:12:56 2023 From: abimpoudis at openjdk.org (Aggelos Biboudis) Date: Tue, 6 Jun 2023 15:12:56 GMT Subject: RFR: 8309235: Unnamed Variables (_) can't be used in JShell Message-ID: This PR addresses the issue of JShell not accepting unnamed local variables. This solution prints all local variables via the `/vars` command. e.g., jshell> int _ = 42; ==> 42 jshell> int _ = 43; ==> 43 jshell> String _ = "44"; ==> "44" jshell> /vars | int _ = 42 | int _ = 43 | String _ = "44" ------------- Commit messages: - Remove whitespace - 8309235: Unnamed Variables (_) can't be used in JShell Changes: https://git.openjdk.org/jdk/pull/14337/files Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=14337&range=00 Issue: https://bugs.openjdk.org/browse/JDK-8309235 Stats: 92 lines in 8 files changed: 77 ins; 1 del; 14 mod Patch: https://git.openjdk.org/jdk/pull/14337.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/14337/head:pull/14337 PR: https://git.openjdk.org/jdk/pull/14337 From abimpoudis at openjdk.org Tue Jun 6 15:33:14 2023 From: abimpoudis at openjdk.org (Aggelos Biboudis) Date: Tue, 6 Jun 2023 15:33:14 GMT Subject: RFR: 8309235: Unnamed Variables (_) can't be used in JShell [v2] In-Reply-To: References: Message-ID: > This PR addresses the issue of JShell not accepting unnamed local variables. This solution prints all local variables via the `/vars` command. e.g., > > > jshell> int _ = 42; > ==> 42 > > jshell> int _ = 43; > ==> 43 > > jshell> String _ = "44"; > ==> "44" > > jshell> /vars > | int _ = 42 > | int _ = 43 > | String _ = "44" Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision: Fix NPE ------------- Changes: - all: https://git.openjdk.org/jdk/pull/14337/files - new: https://git.openjdk.org/jdk/pull/14337/files/2e44300a..953b5846 Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk&pr=14337&range=01 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=14337&range=00-01 Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod Patch: https://git.openjdk.org/jdk/pull/14337.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/14337/head:pull/14337 PR: https://git.openjdk.org/jdk/pull/14337 From aturbanov at openjdk.org Tue Jun 6 15:45:58 2023 From: aturbanov at openjdk.org (Andrey Turbanov) Date: Tue, 6 Jun 2023 15:45:58 GMT Subject: RFR: 8309235: Unnamed Variables (_) can't be used in JShell [v2] In-Reply-To: References: Message-ID: On Tue, 6 Jun 2023 15:33:14 GMT, Aggelos Biboudis wrote: >> This PR addresses the issue of JShell not accepting unnamed local variables. This solution prints all local variables via the `/vars` command. e.g., >> >> >> jshell> int _ = 42; >> ==> 42 >> >> jshell> int _ = 43; >> ==> 43 >> >> jshell> String _ = "44"; >> ==> "44" >> >> jshell> /vars >> | int _ = 42 >> | int _ = 43 >> | String _ = "44" > > Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision: > > Fix NPE src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java line 3354: > 3352: : getResourceString("jshell.msg.vars.not.active"); > 3353: String varName = vk.name(); > 3354: hard(" %s %s = %s", vk.typeName(), varName.isEmpty() ? "_" : varName, val); Suggestion: hard(" %s %s = %s", vk.typeName(), varName.isEmpty() ? "_" : varName, val); ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/14337#discussion_r1219887603 From asotona at openjdk.org Wed Jun 7 17:44:46 2023 From: asotona at openjdk.org (Adam Sotona) Date: Wed, 7 Jun 2023 17:44:46 GMT Subject: RFR: 8309235: Unnamed Variables (_) can't be used in JShell [v2] In-Reply-To: References: Message-ID: On Tue, 6 Jun 2023 15:33:14 GMT, Aggelos Biboudis wrote: >> This PR addresses the issue of JShell not accepting unnamed local variables. This solution prints all local variables via the `/vars` command. e.g., >> >> >> jshell> int _ = 42; >> ==> 42 >> >> jshell> int _ = 43; >> ==> 43 >> >> jshell> String _ = "44"; >> ==> "44" >> >> jshell> /vars >> | int _ = 42 >> | int _ = 43 >> | String _ = "44" > > Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision: > > Fix NPE Looks good ? ------------- Marked as reviewed by asotona (Reviewer). PR Review: https://git.openjdk.org/jdk/pull/14337#pullrequestreview-1468252642 From abimpoudis at openjdk.org Thu Jun 8 07:26:16 2023 From: abimpoudis at openjdk.org (Aggelos Biboudis) Date: Thu, 8 Jun 2023 07:26:16 GMT Subject: RFR: 8309235: Unnamed Variables (_) can't be used in JShell [v3] In-Reply-To: References: Message-ID: > This PR addresses the issue of JShell not accepting unnamed local variables. This solution prints all local variables via the `/vars` command. e.g., > > > jshell> int _ = 42; > ==> 42 > > jshell> int _ = 43; > ==> 43 > > jshell> String _ = "44"; > ==> "44" > > jshell> /vars > | int _ = 42 > | int _ = 43 > | String _ = "44" Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision: Update src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java Co-authored-by: Andrey Turbanov ------------- Changes: - all: https://git.openjdk.org/jdk/pull/14337/files - new: https://git.openjdk.org/jdk/pull/14337/files/953b5846..970a7635 Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk&pr=14337&range=02 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=14337&range=01-02 Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod Patch: https://git.openjdk.org/jdk/pull/14337.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/14337/head:pull/14337 PR: https://git.openjdk.org/jdk/pull/14337 From abimpoudis at openjdk.org Thu Jun 8 07:28:59 2023 From: abimpoudis at openjdk.org (Aggelos Biboudis) Date: Thu, 8 Jun 2023 07:28:59 GMT Subject: Integrated: 8309235: Unnamed Variables (_) can't be used in JShell In-Reply-To: References: Message-ID: On Tue, 6 Jun 2023 14:59:45 GMT, Aggelos Biboudis wrote: > This PR addresses the issue of JShell not accepting unnamed local variables. This solution prints all local variables via the `/vars` command. e.g., > > > jshell> int _ = 42; > ==> 42 > > jshell> int _ = 43; > ==> 43 > > jshell> String _ = "44"; > ==> "44" > > jshell> /vars > | int _ = 42 > | int _ = 43 > | String _ = "44" This pull request has now been integrated. Changeset: 79a4ac79 Author: Aggelos Biboudis Committer: Adam Sotona URL: https://git.openjdk.org/jdk/commit/79a4ac791c826656b3e984fe54dc472c62efd028 Stats: 92 lines in 8 files changed: 77 ins; 1 del; 14 mod 8309235: Unnamed Variables (_) can't be used in JShell Co-authored-by: Jan Lahoda Co-authored-by: Aggelos Biboudis Reviewed-by: asotona ------------- PR: https://git.openjdk.org/jdk/pull/14337 From asotona at openjdk.org Thu Jun 8 09:26:10 2023 From: asotona at openjdk.org (Adam Sotona) Date: Thu, 8 Jun 2023 09:26:10 GMT Subject: RFR: 8308899: Introduce Classfile.Context and improve Classfile.Option(s) [v8] In-Reply-To: References: Message-ID: > Classfile context object and multi-state options have been discussed at https://mail.openjdk.org/pipermail/classfile-api-dev/2023-May/000321.html > This patch implements the proposed changes in Classfile API and fixes all affected code across JDK sources and tests. > > Please review. > > Thanks, > Adam Adam Sotona has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 29 commits: - removal of ClassHierarchyImpl.DEFAULT_RESOLVER introduction of ClassHierarchyResolver::ofSystem factory method ClassfileImpl does not pre-initialize ClassHierarchyResolverOption with default - Merge branch 'master' into JDK-8308899-context # Conflicts: # src/java.base/share/classes/jdk/internal/classfile/impl/Options.java # src/java.base/share/classes/jdk/internal/classfile/snippet-files/PackageSnippets.java # test/jdk/jdk/classfile/ClassHierarchyInfoTest.java # test/jdk/jdk/classfile/VerifierSelfTest.java - Merge branch 'master' into JDK-8308899-context # Conflicts: # src/java.base/share/classes/jdk/internal/classfile/Classfile.java # src/java.base/share/classes/jdk/internal/classfile/impl/DirectCodeBuilder.java # test/jdk/jdk/classfile/DiscontinuedInstructionsTest.java # test/jdk/jdk/classfile/FilterDeadLabelsTest.java # test/jdk/jdk/classfile/ShortJumpsFixTest.java # test/jdk/jdk/classfile/StackMapsTest.java - added missing javadoc - simplified options names - fixed copyright header - Merge branch 'master' into JDK-8308899-context - fixed StackMapGenerator::generatorError and removed obsolete SplitConstantPool clone constructor - Merge branch 'master' into JDK-8308899-context - fixed benchmarks - ... and 19 more: https://git.openjdk.org/jdk/compare/ac3ce2bf...aa691842 ------------- Changes: https://git.openjdk.org/jdk/pull/14180/files Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=14180&range=07 Stats: 1651 lines in 109 files changed: 501 ins; 244 del; 906 mod Patch: https://git.openjdk.org/jdk/pull/14180.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/14180/head:pull/14180 PR: https://git.openjdk.org/jdk/pull/14180 From briangoetz at openjdk.org Thu Jun 8 11:11:52 2023 From: briangoetz at openjdk.org (Brian Goetz) Date: Thu, 8 Jun 2023 11:11:52 GMT Subject: RFR: 8308899: Introduce Classfile.Context and improve Classfile.Option(s) [v8] In-Reply-To: References: Message-ID: On Thu, 8 Jun 2023 09:26:10 GMT, Adam Sotona wrote: >> Classfile context object and multi-state options have been discussed at https://mail.openjdk.org/pipermail/classfile-api-dev/2023-May/000321.html >> This patch implements the proposed changes in Classfile API and fixes all affected code across JDK sources and tests. >> >> Please review. >> >> Thanks, >> Adam > > Adam Sotona has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 29 commits: > > - removal of ClassHierarchyImpl.DEFAULT_RESOLVER > introduction of ClassHierarchyResolver::ofSystem factory method > ClassfileImpl does not pre-initialize ClassHierarchyResolverOption with default > - Merge branch 'master' into JDK-8308899-context > > # Conflicts: > # src/java.base/share/classes/jdk/internal/classfile/impl/Options.java > # src/java.base/share/classes/jdk/internal/classfile/snippet-files/PackageSnippets.java > # test/jdk/jdk/classfile/ClassHierarchyInfoTest.java > # test/jdk/jdk/classfile/VerifierSelfTest.java > - Merge branch 'master' into JDK-8308899-context > > # Conflicts: > # src/java.base/share/classes/jdk/internal/classfile/Classfile.java > # src/java.base/share/classes/jdk/internal/classfile/impl/DirectCodeBuilder.java > # test/jdk/jdk/classfile/DiscontinuedInstructionsTest.java > # test/jdk/jdk/classfile/FilterDeadLabelsTest.java > # test/jdk/jdk/classfile/ShortJumpsFixTest.java > # test/jdk/jdk/classfile/StackMapsTest.java > - added missing javadoc > - simplified options names > - fixed copyright header > - Merge branch 'master' into JDK-8308899-context > - fixed StackMapGenerator::generatorError and removed obsolete SplitConstantPool clone constructor > - Merge branch 'master' into JDK-8308899-context > - fixed benchmarks > - ... and 19 more: https://git.openjdk.org/jdk/compare/ac3ce2bf...aa691842 Agreed.? The need for sync came from the shared static cache. On 6/8/2023 7:07 AM, liach wrote: > > ***@***.**** commented on this pull request. > > ------------------------------------------------------------------------ > > In > src/java.base/share/classes/jdk/internal/classfile/ClassHierarchyResolver.java > : > > > */ > - static ClassHierarchyResolver defaultResolver() { > - return ClassHierarchyImpl.DEFAULT_RESOLVER; > + static ClassHierarchyResolver ofSystem() { > + var sysLoader = ClassLoader.getSystemClassLoader(); > + return ClassHierarchyResolver > + .ofResourceParsing(sysLoader) > + .orElse(ClassHierarchyResolver.ofClassLoading(sysLoader)) > + .cached(new Supplier<>() { > + @Override > + public Map get() { > + return new ConcurrentHashMap<>(); > > Don't think we need to synchronize the cache if we have dedicated CHRs. > > ? > Reply to this email directly, view it on GitHub > , > or unsubscribe > . > You are receiving this because you commented.Message ID: > ***@***.***> > ------------- PR Comment: https://git.openjdk.org/jdk/pull/14180#issuecomment-1582385327 From liach at openjdk.org Thu Jun 8 11:11:54 2023 From: liach at openjdk.org (Chen Liang) Date: Thu, 8 Jun 2023 11:11:54 GMT Subject: RFR: 8308899: Introduce Classfile.Context and improve Classfile.Option(s) [v8] In-Reply-To: References: Message-ID: On Thu, 8 Jun 2023 09:26:10 GMT, Adam Sotona wrote: >> Classfile context object and multi-state options have been discussed at https://mail.openjdk.org/pipermail/classfile-api-dev/2023-May/000321.html >> This patch implements the proposed changes in Classfile API and fixes all affected code across JDK sources and tests. >> >> Please review. >> >> Thanks, >> Adam > > Adam Sotona has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 29 commits: > > - removal of ClassHierarchyImpl.DEFAULT_RESOLVER > introduction of ClassHierarchyResolver::ofSystem factory method > ClassfileImpl does not pre-initialize ClassHierarchyResolverOption with default > - Merge branch 'master' into JDK-8308899-context > > # Conflicts: > # src/java.base/share/classes/jdk/internal/classfile/impl/Options.java > # src/java.base/share/classes/jdk/internal/classfile/snippet-files/PackageSnippets.java > # test/jdk/jdk/classfile/ClassHierarchyInfoTest.java > # test/jdk/jdk/classfile/VerifierSelfTest.java > - Merge branch 'master' into JDK-8308899-context > > # Conflicts: > # src/java.base/share/classes/jdk/internal/classfile/Classfile.java > # src/java.base/share/classes/jdk/internal/classfile/impl/DirectCodeBuilder.java > # test/jdk/jdk/classfile/DiscontinuedInstructionsTest.java > # test/jdk/jdk/classfile/FilterDeadLabelsTest.java > # test/jdk/jdk/classfile/ShortJumpsFixTest.java > # test/jdk/jdk/classfile/StackMapsTest.java > - added missing javadoc > - simplified options names > - fixed copyright header > - Merge branch 'master' into JDK-8308899-context > - fixed StackMapGenerator::generatorError and removed obsolete SplitConstantPool clone constructor > - Merge branch 'master' into JDK-8308899-context > - fixed benchmarks > - ... and 19 more: https://git.openjdk.org/jdk/compare/ac3ce2bf...aa691842 src/java.base/share/classes/jdk/internal/classfile/ClassHierarchyResolver.java line 66: > 64: @Override > 65: public Map get() { > 66: return new ConcurrentHashMap<>(); Don't think we need to synchronize the cache if we have dedicated CHRs. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/14180#discussion_r1222886769 From asotona at openjdk.org Thu Jun 8 11:26:39 2023 From: asotona at openjdk.org (Adam Sotona) Date: Thu, 8 Jun 2023 11:26:39 GMT Subject: RFR: 8308899: Introduce Classfile.Context and improve Classfile.Option(s) [v9] In-Reply-To: References: Message-ID: > Classfile context object and multi-state options have been discussed at https://mail.openjdk.org/pipermail/classfile-api-dev/2023-May/000321.html > This patch implements the proposed changes in Classfile API and fixes all affected code across JDK sources and tests. > > Please review. > > Thanks, > Adam Adam Sotona has updated the pull request incrementally with one additional commit since the last revision: ClassHierarchyResolver::ofSystem is now thread-unsafe ------------- Changes: - all: https://git.openjdk.org/jdk/pull/14180/files - new: https://git.openjdk.org/jdk/pull/14180/files/aa691842..f3099cd5 Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk&pr=14180&range=08 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=14180&range=07-08 Stats: 8 lines in 1 file changed: 0 ins; 6 del; 2 mod Patch: https://git.openjdk.org/jdk/pull/14180.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/14180/head:pull/14180 PR: https://git.openjdk.org/jdk/pull/14180 From asotona at openjdk.org Thu Jun 8 11:26:43 2023 From: asotona at openjdk.org (Adam Sotona) Date: Thu, 8 Jun 2023 11:26:43 GMT Subject: RFR: 8308899: Introduce Classfile.Context and improve Classfile.Option(s) [v8] In-Reply-To: References: Message-ID: On Thu, 8 Jun 2023 11:07:21 GMT, Chen Liang wrote: >> Adam Sotona has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 29 commits: >> >> - removal of ClassHierarchyImpl.DEFAULT_RESOLVER >> introduction of ClassHierarchyResolver::ofSystem factory method >> ClassfileImpl does not pre-initialize ClassHierarchyResolverOption with default >> - Merge branch 'master' into JDK-8308899-context >> >> # Conflicts: >> # src/java.base/share/classes/jdk/internal/classfile/impl/Options.java >> # src/java.base/share/classes/jdk/internal/classfile/snippet-files/PackageSnippets.java >> # test/jdk/jdk/classfile/ClassHierarchyInfoTest.java >> # test/jdk/jdk/classfile/VerifierSelfTest.java >> - Merge branch 'master' into JDK-8308899-context >> >> # Conflicts: >> # src/java.base/share/classes/jdk/internal/classfile/Classfile.java >> # src/java.base/share/classes/jdk/internal/classfile/impl/DirectCodeBuilder.java >> # test/jdk/jdk/classfile/DiscontinuedInstructionsTest.java >> # test/jdk/jdk/classfile/FilterDeadLabelsTest.java >> # test/jdk/jdk/classfile/ShortJumpsFixTest.java >> # test/jdk/jdk/classfile/StackMapsTest.java >> - added missing javadoc >> - simplified options names >> - fixed copyright header >> - Merge branch 'master' into JDK-8308899-context >> - fixed StackMapGenerator::generatorError and removed obsolete SplitConstantPool clone constructor >> - Merge branch 'master' into JDK-8308899-context >> - fixed benchmarks >> - ... and 19 more: https://git.openjdk.org/jdk/compare/ac3ce2bf...aa691842 > > src/java.base/share/classes/jdk/internal/classfile/ClassHierarchyResolver.java line 66: > >> 64: @Override >> 65: public Map get() { >> 66: return new ConcurrentHashMap<>(); > > Don't think we need to synchronize the cache if we have dedicated CHRs. Fixed, thanks. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/14180#discussion_r1222902932 From asotona at openjdk.org Thu Jun 8 13:26:55 2023 From: asotona at openjdk.org (Adam Sotona) Date: Thu, 8 Jun 2023 13:26:55 GMT Subject: RFR: 8308899: Introduce Classfile.Context and improve Classfile.Option(s) [v9] In-Reply-To: References: Message-ID: On Thu, 8 Jun 2023 11:26:39 GMT, Adam Sotona wrote: >> Classfile context object and multi-state options have been discussed at https://mail.openjdk.org/pipermail/classfile-api-dev/2023-May/000321.html >> This patch implements the proposed changes in Classfile API and fixes all affected code across JDK sources and tests. >> >> Please review. >> >> Thanks, >> Adam > > Adam Sotona has updated the pull request incrementally with one additional commit since the last revision: > > ClassHierarchyResolver::ofSystem is now thread-unsafe Unfortunately thread-unsafe context makes sharing of it in tests executed in parallel a nightmare. I can fix our Corpus tests and hope the race condition won't raise also somewhere else later. However how to explain this limitation to users? I suggest to make it always thread-safe (as the context is primary expected to be shared in multi-threaded environment) and users may make it faster in specific cases by providing non-synchronized map. ------------- PR Comment: https://git.openjdk.org/jdk/pull/14180#issuecomment-1582576426 From asotona at openjdk.org Thu Jun 8 13:37:33 2023 From: asotona at openjdk.org (Adam Sotona) Date: Thu, 8 Jun 2023 13:37:33 GMT Subject: RFR: 8308899: Introduce Classfile.Context and improve Classfile.Option(s) [v10] In-Reply-To: References: Message-ID: <8LzoOpItGA_LBdMX5sJxyPJNV2ZCavz2mIs8t1qrWhw=.908dd1f2-6250-4a43-844e-3dcd100be19e@github.com> > Classfile context object and multi-state options have been discussed at https://mail.openjdk.org/pipermail/classfile-api-dev/2023-May/000321.html > This patch implements the proposed changes in Classfile API and fixes all affected code across JDK sources and tests. > > Please review. > > Thanks, > Adam Adam Sotona has updated the pull request incrementally with one additional commit since the last revision: Revert "ClassHierarchyResolver::ofSystem is now thread-unsafe" This reverts commit f3099cd5b252924392995bf65edc710c27822d2b. ------------- Changes: - all: https://git.openjdk.org/jdk/pull/14180/files - new: https://git.openjdk.org/jdk/pull/14180/files/f3099cd5..41fdb2fc Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk&pr=14180&range=09 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=14180&range=08-09 Stats: 8 lines in 1 file changed: 6 ins; 0 del; 2 mod Patch: https://git.openjdk.org/jdk/pull/14180.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/14180/head:pull/14180 PR: https://git.openjdk.org/jdk/pull/14180 From briangoetz at openjdk.org Thu Jun 8 14:09:58 2023 From: briangoetz at openjdk.org (Brian Goetz) Date: Thu, 8 Jun 2023 14:09:58 GMT Subject: RFR: 8308899: Introduce Classfile.Context and improve Classfile.Option(s) [v10] In-Reply-To: <8LzoOpItGA_LBdMX5sJxyPJNV2ZCavz2mIs8t1qrWhw=.908dd1f2-6250-4a43-844e-3dcd100be19e@github.com> References: <8LzoOpItGA_LBdMX5sJxyPJNV2ZCavz2mIs8t1qrWhw=.908dd1f2-6250-4a43-844e-3dcd100be19e@github.com> Message-ID: On Thu, 8 Jun 2023 13:37:33 GMT, Adam Sotona wrote: >> Classfile context object and multi-state options have been discussed at https://mail.openjdk.org/pipermail/classfile-api-dev/2023-May/000321.html >> This patch implements the proposed changes in Classfile API and fixes all affected code across JDK sources and tests. >> >> Please review. >> >> Thanks, >> Adam > > Adam Sotona has updated the pull request incrementally with one additional commit since the last revision: > > Revert "ClassHierarchyResolver::ofSystem is now thread-unsafe" > > This reverts commit f3099cd5b252924392995bf65edc710c27822d2b. Most entities in the system are immutable and therefore freely sharable without additional coordination.? Some have lazily-inflated single-field caches that conform to the "benign race" (there is only one possible non-default value) criteria. The main hole is the CHA resolution cache.? There are two ways to address this: protect the cache, or don't share the context. Unfortunately now that ClassModel refers back to the context, there's a risk of unexpected context sharing.? Here are a few options: ?- Make the CHA cache thread-safe using, say, CHM; ?- Make the CHA cache unshared, by using a ThreadLocal (this brings the context back to being immutable) ?- Detect when implicit use of a context happens on a thread other than the creating thread (currently the only vector for this is Classfile::transform), and inflate a new context with empty cache in that case; ?- Always create a fresh context with an empty cache in Classfile::transform On 6/8/2023 9:24 AM, Adam Sotona wrote: > > Unfortunately thread-unsafe context makes sharing of it in tests > executed in parallel a nightmare. > I can fix our Corpus tests and hope the race condition won't raise > also somewhere else later. > However how to explain this limitation to users? > > I suggest to make it always thread-safe (as the context is primary > expected to be shared in multi-threaded environment) and users may > make it faster in specific cases by providing non-synchronized map. > > ? > Reply to this email directly, view it on GitHub > , > or unsubscribe > . > You are receiving this because you commented.Message ID: > ***@***.***> > ------------- PR Comment: https://git.openjdk.org/jdk/pull/14180#issuecomment-1582643016 From adam.sotona at oracle.com Thu Jun 8 15:00:00 2023 From: adam.sotona at oracle.com (Adam Sotona) Date: Thu, 8 Jun 2023 15:00:00 +0000 Subject: RFR: 8308899: Introduce Classfile.Context and improve Classfile.Option(s) [v10] In-Reply-To: References: <8LzoOpItGA_LBdMX5sJxyPJNV2ZCavz2mIs8t1qrWhw=.908dd1f2-6250-4a43-844e-3dcd100be19e@github.com> Message-ID: From: core-libs-dev on behalf of Brian Goetz Most entities in the system are immutable and therefore freely sharable without additional coordination. Some have lazily-inflated single-field caches that conform to the "benign race" (there is only one possible non-default value) criteria. The main hole is the CHA resolution cache. There are two ways to address this: protect the cache, or don't share the context. Unfortunately now that ClassModel refers back to the context, there's a risk of unexpected context sharing. Here are a few options: - Make the CHA cache thread-safe using, say, CHM; This is current solution for the default system CH cache. We may also remove ClassHierarchyResolver::cached() method to force user think about it and always call ClassHierarchyResolver::cached(Supplier> cacheFactory) for all non-default cases. Or we may also use a bit less strict custom semi-synchronization (just enough to be thread safe) instead of fully-synchronized CHM::computeIfAbsent, for example CHM:get ? ... CHM::put. - Make the CHA cache unshared, by using a ThreadLocal (this brings the context back to being immutable) This is interesting option for small number of threads, however it makes big footprint for heavy-parallel systems. - Detect when implicit use of a context happens on a thread other than the creating thread (currently the only vector for this is Classfile::transform), and inflate a new context with empty cache in that case; This would degrade the caching completely by triggering a new context for each transformed method in case there are two threads working synchronously. - Always create a fresh context with an empty cache in Classfile::transform This would destroy the caching. Such cache would work only in scope of one method. On 6/8/2023 9:24 AM, Adam Sotona wrote: > > Unfortunately thread-unsafe context makes sharing of it in tests > executed in parallel a nightmare. > I can fix our Corpus tests and hope the race condition won't raise > also somewhere else later. > However how to explain this limitation to users? > > I suggest to make it always thread-safe (as the context is primary > expected to be shared in multi-threaded environment) and users may > make it faster in specific cases by providing non-synchronized map. > > ? > Reply to this email directly, view it on GitHub > , > or unsubscribe > . > You are receiving this because you commented.Message ID: > ***@***.***> > ------------- PR Comment: https://git.openjdk.org/jdk/pull/14180#issuecomment-1582643016 -------------- next part -------------- An HTML attachment was scrubbed... URL: From asotona at openjdk.org Thu Jun 8 16:11:49 2023 From: asotona at openjdk.org (Adam Sotona) Date: Thu, 8 Jun 2023 16:11:49 GMT Subject: RFR: 8308899: Introduce Classfile.Context and improve Classfile.Option(s) [v10] In-Reply-To: References: <8LzoOpItGA_LBdMX5sJxyPJNV2ZCavz2mIs8t1qrWhw=.908dd1f2-6250-4a43-844e-3dcd100be19e@github.com> Message-ID: On Thu, 8 Jun 2023 14:07:24 GMT, Brian Goetz wrote: > Here are a few options: ?- Make the CHA cache thread-safe using, say, CHM; This is current solution for the default system CH cache. We may also use a bit less strict custom semi-synchronization (just enough to be thread safe) instead of fully-synchronized `CHM::computeIfAbsent`, for example `CHM:get ? (compute if absent without lock) ... CHM::put`. CHM does not lock on get, so the only penalty would be synchronous put call. >?- Make the CHA cache unshared, by using a ThreadLocal (this brings the context back to being immutable) This is interesting option for small number of threads, however it makes big footprint for heavy-parallel systems. >?- Detect when implicit use of a context happens on a thread other than the creating thread (currently the only vector for this is Classfile::transform), and inflate a new context with empty cache in that case; This would degrade the caching completely by triggering a new context for each transformed method in case there are two threads working synchronously. >?- Always create a fresh context with an empty cache in Classfile::transform This would destroy the caching. Such cache would work only in scope of one method. ------------- PR Comment: https://git.openjdk.org/jdk/pull/14180#issuecomment-1582943385 From asotona at openjdk.org Thu Jun 8 16:37:22 2023 From: asotona at openjdk.org (Adam Sotona) Date: Thu, 8 Jun 2023 16:37:22 GMT Subject: RFR: 8308899: Introduce Classfile.Context and improve Classfile.Option(s) [v11] In-Reply-To: References: Message-ID: > Classfile context object and multi-state options have been discussed at https://mail.openjdk.org/pipermail/classfile-api-dev/2023-May/000321.html > This patch implements the proposed changes in Classfile API and fixes all affected code across JDK sources and tests. > > Please review. > > Thanks, > Adam Adam Sotona has updated the pull request incrementally with two additional commits since the last revision: - proposed semi-synchronized caching, where the map is not locked during delegate call - used Factory.INSTANCE for system ClassHierarchyResolver cache ------------- Changes: - all: https://git.openjdk.org/jdk/pull/14180/files - new: https://git.openjdk.org/jdk/pull/14180/files/41fdb2fc..ae287751 Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk&pr=14180&range=10 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=14180&range=09-10 Stats: 28 lines in 2 files changed: 13 ins; 11 del; 4 mod Patch: https://git.openjdk.org/jdk/pull/14180.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/14180/head:pull/14180 PR: https://git.openjdk.org/jdk/pull/14180 From briangoetz at openjdk.org Thu Jun 8 16:37:45 2023 From: briangoetz at openjdk.org (Brian Goetz) Date: Thu, 8 Jun 2023 16:37:45 GMT Subject: RFR: 8308899: Introduce Classfile.Context and improve Classfile.Option(s) [v10] In-Reply-To: <8LzoOpItGA_LBdMX5sJxyPJNV2ZCavz2mIs8t1qrWhw=.908dd1f2-6250-4a43-844e-3dcd100be19e@github.com> References: <8LzoOpItGA_LBdMX5sJxyPJNV2ZCavz2mIs8t1qrWhw=.908dd1f2-6250-4a43-844e-3dcd100be19e@github.com> Message-ID: On Thu, 8 Jun 2023 13:37:33 GMT, Adam Sotona wrote: >> Classfile context object and multi-state options have been discussed at https://mail.openjdk.org/pipermail/classfile-api-dev/2023-May/000321.html >> This patch implements the proposed changes in Classfile API and fixes all affected code across JDK sources and tests. >> >> Please review. >> >> Thanks, >> Adam > > Adam Sotona has updated the pull request incrementally with one additional commit since the last revision: > > Revert "ClassHierarchyResolver::ofSystem is now thread-unsafe" > > This reverts commit f3099cd5b252924392995bf65edc710c27822d2b. On 6/8/2023 12:09 PM, Adam Sotona wrote: > > Here are a few options: > ?- Make the CHA cache thread-safe using, say, CHM; > > This is current solution for the default system CH cache. > > We may also use a bit less strict custom semi-synchronization (just > enough to be thread safe) instead of fully-synchronized > |CHM::computeIfAbsent|, for example |CHM:get ? (compute if absent > without lock) ... CHM::put|. > CHM does not lock on get, so the only penalty would be synchronous put > call. > > ?- Make the CHA cache unshared, by using a ThreadLocal (this > brings the context back to being immutable) > > This is interesting option for small number of threads, however it > makes big footprint for heavy-parallel systems. > I have a hard time imagining heavy parallel use here; concurrency against the same cache would most likely come from accidental sharing.? So this is not necessarily a problem.? Are you imagining differnet use cases? ------------- PR Comment: https://git.openjdk.org/jdk/pull/14180#issuecomment-1583003584 From brian.goetz at oracle.com Thu Jun 8 19:57:54 2023 From: brian.goetz at oracle.com (Brian Goetz) Date: Thu, 8 Jun 2023 15:57:54 -0400 Subject: RFR: 8308899: Introduce Classfile.Context and improve Classfile.Option(s) [v9] In-Reply-To: References: Message-ID: <2cff101c-d1cb-e557-ff16-cf8240c6f799@oracle.com> I still don't understand this point.? Why are separate tests sharing a context at all? On 6/8/2023 9:26 AM, Adam Sotona wrote: > Unfortunately thread-unsafe context makes sharing of it in tests executed in parallel a nightmare. > I can fix our Corpus tests and hope the race condition won't raise also somewhere else later. > However how to explain this limitation to users? -------------- next part -------------- An HTML attachment was scrubbed... URL: From asotona at openjdk.org Fri Jun 9 06:19:42 2023 From: asotona at openjdk.org (Adam Sotona) Date: Fri, 9 Jun 2023 06:19:42 GMT Subject: RFR: 8308899: Introduce Classfile.Context and improve Classfile.Option(s) [v10] In-Reply-To: References: <8LzoOpItGA_LBdMX5sJxyPJNV2ZCavz2mIs8t1qrWhw=.908dd1f2-6250-4a43-844e-3dcd100be19e@github.com> Message-ID: On Thu, 8 Jun 2023 16:35:28 GMT, Brian Goetz wrote: > I have a hard time imagining heavy parallel use here; concurrency against the same cache would most likely come from accidental sharing.? So this is not necessarily a problem.? Are you imagining differnet use cases? I think it is common practice for example in web services to pre-configure as much of the common parts as possible (and Classfile context logically falls into that category) and then register the service to the server, which use group of thread workers to handle individual requests. With (non-reusable) virtual threads and structured concurrency on the table makes internal use of thread locals even less sense. I can imagine a new virtual thread launched (and finished) for each individual transformation. Our `CorpusTest` relying on Junit parallelization is not so far from that scenario (I'm not sure if Junit already uses virtual threads or just a group of workers). It is technically irrelevant if user will share the context directly or through a `ClassModel` (for example an instrumentor class used to transform all incoming code - this BTW an idea of faster `j.l.r.ProxyGenerator` I'm thinking about). I think we should be sure that `Classfile` context (and also expansion of `ClassModel`) does not fail in parallel environments. ------------- PR Comment: https://git.openjdk.org/jdk/pull/14180#issuecomment-1584034695 From asotona at openjdk.org Fri Jun 9 06:38:47 2023 From: asotona at openjdk.org (Adam Sotona) Date: Fri, 9 Jun 2023 06:38:47 GMT Subject: RFR: 8308899: Introduce Classfile.Context and improve Classfile.Option(s) [v11] In-Reply-To: References: Message-ID: On Thu, 8 Jun 2023 16:37:22 GMT, Adam Sotona wrote: >> Classfile context object and multi-state options have been discussed at https://mail.openjdk.org/pipermail/classfile-api-dev/2023-May/000321.html >> This patch implements the proposed changes in Classfile API and fixes all affected code across JDK sources and tests. >> >> Please review. >> >> Thanks, >> Adam > > Adam Sotona has updated the pull request incrementally with two additional commits since the last revision: > > - proposed semi-synchronized caching, where the map is not locked during delegate call > - used Factory.INSTANCE for system ClassHierarchyResolver cache I'll run our standard benchmarks to compare following scenarios: - static synchronized single instance cache (current master) - context-based non-synchronized caches `HM::computeIfAbsent` - context-based fully synchronized caches `CHM::computeIfAbsent` - context-based thread-safe lazy synchronized caches `CHM::get ... compute ... CHM::put` And let's see the performance impact. ------------- PR Comment: https://git.openjdk.org/jdk/pull/14180#issuecomment-1584050539 From adam.sotona at oracle.com Fri Jun 9 06:54:54 2023 From: adam.sotona at oracle.com (Adam Sotona) Date: Fri, 9 Jun 2023 06:54:54 +0000 Subject: RFR: 8308899: Introduce Classfile.Context and improve Classfile.Option(s) [v9] In-Reply-To: <2cff101c-d1cb-e557-ff16-cf8240c6f799@oracle.com> References: <2cff101c-d1cb-e557-ff16-cf8240c6f799@oracle.com> Message-ID: The tests use statically specified Transforms and each transformation also held set of options. Now the transformations hold static instance of Classfile context instead. Junit execute them in parallel for each individual class file being transformed, so one context is used in parallel environment. If we fall back to store List