Usage feedback rewriting jdk.internal.foreign.abi.BindingSpecializer

Jorn Vernee jorn.vernee at oracle.com
Tue Mar 14 16:41:43 UTC 2023


Sniped some parts, replies inline.

>> 2. I'm not sure what the expected way of mapping a Class<?> (or 
>> ClassDesc) into a TypeKind is. I couldn't find a factory for that in 
>> TypeKind. The code I have often needs to map Class<?> objects into 
>> TypeKinds. I ended up writing a manual 'mapper' method instead [1].
>
> There is TypeKind.fromDescriptor(s); you can go from either Class or 
> ClassDesc to descriptor fairly easily -- is that good enough? Do the 
> docs need to be updated to guide you towards that?
See my other email to liang. TypeKind.fromDescriptor(s) works, but it 
feels a bit 'off' since I have a high-level type like Class, or 
ClassDesc, and have to go down to a low-level type, String, first. This 
seems different from the rest of the API which accepts ClassDesc 
everywhere. (I thought I might be missing a better way of doing the 
Class -> TypeKind translation)
>
>> 3. Sometimes I need to emit a constant zero for a particular type. If 
>> I know the type is e.g. long, I can use `cb.constantInstruction(0L)`, 
>> but sometimes the type is not statically known, and it would be nice 
>> if there was a CodeBuilder::constantZero(TypeKind) for that. I've 
>> implemented this manually as well [2]
>
> Not sure what you are asking for here.  There's no constant pool form 
> for "short constant".  There's bipush/sipush, though.  What bytecode 
> are you hoping to get out?
I'd expect this:

     cb.constantZero(ShortType)

to result in iconst_0 being emitted. Where 'cb' is an instance of 
`CodeBuilder`. (except, 'ShortType' would not be statically know, but 
derived from a Class<?> value that is fed in to the generation code).

Jorn




More information about the classfile-api-dev mailing list