RFR: 8331744: java.lang.classfile.TypeKind improvements [v4]

Adam Sotona asotona at openjdk.org
Thu May 9 07:25:52 UTC 2024


On Tue, 7 May 2024 15:23:10 GMT, Chen Liang <liach at openjdk.org> wrote:

>> A peek into TypeKind during the research for #19105 reveals that TypeKind has a few issues:
>> 1. Name mismatch for `newarraycode` and `fromNewArrayCode`: Renamed both to use "newarray code"
>> 2. `fromDescriptor` can throw IOOBE if the input string is empty: changed to throw IAE and added tests.
>> 3. `from(Class)` can be slow due to descriptor computation: added benchmark, will share result in next comment (as it may change with code changes).
>> 
>> The first 2 changes involves API changes, and a CSR has been created. Requesting @asotona for a review.
>
> Chen Liang has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Hash table, use fixed random seed

src/java.base/share/classes/java/lang/classfile/TypeKind.java line 139:

> 137:             case 'V' -> TypeKind.VoidType;
> 138:             default -> throw new IllegalArgumentException("Bad type: " + s);
> 139:         };

This maps to a `tableswitch`, could you explain why a statically initialized array addressed with a custom hash code suppose to be faster?
Thanks.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/19109#discussion_r1595070662


More information about the core-libs-dev mailing list