JDK-8255342 : Remove non-specified JVM checks on Classes with Record attributes
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 16
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2020-10-23
  • Updated: 2020-12-08
  • Resolved: 2020-10-27
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 16
16 b22Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Description
The JVM should not throw a ClassFormatError exception for abstract or non-final classes that have a Record attribute because that check is not in the JVM Specification.

from dlsmith:
'Record' is not one of the critical attributes described in JVMS 4.7. Like 'Signature' and 'Exceptions', it encodes information that is modeled at the language level, but that the JVM runtime ignores. There is some basic structural validation of these attributes, but nothing that mandates a relationship to other class metadata.

Additionally, the JVM skips Record attributes for classes whose super is not java.lang.Record.  This also needs to change because it's not in the JVM Specification.  The Record attribute should be parsed for these classes.
Comments
InstanceKlass::is_record is misleading since this function returns true on a normal class with `RecordComponents` attribute but not JLS Record (that is a subclass of java.lang.Record and must be final). InstanceKlass::is_record should reflect what a record class really is. No change to JVM class file validation. InstanceKlass::is_record is used by JIT and reflection to determine if the field declared in a record class is non-modifiable by reflection.
12-11-2020

Following this change, Class::isRecord, and by extension Class::getRecordComponents, may return different results, see JDK-8255560.
29-10-2020

Changeset: 18d9905c Author: Harold Seigel <hseigel@openjdk.org> Date: 2020-10-27 12:23:14 +0000 URL: https://git.openjdk.java.net/jdk/commit/18d9905c
27-10-2020