mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8225054: Compiler implementation for records
8225052: javax.lang.model support for records 8225053: Preview APIs support for records 8225055: Javadoc for records 8226314: com.sun.source support for records 8227113: Specification for java.lang.Record 8233526: JVM support for records Implement records in the compiler and the JVM, including serialization, reflection and APIs support Co-authored-by: Brian Goetz <brian.goetz@oracle.com> Co-authored-by: Maurizio Cimadamore <maurizio.cimadamore@oracle.com> Co-authored-by: Harold Seigel <harold.seigel@oracle.com> Co-authored-by: Joe Darcy <joe.darcy@oracle.com> Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com> Co-authored-by: Chris Hegarty <chris.hegarty@oracle.com> Co-authored-by: Jan Lahoda <jan.lahoda@oracle.com> Reviewed-by: mcimadamore, briangoetz, alanb, darcy, chegar, jrose, jlahoda, coleenp, dholmes, lfoltan, mchung, sadayapalam, hannesw, sspitsyn
This commit is contained in:
parent
0a375cfa2d
commit
827e5e3226
351 changed files with 24958 additions and 6395 deletions
|
@ -150,6 +150,10 @@ import sun.reflect.misc.ReflectUtil;
|
|||
* defaultWriteObject and writeFields initially terminate any existing
|
||||
* block-data record.
|
||||
*
|
||||
* @implSpec
|
||||
* Records are serialized differently than ordinary serializable or externalizable
|
||||
* objects, see <a href="ObjectInputStream.html#record-serialization">record serialization</a>.
|
||||
*
|
||||
* @author Mike Warres
|
||||
* @author Roger Riggs
|
||||
* @see java.io.DataOutput
|
||||
|
@ -1431,7 +1435,10 @@ public class ObjectOutputStream
|
|||
bout.writeByte(TC_OBJECT);
|
||||
writeClassDesc(desc, false);
|
||||
handles.assign(unshared ? null : obj);
|
||||
if (desc.isExternalizable() && !desc.isProxy()) {
|
||||
|
||||
if (desc.isRecord()) {
|
||||
writeRecordData(obj, desc);
|
||||
} else if (desc.isExternalizable() && !desc.isProxy()) {
|
||||
writeExternalData((Externalizable) obj);
|
||||
} else {
|
||||
writeSerialData(obj, desc);
|
||||
|
@ -1475,6 +1482,21 @@ public class ObjectOutputStream
|
|||
curPut = oldPut;
|
||||
}
|
||||
|
||||
/** Writes the record component values for the given record object. */
|
||||
@SuppressWarnings("preview")
|
||||
private void writeRecordData(Object obj, ObjectStreamClass desc)
|
||||
throws IOException
|
||||
{
|
||||
assert obj.getClass().isRecord();
|
||||
ObjectStreamClass.ClassDataSlot[] slots = desc.getClassDataLayout();
|
||||
if (slots.length != 1) {
|
||||
throw new InvalidClassException(
|
||||
"expected a single record slot length, but found: " + slots.length);
|
||||
}
|
||||
|
||||
defaultWriteFields(obj, desc); // #### seems unnecessary to use the accessors
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes instance data for each serializable class of given object, from
|
||||
* superclass to subclass.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue