< prev index next > src/java.base/share/classes/java/lang/Record.java
Print this page
/*
! * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
/*
! * Copyright (c) 2019, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* <pre>
* R copy = new R(r.c1(), r.c2(), ..., r.cn());
* </pre>
* then it must be the case that {@code r.equals(copy)}.
*
+ * <div class="preview-block">
+ * <div class="preview-comment">
+ * When preview features are enabled, {@code Record} is
+ * an abstract {@linkplain Class#isValue value class}.
+ * Subclasses of {@code Record} can be either an {@linkplain Class#isIdentity identity class}
+ * or a {@linkplain Class#isValue value class}.
+ * See The Java Language Specification {@jls value-objects-8.1.1.5 Value Classes}.
+ * </div>
+ * </div>
+ *
* @apiNote
* A record class that {@code implements} {@link java.io.Serializable} is said
* to be a <i>serializable record</i>. Serializable records are serialized and
* deserialized differently than ordinary serializable objects. During
* deserialization the record's canonical constructor is invoked to construct
*
* @spec serialization/index.html Java Object Serialization Specification
* @jls 8.10 Record Classes
* @since 16
*/
+ @jdk.internal.MigratedValueClass
+ @jdk.internal.ValueBased
public abstract class Record {
/**
* Constructor for record classes to call.
*/
protected Record() {}
< prev index next >