RFR: 8339260: Move rarely used constants out of ClassFile [v6]

ExE Boss duke at openjdk.org
Wed Sep 11 03:25:07 UTC 2024


On Tue, 10 Sep 2024 21:18:19 GMT, Chen Liang <liach at openjdk.org> wrote:

>> Many constants are cluttered in `ClassFile`. However, only a few of them are ever used by regular users, most notably `ACC_` flags and `JAVA_X_VERSION` constants. All other constants are specific and should live in more local locations, such as getters that return these constants.
>> 
>> This simplification of `ClassFile` constants improves user onramp to the Class-File API.
>> 
>> Notably, before, if `ClassFile` is static imported, `Opcode` enums must be qualified due to name clashes; this relocation allows `Opcode` enums to be static imported with `ACC_` flags, improving class file writing user experience.
>
> Chen Liang has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 14 commits:
> 
>  - Merge branch 'master' of https://github.com/openjdk/jdk into fix/constant-moving
>  - omission in tests
>  - Merge branch 'master' of https://github.com/openjdk/jdk into fix/constant-moving
>  - Rename constants at new locations, link to related factories, cp tag constant names
>  - Fix compile errors
>  - Merge branch 'master' of https://github.com/openjdk/jdk into fix/constant-moving
>  - Merge branch 'master' of https://github.com/openjdk/jdk into fix/constant-moving
>  - Merge branch 'master' of https://github.com/openjdk/jdk into fix/constant-moving
>  - Compile errors; now tests are all green.
>  - Move Constant Pool tags to PoolEntry
>    
>    Two unexpected usages in jlink raw processing, but rest is fine
>  - ... and 4 more: https://git.openjdk.org/jdk/compare/6fd043f1...fa9ea36d

src/java.base/share/classes/jdk/internal/classfile/impl/verifier/VerificationBytecodes.java line 92:

> 90:             case ClassFile.WIDE:
> 91:             case ClassFile.TABLESWITCH:
> 92:             case ClassFile.LOOKUPSWITCH:

This method was removed in [JDK‑8339576] ([GH‑20863]):
Suggestion:



[JDK‑8339576]: https://bugs.openjdk.org/browse/JDK-8339576
[GH‑20863]: https://github.com/openjdk/jdk/pull/20863

src/java.base/share/classes/jdk/internal/classfile/impl/verifier/VerifierImpl.java line 1427:

> 1425:         int keys, delta;
> 1426:         current_frame.pop_stack(VerificationType.integer_type);
> 1427:         if (bcs.rawCode == ClassFile.TABLESWITCH) {

Suggestion:

        if (bcs.rawCode == TABLESWITCH) {

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/20773#discussion_r1753066336
PR Review Comment: https://git.openjdk.org/jdk/pull/20773#discussion_r1753066484


More information about the core-libs-dev mailing list