CSR :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
Summary ------- Introduce a Record attribute in the `class` file format, so that the JVM can provide reflection support for components of record types. Problem ------- Record classes ([JEP 359][1]) are a preview feature of Java SE 14. The JVM will need to support reflecting over records and their components. Solution -------- A Record attribute will be defined in the `ClassFile` format, containing information about the record class and its components. The JVM will use the attribute's contents to satisfy reflection requests when the Java API `Class::getRecordComponents` is used. The format of the Record attribute is checked by the JVM even if no reflection is performed. The checking is done at class load time, and is similar to format checking of attributes such as Exceptions and InnerClasses. For example, the JVM checks that the attribute's constant pool indexes are valid and that each component's attributes occur only once. This contrasts with other attributes, such as MethodParameters, that are not examined unless reflection is performed. Note that the Record attribute could potentially be useful in other ways, for example, in determining if a class is a record. The specifications for class redefinition and retransformation, in the JVM TI specification are enhanced to disallow any modification of the `Record` attribute. Specification ------------- Java Virtual Machine Spec changes for the Record attribute are attached. [1]: https://bugs.openjdk.java.net/browse/JDK-8222777 [2]: http://cr.openjdk.java.net/~gbierman/jep359/jep359-20191031/specs/records-jvms.html The JVM TI specification changes are as follows: @@ -7633,8 +7633,8 @@ (unless explicitly prohibited). The retransformation must not add, remove or rename fields or methods, change the signatures of methods, change modifiers, or change inheritance. - The retransformation must not change the <code>NestHost</code> or - <code>NestMembers</code> attributes. + The retransformation must not change the <code>NestHost</code>, + <code>NestMembers</code>, or <code>Record</code> attributes. These restrictions may be lifted in future versions. See the error return description below for information on error codes returned if an unsupported retransformation is attempted. @@ -7786,11 +7786,11 @@ (unless explicitly prohibited). The redefinition must not add, remove or rename fields or methods, change the signatures of methods, change modifiers, or change inheritance. - The retransformation must not change the <code>NestHost</code> or - <code>NestMembers</code> attributes. + The redefinition must not change the <code>NestHost</code>, + <code>NestMembers</code>, or <code>Record</code> attributes. These restrictions may be lifted in future versions. - See the error return description below for information on error codes - returned if an unsupported redefinition is attempted. + See the error return description below for information on error codes + returned if an unsupported redefinition is attempted. The class file bytes are not verified or installed until they have passed through the chain of <eventlink id="ClassFileLoadHook"/> events, thus the returned error code reflects the result of the transformations applied
|