Constant Descriptors usage and Latest versions
-
liangchenblue at gmail.com
Wed Jun 21 00:35:22 UTC 2023
Hello,
During the recent browsing of Classfile API and its usages, a few
issues stood out to me:
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.
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.
3. We should probably have a set of char constants for annotation tags
in Classfile as well.
Best,
Chen Liang
More information about the classfile-api-dev
mailing list