diff --git a/make/modules/jdk.incubator.vector/Lib.gmk b/make/modules/jdk.incubator.vector/Lib.gmk index 69da7ed059a..7d2ef440b67 100644 --- a/make/modules/jdk.incubator.vector/Lib.gmk +++ b/make/modules/jdk.incubator.vector/Lib.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2021, 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 @@ -64,7 +64,7 @@ ifeq ($(call isTargetOs, linux)+$(call isTargetCpu, aarch64)+$(INCLUDE_COMPILER2 EXTRA_SRC := libsleef/generated, \ DISABLED_WARNINGS_gcc := unused-function sign-compare tautological-compare ignored-qualifiers, \ DISABLED_WARNINGS_clang := unused-function sign-compare tautological-compare ignored-qualifiers, \ - CFLAGS := $(SVE_CFLAGS), \ + vector_math_sve.c_CFLAGS := $(SVE_CFLAGS), \ )) TARGETS += $(BUILD_LIBSLEEF) diff --git a/src/java.base/share/classes/java/lang/classfile/Annotation.java b/src/java.base/share/classes/java/lang/classfile/Annotation.java index 98b6ea783d5..5c4ee630b08 100644 --- a/src/java.base/share/classes/java/lang/classfile/Annotation.java +++ b/src/java.base/share/classes/java/lang/classfile/Annotation.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 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 @@ -41,8 +41,9 @@ * type_annotation} structure (JVMS {@jvms 4.7.20}). This model indicates the * interface of the annotation and a set of element-value pairs. *
- * This model can reconstruct an annotation, given the location of the modeled structure - * in the class file and the definition of the annotation interface. + * This model can reconstruct an annotation, given the location of the modeled + * structure in the {@code class} file and the definition of the annotation + * interface. *
* Two {@code Annotation} objects should be compared using the {@link
* Object#equals(Object) equals} method.
@@ -54,8 +55,8 @@
* elements with default values (JLS {@jls 9.6.2}), and whether the reconstructed annotation
* is a container annotation for multiple annotations (JLS {@jls 9.7.5}).
*
- * @see AnnotationElement
- * @see AnnotationValue
+ * @see java.lang.annotation.Annotation
+ * @see java.lang.reflect.AnnotatedElement Annotations in core reflection
* @see TypeAnnotation
* @see RuntimeVisibleAnnotationsAttribute
* @see RuntimeInvisibleAnnotationsAttribute
@@ -70,11 +71,15 @@ public sealed interface Annotation
/**
* {@return the constant pool entry holding the {@linkplain Class#descriptorString
* descriptor string} of the annotation interface}
+ *
+ * @see java.lang.annotation.Annotation#annotationType()
*/
Utf8Entry className();
/**
* {@return the annotation interface, as a symbolic descriptor}
+ *
+ * @see java.lang.annotation.Annotation#annotationType()
*/
default ClassDesc classSymbol() {
return Util.fieldTypeSymbol(className());
diff --git a/src/java.base/share/classes/java/lang/classfile/AnnotationElement.java b/src/java.base/share/classes/java/lang/classfile/AnnotationElement.java
index 4381bb9733a..23f830f1512 100644
--- a/src/java.base/share/classes/java/lang/classfile/AnnotationElement.java
+++ b/src/java.base/share/classes/java/lang/classfile/AnnotationElement.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2022, 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
@@ -40,8 +40,8 @@
* {@link Object#equals(Object) equals} method.
*
* @see Annotation
- * @see AnnotationValue
- *
+ * @see java.lang.reflect.AnnotatedElement Annotations in core reflection
+ * @jvms 4.7.16.1 The {@code element_value} structure
* @since 24
*/
public sealed interface AnnotationElement
diff --git a/src/java.base/share/classes/java/lang/classfile/AnnotationValue.java b/src/java.base/share/classes/java/lang/classfile/AnnotationValue.java
index 45ed2fbbe81..54a9ed80573 100644
--- a/src/java.base/share/classes/java/lang/classfile/AnnotationValue.java
+++ b/src/java.base/share/classes/java/lang/classfile/AnnotationValue.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2022, 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
@@ -45,6 +45,7 @@
*
* @see Annotation
* @see AnnotationElement
+ * @see java.lang.reflect.AnnotatedElement Annotations in core reflection
*
* @sealedGraph
* @since 24
diff --git a/src/java.base/share/classes/java/lang/classfile/Attribute.java b/src/java.base/share/classes/java/lang/classfile/Attribute.java
index bb5c7bdf8ea..02b9332bb79 100644
--- a/src/java.base/share/classes/java/lang/classfile/Attribute.java
+++ b/src/java.base/share/classes/java/lang/classfile/Attribute.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2022, 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
@@ -31,15 +31,31 @@
import jdk.internal.classfile.impl.UnboundAttribute;
/**
- * Models a classfile attribute (JVMS {@jvms 4.7}). Many, though not all, subtypes of
- * {@linkplain Attribute} will implement {@link ClassElement}, {@link
- * MethodElement}, {@link FieldElement}, or {@link CodeElement}; attributes that
- * are also elements will be delivered when traversing the elements of the
- * corresponding model type. Additionally, all attributes are accessible
- * directly from the corresponding model type through {@link
- * AttributedElement#findAttribute(AttributeMapper)}.
- * @param the attribute type
+ * Models an attribute (JVMS {@jvms 4.7}) in the {@code class} file format.
+ * Attributes exist on certain {@code class} file structures modeled by {@link
+ * AttributedElement}, which provides basic read access to the attributes.
+ *
+ * This sealed interface hierarchy includes attributes predefined in the JVMS
+ * and JDK-specific nonstandard attributes. Their {@linkplain #attributeMapper()
+ * mappers} are available in {@link Attributes}. Two special subtypes of {@code
+ * Attribute} are {@link CustomAttribute}, which all user-defined attributes
+ * should extend from, and {@link UnknownAttribute}, representing attributes
+ * read from {@code class} file but are not recognized by the {@link
+ * ClassFile.AttributeMapperOption}.
+ *
+ * Attributes are read through {@link AttributedElement} or element traversal of
+ * a {@link CompoundElement}; they are written through {@link ClassFileBuilder}.
+ * See {@linkplain java.lang.classfile.attribute##reading Reading Attributes}
+ * and {@linkplain java.lang.classfile.attribute##writing Writing Attributes}
+ * for more details.
*
+ * @param the attribute type
+ * @see java.lang.classfile.attribute
+ * @see AttributeMapper
+ * @see AttributedElement
+ * @see CustomAttribute
+ * @see UnknownAttribute
+ * @jvms 4.7 Attributes
* @sealedGraph
* @since 24
*/
@@ -62,7 +78,13 @@ public sealed interface Attribute>
StackMapTableAttribute, SyntheticAttribute,
UnknownAttribute, BoundAttribute, UnboundAttribute, CustomAttribute {
/**
- * {@return the name of the attribute}
+ * {@return the name of the attribute} The {@linkplain
+ * Utf8Entry#stringValue() string value} of the name is equivalent to the
+ * value of {@link AttributeMapper#name() attributeMapper().name()}.
+ *
+ * If this attribute is read from a {@code class} file, this method returns
+ * the {@link Utf8Entry} indicating the attribute name in the {@code class}
+ * file.
*/
Utf8Entry attributeName();
diff --git a/src/java.base/share/classes/java/lang/classfile/AttributeMapper.java b/src/java.base/share/classes/java/lang/classfile/AttributeMapper.java
index 993da9aa4a8..411da29b1e9 100644
--- a/src/java.base/share/classes/java/lang/classfile/AttributeMapper.java
+++ b/src/java.base/share/classes/java/lang/classfile/AttributeMapper.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2022, 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
@@ -24,54 +24,118 @@
*/
package java.lang.classfile;
+import java.lang.classfile.attribute.BootstrapMethodsAttribute;
+import java.lang.classfile.attribute.CodeAttribute;
+import java.lang.classfile.attribute.UnknownAttribute;
+import java.lang.classfile.constantpool.ConstantPoolBuilder;
+import java.lang.classfile.constantpool.Utf8Entry;
+
/**
- * Bidirectional mapper between the classfile representation of an attribute and
- * how that attribute is modeled in the API. The attribute mapper is used
- * to parse the classfile representation into a model, and to write the model
- * representation back to a classfile. For each standard attribute, there is a
- * predefined attribute mapper defined in {@link Attributes}. For nonstandard
- * attributes, clients can define their own {@linkplain AttributeMapper}.
- * Classes that model nonstandard attributes should extend {@link
- * CustomAttribute}.
- * @param the attribute type
+ * Bidirectional mapper between the {@code class} file representation of an
+ * attribute and its API model. The attribute mapper identifies an attribute
+ * by its {@linkplain Attribute#attributeName name}, and is used to parse the
+ * {@code class} file representation into a model, and to write the model
+ * representation back to a {@code class} file.
+ *
+ * {@link Attributes} defines the mappers for predefined attributes in the JVMS
+ * and certain conventional attributes. For other attributes (JVMS {@jvms
+ * 4.7.1}), users can define their own {@code AttributeMapper}; classes that
+ * model those attributes should extend {@link CustomAttribute}. To read those
+ * attributes, user-defined {@code AttributeMapper}s must be registered to the
+ * {@link ClassFile.AttributeMapperOption}.
*
+ * @param the attribute type
+ * @see Attributes
+ * @see ClassFile.AttributeMapperOption
+ * @see java.lang.classfile.attribute
* @since 24
*/
public interface AttributeMapper> {
/**
- * Attribute stability indicator
+ * Indicates the data dependency of the {@code class} file representation
+ * of an attribute. Whether an attribute can be bulk-copied by its binary
+ * representation to a new {@code class} file depends on if its data refers
+ * to other parts of its enclosing {@code class} file.
*
+ * @apiNote
+ * This dependency is called "stability" because it indicates the conditions
+ * for a {@code class} file attribute to be eligible for bulk-copying to
+ * another {@code class} file.
+ *
+ * @see AttributeMapper#stability()
* @since 24
*/
enum AttributeStability {
/**
- * The attribute contains only pure data, such as timestamps, and can always be bulk-copied.
+ * The attribute contains only standalone data, and has no reference to
+ * other parts of its enclosing {@code class} file, besides the name of
+ * the attribute. Thus, its contents can always be bulk-copied to
+ * another {@code class} file.
+ *
+ * For example, a bit mask is standalone data.
*/
STATELESS,
/**
- * The attribute contains only pure data and CP refs, so can be bulk-copied when CP sharing is in effect,
- * and need to be exploded and rewritten when CP sharing is not in effect.
+ * In addition to standalone data, the attribute refers to the constant
+ * pool, including the {@link BootstrapMethodsAttribute BootstrapMethods}
+ * attribute, of its enclosing {@code class} file. Thus, it can be
+ * bulk-copied when the destination {@code class} file extends its
+ * constant pool from that of the original {@code class}. It must be
+ * expanded to translate constant pool references and rewritten when
+ * constant pool indices are not compatible.
+ *
+ * For example, a {@link Utf8Entry} is a reference to the constant pool.
+ *
+ * @see ConstantPoolBuilder#of(ClassModel)
+ * @see ClassFile.ConstantPoolSharingOption
*/
CP_REFS,
/**
- * The attribute may contain labels, so need to be exploded and rewritten when the Code array is perturbed.
+ * In addition to standalone data and references to the constant pool,
+ * the attribute refers to positions into the {@code code} array of a
+ * {@link CodeAttribute Code} attribute. Thus, it can be bulked-copied
+ * when the {@code code} array is unchanged, which requires that the
+ * destination {@code class} file extends its constant pool from that of
+ * the original {@code class}. It must be expanded to translate {@link
+ * Label}s or constant pool references and rewritten if the {@code code}
+ * array is perturbed, including when constant pool indices are not
+ * compatible.
+ *
+ * For example, a bci value, modeled by a {@link Label}, is a reference
+ * to a position in the {@code code} array.
*/
LABELS,
/**
- * The attribute may contain indexes into structured not managed by the library (type variable lists, etc)
- * and so we consult the {@link ClassFile.AttributesProcessingOption} option to determine whether to preserve
- * or drop it during transformation.
+ * The attribute refers to structures not managed by the library (type
+ * variable lists, etc.). As a result, even when the attribute is
+ * expanded, those references may not be correctly translated, and the
+ * rewritten results may be incorrect.
+ *
+ * If the attribute is read from a {@code class} file, {@link
+ * ClassFile.AttributesProcessingOption} determines whether to preserve
+ * or drop the attribute during transformation.
+ *
+ * @see ClassFile.AttributesProcessingOption#DROP_UNSTABLE_ATTRIBUTES
*/
UNSTABLE,
/**
- * The attribute is completely unknown and so we consult the {@link ClassFile.AttributesProcessingOption} option
- * to determine whether to preserve or drop it during transformation.
+ * The attribute is completely unknown. As a result, expanding and
+ * rewriting is not possible, and any difference between the destination
+ * {@code class} file and its enclosing {@code class} file may make the
+ * attribute incorrect.
+ *
+ * {@link ClassFile.AttributesProcessingOption} determines whether to
+ * preserve or drop the attribute during transformation.
+ *
+ * @see UnknownAttribute
+ * @see ClassFile.AttributesProcessingOption#DROP_UNSTABLE_ATTRIBUTES
+ * @see ClassFile.AttributesProcessingOption#DROP_UNKNOWN_ATTRIBUTES
*/
UNKNOWN
}
@@ -82,35 +146,104 @@ enum AttributeStability {
String name();
/**
- * Create an {@link Attribute} instance from a classfile.
+ * Creates an {@link Attribute} instance from a {@code class} file for the
+ * Class-File API.
+ *
+ * This method is called by the Class-File API to support reading of
+ * attributes. Users should never call this method.
+ *
+ * The Class-File API makes these promises about the call to this method:
+ *
+ * The returned {@code Attribute} must fulfill these requirements:
+ *
+ * This method is called by the Class-File API to support writing of
+ * attributes. Users should never call this method.
+ *
+ * The Class-File API makes these promises about the call to this method:
+ *
+ * The {@code class} file writing must fulfill these requirements:
+ *
+ * If an attribute does not allow multiple instances in one structure,
+ * can be supplied to a {@link ClassFileBuilder}, and multiple instances of
+ * the attribute are supplied to the builder, the last supplied attribute
+ * appears on the built structure.
*
- * @implSpec The default implementation returns {@code false}
+ * @implSpec The default implementation returns {@code false}.
*/
default boolean allowMultiple() {
return false;
}
/**
- * {@return attribute stability indicator}
+ * {@return the data dependency of this attribute on the {@code class} file}
*/
AttributeStability stability();
}
diff --git a/src/java.base/share/classes/java/lang/classfile/AttributedElement.java b/src/java.base/share/classes/java/lang/classfile/AttributedElement.java
index 478ad1e3f0a..0edb79a863d 100644
--- a/src/java.base/share/classes/java/lang/classfile/AttributedElement.java
+++ b/src/java.base/share/classes/java/lang/classfile/AttributedElement.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2022, 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
@@ -24,6 +24,7 @@
*/
package java.lang.classfile;
+import java.lang.classfile.attribute.CodeAttribute;
import java.lang.classfile.attribute.RecordComponentInfo;
import java.util.ArrayList;
import java.util.Collections;
@@ -35,9 +36,11 @@
import static java.util.Objects.requireNonNull;
/**
- * A {@link ClassFileElement} describing an entity that has attributes, such
- * as a class, field, method, code attribute, or record component.
+ * A {@link ClassFileElement} describing a {@code class} file structure that has
+ * attributes, such as a {@code class} file, a field, a method, a {@link
+ * CodeAttribute Code} attribute, or a record component.
*
+ * @jvms 4.7 Attributes
* @sealedGraph
* @since 24
*/
@@ -46,15 +49,28 @@ public sealed interface AttributedElement extends ClassFileElement
RecordComponentInfo, AbstractUnboundModel {
/**
- * {@return the attributes of this element}
+ * {@return the attributes of this structure}
*/
List
- * Unless otherwise specified, mappers returned by each method
- * do not permit multiple attribute instances in a given location.
- *
- * The most stable {@link AttributeStability#STATELESS STATELESS} mappers are:
- *
+ * All numeric values in the {@code class} file format are {@linkplain
+ * ByteOrder#BIG_ENDIAN big endian}. Writing larger numeric values to smaller
+ * numeric values are always done with truncation, that the least significant
+ * bytes are kept and the other bytes are silently dropped. As a result,
+ * numeric value writing methods can write both signed and unsigned values, and
+ * users should validate their values before writing if silent dropping of most
+ * significant bytes is not the intended behavior.
*
+ * @see AttributeMapper#writeAttribute(BufWriter, Attribute)
* @since 24
*/
public sealed interface BufWriter
permits BufWriterImpl {
- /** {@return the constant pool builder associated with this buffer} */
+ /**
+ * {@return the constant pool builder associated with this buffer}
+ *
+ * @see ClassFileBuilder#constantPool()
+ */
ConstantPoolBuilder constantPool();
/**
- * {@return whether the provided constant pool is index-compatible with this
- * one} This may be because they are the same constant pool, or because this
- * constant pool was copied from the other.
+ * {@return whether the provided constant pool is index-compatible with the
+ * constant pool of this buffer}
+ *
+ * This is a shortcut for {@code constantPool().canWriteDirect(other)}.
*
* @param other the other constant pool
+ * @see ConstantPoolBuilder#canWriteDirect(ConstantPool)
*/
boolean canWriteDirect(ConstantPool other);
/**
- * Ensure that the buffer has at least {@code freeBytes} bytes of unused space
+ * Ensures that the buffer has at least {@code freeBytes} bytes of free space
+ * in the end of the buffer.
+ *
+ * The writing result is the same without calls to this method, but the
+ * writing process may be slower.
+ *
+ * @apiNote
+ * This is a hint that changes no visible state of the buffer; it helps to
+ * reduce reallocation of the underlying storage by allocating sufficient
+ * space at once.
+ *
* @param freeBytes the number of bytes to reserve
*/
void reserveSpace(int freeBytes);
/**
- * Write an unsigned byte to the buffer
+ * Writes a byte to the buffer. {@code x} is truncated to a byte and
+ * written.
*
- * @param x the byte value
+ * @param x the value to truncate to a byte
*/
void writeU1(int x);
/**
- * Write an unsigned short to the buffer
+ * Writes 2 bytes, or a short, to the buffer. {@code x} is truncated to two
+ * bytes and written.
*
- * @param x the short value
+ * @param x the value to truncate to a short
*/
void writeU2(int x);
/**
- * Write a signed int to the buffer
+ * Writes 4 bytes, or an int, to the buffer.
*
* @param x the int value
*/
void writeInt(int x);
/**
- * Write a float value to the buffer
+ * Writes a float value, of 4 bytes, to the buffer.
+ *
+ * In the conversions, all NaN values of the {@code float} may or may not be
+ * collapsed into a single {@linkplain Float#NaN "canonical" NaN value}.
*
* @param x the float value
*/
void writeFloat(float x);
/**
- * Write a long value to the buffer
+ * Writes 8 bytes, or a long, to the buffer.
*
* @param x the long value
*/
void writeLong(long x);
/**
- * Write a double value to the buffer
+ * Writes a double value, of 8 bytes, to the buffer.
+ *
+ * In the conversions, all NaN values of the {@code double} may or may not
+ * be collapsed into a single {@linkplain Double#NaN "canonical" NaN value}.
*
- * @param x the int value
+ * @param x the double value
*/
void writeDouble(double x);
/**
- * Write the contents of a byte array to the buffer
+ * Writes the contents of a byte array to the buffer.
*
* @param arr the byte array
*/
void writeBytes(byte[] arr);
/**
- * Write a range of a byte array to the buffer
+ * Writes a range of a byte array to the buffer.
*
* @param arr the byte array
- * @param start the offset within the byte array of the range
+ * @param start the start offset of the range within the byte array
* @param length the length of the range
- * @throws IndexOutOfBoundsException if range is outside of the array bounds
+ * @throws IndexOutOfBoundsException if range is outside the array bounds
*/
void writeBytes(byte[] arr, int start, int length);
/**
- * Patch a previously written integer value. Depending on the specified
- * size, the entire value, or the low 1 or 2 bytes, may be written.
+ * Patches a previously written integer value. {@code value} is truncated
+ * to the given {@code size} number of bytes and written at the given {@code
+ * offset}. The end of this buffer stays unchanged.
+ *
+ * @apiNote
+ * The {@code offset} can be obtained by calling {@link #size()} before
+ * writing the previous integer value.
*
- * @param offset the offset at which to patch
+ * @param offset the offset in this buffer at which to patch
* @param size the size of the integer value being written, in bytes
- * @param value the integer value
+ * @param value the integer value to be truncated
* @throws IndexOutOfBoundsException if patched int is outside of bounds
+ * @see #size()
*/
void patchInt(int offset, int size, int value);
/**
- * Write a 1, 2, 4, or 8 byte integer value to the buffer. Depending on
- * the specified size, the entire value, or the low 1, 2, or 4 bytes, may
- * be written.
+ * Writes a multibyte value to the buffer. {@code intValue} is truncated
+ * to the given {@code intSize} number of bytes and written.
*
* @param intSize the size of the integer value being written, in bytes
- * @param intValue the integer value
+ * @param intValue the value to be truncated
*/
void writeIntBytes(int intSize, long intValue);
/**
- * Write the index of the specified constant pool entry, as a {@code u2},
- * to the buffer
+ * Writes the index of the specified constant pool entry as a {@link
+ * #writeU2 u2}. If the {@code entry} does not belong to the {@linkplain
+ * #constantPool() constant pool} of this buffer, it will be {@linkplain
+ * ConstantPoolBuilder##alien converted}, and the index of the converted
+ * pool entry is written instead.
*
* @param entry the constant pool entry
* @throws IllegalArgumentException if the entry has invalid index
@@ -148,16 +191,23 @@ public sealed interface BufWriter
void writeIndex(PoolEntry entry);
/**
- * Write the index of the specified constant pool entry, as a {@code u2},
- * to the buffer, or zero if the entry is null
+ * Writes the index of the specified constant pool entry, or the value
+ * {@code 0} if the specified entry is {@code null}, as a {@link #writeU2
+ * u2}. If the {@code entry} does not belong to the {@linkplain
+ * #constantPool() constant pool} of this buffer, it will be {@linkplain
+ * ConstantPoolBuilder##alien converted}, and the index of the converted
+ * pool entry is written instead.
*
- * @param entry the constant pool entry
- * @throws IllegalArgumentException if the entry has invalid index
+ * @param entry the constant pool entry, may be {@code null}
+ * @throws IllegalArgumentException if the entry is not {@code null} and has
+ * invalid index
*/
void writeIndexOrZero(PoolEntry entry);
/**
* {@return the number of bytes that have been written to the buffer}
+ *
+ * @see #patchInt(int, int, int)
*/
int size();
}
diff --git a/src/java.base/share/classes/java/lang/classfile/ClassReader.java b/src/java.base/share/classes/java/lang/classfile/ClassReader.java
index 93f2ac5c810..3de188af8b3 100644
--- a/src/java.base/share/classes/java/lang/classfile/ClassReader.java
+++ b/src/java.base/share/classes/java/lang/classfile/ClassReader.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2022, 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
@@ -35,12 +35,21 @@
import jdk.internal.classfile.impl.ClassReaderImpl;
/**
- * Supports reading from a classfile. Methods are provided to read data of
- * various numeric types (e.g., {@code u2}, {@code u4}) at a given offset within
- * the classfile, copying raw bytes, and reading constant pool entries.
- * Encapsulates additional reading context such as mappers for custom attributes
- * and processing options.
+ * Advanced {@code class} file reading support for {@link AttributeMapper}s.
+ * Supports reading arbitrary offsets within a {@code class} file and reading
+ * data of various numeric types (e.g., {@code u2}, {@code u4}) in addition to
+ * constant pool access.
+ *
+ * All numeric values in the {@code class} file format are {@linkplain
+ * java.nio.ByteOrder#BIG_ENDIAN big endian}.
+ *
+ * Unless otherwise specified, all out-of-bounds access result in an {@link
+ * IllegalArgumentException} to indicate the {@code class} file data is
+ * malformed. Since the {@code class} file data is arbitrary, users should
+ * sanity-check the structural integrity of the data before attempting to
+ * interpret the potentially malformed data.
*
+ * @see AttributeMapper#readAttribute(AttributedElement, ClassReader, int)
* @since 24
*/
public sealed interface ClassReader extends ConstantPool
@@ -56,29 +65,41 @@ public sealed interface ClassReader extends ConstantPool
// Class context
- /** {@return the access flags for the class, as a bit mask } */
+ /**
+ * {@return the access flags for the class, as a bit mask}
+ *
+ * @see ClassModel#flags()
+ */
int flags();
- /** {@return the constant pool entry describing the name of class} */
+ /**
+ * {@return the constant pool entry describing the name of class}
+ *
+ * @see ClassModel#thisClass()
+ */
ClassEntry thisClassEntry();
- /** {@return the constant pool entry describing the name of the superclass, if any} */
+ /**
+ * {@return the constant pool entry describing the name of the superclass, if any}
+ *
+ * @see ClassModel#superclass()
+ */
Optional
+ * In the conversions, all NaN values of the {@code float} may or may not be
+ * collapsed into a single {@linkplain Float#NaN "canonical" NaN value}.
+ *
+ * @param offset the offset within the {@code class} file
*/
float readFloat(int offset);
/**
- * {@return the double value at the specified offset within the classfile}
- * @param offset the offset within the classfile
+ * {@return the double value at the specified offset within the {@code
+ * class} file} Reads 8 bytes of value.
+ *
+ * In the conversions, all NaN values of the {@code double} may or may not
+ * be collapsed into a single {@linkplain Double#NaN "canonical" NaN value}.
+ *
+ * @param offset the offset within the {@code class} file
*/
double readDouble(int offset);
/**
- * {@return a copy of the bytes at the specified range in the classfile}
- * @param offset the offset within the classfile
+ * {@return a copy of the bytes at the specified range in the {@code class}
+ * file}
+ *
+ * @param offset the offset within the {@code class} file
* @param len the length of the range
*/
byte[] readBytes(int offset, int len);
/**
- * Copy a range of bytes from the classfile to a {@link BufWriter}
+ * Copy a range of bytes from the {@code class} file to a {@link BufWriter}.
*
* @param buf the {@linkplain BufWriter}
- * @param offset the offset within the classfile
+ * @param offset the offset within the {@code class} file
* @param len the length of the range
*/
void copyBytesTo(BufWriter buf, int offset, int len);
diff --git a/src/java.base/share/classes/java/lang/classfile/ClassSignature.java b/src/java.base/share/classes/java/lang/classfile/ClassSignature.java
index 0e1329fd167..415332f0059 100644
--- a/src/java.base/share/classes/java/lang/classfile/ClassSignature.java
+++ b/src/java.base/share/classes/java/lang/classfile/ClassSignature.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2022, 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
@@ -24,6 +24,7 @@
*/
package java.lang.classfile;
+import java.lang.classfile.attribute.SignatureAttribute;
import java.util.List;
import jdk.internal.classfile.impl.SignaturesImpl;
@@ -31,27 +32,53 @@
import static java.util.Objects.requireNonNull;
/**
- * Models the generic signature of a class file, as defined by JVMS {@jvms 4.7.9}.
+ * Models the generic signature of a class or interface, as defined by JVMS
+ * {@jvms 4.7.9.1}.
*
+ * @see Class
+ * @see SignatureAttribute
+ * @jls 8.1 Class Declarations
+ * @jls 9.1 Interface Declarations
+ * @jvms 4.7.9.1 Signatures
* @since 24
*/
public sealed interface ClassSignature
permits SignaturesImpl.ClassSignatureImpl {
- /** {@return the type parameters of this class} */
+ /**
+ * {@return the type parameters of this class or interface, may be empty}
+ *
+ * @see Class#getTypeParameters()
+ * @jls 8.1.2 Generic Classes and Type Parameters
+ * @jls 9.1.2 Generic Interfaces and Type Parameters
+ */
List
+ * User-defined attributes are currently not delivered in the traversal of a
+ * {@link CodeModel}.
+ *
+ * Accessor methods on user-defined attributes read from {@code class} files
+ * may throw {@link IllegalArgumentException} if the attribute model is lazily
+ * evaluated, and the evaluation encounters malformed {@code class} file format
+ * for the attribute.
*
+ * @param
- * The attribute does not permit multiple instances in a given location.
- * Subsequent occurrence of the attribute takes precedence during the attributed
- * element build or transformation.
+ * This attribute only appears on methods, and does not permit {@linkplain
+ * AttributeMapper#allowMultiple multiple instances} in a method. It has a
+ * data dependency on the {@linkplain AttributeStability#CP_REFS constant pool}.
*
- * The attribute was introduced in the Java SE Platform version 5.0.
+ * This attribute was introduced in the Java SE Platform version 5.0, major
+ * version {@value ClassFile#JAVA_5_VERSION}.
*
+ * @see Attributes#annotationDefault()
+ * @jls 9.6.2 Defaults for Annotation Interface Elements
+ * @jvms 4.7.22 The {@code AnnotationDefault} Attribute
* @since 24
*/
public sealed interface AnnotationDefaultAttribute
@@ -53,14 +60,16 @@ public sealed interface AnnotationDefaultAttribute
UnboundAttribute.UnboundAnnotationDefaultAttribute {
/**
- * {@return the default value of the annotation type element represented by
- * this method}
+ * {@return the default value of the annotation interface element defined by
+ * the enclosing method}
+ *
+ * @see Method#getDefaultValue()
*/
AnnotationValue defaultValue();
/**
* {@return an {@code AnnotationDefault} attribute}
- * @param annotationDefault the default value of the annotation type element
+ * @param annotationDefault the default value of the annotation interface element
*/
static AnnotationDefaultAttribute of(AnnotationValue annotationDefault) {
return new UnboundAttribute.UnboundAnnotationDefaultAttribute(annotationDefault);
diff --git a/src/java.base/share/classes/java/lang/classfile/attribute/BootstrapMethodsAttribute.java b/src/java.base/share/classes/java/lang/classfile/attribute/BootstrapMethodsAttribute.java
index bbea96dc162..0ed08f63512 100644
--- a/src/java.base/share/classes/java/lang/classfile/attribute/BootstrapMethodsAttribute.java
+++ b/src/java.base/share/classes/java/lang/classfile/attribute/BootstrapMethodsAttribute.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2022, 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
@@ -26,24 +26,41 @@
package java.lang.classfile.attribute;
import java.lang.classfile.Attribute;
+import java.lang.classfile.AttributeMapper;
+import java.lang.classfile.AttributeMapper.AttributeStability;
+import java.lang.classfile.Attributes;
import java.lang.classfile.BootstrapMethodEntry;
+import java.lang.classfile.ClassFile;
+import java.lang.classfile.ClassModel;
import java.lang.classfile.constantpool.ConstantPool;
+import java.lang.classfile.constantpool.ConstantPoolBuilder;
import java.util.List;
import jdk.internal.classfile.impl.BoundAttribute;
import jdk.internal.classfile.impl.UnboundAttribute;
/**
- * Models the {@code BootstrapMethods} attribute (JVMS {@jvms 4.7.23}), which serves as
- * an extension to the constant pool of a classfile. Elements of the bootstrap
- * method table are accessed through {@link ConstantPool}.
+ * Models the {@link Attributes#bootstrapMethods() BootstrapMethods} attribute
+ * (JVMS {@jvms 4.7.23}), which stores symbolic information for the execution of
+ * bootstrap methods, used by dynamically-computed call sites and constants.
+ * It is logically a part of the constant pool of a {@code class} file and thus
+ * not delivered in {@link ClassModel} traversal; its elements are accessible
+ * through {@link ConstantPool}.
*
- * The attribute does not permit multiple instances in a given location.
- * Subsequent occurrence of the attribute takes precedence during the attributed
- * element build or transformation.
+ * This attribute only appears on classes, and does not permit {@linkplain
+ * AttributeMapper#allowMultiple multiple instances} in a class. It has a
+ * data dependency on the {@linkplain AttributeStability#CP_REFS constant pool}.
*
- * The attribute was introduced in the Java SE Platform version 7.
+ * This attribute cannot be constructed directly; its entries can be constructed
+ * through {@link ConstantPoolBuilder#bsmEntry}, resulting in at most one
+ * attribute instance in the built {@code class} file.
+ *
+ * The attribute was introduced in the Java SE Platform version 7, major version
+ * {@value ClassFile#JAVA_7_VERSION}.
*
+ * @see Attributes#bootstrapMethods()
+ * @see java.lang.invoke##bsm Execution of bootstrap methods
+ * @jvms 4.7.23 The {@code BootstrapMethods} Attribute
* @since 24
*/
public sealed interface BootstrapMethodsAttribute
@@ -57,8 +74,7 @@ public sealed interface BootstrapMethodsAttribute
List
+ * Each character range entry associates a range of indices in the code array
+ * with a range of character positions in the source file. A character position
+ * in the source file is represented by a line number and a column number, and
+ * its value is encoded as {@code lineNumber << 10 + columnNumber}. Note that
+ * column numbers are not the same as byte indices in a column as multibyte
+ * characters may be present in the source file.
*
+ * Each character range entry includes a
+ * flag which indicates what kind of range is described: statement, assignment,
+ * method call, etc.
+ *
+ * @see CharacterRangeTableAttribute#characterRangeTable()
+ * @see CharacterRange
* @since 24
*/
public sealed interface CharacterRangeInfo
permits UnboundAttribute.UnboundCharacterRangeInfo {
/**
- * {@return the start of the character range region (inclusive)} This is
- * the index into the code array at which the code for this character range
- * begins.
+ * {@return the start of indices in the code array, inclusive}
+ *
+ * @see CharacterRange#startScope()
*/
int startPc();
/**
- * {@return the end of the character range region (exclusive)} This is the
- * index into the code array after which the code for this character range
- * ends.
+ * {@return the end of indices in the code array, exclusive}
+ *
+ * @see CharacterRange#endScope()
*/
int endPc();
/**
- * {@return the encoded start of the character range region (inclusive)}
- * The value is constructed from the line_number/column_number pair as given
- * by {@code line_number << 10 + column_number}, where the source file is
- * viewed as an array of (possibly multi-byte) characters.
+ * {@return the encoded start of character positions in the source file,
+ * inclusive}
*/
int characterRangeStart();
/**
- * {@return the encoded end of the character range region (exclusive)}.
- * The value is constructed from the line_number/column_number pair as given
- * by {@code line_number << 10 + column_number}, where the source file is
- * viewed as an array of (possibly multi-byte) characters.
+ * {@return the encoded end of character positions in the source file,
+ * exclusive}
*/
int characterRangeEnd();
/**
+ * {@return the flags of this character range entry}
+ *
* The value of the flags item describes the kind of range. Multiple flags
* may be set within flags.
*
- * All bits of the flags item not assigned above are reserved for future use. They should be set to zero in generated class files and should be ignored by Java virtual machine implementations.
+ * All bits of the flags item not assigned above are reserved for future use.
+ * They should be set to zero in generated class files and should be ignored
+ * by Java virtual machine implementations.
*
- * @return the flags
* @see CharacterRange#flags()
*/
int flags();
/**
- * {@return a character range description}
- * @param startPc the start of the bytecode range, inclusive
- * @param endPc the end of the bytecode range, exclusive
- * @param characterRangeStart the start of the character range, inclusive,
- * encoded as {@code line_number << 10 + column_number}
- * @param characterRangeEnd the end of the character range, exclusive,
- * encoded as {@code line_number << 10 + column_number}
- * @param flags the range flags
+ * {@return a character range entry}
+ *
+ * @apiNote
+ * The created entry cannot be written to a {@link CodeBuilder}. Use
+ * {@link CodeBuilder#characterRange CodeBuilder::characterRange} instead.
+ *
+ * @param startPc the start of indices in the code array, inclusive
+ * @param endPc the end of indices in the code array, exclusive
+ * @param characterRangeStart the encoded start of character positions in
+ * the source file, inclusive
+ * @param characterRangeEnd the encoded end of character positions in the
+ * source file, exclusive
+ * @param flags the flags of this entry
*/
static CharacterRangeInfo of(int startPc,
int endPc,
diff --git a/src/java.base/share/classes/java/lang/classfile/attribute/CharacterRangeTableAttribute.java b/src/java.base/share/classes/java/lang/classfile/attribute/CharacterRangeTableAttribute.java
index 42a8443f2f6..49168ed99f8 100644
--- a/src/java.base/share/classes/java/lang/classfile/attribute/CharacterRangeTableAttribute.java
+++ b/src/java.base/share/classes/java/lang/classfile/attribute/CharacterRangeTableAttribute.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2022, 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
@@ -26,37 +26,48 @@
package java.lang.classfile.attribute;
import java.lang.classfile.Attribute;
+import java.lang.classfile.AttributeMapper;
+import java.lang.classfile.AttributeMapper.AttributeStability;
+import java.lang.classfile.Attributes;
+import java.lang.classfile.ClassFile;
+import java.lang.classfile.CodeBuilder;
+import java.lang.classfile.CodeModel;
+import java.lang.classfile.instruction.CharacterRange;
import java.util.List;
import jdk.internal.classfile.impl.BoundAttribute;
import jdk.internal.classfile.impl.UnboundAttribute;
/**
- * The CharacterRangeTable attribute is an optional variable-length attribute in
- * the attributes table of a {@code Code} attribute. It may be used by debuggers
- * to determine which part of the Java virtual machine code array corresponds to
- * a given position in the source file or to determine what section of source
- * code corresponds to a given index into the code array. The
- * CharacterRangeTable attribute consists of an array of character range entries.
- * Each character range entry within the table associates a range of indices in
- * the code array with a range of character indices in the source file. If the
- * source file is viewed as an array of characters, a character index is the
- * corresponding index into this array. Note that character indices are not the
- * same as byte indices as multi-byte characters may be present in the source
- * file. Each character range entry includes a flag which indicates what kind of
- * range is described: statement, assignment, method call, etc. Both code index
- * ranges and character ranges may nest within other ranges, but they may not
- * partially overlap. Thus, a given code index may correspond to several
- * character range entries and in turn several character ranges, but there will
- * be a smallest character range, and for each kind of range in which it is
- * enclosed there will be a smallest character range. Similarly, a given
- * character index may correspond to several character range entries and in turn
- * several code index ranges, but there will be a smallest code index range, and
- * for each kind of range in which it is enclosed there will be a smallest code
- * index range. The character range entries may appear in any order.
+ * Models the {@link Attributes#characterRangeTable() CharacterRangeTable}
+ * attribute, which is a bidirectional mapping from ranges of positions in the
+ * source file to ranges of indices into the {@code code} array. Its entries
+ * are delivered as {@link CharacterRange}s when traversing the elements of a
+ * {@link CodeModel}, toggled by {@link ClassFile.DebugElementsOption}.
*
- * The attribute permits multiple instances in a given location.
+ * The {@code CharacterRangeTable} attribute consists of an array of {@linkplain
+ * CharacterRangeInfo character range entries}. The character range entries
+ * form a forest data structure: any two range entries are either disjoint, or
+ * if they overlap, then one entry must be enclosed within the other, both in
+ * {@code code} array indices and source file character positions. The
+ * character range entries may appear in any order.
+ *
+ * This attribute only appears on {@code Code} attributes, permits multiple
+ * appearances but should only {@linkplain AttributeMapper#allowMultiple()
+ * appear once} in a {@code Code} attribute. It has a data dependency on
+ * {@linkplain AttributeStability#LABELS labels}.
+ *
+ * This attribute cannot be sent to a {@link CodeBuilder}; its entries can be
+ * constructed with {@link CharacterRange}, resulting in at most one
+ * attribute instance in the built {@code Code} attribute.
+ *
+ * This attribute is not predefined in the Java SE Platform. This is a
+ * JDK-specific nonstandard attribute produced by the reference implementation
+ * of the system Java compiler, defined by the {@code jdk.compiler} module.
*
+ * @see Attributes#characterRangeTable()
+ * @see CompilationIDAttribute
+ * @see SourceIDAttribute
* @since 24
*/
public sealed interface CharacterRangeTableAttribute
@@ -71,6 +82,11 @@ public sealed interface CharacterRangeTableAttribute
/**
* {@return a {@code CharacterRangeTable} attribute}
+ *
+ * @apiNote
+ * The created attribute cannot be written to a {@link CodeBuilder}. Use
+ * {@link CodeBuilder#characterRange CodeBuilder::characterRange} instead.
+ *
* @param ranges the descriptions of the character ranges
*/
static CharacterRangeTableAttribute of(List
- * The attribute does not permit multiple instances in a given location.
- * Subsequent occurrence of the attribute takes precedence during the attributed
- * element build or transformation.
+ * This attribute only appears on methods, and does not permit {@linkplain
+ * AttributeMapper#allowMultiple multiple instances} in a method. It has a
+ * data dependency on the {@linkplain AttributeStability#CP_REFS constant pool}.
+ *
+ * This attribute was introduced in the Java Platform version 1.0.2, major
+ * version {@value ClassFile#JAVA_1_VERSION}.
+ *
+ * @apiNote
+ * {@code CodeAttribute} models properties of a {@code Code} attribute read
+ * from {@code class} files. General {@code class} file transformation should
+ * process and traverse a {@link CodeModel} in the traversal of a {@link
+ * MethodModel}, to support transformation of {@code Code} attributes currently
+ * being built.
*
+ * @see Attributes#code()
+ * @jvms 4.7.3 The {@code Code} Attribute
* @since 24
*/
public sealed interface CodeAttribute extends Attribute
- * The attribute does not permit multiple instances in a given location.
- * Subsequent occurrence of the attribute takes precedence during the attributed
- * element build or transformation.
+ * This attribute only appears on classes, and does not permit {@linkplain
+ * AttributeMapper#allowMultiple multiple instances} in a class. It has a
+ * data dependency on the {@linkplain AttributeStability#CP_REFS constant pool}.
+ *
+ * This attribute is not predefined in the Java SE Platform. This is a
+ * JDK-specific nonstandard attribute produced by the reference implementation
+ * of the system Java compiler, defined by the {@code jdk.compiler} module.
*
+ * @see Attributes#compilationId()
+ * @see CharacterRangeTableAttribute
+ * @see SourceIDAttribute
* @since 24
*/
public sealed interface CompilationIDAttribute
@@ -51,8 +59,8 @@ public sealed interface CompilationIDAttribute
UnboundAttribute.UnboundCompilationIDAttribute {
/**
- * {@return the compilation ID} The compilation ID is the value of
- * {@link System#currentTimeMillis()} when the classfile is generated.
+ * {@return the compilation ID} The compilation ID is the string value of
+ * {@link System#currentTimeMillis()} when the {@code class} file is generated.
*/
Utf8Entry compilationId();
diff --git a/src/java.base/share/classes/java/lang/classfile/attribute/ConstantValueAttribute.java b/src/java.base/share/classes/java/lang/classfile/attribute/ConstantValueAttribute.java
index 54f4742ab0c..7aa6540aa86 100644
--- a/src/java.base/share/classes/java/lang/classfile/attribute/ConstantValueAttribute.java
+++ b/src/java.base/share/classes/java/lang/classfile/attribute/ConstantValueAttribute.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2022, 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
@@ -25,6 +25,10 @@
package java.lang.classfile.attribute;
import java.lang.classfile.Attribute;
+import java.lang.classfile.AttributeMapper;
+import java.lang.classfile.AttributeMapper.AttributeStability;
+import java.lang.classfile.Attributes;
+import java.lang.classfile.ClassFile;
import java.lang.classfile.FieldElement;
import java.lang.classfile.constantpool.ConstantValueEntry;
import java.lang.constant.ConstantDesc;
@@ -34,15 +38,19 @@
import jdk.internal.classfile.impl.UnboundAttribute;
/**
- * Models the {@code ConstantValue} attribute (JVMS {@jvms 4.7.2}), which can appear on
- * fields and indicates that the field's value is a constant. Delivered as a
- * {@link java.lang.classfile.FieldElement} when traversing the elements of a
- * {@link java.lang.classfile.FieldModel}.
+ * Models the {@link Attributes#constantValue() ConstantValue} attribute (JVMS
+ * {@jvms 4.7.2}), which indicates this field's value is a constant and that
+ * constant value.
*
- * The attribute does not permit multiple instances in a given location.
- * Subsequent occurrence of the attribute takes precedence during the attributed
- * element build or transformation.
+ * This attribute only appears on fields, and does not permit {@linkplain
+ * AttributeMapper#allowMultiple multiple instances} in a field. It has a
+ * data dependency on the {@linkplain AttributeStability#CP_REFS constant pool}.
+ *
+ * This attribute was introduced in the Java Platform version 1.0.2, major
+ * version {@value ClassFile#JAVA_1_VERSION}.
*
+ * @see Attributes#constantValue()
+ * @jvms 4.7.2 The {@code ConstantValue} Attribute
* @since 24
*/
public sealed interface ConstantValueAttribute
diff --git a/src/java.base/share/classes/java/lang/classfile/attribute/DeprecatedAttribute.java b/src/java.base/share/classes/java/lang/classfile/attribute/DeprecatedAttribute.java
index 9e470711e1f..89a0394388c 100644
--- a/src/java.base/share/classes/java/lang/classfile/attribute/DeprecatedAttribute.java
+++ b/src/java.base/share/classes/java/lang/classfile/attribute/DeprecatedAttribute.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2022, 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
@@ -24,22 +24,34 @@
*/
package java.lang.classfile.attribute;
-import java.lang.classfile.Attribute;
-import java.lang.classfile.ClassElement;
-import java.lang.classfile.FieldElement;
-import java.lang.classfile.MethodElement;
+import java.lang.classfile.*;
+import java.lang.classfile.AttributeMapper.AttributeStability;
import jdk.internal.classfile.impl.BoundAttribute;
import jdk.internal.classfile.impl.UnboundAttribute;
/**
- * Models the {@code Deprecated} attribute (JVMS {@jvms 4.7.15}), which can appear on
- * classes, methods, and fields. Delivered as a {@link ClassElement},
- * {@link MethodElement}, or {@link FieldElement} when traversing the elements
- * of a corresponding model.
+ * Models the {@link Attributes#deprecated() Deprecated} attribute (JVMS {@jvms
+ * 4.7.15}), which indicates this structure has been superseded.
*
- * The attribute permits multiple instances in a given location.
+ * This attribute can appear on classes, methods, and fields, and permits
+ * {@linkplain AttributeMapper#allowMultiple multiple instances} in a structure.
+ * It has {@linkplain AttributeStability#STATELESS no data dependency}.
+ *
+ * This attribute was introduced in the Java SE Platform version 1.1, major
+ * version {@value ClassFile#JAVA_1_VERSION}.
+ *
+ * @apiNote
+ * When this attribute is present, the {@link Deprecated} annotation should
+ * also be present in the {@link RuntimeVisibleAnnotationsAttribute
+ * RuntimeVisibleAnnotations} attribute to provide more obvious alerts.
+ * The reference implementation of the system Java compiler emits this attribute
+ * without the annotation when a {@code @deprecated} tag is present in the
+ * documentation comments without the annotation.
*
+ * @see Attributes#deprecated()
+ * @see Deprecated
+ * @jvms 4.7.15 The {@code Deprecated} Attribute
* @since 24
*/
public sealed interface DeprecatedAttribute
diff --git a/src/java.base/share/classes/java/lang/classfile/attribute/EnclosingMethodAttribute.java b/src/java.base/share/classes/java/lang/classfile/attribute/EnclosingMethodAttribute.java
index 06ded8c82a5..c89bed9fde9 100644
--- a/src/java.base/share/classes/java/lang/classfile/attribute/EnclosingMethodAttribute.java
+++ b/src/java.base/share/classes/java/lang/classfile/attribute/EnclosingMethodAttribute.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2022, 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
@@ -25,11 +25,16 @@
package java.lang.classfile.attribute;
import java.lang.classfile.Attribute;
+import java.lang.classfile.AttributeMapper;
+import java.lang.classfile.AttributeMapper.AttributeStability;
+import java.lang.classfile.Attributes;
import java.lang.classfile.ClassElement;
+import java.lang.classfile.ClassFile;
import java.lang.classfile.constantpool.ClassEntry;
import java.lang.classfile.constantpool.NameAndTypeEntry;
import java.lang.classfile.constantpool.Utf8Entry;
import java.lang.constant.ClassDesc;
+import java.lang.constant.ConstantDescs;
import java.lang.constant.MethodTypeDesc;
import java.util.Optional;
@@ -39,17 +44,20 @@
import jdk.internal.classfile.impl.Util;
/**
- * Models the {@code EnclosingMethod} attribute (JVMS {@jvms 4.7.7}), which can appear
- * on classes, and indicates that the class is a local or anonymous class.
- * Delivered as a {@link ClassElement} when traversing the elements of a {@link
- * java.lang.classfile.ClassModel}.
+ * Models the {@link Attributes#enclosingMethod() EnclosingMethod} attribute
+ * (JVMS {@jvms 4.7.7}), which indicates that this class is a local or
+ * anonymous class, and indicates the enclosing method or constructor of this
+ * class if this class is enclosed in exactly one method or constructor.
*
- * The attribute does not permit multiple instances in a given location.
- * Subsequent occurrence of the attribute takes precedence during the attributed
- * element build or transformation.
+ * This attribute only appears on classes, and does not permit {@linkplain
+ * AttributeMapper#allowMultiple multiple instances} in a class. It has a
+ * data dependency on the {@linkplain AttributeStability#CP_REFS constant pool}.
*
- * The attribute was introduced in the Java SE Platform version 5.0.
+ * The attribute was introduced in the Java SE Platform version 5.0, major
+ * version {@value ClassFile#JAVA_5_VERSION}.
*
+ * @see Attributes#enclosingMethod()
+ * @jvms 4.7.7 The {@code EnclosingMethod} Attribute
* @since 24
*/
public sealed interface EnclosingMethodAttribute
@@ -58,36 +66,52 @@ public sealed interface EnclosingMethodAttribute
UnboundAttribute.UnboundEnclosingMethodAttribute {
/**
- * {@return the innermost class that encloses the declaration of the current
- * class}
+ * {@return the class that encloses the declaration of the current
+ * class} If the {@link #enclosingMethod()} is present, this is the
+ * declaring class of that enclosing method or constructor.
+ *
+ * @see Class#getEnclosingClass()
*/
ClassEntry enclosingClass();
/**
* {@return the name and type of the enclosing method, if the class is
- * immediately enclosed by a method or constructor}
+ * immediately enclosed by exactly one method or constructor} This may
+ * be empty if the anonymous or local class appears in a field initializer
+ * (JLS {@jls 8.3.2}), an instance initializer (JLS {@jls 8.6}), or a static
+ * initializer (JLS {@jls 8.7}). As a result, this never describes a class
+ * initialization method {@value ConstantDescs#CLASS_INIT_NAME}.
+ *
+ * @see Class#getEnclosingMethod()
+ * @see Class#getEnclosingConstructor()
*/
Optional
- * The attribute does not permit multiple instances in a given location.
- * Subsequent occurrence of the attribute takes precedence during the attributed
- * element build or transformation.
+ * This attribute only appears on methods, and does not permit {@linkplain
+ * AttributeMapper#allowMultiple multiple instances} in a method. It has a
+ * data dependency on the {@linkplain AttributeStability#CP_REFS constant pool}.
+ *
+ * The attribute was introduced in the Java Platform version 1.0.2, major
+ * version {@value ClassFile#JAVA_1_VERSION}.
+ *
+ * @apiNote
+ * Generic exceptions types thrown by a method and potentially annotated use of
+ * those types are defined by {@link SignatureAttribute} and {@link
+ * RuntimeVisibleTypeAnnotationsAttribute} respectively, which requires this
+ * attribute to be present.
*
+ * @see Attributes#exceptions()
+ * @jvms 4.7.5 The {@code Exceptions} Attribute
* @since 24
*/
public sealed interface ExceptionsAttribute
@@ -54,12 +69,14 @@ public sealed interface ExceptionsAttribute
/**
* {@return the exceptions declared to be thrown by this method}
+ *
+ * @see Executable#getExceptionTypes()
*/
List
- * The attribute does not permit multiple instances in a given location.
- * Subsequent occurrence of the attribute takes precedence during the attributed
- * element build or transformation.
+ * This attribute only appears on classes, and does not permit {@linkplain
+ * AttributeMapper#allowMultiple multiple instances} in a class. It has a
+ * data dependency on the {@linkplain AttributeStability#CP_REFS constant pool}.
+ *
+ * The attribute was introduced in the Java SE Platform version 1.1, major
+ * version {@value ClassFile#JAVA_1_VERSION}.
*
+ * @see Attributes#innerClasses()
+ * @jvms 4.7.6 The {@code InnerClasses} Attribute
* @since 24
*/
public sealed interface InnerClassesAttribute
@@ -50,13 +58,13 @@ public sealed interface InnerClassesAttribute
UnboundAttribute.UnboundInnerClassesAttribute {
/**
- * {@return the inner classes used by this class}
+ * {@return the nested classes used by this {@code class} file}
*/
List
- * The attribute permits multiple instances in a given location.
+ * This attribute only appears on {@code Code} attributes, and permits {@linkplain
+ * AttributeMapper#allowMultiple() multiple instances} in a {@code Code}
+ * attribute. It has a data dependency on {@linkplain AttributeStability#LABELS
+ * labels}.
+ *
+ * This attribute cannot be sent to a {@link CodeBuilder}; its entries can be
+ * constructed with {@link LineNumber}, resulting in at most one attribute
+ * instance in the built {@code Code} attribute.
+ *
+ * The attribute was introduced in the Java Platform version 1.0.2, major
+ * version {@value ClassFile#JAVA_1_VERSION}.
*
+ * @see Attributes#lineNumberTable()
+ * @jvms 4.7.12 The {@code LineNumberTable} Attribute
* @since 24
*/
public sealed interface LineNumberTableAttribute
@@ -54,6 +72,12 @@ public sealed interface LineNumberTableAttribute
/**
* {@return a {@code LineNumberTable} attribute}
+ *
+ * @apiNote
+ * The created attribute cannot be written to a {@link CodeBuilder}. Call
+ * {@link CodeBuilder#lineNumber CodeBuilder::lineNumber} in the correct
+ * order instead.
+ *
* @param lines the line number descriptions
*/
static LineNumberTableAttribute of(List
- * The attribute permits multiple instances in a given location.
+ * This attribute only appears on {@code Code} attributes, and permits {@linkplain
+ * AttributeMapper#allowMultiple() multiple instances} in a {@code Code}
+ * attribute. It has a data dependency on {@linkplain AttributeStability#LABELS
+ * labels}.
+ *
+ * This attribute cannot be sent to a {@link CodeBuilder}; its entries can be
+ * constructed with {@link LocalVariable}, resulting in at most one attribute
+ * instance in the built {@code Code} attribute.
+ *
+ * The attribute was introduced in the Java Platform version 1.0.2, major
+ * version {@value ClassFile#JAVA_1_VERSION}.
+ *
+ * @apiNote
+ * Generic local variable types and potentially annotated use of those types are
+ * defined by {@link LocalVariableTypeTableAttribute} and {@link
+ * RuntimeVisibleTypeAnnotationsAttribute} respectively, which requires this
+ * attribute to be present.
*
+ * @see Attributes#localVariableTable()
+ * @jvms 4.7.13 The {@code LocalVaribleTable} Attribute
* @since 24
*/
public sealed interface LocalVariableTableAttribute
@@ -53,6 +77,11 @@ public sealed interface LocalVariableTableAttribute
/**
* {@return a {@code LocalVariableTable} attribute}
+ *
+ * @apiNote
+ * The created attribute cannot be written to a {@link CodeBuilder}. Use
+ * {@link CodeBuilder#localVariable CodeBuilder::localVariable} instead.
+ *
* @param locals the local variable descriptions
*/
static LocalVariableTableAttribute of(List
- * The attribute permits multiple instances in a given location.
+ * This attribute only appears on {@code Code} attributes, and permits {@linkplain
+ * AttributeMapper#allowMultiple() multiple instances} in a {@code Code}
+ * attribute. It has a data dependency on {@linkplain AttributeStability#LABELS
+ * labels}.
*
- * The attribute was introduced in the Java SE Platform version 5.0.
+ * This attribute cannot be sent to a {@link CodeBuilder}; its entries can be
+ * constructed with {@link LocalVariableType}, resulting in at most one attribute
+ * instance in the built {@code Code} attribute.
+ *
+ * The attribute was introduced in the Java SE Platform version 5.0, major
+ * version {@value ClassFile#JAVA_5_VERSION}.
+ *
+ * @apiNote
+ * Only local variables that have generic field types need to be described by
+ * this attribute. If a local variable is described in a {@code
+ * LocalVariableTypeTable} attribute, it must also be described in a {@link
+ * LocalVariableTableAttribute LocalVariableTable} attribute.
*
+ * @see Attributes#localVariableTypeTable()
+ * @jvms 4.7.14 The {@code LocalVariableTypeTable} Attribute
* @since 24
*/
public sealed interface LocalVariableTypeTableAttribute
@@ -50,7 +72,7 @@ public sealed interface LocalVariableTypeTableAttribute
permits BoundAttribute.BoundLocalVariableTypeTableAttribute, UnboundAttribute.UnboundLocalVariableTypeTableAttribute {
/**
- * {@return debug information for the local variables in this method}
+ * {@return debug information for the local variables with generic types in this method}
*/
List
- * The attribute does not permit multiple instances in a given location.
- * Subsequent occurrence of the attribute takes precedence during the attributed
- * element build or transformation.
+ * This attribute only appears on methods, and does not permit {@linkplain
+ * AttributeMapper#allowMultiple multiple instances} in a method. It has a
+ * data dependency on the {@linkplain AttributeMapper.AttributeStability#CP_REFS
+ * constant pool}.
*
- * The attribute was introduced in the Java SE Platform version 8.
+ * The attribute was introduced in the Java SE Platform version 8, major version
+ * {@value ClassFile#JAVA_8_VERSION}.
*
+ * @see Attributes#methodParameters()
+ * @see Executable#getParameters()
+ * @jvms 4.7.24 The {@code MethodParameters} Attribute
* @since 24
*/
public sealed interface MethodParametersAttribute
@@ -53,7 +61,7 @@ public sealed interface MethodParametersAttribute
/**
* {@return information about the parameters of the method} The i'th entry
- * in the list corresponds to the i'th parameter in the method declaration.
+ * in the list corresponds to the i'th parameter in the method descriptor.
*/
List
- * The attribute does not permit multiple instances in a given location.
- * Subsequent occurrence of the attribute takes precedence during the attributed
- * element build or transformation.
+ * This attribute only appears on classes, and does not permit {@linkplain
+ * AttributeMapper#allowMultiple multiple instances} in a class. It has a
+ * data dependency on the {@linkplain AttributeMapper.AttributeStability#CP_REFS
+ * constant pool}.
*
- * The attribute was introduced in the Java SE Platform version 9.
+ * The attribute was introduced in the Java SE Platform version 9, major version
+ * {@value ClassFile#JAVA_9_VERSION}.
*
+ * @see Attributes#module()
+ * @see ModuleDescriptor
+ * @jvms 4.7.25 The {@code Module} Attribute
* @since 24
*/
public sealed interface ModuleAttribute
@@ -64,25 +75,36 @@ public sealed interface ModuleAttribute
/**
* {@return the name of the module}
+ *
+ * @see ModuleDescriptor#name()
*/
ModuleEntry moduleName();
/**
- * {@return the the module flags of the module, as a bit mask}
+ * {@return the module flags of the module, as a bit mask}
+ *
+ * @see ModuleDescriptor#modifiers()
+ * @see AccessFlag.Location#MODULE
*/
int moduleFlagsMask();
/**
- * {@return the the module flags of the module, as a set of enum constants}
+ * {@return the module flags of the module, as a set of enum constants}
+ *
+ * @throws IllegalArgumentException if the flags mask has any undefined bit set
+ * @see ModuleDescriptor#accessFlags()
+ * @see AccessFlag.Location#MODULE
*/
default Set The specification of the {@code ModuleHashes} attribute is:
+ * Models the {@link Attributes#moduleHashes() ModuleHashes} attribute, which
+ * appears on classes that {@linkplain ClassModel#isModuleInfo() represent}
+ * module descriptors to capture the hashes of a set of co-delivered modules.
+ *
+ * The specification of the {@code ModuleHashes} attribute is:
*
- * The attribute does not permit multiple instances in a given location.
- * Subsequent occurrence of the attribute takes precedence during the attributed
- * element build or transformation.
+ * This attribute only appears on classes, and does not permit {@linkplain
+ * AttributeMapper#allowMultiple multiple instances} in a class. It has a
+ * data dependency on the {@linkplain AttributeStability#CP_REFS constant pool}.
+ *
+ * This attribute is not predefined in the Java SE Platform. This is a
+ * JDK-specific nonstandard attribute produced by the {@code jdk.jlink} module,
+ * which defines the {@code jlink} and {@code jmod} tools.
*
+ * @see Attributes#moduleHashes()
+ * @see ModuleResolutionAttribute
+ * @see ModuleTargetAttribute
* @since 24
*/
public sealed interface ModuleHashesAttribute
diff --git a/src/java.base/share/classes/java/lang/classfile/attribute/ModuleMainClassAttribute.java b/src/java.base/share/classes/java/lang/classfile/attribute/ModuleMainClassAttribute.java
index 7f06eb0f95b..cc88da465fe 100644
--- a/src/java.base/share/classes/java/lang/classfile/attribute/ModuleMainClassAttribute.java
+++ b/src/java.base/share/classes/java/lang/classfile/attribute/ModuleMainClassAttribute.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2022, 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
@@ -26,26 +26,36 @@
package java.lang.classfile.attribute;
import java.lang.classfile.Attribute;
+import java.lang.classfile.AttributeMapper;
+import java.lang.classfile.AttributeMapper.AttributeStability;
+import java.lang.classfile.Attributes;
import java.lang.classfile.ClassElement;
+import java.lang.classfile.ClassFile;
+import java.lang.classfile.ClassModel;
import java.lang.classfile.constantpool.ClassEntry;
import java.lang.constant.ClassDesc;
+import java.lang.module.ModuleDescriptor;
import jdk.internal.classfile.impl.BoundAttribute;
import jdk.internal.classfile.impl.TemporaryConstantPool;
import jdk.internal.classfile.impl.UnboundAttribute;
/**
- * Models the {@code ModuleMainClass} attribute (JVMS {@jvms 4.7.27}), which can
- * appear on classes that represent module descriptors.
- * Delivered as a {@link java.lang.classfile.ClassElement} when
- * traversing the elements of a {@link java.lang.classfile.ClassModel}.
+ * Models the {@link Attributes#moduleMainClass() ModuleMainClass} attribute
+ * (JVMS {@jvms 4.7.27}), which appears on classes that {@linkplain
+ * ClassModel#isModuleInfo() represent} module descriptors to indicate the main
+ * class of the module.
*
- * The attribute does not permit multiple instances in a given location.
- * Subsequent occurrence of the attribute takes precedence during the attributed
- * element build or transformation.
+ * This attribute only appears on classes, and does not permit {@linkplain
+ * AttributeMapper#allowMultiple multiple instances} in a class. It has a
+ * data dependency on the {@linkplain AttributeStability#CP_REFS constant pool}.
*
- * The attribute was introduced in the Java SE Platform version 9.
+ * The attribute was introduced in the Java SE Platform version 9, major version
+ * {@value ClassFile#JAVA_9_VERSION}.
*
+ * @see Attributes#moduleMainClass()
+ * @see ModuleDescriptor#mainClass()
+ * @jvms 4.7.27 The {@code ModuleMainClass} Attribute
* @since 24
*/
public sealed interface ModuleMainClassAttribute
diff --git a/src/java.base/share/classes/java/lang/classfile/attribute/ModuleOpenInfo.java b/src/java.base/share/classes/java/lang/classfile/attribute/ModuleOpenInfo.java
index a16c9973627..16c0cf8a057 100644
--- a/src/java.base/share/classes/java/lang/classfile/attribute/ModuleOpenInfo.java
+++ b/src/java.base/share/classes/java/lang/classfile/attribute/ModuleOpenInfo.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2022, 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
@@ -28,6 +28,8 @@
import java.lang.classfile.constantpool.PackageEntry;
import java.lang.constant.ModuleDesc;
import java.lang.constant.PackageDesc;
+import java.lang.invoke.MethodHandles;
+import java.lang.module.ModuleDescriptor;
import java.lang.reflect.AccessFlag;
import java.util.Collection;
import java.util.List;
@@ -40,6 +42,14 @@
/**
* Models a single "opens" declaration in the {@link ModuleAttribute}.
*
+ * @apiNote
+ * Opening a package to another module allows that other module to gain
+ * the same full privilege access as members in this module. See {@link
+ * MethodHandles#privateLookupIn} for more details.
+ *
+ * @see ModuleAttribute#exports()
+ * @see ModuleDescriptor.Opens
+ * @jvms 4.7.25 The {@code Module} Attribute
* @since 24
*/
public sealed interface ModuleOpenInfo
@@ -47,44 +57,57 @@ public sealed interface ModuleOpenInfo
/**
* {@return the package being opened}
+ *
+ * @see ModuleDescriptor.Opens#source()
*/
PackageEntry openedPackage();
/**
* {@return the flags associated with this open declaration, as a bit mask}
- * Valid flags include {@link java.lang.classfile.ClassFile#ACC_SYNTHETIC} and
- * {@link java.lang.classfile.ClassFile#ACC_MANDATED}
+ *
+ * @see ModuleDescriptor.Opens#modifiers()
+ * @see AccessFlag.Location#MODULE_OPENS
*/
int opensFlagsMask();
/**
- * {@return the access flags}
+ * {@return the flags associated with this open declaration, as a set of
+ * flag enums}
+ *
+ * @throws IllegalArgumentException if the flags mask has any undefined bit set
+ * @see ModuleDescriptor.Opens#accessFlags()
+ * @see AccessFlag.Location#MODULE_OPENS
*/
default Set
- * The attribute does not permit multiple instances in a given location.
- * Subsequent occurrence of the attribute takes precedence during the attributed
- * element build or transformation.
+ * This attribute only appears on classes, and does not permit {@linkplain
+ * AttributeMapper#allowMultiple multiple instances} in a class. It has a
+ * data dependency on the {@linkplain AttributeStability#CP_REFS constant pool}.
*
- * The attribute was introduced in the Java SE Platform version 9.
+ * The attribute was introduced in the Java SE Platform version 9, major version
+ * {@value ClassFile#JAVA_9_VERSION}.
*
+ * @see Attributes#modulePackages()
+ * @see ModuleDescriptor#packages()
+ * @jvms 4.7.26 The {@code ModulePackages} Attribute
* @since 24
*/
public sealed interface ModulePackagesAttribute
@@ -55,7 +65,9 @@ public sealed interface ModulePackagesAttribute
UnboundAttribute.UnboundModulePackagesAttribute {
/**
- * {@return the packages that are opened or exported by this module}
+ * {@return the packages used by the module descriptor} This must include
+ * all packages opened or exported by the module, as well as the packages of
+ * any service providers, and the package for the main class.
*/
List The specification of the {@code ModuleResolution} attribute is:
+ * Models the {@link Attributes#moduleResolution() ModuleResolution} attribute,
+ * which can appear on classes that {@linkplain ClassModel#isModuleInfo()
+ * represent} module descriptors, to capture resolution metadata for modules.
+ *
+ * The specification of the {@code ModuleResolution} attribute is:
*
- * The attribute does not permit multiple instances in a given location.
- * Subsequent occurrence of the attribute takes precedence during the attributed
- * element build or transformation.
+ * This attribute only appears on classes, and does not permit {@linkplain
+ * AttributeMapper#allowMultiple multiple instances} in a class. It has
+ * {@linkplain AttributeStability#STATELESS no data dependency}.
+ *
+ * This attribute is not predefined in the Java SE Platform. This is a
+ * JDK-specific nonstandard attribute produced by the {@code jdk.jlink} module,
+ * which defines the {@code jlink} and {@code jmod} tools.
*
+ * @see Attributes#moduleResolution()
+ * @see ModuleHashesAttribute
+ * @see ModuleTargetAttribute
* @since 24
*/
public sealed interface ModuleResolutionAttribute
@@ -69,8 +78,10 @@ public sealed interface ModuleResolutionAttribute
permits BoundAttribute.BoundModuleResolutionAttribute, UnboundAttribute.UnboundModuleResolutionAttribute {
/**
- * The value of the resolution_flags item is a mask of flags used to denote
- * properties of module resolution. The flags are as follows:
+ * {@return the module resolution flags}
+ *
+ * The value of the resolution_flags item is a mask of flags used to denote
+ * properties of module resolution. The flags are as follows:
* The specification of the {@code ModuleTarget} attribute is:
+ * Models the {@link Attributes#moduleTarget() ModuleTarget} attribute, which
+ * can appear on classes that {@linkplain ClassModel#isModuleInfo() represent}
+ * module descriptors, to represent constraints on the target platform.
+ *
+ * The specification of the {@code ModuleTarget} attribute is:
*
- * The attribute does not permit multiple instances in a given location.
- * Subsequent occurrence of the attribute takes precedence during the attributed
- * element build or transformation.
+ * This attribute only appears on classes, and does not permit {@linkplain
+ * AttributeMapper#allowMultiple multiple instances} in a class. It has a
+ * data dependency on the {@linkplain AttributeStability#CP_REFS constant pool}.
+ *
+ * This attribute is not predefined in the Java SE Platform. This is a
+ * JDK-specific nonstandard attribute produced by the {@code jdk.jlink} module,
+ * which defines the {@code jlink} and {@code jmod} tools.
*
+ * @see Attributes#moduleTarget()
+ * @see ModuleHashesAttribute
+ * @see ModuleResolutionAttribute
* @since 24
*/
public sealed interface ModuleTargetAttribute
@@ -70,6 +79,7 @@ public sealed interface ModuleTargetAttribute
/**
* {@return a {@code ModuleTarget} attribute}
+ *
* @param targetPlatform the target platform
*/
static ModuleTargetAttribute of(String targetPlatform) {
@@ -78,6 +88,7 @@ static ModuleTargetAttribute of(String targetPlatform) {
/**
* {@return a {@code ModuleTarget} attribute}
+ *
* @param targetPlatform the target platform
*/
static ModuleTargetAttribute of(Utf8Entry targetPlatform) {
diff --git a/src/java.base/share/classes/java/lang/classfile/attribute/NestHostAttribute.java b/src/java.base/share/classes/java/lang/classfile/attribute/NestHostAttribute.java
index ccfb61242cd..d2c398e556b 100644
--- a/src/java.base/share/classes/java/lang/classfile/attribute/NestHostAttribute.java
+++ b/src/java.base/share/classes/java/lang/classfile/attribute/NestHostAttribute.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2022, 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
@@ -26,7 +26,11 @@
package java.lang.classfile.attribute;
import java.lang.classfile.Attribute;
+import java.lang.classfile.AttributeMapper;
+import java.lang.classfile.AttributeMapper.AttributeStability;
+import java.lang.classfile.Attributes;
import java.lang.classfile.ClassElement;
+import java.lang.classfile.ClassFile;
import java.lang.classfile.constantpool.ClassEntry;
import java.lang.constant.ClassDesc;
@@ -35,17 +39,22 @@
import jdk.internal.classfile.impl.UnboundAttribute;
/**
- * Models the {@code NestHost} attribute (JVMS {@jvms 4.7.28}), which can
- * appear on classes to indicate that this class is a member of a nest.
- * Delivered as a {@link java.lang.classfile.ClassElement} when
- * traversing the elements of a {@link java.lang.classfile.ClassModel}.
+ * Models the {@link Attributes#nestHost() NestHost} attribute (JVMS {@jvms
+ * 4.7.28}), which indicates this class is a member of a nest and the host
+ * class of the nest.
*
- * The attribute does not permit multiple instances in a given location.
- * Subsequent occurrence of the attribute takes precedence during the attributed
- * element build or transformation.
+ * This attribute only appears on classes, and does not permit {@linkplain
+ * AttributeMapper#allowMultiple multiple instances} in a class. It has a
+ * data dependency on the {@linkplain AttributeStability#CP_REFS constant pool}.
*
- * The attribute was introduced in the Java SE Platform version 11.
+ * The attribute was introduced in the Java SE Platform version 11, major
+ * version {@value ClassFile#JAVA_11_VERSION}.
*
+ * @see Attributes#nestHost()
+ * @see NestMembersAttribute
+ * @see Class#getNestHost()
+ * @see Class#isNestmateOf(Class)
+ * @jvms 4.7.28 The {@code NestHost} Attribute
* @since 24
*/
public sealed interface NestHostAttribute extends Attribute
- * The attribute does not permit multiple instances in a given location.
- * Subsequent occurrence of the attribute takes precedence during the attributed
- * element build or transformation.
+ * This attribute only appears on classes, and does not permit {@linkplain
+ * AttributeMapper#allowMultiple multiple instances} in a class. It has a
+ * data dependency on the {@linkplain AttributeStability#CP_REFS constant pool}.
*
- * The attribute was introduced in the Java SE Platform version 11.
+ * The attribute was introduced in the Java SE Platform version 11, major
+ * version {@value ClassFile#JAVA_11_VERSION}.
*
+ * @see Attributes#nestMembers()
+ * @see NestHostAttribute
+ * @see Class#getNestMembers()
+ * @see Class#isNestmateOf(Class)
+ * @jvms 4.7.29 The {@code NestMembers} Attribute
* @since 24
*/
public sealed interface NestMembersAttribute extends Attribute
- * The attribute does not permit multiple instances in a given location.
- * Subsequent occurrence of the attribute takes precedence during the attributed
- * element build or transformation.
+ * This attribute only appears on classes, and does not permit {@linkplain
+ * AttributeMapper#allowMultiple multiple instances} in a class. It has a
+ * data dependency on the {@linkplain AttributeStability#CP_REFS constant pool}.
*
- * The attribute was introduced in the Java SE Platform version 17.
+ * The attribute was introduced in the Java SE Platform version 17, major
+ * version {@value ClassFile#JAVA_17_VERSION}.
*
+ * @see Attributes#permittedSubclasses()
+ * @see Class#isSealed()
+ * @see Class#getPermittedSubclasses()
+ * @jls 8.1.1.2 {@code sealed}, {@code non-sealed}, and {@code final} Classes
+ * @jls 9.1.1.4 {@code sealed} and {@code non-sealed} Interfaces
+ * @jvms 4.7.31 The {@code PermittedSubclasses} Attribute
* @since 24
*/
+@SuppressWarnings("doclint:reference")
public sealed interface PermittedSubclassesAttribute
extends Attribute
- * The attribute does not permit multiple instances in a given location.
- * Subsequent occurrence of the attribute takes precedence during the attributed
- * element build or transformation.
+ * This attribute only appears on classes, and does not permit {@linkplain
+ * AttributeMapper#allowMultiple multiple instances} in a class. It has a
+ * data dependency on the {@linkplain AttributeStability#CP_REFS constant pool}.
*
- * The attribute was introduced in the Java SE Platform version 16.
+ * The attribute was introduced in the Java SE Platform version 16, major
+ * version {@value ClassFile#JAVA_16_VERSION}.
*
+ * @see Attributes#record()
+ * @see Class#isRecord()
+ * @see Class#getRecordComponents()
+ * @jvms 4.7.30 The {@code Record} Attribute
* @since 24
*/
public sealed interface RecordAttribute extends Attribute
+ * {@link SignatureAttribute}, {@link RuntimeVisibleAnnotationsAttribute},
+ * {@link RuntimeInvisibleAnnotationsAttribute}, {@link
+ * RuntimeVisibleTypeAnnotationsAttribute}, and {@link
+ * RuntimeInvisibleTypeAnnotationsAttribute} are the only predefined attributes
+ * that may exist on record components.
*
+ * @see RecordAttribute#components()
+ * @see RecordComponent
+ * @jvms 4.7.30 The {@code Record} Attribute
* @since 24
*/
public sealed interface RecordComponentInfo
@@ -45,16 +55,30 @@ public sealed interface RecordComponentInfo
permits BoundRecordComponentInfo, UnboundAttribute.UnboundRecordComponentInfo {
/**
* {@return the name of this component}
+ *
+ * @see RecordComponent#getName()
*/
Utf8Entry name();
/**
- * {@return the field descriptor of this component}
+ * {@return the field descriptor string of this component}
+ *
+ * @apiNote
+ * A record component may have a generic type; this information is stored
+ * in the {@link SignatureAttribute Signature} attribute in this component.
+ *
+ * @see RecordComponent#getType()
*/
Utf8Entry descriptor();
/**
- * {@return the field descriptor of this component, as a {@linkplain ClassDesc}}
+ * {@return the symbolic field descriptor of this component}
+ *
+ * @apiNote
+ * A record component may have a generic type; this information is stored
+ * in the {@link SignatureAttribute Signature} attribute in this component.
+ *
+ * @see RecordComponent#getType()
*/
default ClassDesc descriptorSymbol() {
return Util.fieldTypeSymbol(descriptor());
@@ -62,8 +86,9 @@ default ClassDesc descriptorSymbol() {
/**
* {@return a record component description}
+ *
* @param name the component name
- * @param descriptor the component field descriptor
+ * @param descriptor the component field descriptor string
* @param attributes the component attributes
*/
static RecordComponentInfo of(Utf8Entry name,
@@ -74,8 +99,9 @@ static RecordComponentInfo of(Utf8Entry name,
/**
* {@return a record component description}
+ *
* @param name the component name
- * @param descriptor the component field descriptor
+ * @param descriptor the component field descriptor sting
* @param attributes the component attributes
*/
static RecordComponentInfo of(Utf8Entry name,
@@ -86,8 +112,9 @@ static RecordComponentInfo of(Utf8Entry name,
/**
* {@return a record component description}
+ *
* @param name the component name
- * @param descriptor the component field descriptor
+ * @param descriptor the component symbolic field descriptor
* @param attributes the component attributes
*/
static RecordComponentInfo of(String name,
@@ -100,8 +127,9 @@ static RecordComponentInfo of(String name,
/**
* {@return a record component description}
+ *
* @param name the component name
- * @param descriptor the component field descriptor
+ * @param descriptor the component symbolic field descriptor
* @param attributes the component attributes
*/
static RecordComponentInfo of(String name,
diff --git a/src/java.base/share/classes/java/lang/classfile/attribute/RuntimeInvisibleAnnotationsAttribute.java b/src/java.base/share/classes/java/lang/classfile/attribute/RuntimeInvisibleAnnotationsAttribute.java
index 58903859464..da453ad4f5e 100644
--- a/src/java.base/share/classes/java/lang/classfile/attribute/RuntimeInvisibleAnnotationsAttribute.java
+++ b/src/java.base/share/classes/java/lang/classfile/attribute/RuntimeInvisibleAnnotationsAttribute.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2022, 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
@@ -25,30 +25,39 @@
package java.lang.classfile.attribute;
-import java.lang.classfile.Annotation;
-import java.lang.classfile.Attribute;
-import java.lang.classfile.ClassElement;
-import java.lang.classfile.FieldElement;
-import java.lang.classfile.MethodElement;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.classfile.*;
+import java.lang.classfile.AttributeMapper.AttributeStability;
+import java.lang.reflect.AnnotatedElement;
import java.util.List;
import jdk.internal.classfile.impl.BoundAttribute;
import jdk.internal.classfile.impl.UnboundAttribute;
/**
- * Models the {@code RuntimeInvisibleAnnotations} attribute (JVMS {@jvms 4.7.17}), which
- * can appear on classes, methods, and fields. Delivered as a
- * {@link java.lang.classfile.ClassElement}, {@link java.lang.classfile.FieldElement}, or
- * {@link java.lang.classfile.MethodElement} when traversing the corresponding model type.
+ * Models the {@link Attributes#runtimeInvisibleAnnotations()
+ * RuntimeInvisibleAnnotations} attribute (JVMS {@jvms 4.7.17}), which stores
+ * declaration annotations on this structure that are visible to {@code
+ * class} file consumers but are not visible to {@linkplain AnnotatedElement
+ * core reflection}.
*
- * The attribute does not permit multiple instances in a given location.
- * Subsequent occurrence of the attribute takes precedence during the attributed
- * element build or transformation.
+ * This attribute appears on classes, fields, methods, and record components,
+ * and does not permit {@linkplain AttributeMapper#allowMultiple multiple
+ * instances} in one structure. It has a data dependency on the {@linkplain
+ * AttributeStability#CP_REFS constant pool}.
*
- * The attribute was introduced in the Java SE Platform version 5.0.
+ * The attribute was introduced in the Java SE Platform version 5.0, major
+ * version {@value ClassFile#JAVA_5_VERSION}.
*
+ * @see Attributes#runtimeInvisibleAnnotations()
+ * @see java.compiler/javax.lang.model.element.Element
+ * @see ElementType
+ * @see RetentionPolicy#CLASS
+ * @jvms 4.7.17 The {@code RuntimeInvisibleAnnotations} Attribute
* @since 24
*/
+@SuppressWarnings("doclint:reference")
public sealed interface RuntimeInvisibleAnnotationsAttribute
extends Attribute
- * The attribute does not permit multiple instances in a given location.
- * Subsequent occurrence of the attribute takes precedence during the attributed
- * element build or transformation.
+ * This attribute only appears on methods, and does not permit {@linkplain
+ * AttributeMapper#allowMultiple multiple instances} in a method. It has a
+ * data dependency on the {@linkplain AttributeStability#CP_REFS constant pool}.
*
- * The attribute was introduced in the Java SE Platform version 5.0.
+ * The attribute was introduced in the Java SE Platform version 5.0, major
+ * version {@value ClassFile#JAVA_5_VERSION}.
*
+ * @see Attributes#runtimeInvisibleParameterAnnotations()
+ * @see ElementType#PARAMETER
+ * @see RetentionPolicy#CLASS
+ * @jvms 4.7.19 The {@code RuntimeInvisibleParameterAnnotations} Attribute
* @since 24
*/
public sealed interface RuntimeInvisibleParameterAnnotationsAttribute
@@ -53,15 +66,26 @@ public sealed interface RuntimeInvisibleParameterAnnotationsAttribute
UnboundAttribute.UnboundRuntimeInvisibleParameterAnnotationsAttribute {
/**
- * {@return the list of annotations corresponding to each method parameter}
+ * {@return the list of run-time invisible annotations on the method parameters}
* The element at the i'th index corresponds to the annotations on the i'th
- * parameter.
+ * formal parameter, but note that some synthetic or implicit parameters
+ * may be omitted by this list. If a parameter has no annotations, that
+ * element is left empty, but is not omitted; thus, the list will never be
+ * truncated because trailing parameters are not annotated.
+ *
+ * @see java.lang.reflect##LanguageJvmModel Java programming language and
+ * JVM modeling in core reflection
*/
List
- * The attribute does not permit multiple instances in a given location.
- * Subsequent occurrence of the attribute takes precedence during the attributed
- * element build or transformation.
+ * This attribute appears on classes, fields, methods, {@code Code} attributes,
+ * and record components, and does not permit {@linkplain
+ * AttributeMapper#allowMultiple multiple instances} in one structure. It has a
+ * data dependency on {@linkplain AttributeStability#UNSTABLE arbitrary indices}
+ * in the {@code class} file format, so users must take great care to ensure
+ * this attribute is still correct after a {@code class} file has been transformed.
*
- * The attribute was introduced in the Java SE Platform version 8.
+ * The attribute was introduced in the Java SE Platform version 8, major version
+ * {@value ClassFile#JAVA_8_VERSION}.
*
+ * @see Attributes#runtimeInvisibleTypeAnnotations()
+ * @see java.compiler/javax.lang.model.type.TypeMirror
+ * @see ElementType#TYPE_PARAMETER
+ * @see ElementType#TYPE_USE
+ * @see RetentionPolicy#CLASS
+ * @jvms 4.7.21 The {@code RuntimeInvisibleTypeAnnotations} Attribute
* @since 24
*/
+@SuppressWarnings("doclint:reference")
public sealed interface RuntimeInvisibleTypeAnnotationsAttribute
extends Attribute
- * The attribute does not permit multiple instances in a given location.
- * Subsequent occurrence of the attribute takes precedence during the attributed
- * element build or transformation.
+ * This attribute appears on classes, fields, methods, and record components,
+ * and does not permit {@linkplain AttributeMapper#allowMultiple multiple
+ * instances} in one structure. It has a data dependency on the {@linkplain
+ * AttributeStability#CP_REFS constant pool}.
*
- * The attribute was introduced in the Java SE Platform version 5.0.
+ * The attribute was introduced in the Java SE Platform version 5.0, major
+ * version {@value ClassFile#JAVA_5_VERSION}.
*
+ * @see Attributes#runtimeVisibleAnnotations()
+ * @see java.compiler/javax.lang.model.element.Element
+ * @see AnnotatedElement
+ * @see ElementType
+ * @see RetentionPolicy#RUNTIME
+ * @jvms 4.7.16 The {@code RuntimeVisibleAnnotations} Attribute
* @since 24
*/
+@SuppressWarnings("doclint:reference")
public sealed interface RuntimeVisibleAnnotationsAttribute
extends Attribute
+ * This attribute only appears on methods, and does not permit {@linkplain
+ * AttributeMapper#allowMultiple multiple instances} in a method. It has a
+ * data dependency on the {@linkplain AttributeStability#CP_REFS constant pool}.
*
- * The attribute was introduced in the Java SE Platform version 5.0.
+ * The attribute was introduced in the Java SE Platform version 5.0, major
+ * version {@value ClassFile#JAVA_5_VERSION}.
*
+ * @see Attributes#runtimeVisibleParameterAnnotations()
+ * @see Executable#getParameterAnnotations()
+ * @see ElementType#PARAMETER
+ * @see RetentionPolicy#RUNTIME
+ * @jvms 4.7.18 The {@code RuntimeVisibleParameterAnnotations} Attribute
* @since 24
*/
public sealed interface RuntimeVisibleParameterAnnotationsAttribute
@@ -53,15 +68,26 @@ public sealed interface RuntimeVisibleParameterAnnotationsAttribute
UnboundAttribute.UnboundRuntimeVisibleParameterAnnotationsAttribute {
/**
- * {@return the list of annotations corresponding to each method parameter}
+ * {@return the list of run-time visible annotations on the method parameters}
* The element at the i'th index corresponds to the annotations on the i'th
- * parameter.
+ * formal parameter, but note that some synthetic or implicit parameters
+ * may be omitted by this list. If a parameter has no annotations, that
+ * element is left empty, but is not omitted; thus, the list will never be
+ * truncated because trailing parameters are not annotated.
+ *
+ * @see java.lang.reflect##LanguageJvmModel Java programming language and
+ * JVM modeling in core reflection
*/
List
- * The attribute does not permit multiple instances in a given location.
- * Subsequent occurrence of the attribute takes precedence during the attributed
- * element build or transformation.
+ * This attribute appears on classes, fields, methods, {@code Code} attributes,
+ * and record components, and does not permit {@linkplain
+ * AttributeMapper#allowMultiple multiple instances} in one structure. It has a
+ * data dependency on {@linkplain AttributeStability#UNSTABLE arbitrary indices}
+ * in the {@code class} file format, so users must take great care to ensure
+ * this attribute is still correct after a {@code class} file has been transformed.
*
- * The attribute was introduced in the Java SE Platform version 8.
+ * The attribute was introduced in the Java SE Platform version 8, major version
+ * {@value ClassFile#JAVA_8_VERSION}.
*
+ * @see Attributes#runtimeVisibleTypeAnnotations()
+ * @see java.compiler/javax.lang.model.type.TypeMirror
+ * @see AnnotatedType
+ * @see ElementType#TYPE_PARAMETER
+ * @see ElementType#TYPE_USE
+ * @see RetentionPolicy#RUNTIME
+ * @jvms 4.7.20 the {@code RuntimeVisibleTypeAnnotations} Attribute
* @since 24
*/
+@SuppressWarnings("doclint:reference")
public sealed interface RuntimeVisibleTypeAnnotationsAttribute
extends Attribute
- * The attribute does not permit multiple instances in a given location.
- * Subsequent occurrence of the attribute takes precedence during the attributed
- * element build or transformation.
+ * This attribute appears on classes, fields, methods, and record components,
+ * and does not permit {@linkplain AttributeMapper#allowMultiple multiple
+ * instances} in one structure. It has a data dependency on the {@linkplain
+ * AttributeMapper.AttributeStability#CP_REFS constant pool}.
*
- * The attribute was introduced in the Java SE Platform version 5.0.
+ * The attribute was introduced in the Java SE Platform version 5.0, major
+ * version {@value ClassFile#JAVA_5_VERSION}.
*
+ * @see Signature
+ * @see ClassSignature
+ * @see MethodSignature
+ * @jvms 4.7.9 The {@code Signature} Attribute
* @since 24
*/
public sealed interface SignatureAttribute
@@ -53,29 +58,46 @@ public sealed interface SignatureAttribute
permits BoundAttribute.BoundSignatureAttribute, UnboundAttribute.UnboundSignatureAttribute {
/**
- * {@return the signature for the class, method, or field}
+ * {@return the signature string for the class, method, field, or record
+ * component} It is a class signature string if this attribute is on a
+ * class, a method signature string if this attribute is on a method, or
+ * a field signature string if this attribute is on a field or a record
+ * component.
+ *
+ * @jvms 4.7.9.1 Signatures
*/
Utf8Entry signature();
/**
- * Parse the signature as a class signature.
+ * Parses the signature string as a class signature.
+ *
* @return the class signature
+ * @throws IllegalArgumentException if the signature string is not a valid
+ * class signature string
*/
default ClassSignature asClassSignature() {
return ClassSignature.parseFrom(signature().stringValue());
}
/**
- * Parse the signature as a method signature.
+ * Parse the signature string as a method signature.
+ *
* @return the method signature
+ * @throws IllegalArgumentException if the signature string is not a valid
+ * method signature string
*/
default MethodSignature asMethodSignature() {
return MethodSignature.parseFrom(signature().stringValue());
}
/**
- * Parse the signature as a type signature.
+ * Parses the signature string as a Java type signature.
+ *
* @return the type signature
+ * @throws IllegalArgumentException if the signature string is not a valid
+ * Java type signature string
+ * @see Field#getGenericType()
+ * @see RecordComponent#getGenericType()
*/
default Signature asTypeSignature() {
return Signature.parseFrom(signature().stringValue());
@@ -83,7 +105,8 @@ default Signature asTypeSignature() {
/**
* {@return a {@code Signature} attribute for a class}
- * @param classSignature the signature
+ *
+ * @param classSignature the class signature
*/
static SignatureAttribute of(ClassSignature classSignature) {
return of(TemporaryConstantPool.INSTANCE.utf8Entry(classSignature.signatureString()));
@@ -91,15 +114,17 @@ static SignatureAttribute of(ClassSignature classSignature) {
/**
* {@return a {@code Signature} attribute for a method}
- * @param methodSignature the signature
+ *
+ * @param methodSignature the method signature
*/
static SignatureAttribute of(MethodSignature methodSignature) {
return of(TemporaryConstantPool.INSTANCE.utf8Entry(methodSignature.signatureString()));
}
/**
- * {@return a {@code Signature} attribute}
- * @param signature the signature
+ * {@return a {@code Signature} attribute for a field or a record component}
+ *
+ * @param signature the Java type signature
*/
static SignatureAttribute of(Signature signature) {
return of(TemporaryConstantPool.INSTANCE.utf8Entry(signature.signatureString()));
@@ -107,7 +132,8 @@ static SignatureAttribute of(Signature signature) {
/**
* {@return a {@code Signature} attribute}
- * @param signature the signature
+ *
+ * @param signature the signature string
*/
static SignatureAttribute of(Utf8Entry signature) {
return new UnboundAttribute.UnboundSignatureAttribute(signature);
diff --git a/src/java.base/share/classes/java/lang/classfile/attribute/SourceDebugExtensionAttribute.java b/src/java.base/share/classes/java/lang/classfile/attribute/SourceDebugExtensionAttribute.java
index 0e6b7267263..9634ebe3011 100644
--- a/src/java.base/share/classes/java/lang/classfile/attribute/SourceDebugExtensionAttribute.java
+++ b/src/java.base/share/classes/java/lang/classfile/attribute/SourceDebugExtensionAttribute.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2022, 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
@@ -25,23 +25,31 @@
package java.lang.classfile.attribute;
+import java.io.DataInput;
import java.lang.classfile.Attribute;
+import java.lang.classfile.AttributeMapper;
+import java.lang.classfile.AttributeMapper.AttributeStability;
+import java.lang.classfile.Attributes;
import java.lang.classfile.ClassElement;
+import java.lang.classfile.ClassFile;
import jdk.internal.classfile.impl.BoundAttribute;
import jdk.internal.classfile.impl.UnboundAttribute;
/**
- * Models the {@code SourceDebugExtension} attribute.
- * Delivered as a {@link java.lang.classfile.ClassElement} when traversing the elements of
- * a {@link java.lang.classfile.ClassModel}.
+ * Models the {@link Attributes#sourceDebugExtension() SourceDebugExtension}
+ * attribute (JVMS {@jvms 4.7.11}), which stores arbitrary {@linkplain
+ * DataInput##modified-utf-8 modified UTF-8} data.
*
- * The attribute does not permit multiple instances in a given location.
- * Subsequent occurrence of the attribute takes precedence during the attributed
- * element build or transformation.
+ * This attribute only appears on classes, and does not permit {@linkplain
+ * AttributeMapper#allowMultiple multiple instances} in a class. It has
+ * {@linkplain AttributeStability#STATELESS no data dependency}.
*
- * The attribute was introduced in the Java SE Platform version 5.0.
+ * The attribute was introduced in the Java SE Platform version 5.0, major
+ * version {@value ClassFile#JAVA_5_VERSION}.
*
+ * @see Attributes#sourceDebugExtension()
+ * @jvms 4.7.11 The {@code SourceDebugExtension} Attribute
* @since 24
*/
public sealed interface SourceDebugExtensionAttribute
@@ -49,7 +57,8 @@ public sealed interface SourceDebugExtensionAttribute
permits BoundAttribute.BoundSourceDebugExtensionAttribute, UnboundAttribute.UnboundSourceDebugExtensionAttribute {
/**
- * {@return the debug extension payload}
+ * {@return the debug extension payload} The payload may denote a string
+ * longer than that which can be represented with a {@link String}.
*/
byte[] contents();
diff --git a/src/java.base/share/classes/java/lang/classfile/attribute/SourceFileAttribute.java b/src/java.base/share/classes/java/lang/classfile/attribute/SourceFileAttribute.java
index 70f3d1e72ce..e2621d241fb 100644
--- a/src/java.base/share/classes/java/lang/classfile/attribute/SourceFileAttribute.java
+++ b/src/java.base/share/classes/java/lang/classfile/attribute/SourceFileAttribute.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2022, 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
@@ -26,8 +26,11 @@
package java.lang.classfile.attribute;
import java.lang.classfile.Attribute;
+import java.lang.classfile.AttributeMapper;
+import java.lang.classfile.AttributeMapper.AttributeStability;
+import java.lang.classfile.Attributes;
import java.lang.classfile.ClassElement;
-import java.lang.classfile.ClassModel;
+import java.lang.classfile.ClassFile;
import java.lang.classfile.constantpool.Utf8Entry;
import jdk.internal.classfile.impl.BoundAttribute;
@@ -35,14 +38,19 @@
import jdk.internal.classfile.impl.UnboundAttribute;
/**
- * Models the {@code SourceFile} attribute (JVMS {@jvms 4.7.10}), which
- * can appear on classes. Delivered as a {@link java.lang.classfile.ClassElement}
- * when traversing a {@link ClassModel}.
+ * Models the {@link Attributes#sourceFile() SourceFile} attribute (JVMS {@jvms
+ * 4.7.10}), which indicates the name of the source file from which this {@code
+ * class} file was compiled.
*
- * The attribute does not permit multiple instances in a given location.
- * Subsequent occurrence of the attribute takes precedence during the attributed
- * element build or transformation.
+ * This attribute only appears on classes, and does not permit {@linkplain
+ * AttributeMapper#allowMultiple multiple instances} in a class. It has a data
+ * dependency on the {@linkplain AttributeStability#CP_REFS constant pool}.
+ *
+ * The attribute was introduced in the Java SE Platform version 5.0, major
+ * version {@value ClassFile#JAVA_5_VERSION}.
*
+ * @see Attributes#sourceFile()
+ * @jvms 4.7.10 The {@code SourceFile} Attribute
* @since 24
*/
public sealed interface SourceFileAttribute
@@ -56,6 +64,7 @@ public sealed interface SourceFileAttribute
/**
* {@return a source file attribute}
+ *
* @param sourceFile the source file name
*/
static SourceFileAttribute of(String sourceFile) {
@@ -64,6 +73,7 @@ static SourceFileAttribute of(String sourceFile) {
/**
* {@return a source file attribute}
+ *
* @param sourceFile the source file name
*/
static SourceFileAttribute of(Utf8Entry sourceFile) {
diff --git a/src/java.base/share/classes/java/lang/classfile/attribute/SourceIDAttribute.java b/src/java.base/share/classes/java/lang/classfile/attribute/SourceIDAttribute.java
index 71fd9d5b059..b7d2e3cf9b7 100644
--- a/src/java.base/share/classes/java/lang/classfile/attribute/SourceIDAttribute.java
+++ b/src/java.base/share/classes/java/lang/classfile/attribute/SourceIDAttribute.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2022, 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
@@ -26,8 +26,10 @@
package java.lang.classfile.attribute;
import java.lang.classfile.Attribute;
+import java.lang.classfile.AttributeMapper;
+import java.lang.classfile.AttributeMapper.AttributeStability;
+import java.lang.classfile.Attributes;
import java.lang.classfile.ClassElement;
-import java.lang.classfile.ClassModel;
import java.lang.classfile.constantpool.Utf8Entry;
import jdk.internal.classfile.impl.BoundAttribute;
@@ -35,14 +37,21 @@
import jdk.internal.classfile.impl.UnboundAttribute;
/**
- * Models the {@code SourceID} attribute, which can
- * appear on classes. Delivered as a {@link java.lang.classfile.ClassElement} when
- * traversing a {@link ClassModel}.
+ * Models the {@link Attributes#sourceId() SourceID} attribute, which records
+ * the last modified time of the source file from which this {@code class} file
+ * was compiled.
*
- * The attribute does not permit multiple instances in a given location.
- * Subsequent occurrence of the attribute takes precedence during the attributed
- * element build or transformation.
+ * This attribute only appears on classes, and does not permit {@linkplain
+ * AttributeMapper#allowMultiple multiple instances} in a class. It has a
+ * data dependency on the {@linkplain AttributeStability#CP_REFS constant pool}.
+ *
+ * This attribute is not predefined in the Java SE Platform. This is a
+ * JDK-specific nonstandard attribute produced by the reference implementation
+ * of the system Java compiler, defined by the {@code jdk.compiler} module.
*
+ * @see Attributes#sourceId()
+ * @see CompilationIDAttribute
+ * @see CharacterRangeTableAttribute
* @since 24
*/
public sealed interface SourceIDAttribute
@@ -51,13 +60,14 @@ public sealed interface SourceIDAttribute
/**
* {@return the source id} The source id is the last modified time of the
- * source file (as reported by the filesystem, in milliseconds) when the
- * classfile is compiled.
+ * source file (as reported by the file system, in milliseconds) when this
+ * {@code class} file is compiled.
*/
Utf8Entry sourceId();
/**
* {@return a {@code SourceID} attribute}
+ *
* @param sourceId the source id
*/
static SourceIDAttribute of(Utf8Entry sourceId) {
@@ -66,6 +76,7 @@ static SourceIDAttribute of(Utf8Entry sourceId) {
/**
* {@return a {@code SourceID} attribute}
+ *
* @param sourceId the source id
*/
static SourceIDAttribute of(String sourceId) {
diff --git a/src/java.base/share/classes/java/lang/classfile/attribute/StackMapFrameInfo.java b/src/java.base/share/classes/java/lang/classfile/attribute/StackMapFrameInfo.java
index 920db8ac9d7..71d5ccc79a4 100644
--- a/src/java.base/share/classes/java/lang/classfile/attribute/StackMapFrameInfo.java
+++ b/src/java.base/share/classes/java/lang/classfile/attribute/StackMapFrameInfo.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2023, 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
@@ -25,8 +25,11 @@
package java.lang.classfile.attribute;
+import java.lang.classfile.ClassFile;
import java.lang.classfile.Label;
+import java.lang.classfile.Opcode;
import java.lang.classfile.constantpool.ClassEntry;
+import java.lang.classfile.instruction.BranchInstruction;
import java.lang.constant.ClassDesc;
import java.util.List;
@@ -34,15 +37,28 @@
import jdk.internal.classfile.impl.TemporaryConstantPool;
/**
- * Models stack map frame of {@code StackMapTable} attribute (JVMS {@jvms 4.7.4}).
+ * Models a stack map frame in a {@link StackMapTableAttribute StackMapTable}
+ * attribute (JVMS {@jvms 4.7.4}). A stack map frame must appear at the
+ * beginning of each basic block in a method (JVMS {@jvms 4.10.1}).
*
+ * @apiNote
+ * In general, a stack map frame should be defined for each target of a
+ * {@link BranchInstruction}, or unreachable code right after an unconditional
+ * branch instruction like {@link Opcode#GOTO goto}. The automatic stack map
+ * generation cannot handle unreachable code right after an unconditional jump;
+ * The {@link ClassFile.DeadCodeOption} allows substituting such code, or
+ * advanced users can provide their own stack maps for dead code.
+ *
+ * @see StackMapTableAttribute#entries()
+ * @jvms 4.7.4 The {@code StackMapTable} Attribute
+ * @jvms 4.10.1 Verification by Type Checking
* @since 24
*/
public sealed interface StackMapFrameInfo
permits StackMapDecoder.StackMapFrameImpl {
/**
- * {@return the frame compact form type}
+ * {@return the raw {@code u1 frame_type}}
*/
int frameType();
@@ -57,12 +73,13 @@ public sealed interface StackMapFrameInfo
List
- * The attribute does not permit multiple instances in a given location.
- * Subsequent occurrence of the attribute takes precedence during the attributed
- * element build or transformation.
+ * This attribute is not delivered in the traversal of a {@link CodeAttribute},
+ * but instead automatically generated upon {@code class} file writing.
+ * Advanced users can supply their own stack maps according to the {@link
+ * ClassFile.StackMapsOption}.
*
- * The attribute was introduced in the Java SE Platform version 6.
+ * This attribute only appears on {@code Code} attributes, and does not permit
+ * {@linkplain AttributeMapper#allowMultiple multiple instances} in a {@code
+ * Code} attribute. It has a data dependency on {@linkplain
+ * AttributeStability#LABELS labels} in the {@code code} array.
+ *
+ * This attribute was introduced in the Java SE Platform version 6, major
+ * version {@value ClassFile#JAVA_6_VERSION}.
*
+ * @see Attributes#stackMapTable()
+ * @see DiscontinuedInstruction.JsrInstruction
+ * @see DiscontinuedInstruction.RetInstruction
+ * @jvms 4.7.4 The {@code StackMapTable} Attribute
+ * @jvms 4.10.1 Verification by Type Checking
* @since 24
*/
public sealed interface StackMapTableAttribute
@@ -55,6 +73,7 @@ public sealed interface StackMapTableAttribute
/**
* {@return a stack map table attribute}
+ *
* @param entries the stack map frames
*/
public static StackMapTableAttribute of(List
- * The attribute permits multiple instances in a given location.
+ * This attribute can appear on classes, methods, and fields, and permits
+ * {@linkplain AttributeMapper#allowMultiple multiple instances} in a structure.
+ * It has {@linkplain AttributeStability#STATELESS no data dependency}.
+ *
+ * This attribute was introduced in the Java SE Platform version 1.1, major
+ * version {@value ClassFile#JAVA_1_VERSION}.
+ *
+ * @apiNote
+ * This attribute has been largely superseded by the {@link AccessFlag#SYNTHETIC
+ * ACC_SYNTHETIC} modifier in newer {@code class} files. See {@link
+ * java.compiler/javax.lang.model.util.Elements.Origin} for a more in-depth
+ * description about the differences between synthetic and implicit (mandated)
+ * constructs generated by compilers.
*
+ * @see Attributes#synthetic()
+ * @see AccessFlag#SYNTHETIC
+ * @jvms 4.7.8 The {@code Synthetic} Attribute
* @since 24
*/
+@SuppressWarnings("doclint:reference")
public sealed interface SyntheticAttribute
extends Attribute
+ * This attribute is not delivered in the traversal of a {@link CodeModel}.
+ *
+ * An unknown attribute may appear anywhere where an attribute may appear, and
+ * has an {@linkplain AttributeStability#UNKNOWN unknown} data dependency.
*
+ * @see CustomAttribute
* @since 24
*/
public sealed interface UnknownAttribute
diff --git a/src/java.base/share/classes/java/lang/classfile/attribute/package-info.java b/src/java.base/share/classes/java/lang/classfile/attribute/package-info.java
index 08bd28cbc58..1ddd0511d85 100644
--- a/src/java.base/share/classes/java/lang/classfile/attribute/package-info.java
+++ b/src/java.base/share/classes/java/lang/classfile/attribute/package-info.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2023, 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
@@ -24,11 +24,79 @@
*/
/**
- *
+ * Unless otherwise specified, passing {@code null} or an array or collection containing a {@code null} element as an
+ * argument to a constructor or method of any Class-File API class or interface will cause a {@link NullPointerException}
+ * to be thrown.
*
+ *
+ * When read from {@code class} files, the attributes are lazily inflated; the contents of these attributes are not
+ * evaluated to speed up parsing, and user-defined attributes from {@link AttributeMapper#readAttribute} should be
+ * lazy too. Contents to users interest can be read on demand, so errors in one attribute does not prevent access to
+ * other attributes.
+ *
+ * Attribute contents are represented with constant pool entries to closely represent the original {@code class} file.
+ * These entries provide conversion methods to view them as validated symbolic descriptors. Check {@link
+ * java.lang.classfile.constantpool} for effective reading of constant pool entries, which can affect attribute reading
+ * speed as well. See this example of checking the presence of a {@link Deprecated} annotation:
+ * {@snippet lang="java" class="PackageSnippets" region="hasDeprecated"}
+ *
+ * Due to the lazy nature of {@code class} file parsing, {@link IllegalArgumentException} indicating malformed
+ * {@code class} file data can be thrown at any method invocation, either from the attribute itself due to structural
+ * corruption, or from a constant pool entry referred by the attribute. Some attributes, such as annotation attributes,
+ * must be ignored silently if they are malformed per JVMS; as a result, attribute processing code should anticipate
+ * {@link IllegalArgumentException} and skip, instead of propagating the failure, on such attributes.
+ *
+ *
+ * The attribute factories generally have two sets of factory methods: one that accepts symbolic information
+ * representing the uses, and another that accepts constant pool entries. Most of time, the symbolic factories are
+ * sufficent, but the constant pool entry ones can be used for fine-grained control over {@code class} file generation;
+ * see "{@linkplain java.lang.classfile.constantpool##writing Writing the constant pool entries}" for more details.
+ *
+ * Many attributes can be bulk-copied if the data it depends on does not change; this information is exposed in {@link
+ * AttributeMapper#stability()} and is documented for each attribute on its modeling interface. Ability to bulk-copy
+ * can massively speed up {@code class} file generation or transformation. In addition, in conjunction with {@link
+ * ClassFile.AttributesProcessingOption}, attributes read from other {@code class} files that cannot confirm its data
+ * is still valid for the currently building {@code class} file may be dropped.
+ *
+ * @see Attribute
+ * @see AttributeMapper
+ * @see Attributes
+ * @jvms 4.7 Attributes
* @since 24
*/
package java.lang.classfile.attribute;
+import java.lang.classfile.Attribute;
+import java.lang.classfile.AttributeMapper;
+import java.lang.classfile.AttributedElement;
+import java.lang.classfile.Attributes;
+import java.lang.classfile.ClassElement;
+import java.lang.classfile.ClassFile;
+import java.lang.classfile.ClassFileBuilder;
+import java.lang.classfile.ClassModel;
+import java.lang.classfile.CodeElement;
+import java.lang.classfile.CompoundElement;
+import java.lang.classfile.CustomAttribute;
+import java.lang.classfile.FieldElement;
+import java.lang.classfile.MethodElement;
diff --git a/src/java.base/share/classes/java/lang/classfile/attribute/snippet-files/PackageSnippets.java b/src/java.base/share/classes/java/lang/classfile/attribute/snippet-files/PackageSnippets.java
new file mode 100644
index 00000000000..452f39f56db
--- /dev/null
+++ b/src/java.base/share/classes/java/lang/classfile/attribute/snippet-files/PackageSnippets.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 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
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.lang.classfile.attribute.snippet;
+
+import java.lang.classfile.AttributedElement;
+import java.lang.classfile.Attributes;
+import java.lang.classfile.CodeBuilder;
+import java.lang.classfile.MethodModel;
+import java.lang.classfile.attribute.RuntimeVisibleAnnotationsAttribute;
+import java.util.List;
+
+class PackageSnippets {
+
+ // @start region=hasDeprecated
+ private static final String DEPRECATED_DESC = Deprecated.class.descriptorString();
+
+ static boolean hasDeprecated(AttributedElement element) {
+ var annotations = element.findAttribute(Attributes.runtimeVisibleAnnotations())
+ .map(RuntimeVisibleAnnotationsAttribute::annotations)
+ .orElse(List.of());
+ for (var anno : annotations) {
+ // equalsString reduces extra computations for raw UTF-8 entries
+ if (anno.className().equalsString(DEPRECATED_DESC)) {
+ return true;
+ }
+ }
+ return false;
+ }
+ // @end
+
+ // @start region=reuseStackMaps
+ static void reuseStackMaps(MethodModel oldMethod, CodeBuilder cob) {
+ var oldCode = oldMethod.code().orElseThrow();
+ // The StackMapTable attribute is not streamed in CodeModel, so this is
+ // the only way to obtain it
+ // @link substring="findAttribute" target="AttributedElement#findAttribute" :
+ var stackMaps = oldCode.findAttribute(Attributes.stackMapTable());
+ stackMaps.ifPresent(cob); // Note: CodeBuilder is a Consumer
* The use of a {@code DoubleEntry} is modeled by a {@code double}. Conversions
* are through {@link ConstantPoolBuilder#doubleEntry} and {@link #doubleValue()}.
- * In the conversions, all NaN values of the {@code double} may be collapsed
- * into a single {@linkplain Double#NaN "canonical" NaN value}.
+ * In the conversions, all NaN values of the {@code double} may or may not be
+ * collapsed into a single {@linkplain Double#NaN "canonical" NaN value}.
*
* A double entry has a {@linkplain #width() width} of {@code 2}, making its
* subsequent constant pool index valid and unusable.
diff --git a/src/java.base/share/classes/java/lang/classfile/constantpool/FloatEntry.java b/src/java.base/share/classes/java/lang/classfile/constantpool/FloatEntry.java
index 2ccf3fb94e4..add8707ce82 100644
--- a/src/java.base/share/classes/java/lang/classfile/constantpool/FloatEntry.java
+++ b/src/java.base/share/classes/java/lang/classfile/constantpool/FloatEntry.java
@@ -34,8 +34,8 @@
*
* The use of a {@code FloatEntry} is modeled by a {@code float}. Conversions
* are through {@link ConstantPoolBuilder#floatEntry} and {@link #floatValue()}.
- * In the conversions, all NaN values of the {@code float} may be collapsed into
- * a single {@linkplain Float#NaN "canonical" NaN value}.
+ * In the conversions, all NaN values of the {@code float} may or may not be
+ * collapsed into a single {@linkplain Float#NaN "canonical" NaN value}.
*
* @see ConstantPoolBuilder#floatEntry ConstantPoolBuilder::floatEntry
* @jvms 4.4.4 The {@code CONSTANT_Integer_info} and {@code CONSTANT_Float_info}
diff --git a/src/java.base/share/classes/java/lang/classfile/instruction/DiscontinuedInstruction.java b/src/java.base/share/classes/java/lang/classfile/instruction/DiscontinuedInstruction.java
index 4170e142ffe..906aaea421d 100644
--- a/src/java.base/share/classes/java/lang/classfile/instruction/DiscontinuedInstruction.java
+++ b/src/java.base/share/classes/java/lang/classfile/instruction/DiscontinuedInstruction.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2023, 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
@@ -25,6 +25,7 @@
package java.lang.classfile.instruction;
import java.lang.classfile.*;
+import java.lang.classfile.attribute.StackMapTableAttribute;
import jdk.internal.classfile.impl.AbstractInstruction;
import jdk.internal.classfile.impl.BytecodeHelpers;
@@ -71,7 +72,13 @@ public sealed interface DiscontinuedInstruction extends Instruction {
* astore} series of instructions can then store this value to a local
* variable slot.
*
+ * @apiNote
+ * Jump subroutine instructions are discontinued to enforce verification by
+ * type checking (JVMS {@jvms 4.10.1}) using the {@link StackMapTableAttribute
+ * StackMapTable} attribute.
+ *
* @see Opcode.Kind#DISCONTINUED_JSR
+ * @see StackMapTableAttribute
* @since 24
*/
sealed interface JsrInstruction extends DiscontinuedInstruction
@@ -130,8 +137,14 @@ static JsrInstruction of(Label target) {
* TypeKind##returnAddress returnAddress} value to a local variable slot,
* making the slot usable by a return from subroutine instruction.
*
+ * @apiNote
+ * Return from subroutine instructions are discontinued to enforce
+ * verification by type checking (JVMS {@jvms 4.10.1}) using the {@link
+ * StackMapTableAttribute StackMapTable} attribute.
+ *
* @jvms 6.5.ret ret
* @see Opcode.Kind#DISCONTINUED_RET
+ * @see StackMapTableAttribute
* @since 24
*/
sealed interface RetInstruction extends DiscontinuedInstruction
diff --git a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_de.java b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_de.java
index a6f8370a2d7..bcdb0f59f5c 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_de.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_de.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -31,7 +31,7 @@
* Array. You also need to update MAX_CODE for error strings
* and MAX_WARNING for warnings ( Needed for only information
* purpose )
- * @LastModified: May 2022
+ * @LastModified: Dec 2024
*/
public class XSLTErrorResources_de extends ListResourceBundle
{
@@ -1197,7 +1197,7 @@ public Object[][] getContents()
"Das Feature \"{0}\" kann nicht f\u00FCr diese TransformerFactory festgelegt werden."},
{ ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING,
- "Verwendung des Erweiterungselements \"{0}\" ist nicht zul\u00E4ssig, wenn das Feature f\u00FCr die sichere Verarbeitung auf \"true\" gesetzt ist."},
+ "Verwendung der Erweiterungsfunktion \"{0}\" ist nicht zul\u00E4ssig, wenn die Erweiterungsfunktionen vom Feature f\u00FCr die sichere Verarbeitung oder der Eigenschaft \"jdk.xml.enableExtensionFunctions\" deaktiviert wurden. Setzen Sie \"jdk.xml.enableExtensionFunctions\" auf \"true\", um die Erweiterungsfunktionen zu aktivieren."},
{ ER_NAMESPACE_CONTEXT_NULL_NAMESPACE,
"Pr\u00E4fix f\u00FCr Null-Namespace-URI kann nicht abgerufen werden."},
diff --git a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_ja.java b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_ja.java
index cf8a0f2563b..8555d69597b 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_ja.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_ja.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -31,7 +31,7 @@
* Array. You also need to update MAX_CODE for error strings
* and MAX_WARNING for warnings ( Needed for only information
* purpose )
- * @LastModified: May 2022
+ * @LastModified: Dec 2024
*/
public class XSLTErrorResources_ja extends ListResourceBundle
{
@@ -1197,7 +1197,7 @@ public Object[][] getContents()
"\u6A5F\u80FD''{0}''\u3092\u3053\u306ETransformerFactory\u306B\u8A2D\u5B9A\u3067\u304D\u307E\u305B\u3093\u3002"},
{ ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING,
- "\u30BB\u30AD\u30E5\u30A2\u51E6\u7406\u6A5F\u80FD\u304Ctrue\u306B\u8A2D\u5B9A\u3055\u308C\u3066\u3044\u308B\u3068\u304D\u3001\u62E1\u5F35\u8981\u7D20''{0}''\u306E\u4F7F\u7528\u306F\u8A31\u53EF\u3055\u308C\u307E\u305B\u3093\u3002"},
+ "\u30BB\u30AD\u30E5\u30A2\u51E6\u7406\u6A5F\u80FD\u307E\u305F\u306F\u30D7\u30ED\u30D1\u30C6\u30A3''jdk.xml.enableExtensionFunctions''\u306B\u3088\u3063\u3066\u62E1\u5F35\u95A2\u6570\u304C\u7121\u52B9\u306B\u306A\u3063\u3066\u3044\u308B\u3068\u304D\u3001\u62E1\u5F35\u95A2\u6570''{0}''\u306E\u4F7F\u7528\u306F\u8A31\u53EF\u3055\u308C\u307E\u305B\u3093\u3002\u62E1\u5F35\u95A2\u6570\u3092\u6709\u52B9\u306B\u3059\u308B\u306B\u306F\u3001''jdk.xml.enableExtensionFunctions''\u3092''true''\u306B\u8A2D\u5B9A\u3057\u307E\u3059\u3002"},
{ ER_NAMESPACE_CONTEXT_NULL_NAMESPACE,
"null\u306E\u30CD\u30FC\u30E0\u30B9\u30DA\u30FC\u30B9URI\u306B\u3064\u3044\u3066\u63A5\u982D\u8F9E\u3092\u53D6\u5F97\u3067\u304D\u307E\u305B\u3093\u3002"},
diff --git a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_zh_CN.java b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_zh_CN.java
index dc7ecef28f8..c5ae6af08c0 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_zh_CN.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_zh_CN.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -31,7 +31,7 @@
* Array. You also need to update MAX_CODE for error strings
* and MAX_WARNING for warnings ( Needed for only information
* purpose )
- * @LastModified: May 2022
+ * @LastModified: Dec 2024
*/
public class XSLTErrorResources_zh_CN extends ListResourceBundle
{
@@ -1197,7 +1197,7 @@ public Object[][] getContents()
"\u65E0\u6CD5\u5BF9\u6B64 TransformerFactory \u8BBE\u7F6E\u529F\u80FD ''{0}''\u3002"},
{ ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING,
- "\u5F53\u5B89\u5168\u5904\u7406\u529F\u80FD\u8BBE\u7F6E\u4E3A\u201C\u771F\u201D\u65F6, \u4E0D\u5141\u8BB8\u4F7F\u7528\u6269\u5C55\u5143\u7D20 ''{0}''\u3002"},
+ "\u5F53\u6269\u5C55\u51FD\u6570\u88AB\u5B89\u5168\u5904\u7406\u529F\u80FD\u6216\u5C5E\u6027 ''jdk.xml.enableExtensionFunctions'' \u7981\u7528\u65F6\uFF0C\u4E0D\u5141\u8BB8\u4F7F\u7528\u6269\u5C55\u51FD\u6570 ''{0}''\u3002\u8981\u542F\u7528\u6269\u5C55\u51FD\u6570\uFF0C\u8BF7\u5C06 ''jdk.xml.enableExtensionFunctions'' \u8BBE\u7F6E\u4E3A ''true''\u3002"},
{ ER_NAMESPACE_CONTEXT_NULL_NAMESPACE,
"\u65E0\u6CD5\u83B7\u53D6\u7A7A\u540D\u79F0\u7A7A\u95F4 uri \u7684\u524D\u7F00\u3002"},
diff --git a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMessages_de.java b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMessages_de.java
index 12ec243bbc9..c16620ec7b1 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMessages_de.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMessages_de.java
@@ -24,7 +24,7 @@
/**
* @author Morten Jorgensen
- * @LastModified: Nov 2024
+ * @LastModified: Dec 2024
*/
public class ErrorMessages_de extends ListResourceBundle {
@@ -548,6 +548,12 @@ public Object[][] getContents()
{ErrorMsg.DATA_CONVERSION_ERR,
"Datentyp \"{0}\" kann nicht in \"{1}\" konvertiert werden."},
+ /*
+ * Note to translators: property name "jdk.xml.enableExtensionFunctions"
+ * and value "true" should not be translated.
+ */
+ {ErrorMsg.UNSUPPORTED_EXT_FUNC_ERR,
+ "Verwendung der Erweiterungsfunktion \"{0}\" ist nicht zul\u00E4ssig, wenn die Erweiterungsfunktionen vom Feature f\u00FCr die sichere Verarbeitung oder der Eigenschaft \"jdk.xml.enableExtensionFunctions\" deaktiviert wurden. Setzen Sie \"jdk.xml.enableExtensionFunctions\" auf \"true\", um die Erweiterungsfunktionen zu aktivieren."},
/*
* Note to translators: "Templates" is a Java class name that should
* not be translated.
diff --git a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMessages_ja.java b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMessages_ja.java
index 5e03673aef5..48f7d63f353 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMessages_ja.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMessages_ja.java
@@ -24,7 +24,7 @@
/**
* @author Morten Jorgensen
- * @LastModified: Nov 2024
+ * @LastModified: Dec 2024
*/
public class ErrorMessages_ja extends ListResourceBundle {
@@ -548,6 +548,12 @@ public Object[][] getContents()
{ErrorMsg.DATA_CONVERSION_ERR,
"\u30C7\u30FC\u30BF\u578B''{0}''\u3092''{1}''\u306B\u5909\u63DB\u3067\u304D\u307E\u305B\u3093\u3002"},
+ /*
+ * Note to translators: property name "jdk.xml.enableExtensionFunctions"
+ * and value "true" should not be translated.
+ */
+ {ErrorMsg.UNSUPPORTED_EXT_FUNC_ERR,
+ "\u30BB\u30AD\u30E5\u30A2\u51E6\u7406\u6A5F\u80FD\u307E\u305F\u306F\u30D7\u30ED\u30D1\u30C6\u30A3''jdk.xml.enableExtensionFunctions''\u306B\u3088\u3063\u3066\u62E1\u5F35\u95A2\u6570\u304C\u7121\u52B9\u306B\u306A\u3063\u3066\u3044\u308B\u3068\u304D\u3001\u62E1\u5F35\u95A2\u6570''{0}''\u306E\u4F7F\u7528\u306F\u8A31\u53EF\u3055\u308C\u307E\u305B\u3093\u3002\u62E1\u5F35\u95A2\u6570\u3092\u6709\u52B9\u306B\u3059\u308B\u306B\u306F\u3001''jdk.xml.enableExtensionFunctions''\u3092''true''\u306B\u8A2D\u5B9A\u3057\u307E\u3059\u3002"},
/*
* Note to translators: "Templates" is a Java class name that should
* not be translated.
diff --git a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMessages_zh_CN.java b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMessages_zh_CN.java
index 728abc0df37..0affded17e3 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMessages_zh_CN.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMessages_zh_CN.java
@@ -24,7 +24,7 @@
/**
* @author Morten Jorgensen
- * @LastModified: Nov 2024
+ * @LastModified: Dec 2024
*/
public class ErrorMessages_zh_CN extends ListResourceBundle {
@@ -548,6 +548,12 @@ public Object[][] getContents()
{ErrorMsg.DATA_CONVERSION_ERR,
"\u65E0\u6CD5\u5C06\u6570\u636E\u7C7B\u578B ''{0}'' \u8F6C\u6362\u4E3A ''{1}''\u3002"},
+ /*
+ * Note to translators: property name "jdk.xml.enableExtensionFunctions"
+ * and value "true" should not be translated.
+ */
+ {ErrorMsg.UNSUPPORTED_EXT_FUNC_ERR,
+ "\u5F53\u6269\u5C55\u51FD\u6570\u88AB\u5B89\u5168\u5904\u7406\u529F\u80FD\u6216\u5C5E\u6027 ''jdk.xml.enableExtensionFunctions'' \u7981\u7528\u65F6\uFF0C\u4E0D\u5141\u8BB8\u4F7F\u7528\u6269\u5C55\u51FD\u6570 ''{0}''\u3002\u8981\u542F\u7528\u6269\u5C55\u51FD\u6570\uFF0C\u8BF7\u5C06 ''jdk.xml.enableExtensionFunctions'' \u8BBE\u7F6E\u4E3A ''true''\u3002"},
/*
* Note to translators: "Templates" is a Java class name that should
* not be translated.
diff --git a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/runtime/ErrorMessages_de.java b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/runtime/ErrorMessages_de.java
index dadea4ba3b0..c93e05d74e4 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/runtime/ErrorMessages_de.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/runtime/ErrorMessages_de.java
@@ -1,6 +1,5 @@
/*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -25,6 +24,7 @@
/**
* @author Morten Jorgensen
+ * @LastModified: Dec 2024
*/
public class ErrorMessages_de extends ListResourceBundle {
@@ -275,10 +275,10 @@ public Object[][] getContents()
"Ein Attribut, dessen Wert ein NCName sein muss, hatte den Wert \"{0}\""},
{BasisLibrary.UNALLOWED_EXTENSION_FUNCTION_ERR,
- "Verwendung der Erweiterungsfunktion \"{0}\" ist nicht zul\u00E4ssig, wenn das Feature f\u00FCr die sichere Verarbeitung auf \"true\" gesetzt ist."},
+ "Verwendung der Erweiterungsfunktion \"{0}\" ist nicht zul\u00E4ssig, wenn die Erweiterungsfunktionen vom Feature f\u00FCr die sichere Verarbeitung oder der Eigenschaft \"jdk.xml.enableExtensionFunctions\" deaktiviert wurden. Setzen Sie \"jdk.xml.enableExtensionFunctions\" auf \"true\", um die Erweiterungsfunktionen zu aktivieren."},
{BasisLibrary.UNALLOWED_EXTENSION_ELEMENT_ERR,
- "Verwendung des Erweiterungselements \"{0}\" ist nicht zul\u00E4ssig, wenn das Feature f\u00FCr die sichere Verarbeitung auf \"true\" gesetzt ist."},
+ "Verwendung des Erweiterungselements \"{0}\" ist nicht zul\u00E4ssig, wenn die Erweiterungsfunktionen vom Feature f\u00FCr die sichere Verarbeitung oder der Eigenschaft \"jdk.xml.enableExtensionFunctions\" deaktiviert wurden. Setzen Sie \"jdk.xml.enableExtensionFunctions\" auf \"true\", um die Erweiterungsfunktionen zu aktivieren."},
};
}
diff --git a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/runtime/ErrorMessages_ja.java b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/runtime/ErrorMessages_ja.java
index 8108e8f7218..941c1c38c00 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/runtime/ErrorMessages_ja.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/runtime/ErrorMessages_ja.java
@@ -1,6 +1,5 @@
/*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -25,6 +24,7 @@
/**
* @author Morten Jorgensen
+ * @LastModified: Dec 2024
*/
public class ErrorMessages_ja extends ListResourceBundle {
@@ -275,10 +275,10 @@ public Object[][] getContents()
"\u5024\u304CNCName\u3067\u3042\u308B\u3053\u3068\u304C\u5FC5\u8981\u306A\u5C5E\u6027\u306E\u5024\u304C''{0}''\u3067\u3057\u305F"},
{BasisLibrary.UNALLOWED_EXTENSION_FUNCTION_ERR,
- "\u30BB\u30AD\u30E5\u30A2\u51E6\u7406\u6A5F\u80FD\u304Ctrue\u306B\u8A2D\u5B9A\u3055\u308C\u3066\u3044\u308B\u3068\u304D\u3001\u62E1\u5F35\u95A2\u6570''{0}''\u306E\u4F7F\u7528\u306F\u8A31\u53EF\u3055\u308C\u307E\u305B\u3093\u3002"},
+ "\u30BB\u30AD\u30E5\u30A2\u51E6\u7406\u6A5F\u80FD\u307E\u305F\u306F\u30D7\u30ED\u30D1\u30C6\u30A3''jdk.xml.enableExtensionFunctions''\u306B\u3088\u3063\u3066\u62E1\u5F35\u95A2\u6570\u304C\u7121\u52B9\u306B\u306A\u3063\u3066\u3044\u308B\u3068\u304D\u3001\u62E1\u5F35\u95A2\u6570''{0}''\u306E\u4F7F\u7528\u306F\u8A31\u53EF\u3055\u308C\u307E\u305B\u3093\u3002\u62E1\u5F35\u95A2\u6570\u3092\u6709\u52B9\u306B\u3059\u308B\u306B\u306F\u3001''jdk.xml.enableExtensionFunctions''\u3092''true''\u306B\u8A2D\u5B9A\u3057\u307E\u3059\u3002"},
{BasisLibrary.UNALLOWED_EXTENSION_ELEMENT_ERR,
- "\u30BB\u30AD\u30E5\u30A2\u51E6\u7406\u6A5F\u80FD\u304Ctrue\u306B\u8A2D\u5B9A\u3055\u308C\u3066\u3044\u308B\u3068\u304D\u3001\u62E1\u5F35\u8981\u7D20''{0}''\u306E\u4F7F\u7528\u306F\u8A31\u53EF\u3055\u308C\u307E\u305B\u3093\u3002"},
+ "\u30BB\u30AD\u30E5\u30A2\u51E6\u7406\u6A5F\u80FD\u307E\u305F\u306F\u30D7\u30ED\u30D1\u30C6\u30A3''jdk.xml.enableExtensionFunctions''\u306B\u3088\u3063\u3066\u62E1\u5F35\u95A2\u6570\u304C\u7121\u52B9\u306B\u306A\u3063\u3066\u3044\u308B\u3068\u304D\u3001\u62E1\u5F35\u8981\u7D20''{0}''\u306E\u4F7F\u7528\u306F\u8A31\u53EF\u3055\u308C\u307E\u305B\u3093\u3002\u62E1\u5F35\u95A2\u6570\u3092\u6709\u52B9\u306B\u3059\u308B\u306B\u306F\u3001''jdk.xml.enableExtensionFunctions''\u3092''true''\u306B\u8A2D\u5B9A\u3057\u307E\u3059\u3002"},
};
}
diff --git a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/runtime/ErrorMessages_zh_CN.java b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/runtime/ErrorMessages_zh_CN.java
index 076b06d50db..55484c2b10c 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/runtime/ErrorMessages_zh_CN.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/runtime/ErrorMessages_zh_CN.java
@@ -1,6 +1,5 @@
/*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -25,6 +24,7 @@
/**
* @author Morten Jorgensen
+ * @LastModified: Dec 2024
*/
public class ErrorMessages_zh_CN extends ListResourceBundle {
@@ -275,10 +275,10 @@ public Object[][] getContents()
"\u5176\u503C\u5FC5\u987B\u4E3A NCName \u7684\u5C5E\u6027\u5177\u6709\u503C ''{0}''"},
{BasisLibrary.UNALLOWED_EXTENSION_FUNCTION_ERR,
- "\u5F53\u5B89\u5168\u5904\u7406\u529F\u80FD\u8BBE\u7F6E\u4E3A\u201C\u771F\u201D\u65F6, \u4E0D\u5141\u8BB8\u4F7F\u7528\u6269\u5C55\u51FD\u6570 ''{0}''\u3002"},
+ "\u5F53\u6269\u5C55\u51FD\u6570\u88AB\u5B89\u5168\u5904\u7406\u529F\u80FD\u6216\u5C5E\u6027 ''jdk.xml.enableExtensionFunctions'' \u7981\u7528\u65F6\uFF0C\u4E0D\u5141\u8BB8\u4F7F\u7528\u6269\u5C55\u51FD\u6570 ''{0}''\u3002\u8981\u542F\u7528\u6269\u5C55\u51FD\u6570\uFF0C\u8BF7\u5C06 ''jdk.xml.enableExtensionFunctions'' \u8BBE\u7F6E\u4E3A ''true''\u3002"},
{BasisLibrary.UNALLOWED_EXTENSION_ELEMENT_ERR,
- "\u5F53\u5B89\u5168\u5904\u7406\u529F\u80FD\u8BBE\u7F6E\u4E3A\u201C\u771F\u201D\u65F6, \u4E0D\u5141\u8BB8\u4F7F\u7528\u6269\u5C55\u5143\u7D20 ''{0}''\u3002"},
+ "\u5F53\u6269\u5C55\u51FD\u6570\u88AB\u5B89\u5168\u5904\u7406\u529F\u80FD\u6216\u5C5E\u6027 ''jdk.xml.enableExtensionFunctions'' \u7981\u7528\u65F6\uFF0C\u4E0D\u5141\u8BB8\u4F7F\u7528\u6269\u5C55\u5143\u7D20 ''{0}''\u3002\u8981\u542F\u7528\u6269\u5C55\u51FD\u6570\uFF0C\u8BF7\u5C06 ''jdk.xml.enableExtensionFunctions'' \u8BBE\u7F6E\u4E3A ''true''\u3002"},
};
}
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler_de.properties b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler_de.properties
index 130a644da94..8761d334157 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler_de.properties
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler_de.properties
@@ -839,8 +839,6 @@ compiler.misc.user.selected.completion.failure=Von Benutzer ausgewählter Abschl
# 0: collection of string
compiler.err.proc.no.explicit.annotation.processing.requested=Klassennamen "{0}" werden nur akzeptiert, wenn die Annotationsverarbeitung explizit angefordert wird
-compiler.err.proc.no.service=ServiceLoader konnte nicht verwendet werden und ist für Annotationsverarbeitung erforderlich.
-
# 0: string, 1: string
compiler.err.proc.processor.bad.option.name=Ungültiger Optionsname "{0}" von Prozessor "{1}" angegeben
@@ -2300,7 +2298,7 @@ compiler.misc.feature.flexible.constructors=Flexible Konstruktoren
compiler.misc.feature.module.imports=Modulimporte
# L10N: do not localize: transitive
-compiler.misc.feature.java.base.transitive=transitive Modifikator für java.base
+compiler.misc.feature.java.base.transitive=Modifikator "transitive" für java.base
compiler.warn.underscore.as.identifier=Ab Release 9 ist "_" ein Schlüsselwort und kann nicht als ID verwendet werden
@@ -2668,7 +2666,7 @@ compiler.misc.locn.module_path=Anwendungsmodulpfad
compiler.misc.cant.resolve.modules=Module können nicht aufgelöst werden
-compiler.misc.bad.requires.flag=Ungültiges requires-Kennzeichen: {0}
+compiler.misc.bad.requires.flag=Ungültiges Kennzeichen für "requires java.base": {0}
# 0: string
compiler.err.invalid.module.specifier=Modulbezeichner nicht zulässig: {0}
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler_ja.properties b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler_ja.properties
index 2c108edf692..9ab2862407f 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler_ja.properties
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler_ja.properties
@@ -839,8 +839,6 @@ compiler.misc.user.selected.completion.failure=クラス名によるユーザー
# 0: collection of string
compiler.err.proc.no.explicit.annotation.processing.requested=クラス名''{0}''が受け入れられるのは、注釈処理が明示的にリクエストされた場合のみです
-compiler.err.proc.no.service=サービス・ローダーが使用できませんでしたが、注釈処理に必要です。
-
# 0: string, 1: string
compiler.err.proc.processor.bad.option.name=プロセッサ''{1}''によって指定されたオプション名''{0}''が不正です
@@ -2300,7 +2298,7 @@ compiler.misc.feature.flexible.constructors=柔軟なコンストラクタ
compiler.misc.feature.module.imports=モジュール・インポート
# L10N: do not localize: transitive
-compiler.misc.feature.java.base.transitive=java.baseの推移的修飾子
+compiler.misc.feature.java.base.transitive=java.baseのtransitive 修飾子
compiler.warn.underscore.as.identifier=リリース9から''_''はキーワードなので識別子として使用することはできません
@@ -2668,7 +2666,7 @@ compiler.misc.locn.module_path=アプリケーション・モジュール・パ
compiler.misc.cant.resolve.modules=モジュールを解決できません
-compiler.misc.bad.requires.flag=不正な必須フラグ: {0}
+compiler.misc.bad.requires.flag="requires java.base"のフラグが無効です: {0}
# 0: string
compiler.err.invalid.module.specifier=モジュール指定子は許可されません: {0}
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler_zh_CN.properties b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler_zh_CN.properties
index c841c3715fc..52a6ec23e51 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler_zh_CN.properties
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler_zh_CN.properties
@@ -839,8 +839,6 @@ compiler.misc.user.selected.completion.failure=按类名列出的用户选择输
# 0: collection of string
compiler.err.proc.no.explicit.annotation.processing.requested=仅当显式请求批注处理时才接受类名称 ''{0}''
-compiler.err.proc.no.service=ServiceLoader 不可用, 但它是批注处理所必需的。
-
# 0: string, 1: string
compiler.err.proc.processor.bad.option.name=处理程序 ''{1}'' 提供的选项名称 ''{0}'' 错误
@@ -2300,7 +2298,7 @@ compiler.misc.feature.flexible.constructors=灵活构造器
compiler.misc.feature.module.imports=模块导入
# L10N: do not localize: transitive
-compiler.misc.feature.java.base.transitive=java.base 的过渡修饰符
+compiler.misc.feature.java.base.transitive=java.base 的 transitive 修饰符
compiler.warn.underscore.as.identifier=从发行版 9 开始, ''_'' 为关键字, 不能用作标识符
@@ -2668,7 +2666,7 @@ compiler.misc.locn.module_path=应用程序模块路径
compiler.misc.cant.resolve.modules=无法解析模块
-compiler.misc.bad.requires.flag=错误的请求标记:{0}
+compiler.misc.bad.requires.flag="requires java.base" 的标记无效:{0}
# 0: string
compiler.err.invalid.module.specifier=不允许模块说明符: {0}
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/launcher_de.properties b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/launcher_de.properties
index efcc594ca6c..0c67a60aa0a 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/launcher_de.properties
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/launcher_de.properties
@@ -82,8 +82,6 @@ launcher.error=Fehler:\u0020
launcher.err.no.args=kein Pfad für Quelldatei
-launcher.err.security.manager=Quellcode-Launcher kann nicht mit aktiviertem Sicherheitsmanager verwendet werden
-
# 0: string
launcher.err.invalid.filename=ungültiger Pfad für Quelldatei: {0}
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/launcher_ja.properties b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/launcher_ja.properties
index 72e2478bff3..ef4d0f1f9e0 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/launcher_ja.properties
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/launcher_ja.properties
@@ -82,8 +82,6 @@ launcher.error=エラー:\u0020
launcher.err.no.args=ソース・ファイルのパスがありません
-launcher.err.security.manager=セキュリティ・マネージャが有効な状態でソースコード・ランチャを使用することはできません
-
# 0: string
launcher.err.invalid.filename=ソース・ファイルの無効なパス: {0}
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/launcher_zh_CN.properties b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/launcher_zh_CN.properties
index 9382ac9e348..a442cfe1e68 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/launcher_zh_CN.properties
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/launcher_zh_CN.properties
@@ -82,8 +82,6 @@ launcher.error=错误:\u0020
launcher.err.no.args=无源文件的路径
-launcher.err.security.manager=无法在启用安全管理器的情况下使用源代码启动程序
-
# 0: string
launcher.err.invalid.filename=源文件的路径无效:{0}
diff --git a/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink_de.properties b/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink_de.properties
index eebf34ce355..06ec470a877 100644
--- a/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink_de.properties
+++ b/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink_de.properties
@@ -65,17 +65,19 @@ main.extended.help.footer=Bei Optionen, die eine
+ *
+ *
+ *
+ *
+ * @apiNote
+ * Implementations of this method should perform minimal work to return an
+ * attribute, as this method is called even if the resulting attribute is
+ * never used. In particular, the implementation should avoid checking the
+ * validity of the attribute {@code class} file data or performing actions
+ * that may throw exceptions.
*
- * @param enclosing The class, method, field, or code attribute in which
- * this attribute appears
- * @param cf The {@link ClassReader} describing the classfile to read from
- * @param pos The offset into the classfile at which the attribute starts
- * @return the new attribute
+ * @param enclosing the structure in which this attribute appears
+ * @param cf provides access to the {@code class} file to read from
+ * @param pos the offset into the {@code class} file at which the contents
+ * of the attribute starts
+ * @return the read attribute
*/
A readAttribute(AttributedElement enclosing, ClassReader cf, int pos);
/**
- * Write an {@link Attribute} instance to a classfile.
+ * Writes an {@link Attribute} instance to a {@code class} file for the
+ * Class-File API.
+ *
+ *
+ *
+ *
+ *
+ * @apiNote
+ * {@link BufWriter#patchInt} can be used to update the attribute length
+ * after the attribute contents are written to the {@code buf}.
*
- * @param buf The {@link BufWriter} to which the attribute should be written
- * @param attr The attribute to write
+ * @param buf the {@link BufWriter} to which the attribute should be written
+ * @param attr the attribute to write
+ * @throws IllegalArgumentException if some data in the API model of the
+ * attribute is invalid for the {@code class} file format
*/
void writeAttribute(BufWriter buf, A attr);
/**
- * {@return whether this attribute may appear more than once in a given location}
+ * {@return whether this attribute may appear more than once in one
+ * structure}
+ *
- *
- *
- * The mappers with {@link AttributeStability#CP_REFS CP_REFS} stability are:
- *
- *
- *
- * The mappers with {@link AttributeStability#LABELS LABELS} stability are:
+ * Unless otherwise specified, each mapper returned by methods in this class:
*
- *
- *
- * The {@link AttributeStability#UNSTABLE UNSTABLE} mappers are:
- *
- *
*
* @see AttributeMapper
- *
+ * @see java.lang.classfile.attribute
* @since 24
*/
public final class Attributes {
@@ -204,258 +160,278 @@ private Attributes() {
}
/**
- * {@return Attribute mapper for the {@code AnnotationDefault} attribute}
+ * {@return the mapper for the {@code AnnotationDefault} attribute}
*/
public static AttributeMapper
*
*
* if ( Flowcon ) Statement [else Statement]
* for ( ForInitOpt ; [Flowcon] ; ForUpdateOpt ) Statement
@@ -131,22 +144,28 @@ public sealed interface CharacterRangeInfo
* if<cond>, ifnonull, ifnull or goto.
*
{@code
*
* ModuleHashes_attribute {
@@ -63,10 +65,17 @@
* }
* }
* {@code
* ModuleResolution_attribute {
* u2 attribute_name_index; // "ModuleResolution"
@@ -58,10 +60,17 @@
* }
* }
* {@code
* // Optional
* 0x0001 (DO_NOT_RESOLVE_BY_DEFAULT)
@@ -80,12 +91,12 @@ public sealed interface ModuleResolutionAttribute
* 0x0004 (WARN_DEPRECATED_FOR_REMOVAL)
* 0x0008 (WARN_INCUBATING)
* }
- * @return the module resolution flags
*/
int resolutionFlags();
/**
* {@return a {@code ModuleResolution} attribute}
+ *
* @param resolutionFlags the resolution flags
*/
static ModuleResolutionAttribute of(int resolutionFlags) {
diff --git a/src/java.base/share/classes/java/lang/classfile/attribute/ModuleTargetAttribute.java b/src/java.base/share/classes/java/lang/classfile/attribute/ModuleTargetAttribute.java
index ac390c3d391..6d727db6851 100644
--- a/src/java.base/share/classes/java/lang/classfile/attribute/ModuleTargetAttribute.java
+++ b/src/java.base/share/classes/java/lang/classfile/attribute/ModuleTargetAttribute.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2022, 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
@@ -26,7 +26,11 @@
package java.lang.classfile.attribute;
import java.lang.classfile.Attribute;
+import java.lang.classfile.AttributeMapper;
+import java.lang.classfile.AttributeMapper.AttributeStability;
+import java.lang.classfile.Attributes;
import java.lang.classfile.ClassElement;
+import java.lang.classfile.ClassModel;
import java.lang.classfile.constantpool.Utf8Entry;
import jdk.internal.classfile.impl.BoundAttribute;
@@ -34,13 +38,11 @@
import jdk.internal.classfile.impl.UnboundAttribute;
/**
- * Models the {@code ModuleTarget} attribute, which can
- * appear on classes that represent module descriptors. This is a JDK-specific
- * attribute, which captures constraints on the target platform.
- * Delivered as a {@link java.lang.classfile.ClassElement} when
- * traversing the elements of a {@link java.lang.classfile.ClassModel}.
- *
- * {@code
* TargetPlatform_attribute {
* // index to CONSTANT_utf8_info structure in constant pool representing
@@ -53,10 +55,17 @@
* }
* }
* > parameterAnnotations();
/**
* {@return a {@code RuntimeInvisibleParameterAnnotations} attribute}
- * @param parameterAnnotations a list of parameter annotations for each parameter
+ * The {@code parameterAnnotations} list should not be truncated, and must
+ * have a length equal to the number of formal parameters; elements for
+ * unannotated parameters may be empty, but may not be omitted. It may omit
+ * some synthetic or implicit parameters.
+ *
+ * @param parameterAnnotations a list of run-time invisible annotations for each parameter
*/
static RuntimeInvisibleParameterAnnotationsAttribute of(List
> parameterAnnotations) {
return new UnboundAttribute.UnboundRuntimeInvisibleParameterAnnotationsAttribute(parameterAnnotations);
diff --git a/src/java.base/share/classes/java/lang/classfile/attribute/RuntimeInvisibleTypeAnnotationsAttribute.java b/src/java.base/share/classes/java/lang/classfile/attribute/RuntimeInvisibleTypeAnnotationsAttribute.java
index 7500d39fc19..3ff1a643a82 100644
--- a/src/java.base/share/classes/java/lang/classfile/attribute/RuntimeInvisibleTypeAnnotationsAttribute.java
+++ b/src/java.base/share/classes/java/lang/classfile/attribute/RuntimeInvisibleTypeAnnotationsAttribute.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2022, 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
@@ -25,32 +25,44 @@
package java.lang.classfile.attribute;
-import java.lang.classfile.Attribute;
-import java.lang.classfile.ClassElement;
-import java.lang.classfile.CodeElement;
-import java.lang.classfile.FieldElement;
-import java.lang.classfile.MethodElement;
-import java.lang.classfile.TypeAnnotation;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.classfile.*;
+import java.lang.classfile.AttributeMapper.AttributeStability;
+import java.lang.reflect.AnnotatedType;
import java.util.List;
import jdk.internal.classfile.impl.BoundAttribute;
import jdk.internal.classfile.impl.UnboundAttribute;
/**
- * Models the {@code RuntimeInvisibleTypeAnnotations} attribute (JVMS {@jvms 4.7.21}), which
- * can appear on classes, methods, fields, and code attributes. Delivered as a
- * {@link java.lang.classfile.ClassElement}, {@link java.lang.classfile.FieldElement},
- * {@link java.lang.classfile.MethodElement}, or {@link CodeElement} when traversing
- * the corresponding model type.
+ * Models the {@link Attributes#runtimeInvisibleTypeAnnotations()
+ * RuntimeInvisibleTypeAnnotations} attribute (JVMS {@jvms 4.7.21}), which
+ * stores type-use annotations for the annotated uses of types in this
+ * structure that are visible to {@code class} file consumers but are not
+ * visible to {@linkplain AnnotatedType core reflection}. Its delivery in the
+ * traversal of a {@link CodeModel} may be toggled by {@link
+ * ClassFile.DebugElementsOption}.
*
> parameterAnnotations();
/**
* {@return a {@code RuntimeVisibleParameterAnnotations} attribute}
- * @param parameterAnnotations a list of parameter annotations for each parameter
+ * The {@code parameterAnnotations} list should not be truncated, and must
+ * have a length equal to the number of formal parameters; elements for
+ * unannotated parameters may be empty, but may not be omitted. It may omit
+ * some synthetic or implicit parameters.
+ *
+ * @param parameterAnnotations a list of run-time visible annotations for each parameter
*/
static RuntimeVisibleParameterAnnotationsAttribute of(List
> parameterAnnotations) {
return new UnboundAttribute.UnboundRuntimeVisibleParameterAnnotationsAttribute(parameterAnnotations);
diff --git a/src/java.base/share/classes/java/lang/classfile/attribute/RuntimeVisibleTypeAnnotationsAttribute.java b/src/java.base/share/classes/java/lang/classfile/attribute/RuntimeVisibleTypeAnnotationsAttribute.java
index a4e780c4536..ad4595ffb6b 100644
--- a/src/java.base/share/classes/java/lang/classfile/attribute/RuntimeVisibleTypeAnnotationsAttribute.java
+++ b/src/java.base/share/classes/java/lang/classfile/attribute/RuntimeVisibleTypeAnnotationsAttribute.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2022, 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
@@ -25,32 +25,44 @@
package java.lang.classfile.attribute;
-import java.lang.classfile.Attribute;
-import java.lang.classfile.ClassElement;
-import java.lang.classfile.CodeElement;
-import java.lang.classfile.FieldElement;
-import java.lang.classfile.MethodElement;
-import java.lang.classfile.TypeAnnotation;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.classfile.*;
+import java.lang.classfile.AttributeMapper.AttributeStability;
+import java.lang.reflect.AnnotatedType;
import java.util.List;
import jdk.internal.classfile.impl.BoundAttribute;
import jdk.internal.classfile.impl.UnboundAttribute;
/**
- * Models the {@code RuntimeVisibleTypeAnnotations} attribute (JVMS {@jvms 4.7.20}), which
- * can appear on classes, methods, fields, and code attributes. Delivered as a
- * {@link java.lang.classfile.ClassElement}, {@link java.lang.classfile.FieldElement},
- * {@link java.lang.classfile.MethodElement}, or {@link CodeElement} when traversing
- * the corresponding model type.
+ * Models the {@link Attributes#runtimeVisibleTypeAnnotations()
+ * RuntimeVisibleTypeAnnotations} attribute (JVMS {@jvms 4.7.20}), which
+ * stores type-use annotations for the annotated uses of types in this
+ * structure that are visible to both {@code class} file consumers and
+ * {@linkplain AnnotatedType core reflection}. Its delivery in the traversal of
+ * a {@link CodeModel} may be toggled by {@link ClassFile.DebugElementsOption}.
*
Provides interfaces describing classfile attributes for the {@link java.lang.classfile} library.
+ * Provides interfaces describing {@code class} file attributes for the {@link java.lang.classfile} library.
*
- * The {@code java.lang.classfile.attribute} package contains interfaces describing classfile attributes.
+ * The {@code java.lang.classfile.attribute} package contains interfaces describing specific {@code class} file
+ * attributes, including predefined (JVMS {@jvms 4.7}) and JDK-specific nonstandard attributes, whose mappers are
+ * defined in {@link Attributes}. This package summary provides an overview to the {@code class} file attribute system,
+ * including {@link Attribute}, {@link AttributedElement}, {@link AttributeMapper}, and {@link CustomAttribute}, which
+ * do not reside in this package.
+ * Reading Attributes
+ * The general way to obtain attributes is through {@link AttributedElement}. In addition to that, many attributes
+ * implement {@link ClassElement}, {@link FieldElement}, {@link MethodElement}, or {@link CodeElement}, and these
+ * attributes are generally delivered when their enclosing elements are viewed as {@link CompoundElement}s in streaming
+ * traversal, unless otherwise specified.
+ * Writing Attributes
+ * Most attributes implement at least one of {@link ClassElement}, {@link FieldElement}, {@link MethodElement}, or
+ * {@link CodeElement}, so they can be sent to the respective {@link ClassFileBuilder} to be written as part of those
+ * structure. Attributes define if they can {@linkplain AttributeMapper#allowMultiple() appear multiple times} in one
+ * structure; if they cannot, the last attribute instance supplied to the builder is the one written to the final
+ * structure. Some attributes, such as {@link BootstrapMethodsAttribute}, implement none of those interfaces. They are
+ * created through other means, specified in the modeling interface for each of the attributes. Attributes for a {@link
+ * RecordComponentInfo} are supplied through its factory methods.
+ *