constantInstruction() & DynamicConstantDesc

Michael van Acken michael.van.acken at gmail.com
Tue Jul 19 05:20:50 UTC 2022


Am Mo., 18. Juli 2022 um 15:06 Uhr schrieb Brian Goetz <
brian.goetz at oracle.com>:

> [...]
>
> Handling ConstantDescs.NULL is an interesting question.  Since this is a
> “convenience” method (the user isn’t asking for a specific opcode, they’re
> saying “here’s a constant, do something”), either treatment of NULL is
> probably valid.  If we do nothing, you’ll get a condy that evaluates to
> null, so you get the same runtime behavior, but then again we could LDC an
> integer constant of zero rather than iconst_0.  So this is probably
> reasonable behavior to special-case NULL here.


Besides the symmetry to the other single-byte encodings, having NULL leaves
room for the application to have its own interpretation of lowercase null.
This is
what happened to me: every expression node of the compiler has a
ConstantDesc
member, with null signalling that the node cannot be represented by a
constant.
I never call  constantInstruction(null) because here the literal meaning of
lowercase
null is "constantInstruction() is not applicable".

-- mva
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/classfile-api-dev/attachments/20220719/b58daed9/attachment.htm>


More information about the classfile-api-dev mailing list