RFR: 8308899: Introduce Classfile.Context and improve Classfile.Option(s) [v2]

Adam Sotona asotona at openjdk.org
Thu Jun 1 19:28:11 UTC 2023


On Thu, 1 Jun 2023 15:04:00 GMT, Chen Liang <liach at openjdk.org> 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


More information about the core-libs-dev mailing list