Constant Descriptors usage and Latest versions
Brian Goetz
brian.goetz at oracle.com
Wed Jun 21 01:53:14 UTC 2023
> 1. LATEST_MAJOR_VERSION and LATEST_MINOR_VERSION should become static
> methods: otherwise, javac will inline the constant values, making a
> program compiled with an older JDK unable to fetch the latest Major
> class file version.
Good catch.
> 2. Many usages (in user code) of Constant Descriptors from
> java.lang.constant package are somewhat inefficient: for instance,
> ClassDesc and MethodTypeDesc should both be stored in static final
> fields than constructed on each call; MethodTypeDesc should be
> constructed with a parameter array instead of with a descriptor
> string, as descriptor string parsing has been proven slow in recent
> benchmarks.
The XxxDesc-accepting methods were built on top of XxxEntry-accepting
methods, so you should be able to do everything you need (just with
fewer seat belts) by constructing constant pool entries using UTF8
descriptors.
Are there other changes you want to suggest here, or are you making a
suggestion for the docs? Having a section on constant pool entries /
descriptors in the package javadoc would make sense.
> 3. We should probably have a set of char constants for annotation tags
> in Classfile as well.
>
Seems reasonable.
No objections to any of this. Would you like to propose something concrete?
More information about the classfile-api-dev
mailing list