JDK 14 record type representation in classfile format?

Brian Goetz brian.goetz at oracle.com
Sun Mar 22 15:31:17 UTC 2020


This does not appear to be specific to records at all; javac seems to 
generate an IC attribute whenever you _use_ a nested class.  For example:

import java.lang.invoke.*;
public class Foo {
     MethodHandles.Lookup lookup = null;
}

has the following attribute in it:

InnerClasses:
   public static final #7= #6 of #20;      // Lookup=class 
java/lang/invoke/MethodHandles$Lookup of class 
java/lang/invoke/MethodHandles


While this has nothing to do with records, it may still be worth 
discussing whether this attribute is necessary, incorrect, or harmful.   
(Note that Lookup is a _nested_ class of MethodHandles, but not an 
_inner_ one, since it is static.)


On 3/21/2020 7:42 PM, Luke Hutchison wrote:
> In classes I have looked at in the past, if there is an InnerClasses class
> attribute, then the listed inner class containment hierarchy always forms a
> tree rooted at the defining class, and with the tree structure defined by
> the outer_class_info and inner_class_info entries in the InnerClasses
> attribute.
>
> In this case, the outer_class_info is for MethodHandle, and MethodHandle is
> not actually an inner class of the record class, so it seems strange that
> the record class would list MethodHandle$Lookup as an inner class, rather
> than the MethodHandle class listing MethodHandle$Lookup as an inner class.
>
> (I admit I don't understand how bootstrap methods work at the deepest level
> though, so maybe I'm missing something.)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20200322/96300ec5/attachment.htm>


More information about the compiler-dev mailing list