JDK 14 record type representation in classfile format?
Vicente Romero
vicente.romero at oracle.com
Sat Mar 21 21:52:43 UTC 2020
cc'ing compiler-dev
OK the discussion has continued on the JBS entry see [1]. I think now
that javac is generating an InnerClasses attribute just because a code
that is used to generate signatures is being reused here to generate the
descriptor for the bootstrap method. This seems to be the only reason
why an InnerClasses attribute is generated whenever there a class refers
/ uses a bootstrap method. The thing is that as this code has been
around since a while, I'm not sure if some other code in the VM or
reflection could be depending on it. Does anybody can shed some light on
this issue?
Thanks,
Vicente
[1] https://bugs.openjdk.java.net/browse/JDK-8241398
On 3/21/20 4:19 PM, Vicente Romero wrote:
> I don't think that this is a bug. Records are using indy to invoke
> bootstrap methods that implement: toString, equals and hashCode. The
> first parameter of every bootstrap method is:
> java/lang/invoke/MethodHandles$Lookup which is an inner class and thus
> requires a dedicated InnerClasses attribute. You can reproduce a very
> similar pattern with any code that uses bootstrap methods like:
>
> class StringTest {
> String m(String s) {
> return s + "";
> }
> }
>
> Thanks,
> Vicente
>
> On 3/21/20 4:01 PM, Remi Forax wrote:
>> ----- Mail original -----
>>> De: "Remi Forax" <forax at univ-mlv.fr>
>>> À: "Luke Hutchison" <luke.hutch at gmail.com>
>>> Cc: "jdk-dev" <jdk-dev at openjdk.java.net>, "amber-dev"
>>> <amber-dev at openjdk.java.net>
>>> Envoyé: Samedi 21 Mars 2020 19:00:04
>>> Objet: Re: JDK 14 record type representation in classfile format?
>> [...]
>>
>>>> Also, records have an "InnerClasses" class attribute, with an inner
>>>> class
>>>> name of "java.lang.invoke.MethodHandles$Lookup" and an outer class
>>>> name of
>>>> "java.lang.invoke.MethodHandles". Normally the outer class name
>>>> matches the
>>>> class whose classfile the attribute is contained in. Why is this inner
>>>> class attribute there, and why does the outer class name not match
>>>> the name
>>>> of the record?
>>> This look like a bug to me.
>> I've created https://bugs.openjdk.java.net/browse/JDK-8241398 to
>> track that.
>>
>> cheers,
>> Rémi
>
More information about the amber-dev
mailing list