New constant API addition proposals for Classfile API
-
liangchenblue at gmail.com
Mon Mar 13 18:41:32 UTC 2023
Agreed, that I indeed have yet to see usages of (3) besides classData
condys. It will be dropped.
I have a patch ready for (2) and will open a pull request for it.
For (1), I have another question: I feel CONSTRUCTOR_NAME and
CLASS_INITIALIZER_NAME are not concise enough. Can you think of more
concise names to facilitate their usage?
On Mon, Mar 13, 2023 at 12:54 PM Brian Goetz <brian.goetz at oracle.com> wrote:
>
> (1) and (2) make total sense; (3) seems a little much, since it is just defaulting in a single argument?
>
>
> On 3/13/2023 1:49 PM, - wrote:
>
> Hi,
> After migrating 26/30 classes in test/jdk/java to Classfile API
> (https://github.com/liachmodded/jdk/commit/65ca55bc2e838823471de40f0e16f9770d932117),
> I suggest to add these new APIs to constant API for ease of Classfile
> API usage:
>
> 1. In ConstantDescs:
> public static final String CONSTRUCTOR_NAME = "<init>";
> public static final String CLASS_INITIALIZER_NAME = "<clinit>";
> public static final MethodTypeDesc MTD_void = MethodTypeDesc.of(CD_void);
>
> Since every instance class always has a constructor, and most likely,
> its constructor has to call Object's no-arg constructor. The same
> method type descriptor is shared for the static initializer too.
>
> 2. In ConstantDescs:
> public static final DirectMethodHandleDesc BSM_CLASS_DATA = ...
> public static final DirectMethodHandleDesc BSM_CLASS_DATA_AT = ...
>
> Representing MethodHandles.classData and MethodHandles.classDataAt,
> used by hidden classes frequently.
>
> 3. In DynamicConstantDesc:
> public static DynamicConstantDesc ofTyped(DirectMethodHandleDesc
> bootstrapMethod, ClassDesc constantType, ConstantDesc...
> bootstrapArgs)
>
> This is equivalent to calling ofNamed with ConstantDescs.DEFAULT_NAME,
> useful for classData and classDataAt bootstrap methods.
>
>
More information about the classfile-api-dev
mailing list