Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/java.base/share/classes/java/lang/IdentityException.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,17 @@
*
* @since Valhalla
*/
@PreviewFeature(feature = PreviewFeature.Feature.VALUE_OBJECTS)
// Non-preview programs can anticipate to catch this when preview is enabled,
// but should never construct an IdentityException
@PreviewFeature(feature = PreviewFeature.Feature.VALUE_OBJECTS, reflective = true)
public class IdentityException extends RuntimeException {
@java.io.Serial
private static final long serialVersionUID = 1L;

/**
* Create an {@code IdentityException} with no message.
*/
@PreviewFeature(feature = PreviewFeature.Feature.VALUE_OBJECTS, reflective = false)
public IdentityException() {
}

Expand All @@ -50,6 +53,7 @@ public IdentityException() {
*
* @param clazz the class of the object
*/
@PreviewFeature(feature = PreviewFeature.Feature.VALUE_OBJECTS, reflective = false)
public IdentityException(Class<?> clazz) {
super(clazz.getName() + " is not an identity class");
}
Expand All @@ -59,6 +63,7 @@ public IdentityException(Class<?> clazz) {
*
* @param message the detail message; can be {@code null}
*/
@PreviewFeature(feature = PreviewFeature.Feature.VALUE_OBJECTS, reflective = false)
public IdentityException(String message) {
super(message);
}
Expand All @@ -69,6 +74,7 @@ public IdentityException(String message) {
* @param cause the cause; {@code null} is permitted, and indicates
* that the cause is nonexistent or unknown.
*/
@PreviewFeature(feature = PreviewFeature.Feature.VALUE_OBJECTS, reflective = false)
public IdentityException(Throwable cause) {
super(cause);
}
Expand All @@ -80,6 +86,7 @@ public IdentityException(Throwable cause) {
* @param cause the cause; {@code null} is permitted, and indicates
* that the cause is nonexistent or unknown.
*/
@PreviewFeature(feature = PreviewFeature.Feature.VALUE_OBJECTS, reflective = false)
public IdentityException(String message, Throwable cause) {
super(message, cause);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
* This code and its internal interfaces are subject to change or
* deletion without notice.</b>
*/
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
@PreviewFeature(feature = PreviewFeature.Feature.VALUE_OBJECTS, reflective = true)
public sealed interface LoadableDescriptorsAttribute
extends Attribute<LoadableDescriptorsAttribute>, ClassElement
permits BoundAttribute.BoundLoadableDescriptorsAttribute, UnboundAttribute.UnboundLoadableDescriptorsAttribute {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

import jdk.internal.classfile.impl.StackMapDecoder;
import jdk.internal.classfile.impl.TemporaryConstantPool;
import jdk.internal.javac.PreviewFeature;

/**
* Models a stack map frame in a {@link StackMapTableAttribute StackMapTable}
Expand Down Expand Up @@ -83,6 +84,7 @@ public sealed interface StackMapFrameInfo
*
* @see <a href="https://cr.openjdk.org/~dlsmith/jep401/jep401-20250409/specs/strict-fields-jvms.html">Specs</a>
*/
@PreviewFeature(feature = PreviewFeature.Feature.STRICT_FIELDS, reflective = true)
List<NameAndTypeEntry> unsetFields();

/**
Expand All @@ -109,6 +111,7 @@ public static StackMapFrameInfo of(Label target,
* {@link SimpleVerificationTypeInfo#UNINITIALIZED_THIS uninitializedThis}
* is present in {@code locals}
*/
@PreviewFeature(feature = PreviewFeature.Feature.STRICT_FIELDS, reflective = true)
public static StackMapFrameInfo of(Label target,
List<VerificationTypeInfo> locals,
List<VerificationTypeInfo> stack,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ public Set<Location> apply(ClassFileFormatVersion cffv) {
* @jvms 4.5 Fields
* @since Valhalla
*/
@PreviewFeature(feature = PreviewFeature.Feature.VALUE_OBJECTS, reflective=true)
@PreviewFeature(feature = PreviewFeature.Feature.STRICT_FIELDS, reflective=true)
STRICT_INIT(Modifier.STRICT, false,
PreviewFeatures.isEnabled() ? Location.SET_FIELD : Location.EMPTY_SET,
new Function<ClassFileFormatVersion, Set<Location>>() {
Expand Down
8 changes: 4 additions & 4 deletions src/java.base/share/classes/java/util/Objects.java
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public static String toIdentityString(Object o) {
* @throws NullPointerException if {@code obj} is {@code null}
* @since Valhalla
*/
@PreviewFeature(feature = PreviewFeature.Feature.VALUE_OBJECTS)
@PreviewFeature(feature = PreviewFeature.Feature.VALUE_OBJECTS, reflective = true)
// @IntrinsicCandidate
public static boolean hasIdentity(Object obj) {
requireNonNull(obj);
Expand All @@ -205,7 +205,7 @@ public static boolean hasIdentity(Object obj) {
* @throws IdentityException if {@code obj} is not an identity object
* @since Valhalla
*/
@PreviewFeature(feature = PreviewFeature.Feature.VALUE_OBJECTS)
@PreviewFeature(feature = PreviewFeature.Feature.VALUE_OBJECTS, reflective = true)
@ForceInline
public static <T> T requireIdentity(T obj) {
Objects.requireNonNull(obj);
Expand All @@ -226,7 +226,7 @@ public static <T> T requireIdentity(T obj) {
* @throws IdentityException if {@code obj} is not an identity object
* @since Valhalla
*/
@PreviewFeature(feature = PreviewFeature.Feature.VALUE_OBJECTS)
@PreviewFeature(feature = PreviewFeature.Feature.VALUE_OBJECTS, reflective = true)
@ForceInline
public static <T> T requireIdentity(T obj, String message) {
Objects.requireNonNull(obj);
Expand All @@ -247,7 +247,7 @@ public static <T> T requireIdentity(T obj, String message) {
* @throws IdentityException if {@code obj} is not an identity object
* @since Valhalla
*/
@PreviewFeature(feature = PreviewFeature.Feature.VALUE_OBJECTS)
@PreviewFeature(feature = PreviewFeature.Feature.VALUE_OBJECTS, reflective = true)
@ForceInline
public static <T> T requireIdentity(T obj, Supplier<String> messageSupplier) {
Objects.requireNonNull(obj);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@
public enum Feature {
@JEP(number=401, title="Value Classes and Objects", status = "Preview")
VALUE_OBJECTS,
@JEP(number=8350458, title="Strict Field Initialization in the JVM", status="Preview")
STRICT_FIELDS,

// while building the interim javac, the ClassReader will produce a warning when loading a class
// keeping the constant of a feature that has been integrated or dropped, serves the purpose of muting such warnings.
Expand Down