java.lang.constant.ClassDesc and TypeDescriptor for hidden class??
john.r.rose at oracle.com
Thu Apr 2 17:10:14 UTC 2020
On Apr 2, 2020, at 9:35 AM, Brian Goetz <brian.goetz at oracle.com> wrote:
> Hidden classes are not representable in the constant pool of any class other than the hidden class itself. Its instances can arguably describe themselves nominally, but those nominal descriptions are of limited usefulness, since they can't be resolved with the aid of a Lookup. 
> I believe, then, that the right choice is to return an empty Optional, rather than return null or throw an exception.
I’m fine with that reasoning too. We are pushing irregularities
around here, hopefully into the least important corner.
>  Is this correct? I believe even the Lookup for the hidden class itself cannot resolve the name foo.Bar/0x1234?
That is correct. The string name of a HC is (by design) absolutely
useless for any resolution operation. The self-reference of a HC
to itself, within CP of its own classfile, is not distinguished by
the spelling of the CP entry, but rather by the special relation
of the ClassInfo.this_class index to the HC itself. That special
CP entry is (necessarily) pre-resolved to the live HC itself.
There is never a by-name symbolic lookup of an HC at any time.
Any reference to a HC inside a CP would have to use a condy-flavored
ConstantDesc, not a ClassDesc. So I think returning an empty
Optional doesn’t hinder legitimate creation of CP entries that point
More information about the valhalla-dev