8308753: Class-File API transition to Preview

Reviewed-by: ihse, mchung, vromero
This commit is contained in:
Adam Sotona 2023-12-04 07:07:57 +00:00
parent b9df827adc
commit 2b00ac0d02
681 changed files with 7518 additions and 6502 deletions

View file

@ -473,6 +473,11 @@ public class GenModuleInfoSource {
if (parser.peekToken() != null) { // must be EOF if (parser.peekToken() != null) { // must be EOF
throw parser.newError("is malformed"); throw parser.newError("is malformed");
} }
} else if (token.equals("import")) {
nextIdentifier(parser);
skipTokenOrThrow(parser, ";", "missing semicolon");
} else if (token.startsWith("@")) {
continue;
} else { } else {
throw parser.newError("missing keyword"); throw parser.newError("missing keyword");
} }

View file

@ -36,8 +36,8 @@ EXCLUDE_FILES += \
$(TOPDIR)/src/java.base/share/classes/jdk/internal/module/ModuleLoaderMap.java $(TOPDIR)/src/java.base/share/classes/jdk/internal/module/ModuleLoaderMap.java
EXCLUDES += java/lang/doc-files \ EXCLUDES += java/lang/doc-files \
jdk/internal/classfile/snippet-files \ java/lang/classfile/snippet-files \
jdk/internal/classfile/components/snippet-files java/lang/classfile/components/snippet-files
# Exclude BreakIterator classes that are just used in compile process to generate # Exclude BreakIterator classes that are just used in compile process to generate
# data files and shouldn't go in the product # data files and shouldn't go in the product

View file

@ -98,11 +98,6 @@ $(eval $(call SetupJavaCompilation, BUILD_JDK_MICROBENCHMARK, \
BIN := $(MICROBENCHMARK_CLASSES), \ BIN := $(MICROBENCHMARK_CLASSES), \
JAVAC_FLAGS := --add-exports java.base/sun.security.util=ALL-UNNAMED \ JAVAC_FLAGS := --add-exports java.base/sun.security.util=ALL-UNNAMED \
--add-exports java.base/sun.invoke.util=ALL-UNNAMED \ --add-exports java.base/sun.invoke.util=ALL-UNNAMED \
--add-exports java.base/jdk.internal.classfile=ALL-UNNAMED \
--add-exports java.base/jdk.internal.classfile.attribute=ALL-UNNAMED \
--add-exports java.base/jdk.internal.classfile.constantpool=ALL-UNNAMED \
--add-exports java.base/jdk.internal.classfile.instruction=ALL-UNNAMED \
--add-exports java.base/jdk.internal.classfile.components=ALL-UNNAMED \
--add-exports java.base/jdk.internal.classfile.impl=ALL-UNNAMED \ --add-exports java.base/jdk.internal.classfile.impl=ALL-UNNAMED \
--add-exports java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED \ --add-exports java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED \
--add-exports java.base/jdk.internal.org.objectweb.asm.tree=ALL-UNNAMED \ --add-exports java.base/jdk.internal.org.objectweb.asm.tree=ALL-UNNAMED \

View file

@ -52,13 +52,13 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import jdk.internal.classfile.AccessFlags; import java.lang.classfile.AccessFlags;
import jdk.internal.classfile.Attribute; import java.lang.classfile.Attribute;
import jdk.internal.classfile.ClassModel; import java.lang.classfile.ClassModel;
import jdk.internal.classfile.ClassTransform; import java.lang.classfile.ClassTransform;
import jdk.internal.classfile.Classfile; import java.lang.classfile.ClassFile;
import jdk.internal.classfile.attribute.ModuleAttribute; import java.lang.classfile.attribute.ModuleAttribute;
import jdk.internal.classfile.attribute.RuntimeVisibleAnnotationsAttribute; import java.lang.classfile.attribute.RuntimeVisibleAnnotationsAttribute;
import jdk.internal.javac.PreviewFeature; import jdk.internal.javac.PreviewFeature;
import jdk.internal.loader.BuiltinClassLoader; import jdk.internal.loader.BuiltinClassLoader;
@ -1591,7 +1591,7 @@ public final class Module implements AnnotatedElement {
*/ */
private Class<?> loadModuleInfoClass(InputStream in) throws IOException { private Class<?> loadModuleInfoClass(InputStream in) throws IOException {
final String MODULE_INFO = "module-info"; final String MODULE_INFO = "module-info";
var cc = Classfile.of(Classfile.ConstantPoolSharingOption.NEW_POOL); var cc = ClassFile.of(ClassFile.ConstantPoolSharingOption.NEW_POOL);
byte[] bytes = cc.transform(cc.parse(in.readAllBytes()), (clb, cle) -> { byte[] bytes = cc.transform(cc.parse(in.readAllBytes()), (clb, cle) -> {
switch (cle) { switch (cle) {
case AccessFlags af -> clb.withFlags(AccessFlag.INTERFACE, case AccessFlags af -> clb.withFlags(AccessFlag.INTERFACE,

View file

@ -22,17 +22,21 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
package jdk.internal.classfile; package java.lang.classfile;
import java.util.Set; import java.util.Set;
import jdk.internal.classfile.impl.AccessFlagsImpl; import jdk.internal.classfile.impl.AccessFlagsImpl;
import java.lang.reflect.AccessFlag; import java.lang.reflect.AccessFlag;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models the access flags for a class, method, or field. Delivered as a * Models the access flags for a class, method, or field. Delivered as a
* {@link ClassElement}, {@link FieldElement}, or {@link MethodElement} * {@link ClassElement}, {@link FieldElement}, or {@link MethodElement}
* when traversing the corresponding model type. * when traversing the corresponding model type.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface AccessFlags public sealed interface AccessFlags
extends ClassElement, MethodElement, FieldElement extends ClassElement, MethodElement, FieldElement
permits AccessFlagsImpl { permits AccessFlagsImpl {

View file

@ -22,18 +22,19 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
package jdk.internal.classfile; package java.lang.classfile;
import jdk.internal.classfile.attribute.RuntimeInvisibleAnnotationsAttribute; import java.lang.classfile.attribute.RuntimeInvisibleAnnotationsAttribute;
import jdk.internal.classfile.attribute.RuntimeInvisibleParameterAnnotationsAttribute; import java.lang.classfile.attribute.RuntimeInvisibleParameterAnnotationsAttribute;
import jdk.internal.classfile.attribute.RuntimeVisibleAnnotationsAttribute; import java.lang.classfile.attribute.RuntimeVisibleAnnotationsAttribute;
import jdk.internal.classfile.attribute.RuntimeVisibleParameterAnnotationsAttribute; import java.lang.classfile.attribute.RuntimeVisibleParameterAnnotationsAttribute;
import jdk.internal.classfile.constantpool.Utf8Entry; import java.lang.classfile.constantpool.Utf8Entry;
import jdk.internal.classfile.impl.AnnotationImpl; import jdk.internal.classfile.impl.AnnotationImpl;
import jdk.internal.classfile.impl.TemporaryConstantPool; import jdk.internal.classfile.impl.TemporaryConstantPool;
import java.lang.constant.ClassDesc; import java.lang.constant.ClassDesc;
import java.util.List; import java.util.List;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models an annotation on a declaration. * Models an annotation on a declaration.
@ -44,7 +45,11 @@ import java.util.List;
* @see RuntimeInvisibleAnnotationsAttribute * @see RuntimeInvisibleAnnotationsAttribute
* @see RuntimeVisibleParameterAnnotationsAttribute * @see RuntimeVisibleParameterAnnotationsAttribute
* @see RuntimeInvisibleParameterAnnotationsAttribute * @see RuntimeInvisibleParameterAnnotationsAttribute
*
* @sealedGraph
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface Annotation public sealed interface Annotation
extends WritableElement<Annotation> extends WritableElement<Annotation>
permits TypeAnnotation, AnnotationImpl { permits TypeAnnotation, AnnotationImpl {

View file

@ -22,20 +22,24 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
package jdk.internal.classfile; package java.lang.classfile;
import java.lang.constant.ClassDesc; import java.lang.constant.ClassDesc;
import jdk.internal.classfile.constantpool.Utf8Entry; import java.lang.classfile.constantpool.Utf8Entry;
import jdk.internal.classfile.impl.AnnotationImpl; import jdk.internal.classfile.impl.AnnotationImpl;
import jdk.internal.classfile.impl.TemporaryConstantPool; import jdk.internal.classfile.impl.TemporaryConstantPool;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models a key-value pair of an annotation. * Models a key-value pair of an annotation.
* *
* @see Annotation * @see Annotation
* @see AnnotationValue * @see AnnotationValue
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface AnnotationElement public sealed interface AnnotationElement
extends WritableElement<AnnotationElement> extends WritableElement<AnnotationElement>
permits AnnotationImpl.AnnotationElementImpl { permits AnnotationImpl.AnnotationElementImpl {

View file

@ -22,14 +22,14 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
package jdk.internal.classfile; package java.lang.classfile;
import jdk.internal.classfile.constantpool.AnnotationConstantValueEntry; import java.lang.classfile.constantpool.AnnotationConstantValueEntry;
import jdk.internal.classfile.constantpool.DoubleEntry; import java.lang.classfile.constantpool.DoubleEntry;
import jdk.internal.classfile.constantpool.FloatEntry; import java.lang.classfile.constantpool.FloatEntry;
import jdk.internal.classfile.constantpool.IntegerEntry; import java.lang.classfile.constantpool.IntegerEntry;
import jdk.internal.classfile.constantpool.LongEntry; import java.lang.classfile.constantpool.LongEntry;
import jdk.internal.classfile.constantpool.Utf8Entry; import java.lang.classfile.constantpool.Utf8Entry;
import jdk.internal.classfile.impl.AnnotationImpl; import jdk.internal.classfile.impl.AnnotationImpl;
import jdk.internal.classfile.impl.TemporaryConstantPool; import jdk.internal.classfile.impl.TemporaryConstantPool;
@ -37,34 +37,54 @@ import java.lang.constant.ClassDesc;
import java.lang.constant.ConstantDesc; import java.lang.constant.ConstantDesc;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models the value of a key-value pair of an annotation. * Models the value of a key-value pair of an annotation.
* *
* @see Annotation * @see Annotation
* @see AnnotationElement * @see AnnotationElement
*
* @sealedGraph
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface AnnotationValue extends WritableElement<AnnotationValue> public sealed interface AnnotationValue extends WritableElement<AnnotationValue>
permits AnnotationValue.OfAnnotation, AnnotationValue.OfArray, permits AnnotationValue.OfAnnotation, AnnotationValue.OfArray,
AnnotationValue.OfConstant, AnnotationValue.OfClass, AnnotationValue.OfConstant, AnnotationValue.OfClass,
AnnotationValue.OfEnum { AnnotationValue.OfEnum {
/** Models an annotation-valued element */ /**
* Models an annotation-valued element
*
* @since 22
*/
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
sealed interface OfAnnotation extends AnnotationValue sealed interface OfAnnotation extends AnnotationValue
permits AnnotationImpl.OfAnnotationImpl { permits AnnotationImpl.OfAnnotationImpl {
/** {@return the annotation} */ /** {@return the annotation} */
Annotation annotation(); Annotation annotation();
} }
/** Models an array-valued element */ /**
* Models an array-valued element
*
* @since 22
*/
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
sealed interface OfArray extends AnnotationValue sealed interface OfArray extends AnnotationValue
permits AnnotationImpl.OfArrayImpl { permits AnnotationImpl.OfArrayImpl {
/** {@return the values} */ /** {@return the values} */
List<AnnotationValue> values(); List<AnnotationValue> values();
} }
/** Models a constant-valued element */ /**
* Models a constant-valued element
*
* @sealedGraph
* @since 22
*/
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
sealed interface OfConstant extends AnnotationValue sealed interface OfConstant extends AnnotationValue
permits AnnotationValue.OfString, AnnotationValue.OfDouble, permits AnnotationValue.OfString, AnnotationValue.OfDouble,
AnnotationValue.OfFloat, AnnotationValue.OfLong, AnnotationValue.OfFloat, AnnotationValue.OfLong,
@ -77,70 +97,120 @@ public sealed interface AnnotationValue extends WritableElement<AnnotationValue>
ConstantDesc constantValue(); ConstantDesc constantValue();
} }
/** Models a constant-valued element */ /**
* Models a constant-valued element
*
* @since 22
*/
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
sealed interface OfString extends AnnotationValue.OfConstant sealed interface OfString extends AnnotationValue.OfConstant
permits AnnotationImpl.OfStringImpl { permits AnnotationImpl.OfStringImpl {
/** {@return the constant} */ /** {@return the constant} */
String stringValue(); String stringValue();
} }
/** Models a constant-valued element */ /**
* Models a constant-valued element
*
* @since 22
*/
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
sealed interface OfDouble extends AnnotationValue.OfConstant sealed interface OfDouble extends AnnotationValue.OfConstant
permits AnnotationImpl.OfDoubleImpl { permits AnnotationImpl.OfDoubleImpl {
/** {@return the constant} */ /** {@return the constant} */
double doubleValue(); double doubleValue();
} }
/** Models a constant-valued element */ /**
* Models a constant-valued element
*
* @since 22
*/
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
sealed interface OfFloat extends AnnotationValue.OfConstant sealed interface OfFloat extends AnnotationValue.OfConstant
permits AnnotationImpl.OfFloatImpl { permits AnnotationImpl.OfFloatImpl {
/** {@return the constant} */ /** {@return the constant} */
float floatValue(); float floatValue();
} }
/** Models a constant-valued element */ /**
* Models a constant-valued element
*
* @since 22
*/
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
sealed interface OfLong extends AnnotationValue.OfConstant sealed interface OfLong extends AnnotationValue.OfConstant
permits AnnotationImpl.OfLongImpl { permits AnnotationImpl.OfLongImpl {
/** {@return the constant} */ /** {@return the constant} */
long longValue(); long longValue();
} }
/** Models a constant-valued element */ /**
* Models a constant-valued element
*
* @since 22
*/
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
sealed interface OfInteger extends AnnotationValue.OfConstant sealed interface OfInteger extends AnnotationValue.OfConstant
permits AnnotationImpl.OfIntegerImpl { permits AnnotationImpl.OfIntegerImpl {
/** {@return the constant} */ /** {@return the constant} */
int intValue(); int intValue();
} }
/** Models a constant-valued element */ /**
* Models a constant-valued element
*
* @since 22
*/
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
sealed interface OfShort extends AnnotationValue.OfConstant sealed interface OfShort extends AnnotationValue.OfConstant
permits AnnotationImpl.OfShortImpl { permits AnnotationImpl.OfShortImpl {
/** {@return the constant} */ /** {@return the constant} */
short shortValue(); short shortValue();
} }
/** Models a constant-valued element */ /**
* Models a constant-valued element
*
* @since 22
*/
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
sealed interface OfCharacter extends AnnotationValue.OfConstant sealed interface OfCharacter extends AnnotationValue.OfConstant
permits AnnotationImpl.OfCharacterImpl { permits AnnotationImpl.OfCharacterImpl {
/** {@return the constant} */ /** {@return the constant} */
char charValue(); char charValue();
} }
/** Models a constant-valued element */ /**
* Models a constant-valued element
*
* @since 22
*/
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
sealed interface OfByte extends AnnotationValue.OfConstant sealed interface OfByte extends AnnotationValue.OfConstant
permits AnnotationImpl.OfByteImpl { permits AnnotationImpl.OfByteImpl {
/** {@return the constant} */ /** {@return the constant} */
byte byteValue(); byte byteValue();
} }
/** Models a constant-valued element */ /**
* Models a constant-valued element
*
* @since 22
*/
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
sealed interface OfBoolean extends AnnotationValue.OfConstant sealed interface OfBoolean extends AnnotationValue.OfConstant
permits AnnotationImpl.OfBooleanImpl { permits AnnotationImpl.OfBooleanImpl {
/** {@return the constant} */ /** {@return the constant} */
boolean booleanValue(); boolean booleanValue();
} }
/** Models a class-valued element */ /**
* Models a class-valued element
*
* @since 22
*/
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
sealed interface OfClass extends AnnotationValue sealed interface OfClass extends AnnotationValue
permits AnnotationImpl.OfClassImpl { permits AnnotationImpl.OfClassImpl {
/** {@return the class name} */ /** {@return the class name} */
@ -152,7 +222,12 @@ public sealed interface AnnotationValue extends WritableElement<AnnotationValue>
} }
} }
/** Models an enum-valued element */ /**
* Models an enum-valued element
*
* @since 22
*/
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
sealed interface OfEnum extends AnnotationValue sealed interface OfEnum extends AnnotationValue
permits AnnotationImpl.OfEnumImpl { permits AnnotationImpl.OfEnumImpl {
/** {@return the enum class name} */ /** {@return the enum class name} */
@ -168,7 +243,7 @@ public sealed interface AnnotationValue extends WritableElement<AnnotationValue>
} }
/** /**
* @return the tag character for this type as per {@jvms 4.7.16.1} * {@return the tag character for this type as per {@jvms 4.7.16.1}}
*/ */
char tag(); char tag();
@ -379,10 +454,13 @@ public sealed interface AnnotationValue extends WritableElement<AnnotationValue>
/** /**
* {@return an annotation element} The {@code value} parameter must be * {@return an annotation element} The {@code value} parameter must be
* a primitive, a String, a ClassDesc, an enum constant, or an array of * a primitive, a wrapper of primitive, a String, a ClassDesc, an enum
* one of these. * constant, or an array of one of these.
* *
* @param value the annotation value * @param value the annotation value
* @throws IllegalArgumentException when the {@code value} parameter is not
* a primitive, a wrapper of primitive, a String, a ClassDesc,
* an enum constant, or an array of one of these.
*/ */
static AnnotationValue of(Object value) { static AnnotationValue of(Object value) {
if (value instanceof String s) { if (value instanceof String s) {

View file

@ -22,47 +22,48 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
package jdk.internal.classfile; package java.lang.classfile;
import jdk.internal.classfile.attribute.AnnotationDefaultAttribute; import java.lang.classfile.attribute.AnnotationDefaultAttribute;
import jdk.internal.classfile.attribute.BootstrapMethodsAttribute; import java.lang.classfile.attribute.BootstrapMethodsAttribute;
import jdk.internal.classfile.attribute.CharacterRangeTableAttribute; import java.lang.classfile.attribute.CharacterRangeTableAttribute;
import jdk.internal.classfile.attribute.CodeAttribute; import java.lang.classfile.attribute.CodeAttribute;
import jdk.internal.classfile.attribute.CompilationIDAttribute; import java.lang.classfile.attribute.CompilationIDAttribute;
import jdk.internal.classfile.attribute.ConstantValueAttribute; import java.lang.classfile.attribute.ConstantValueAttribute;
import jdk.internal.classfile.attribute.DeprecatedAttribute; import java.lang.classfile.attribute.DeprecatedAttribute;
import jdk.internal.classfile.attribute.EnclosingMethodAttribute; import java.lang.classfile.attribute.EnclosingMethodAttribute;
import jdk.internal.classfile.attribute.ExceptionsAttribute; import java.lang.classfile.attribute.ExceptionsAttribute;
import jdk.internal.classfile.attribute.InnerClassesAttribute; import java.lang.classfile.attribute.InnerClassesAttribute;
import jdk.internal.classfile.attribute.LineNumberTableAttribute; import java.lang.classfile.attribute.LineNumberTableAttribute;
import jdk.internal.classfile.attribute.LocalVariableTableAttribute; import java.lang.classfile.attribute.LocalVariableTableAttribute;
import jdk.internal.classfile.attribute.LocalVariableTypeTableAttribute; import java.lang.classfile.attribute.LocalVariableTypeTableAttribute;
import jdk.internal.classfile.attribute.MethodParametersAttribute; import java.lang.classfile.attribute.MethodParametersAttribute;
import jdk.internal.classfile.attribute.ModuleAttribute; import java.lang.classfile.attribute.ModuleAttribute;
import jdk.internal.classfile.attribute.ModuleHashesAttribute; import java.lang.classfile.attribute.ModuleHashesAttribute;
import jdk.internal.classfile.attribute.ModuleMainClassAttribute; import java.lang.classfile.attribute.ModuleMainClassAttribute;
import jdk.internal.classfile.attribute.ModulePackagesAttribute; import java.lang.classfile.attribute.ModulePackagesAttribute;
import jdk.internal.classfile.attribute.ModuleResolutionAttribute; import java.lang.classfile.attribute.ModuleResolutionAttribute;
import jdk.internal.classfile.attribute.ModuleTargetAttribute; import java.lang.classfile.attribute.ModuleTargetAttribute;
import jdk.internal.classfile.attribute.NestHostAttribute; import java.lang.classfile.attribute.NestHostAttribute;
import jdk.internal.classfile.attribute.NestMembersAttribute; import java.lang.classfile.attribute.NestMembersAttribute;
import jdk.internal.classfile.attribute.PermittedSubclassesAttribute; import java.lang.classfile.attribute.PermittedSubclassesAttribute;
import jdk.internal.classfile.attribute.RecordAttribute; import java.lang.classfile.attribute.RecordAttribute;
import jdk.internal.classfile.attribute.RuntimeInvisibleAnnotationsAttribute; import java.lang.classfile.attribute.RuntimeInvisibleAnnotationsAttribute;
import jdk.internal.classfile.attribute.RuntimeInvisibleParameterAnnotationsAttribute; import java.lang.classfile.attribute.RuntimeInvisibleParameterAnnotationsAttribute;
import jdk.internal.classfile.attribute.RuntimeInvisibleTypeAnnotationsAttribute; import java.lang.classfile.attribute.RuntimeInvisibleTypeAnnotationsAttribute;
import jdk.internal.classfile.attribute.RuntimeVisibleAnnotationsAttribute; import java.lang.classfile.attribute.RuntimeVisibleAnnotationsAttribute;
import jdk.internal.classfile.attribute.RuntimeVisibleParameterAnnotationsAttribute; import java.lang.classfile.attribute.RuntimeVisibleParameterAnnotationsAttribute;
import jdk.internal.classfile.attribute.RuntimeVisibleTypeAnnotationsAttribute; import java.lang.classfile.attribute.RuntimeVisibleTypeAnnotationsAttribute;
import jdk.internal.classfile.attribute.SignatureAttribute; import java.lang.classfile.attribute.SignatureAttribute;
import jdk.internal.classfile.attribute.SourceDebugExtensionAttribute; import java.lang.classfile.attribute.SourceDebugExtensionAttribute;
import jdk.internal.classfile.attribute.SourceFileAttribute; import java.lang.classfile.attribute.SourceFileAttribute;
import jdk.internal.classfile.attribute.SourceIDAttribute; import java.lang.classfile.attribute.SourceIDAttribute;
import jdk.internal.classfile.attribute.StackMapTableAttribute; import java.lang.classfile.attribute.StackMapTableAttribute;
import jdk.internal.classfile.attribute.SyntheticAttribute; import java.lang.classfile.attribute.SyntheticAttribute;
import jdk.internal.classfile.attribute.UnknownAttribute; import java.lang.classfile.attribute.UnknownAttribute;
import jdk.internal.classfile.impl.BoundAttribute; import jdk.internal.classfile.impl.BoundAttribute;
import jdk.internal.classfile.impl.UnboundAttribute; import jdk.internal.classfile.impl.UnboundAttribute;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models a classfile attribute {@jvms 4.7}. Many, though not all, subtypes of * Models a classfile attribute {@jvms 4.7}. Many, though not all, subtypes of
@ -73,7 +74,11 @@ import jdk.internal.classfile.impl.UnboundAttribute;
* directly from the corresponding model type through {@link * directly from the corresponding model type through {@link
* AttributedElement#findAttribute(AttributeMapper)}. * AttributedElement#findAttribute(AttributeMapper)}.
* @param <A> the attribute type * @param <A> the attribute type
*
* @sealedGraph
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface Attribute<A extends Attribute<A>> public sealed interface Attribute<A extends Attribute<A>>
extends WritableElement<A> extends WritableElement<A>
permits AnnotationDefaultAttribute, BootstrapMethodsAttribute, permits AnnotationDefaultAttribute, BootstrapMethodsAttribute,
@ -91,7 +96,7 @@ public sealed interface Attribute<A extends Attribute<A>>
RuntimeVisibleTypeAnnotationsAttribute, SignatureAttribute, RuntimeVisibleTypeAnnotationsAttribute, SignatureAttribute,
SourceDebugExtensionAttribute, SourceFileAttribute, SourceIDAttribute, SourceDebugExtensionAttribute, SourceFileAttribute, SourceIDAttribute,
StackMapTableAttribute, SyntheticAttribute, StackMapTableAttribute, SyntheticAttribute,
UnknownAttribute, BoundAttribute, UnboundAttribute { UnknownAttribute, BoundAttribute, UnboundAttribute, CustomAttribute {
/** /**
* {@return the name of the attribute} * {@return the name of the attribute}
*/ */

View file

@ -22,7 +22,9 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
package jdk.internal.classfile; package java.lang.classfile;
import jdk.internal.javac.PreviewFeature;
/** /**
* Bidirectional mapper between the classfile representation of an attribute and * Bidirectional mapper between the classfile representation of an attribute and
@ -34,12 +36,18 @@ package jdk.internal.classfile;
* Classes that model nonstandard attributes should extend {@link * Classes that model nonstandard attributes should extend {@link
* CustomAttribute}. * CustomAttribute}.
* @param <A> the attribute type * @param <A> the attribute type
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public interface AttributeMapper<A> { public interface AttributeMapper<A> {
/** /**
* Attribute stability indicator * Attribute stability indicator
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
enum AttributeStability { enum AttributeStability {
/** /**
@ -60,13 +68,13 @@ public interface AttributeMapper<A> {
/** /**
* The attribute may contain indexes into structured not managed by the library (type variable lists, etc) * 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 * and so we consult the {@link ClassFile.AttributesProcessingOption} option to determine whether to preserve
* or drop it during transformation. * or drop it during transformation.
*/ */
UNSTABLE, UNSTABLE,
/** /**
* The attribute is completely unknown and so we consult the {@link Classfile.AttributesProcessingOption} option * The attribute is completely unknown and so we consult the {@link ClassFile.AttributesProcessingOption} option
* to determine whether to preserve or drop it during transformation. * to determine whether to preserve or drop it during transformation.
*/ */
UNKNOWN UNKNOWN
@ -96,16 +104,10 @@ public interface AttributeMapper<A> {
*/ */
void writeAttribute(BufWriter buf, A attr); void writeAttribute(BufWriter buf, A attr);
/**
* {@return The earliest classfile version for which this attribute is
* applicable}
*/
default int validSince() {
return Classfile.JAVA_1_VERSION;
}
/** /**
* {@return whether this attribute may appear more than once in a given location} * {@return whether this attribute may appear more than once in a given location}
*
* @implSpec The default implementation returns {@code false}
*/ */
default boolean allowMultiple() { default boolean allowMultiple() {
return false; return false;

View file

@ -22,20 +22,25 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
package jdk.internal.classfile; package java.lang.classfile;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import jdk.internal.classfile.attribute.RecordComponentInfo; import java.lang.classfile.attribute.RecordComponentInfo;
import jdk.internal.classfile.impl.AbstractUnboundModel; import jdk.internal.classfile.impl.AbstractUnboundModel;
import jdk.internal.javac.PreviewFeature;
/** /**
* A {@link ClassfileElement} describing an entity that has attributes, such * A {@link ClassFileElement} describing an entity that has attributes, such
* as a class, field, method, code attribute, or record component. * as a class, field, method, code attribute, or record component.
*
* @sealedGraph
* @since 22
*/ */
public sealed interface AttributedElement extends ClassfileElement @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface AttributedElement extends ClassFileElement
permits ClassModel, CodeModel, FieldModel, MethodModel, permits ClassModel, CodeModel, FieldModel, MethodModel,
RecordComponentInfo, AbstractUnboundModel { RecordComponentInfo, AbstractUnboundModel {

View file

@ -22,7 +22,7 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
package jdk.internal.classfile; package java.lang.classfile;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
@ -30,66 +30,70 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import jdk.internal.classfile.attribute.AnnotationDefaultAttribute; import java.lang.classfile.attribute.AnnotationDefaultAttribute;
import jdk.internal.classfile.attribute.BootstrapMethodsAttribute; import java.lang.classfile.attribute.BootstrapMethodsAttribute;
import jdk.internal.classfile.attribute.CharacterRangeInfo; import java.lang.classfile.attribute.CharacterRangeInfo;
import jdk.internal.classfile.attribute.CharacterRangeTableAttribute; import java.lang.classfile.attribute.CharacterRangeTableAttribute;
import jdk.internal.classfile.attribute.CodeAttribute; import java.lang.classfile.attribute.CodeAttribute;
import jdk.internal.classfile.attribute.CompilationIDAttribute; import java.lang.classfile.attribute.CompilationIDAttribute;
import jdk.internal.classfile.attribute.ConstantValueAttribute; import java.lang.classfile.attribute.ConstantValueAttribute;
import jdk.internal.classfile.attribute.DeprecatedAttribute; import java.lang.classfile.attribute.DeprecatedAttribute;
import jdk.internal.classfile.attribute.EnclosingMethodAttribute; import java.lang.classfile.attribute.EnclosingMethodAttribute;
import jdk.internal.classfile.attribute.ExceptionsAttribute; import java.lang.classfile.attribute.ExceptionsAttribute;
import jdk.internal.classfile.attribute.InnerClassInfo; import java.lang.classfile.attribute.InnerClassInfo;
import jdk.internal.classfile.attribute.InnerClassesAttribute; import java.lang.classfile.attribute.InnerClassesAttribute;
import jdk.internal.classfile.attribute.LineNumberInfo; import java.lang.classfile.attribute.LineNumberInfo;
import jdk.internal.classfile.attribute.LineNumberTableAttribute; import java.lang.classfile.attribute.LineNumberTableAttribute;
import jdk.internal.classfile.attribute.LocalVariableInfo; import java.lang.classfile.attribute.LocalVariableInfo;
import jdk.internal.classfile.attribute.LocalVariableTableAttribute; import java.lang.classfile.attribute.LocalVariableTableAttribute;
import jdk.internal.classfile.attribute.LocalVariableTypeInfo; import java.lang.classfile.attribute.LocalVariableTypeInfo;
import jdk.internal.classfile.attribute.LocalVariableTypeTableAttribute; import java.lang.classfile.attribute.LocalVariableTypeTableAttribute;
import jdk.internal.classfile.attribute.MethodParameterInfo; import java.lang.classfile.attribute.MethodParameterInfo;
import jdk.internal.classfile.attribute.MethodParametersAttribute; import java.lang.classfile.attribute.MethodParametersAttribute;
import jdk.internal.classfile.attribute.ModuleAttribute; import java.lang.classfile.attribute.ModuleAttribute;
import jdk.internal.classfile.attribute.ModuleExportInfo; import java.lang.classfile.attribute.ModuleExportInfo;
import jdk.internal.classfile.attribute.ModuleHashInfo; import java.lang.classfile.attribute.ModuleHashInfo;
import jdk.internal.classfile.attribute.ModuleHashesAttribute; import java.lang.classfile.attribute.ModuleHashesAttribute;
import jdk.internal.classfile.attribute.ModuleMainClassAttribute; import java.lang.classfile.attribute.ModuleMainClassAttribute;
import jdk.internal.classfile.attribute.ModuleOpenInfo; import java.lang.classfile.attribute.ModuleOpenInfo;
import jdk.internal.classfile.attribute.ModulePackagesAttribute; import java.lang.classfile.attribute.ModulePackagesAttribute;
import jdk.internal.classfile.attribute.ModuleProvideInfo; import java.lang.classfile.attribute.ModuleProvideInfo;
import jdk.internal.classfile.attribute.ModuleRequireInfo; import java.lang.classfile.attribute.ModuleRequireInfo;
import jdk.internal.classfile.attribute.ModuleResolutionAttribute; import java.lang.classfile.attribute.ModuleResolutionAttribute;
import jdk.internal.classfile.attribute.ModuleTargetAttribute; import java.lang.classfile.attribute.ModuleTargetAttribute;
import jdk.internal.classfile.attribute.NestHostAttribute; import java.lang.classfile.attribute.NestHostAttribute;
import jdk.internal.classfile.attribute.NestMembersAttribute; import java.lang.classfile.attribute.NestMembersAttribute;
import jdk.internal.classfile.attribute.PermittedSubclassesAttribute; import java.lang.classfile.attribute.PermittedSubclassesAttribute;
import jdk.internal.classfile.attribute.RecordAttribute; import java.lang.classfile.attribute.RecordAttribute;
import jdk.internal.classfile.attribute.RecordComponentInfo; import java.lang.classfile.attribute.RecordComponentInfo;
import jdk.internal.classfile.attribute.RuntimeInvisibleAnnotationsAttribute; import java.lang.classfile.attribute.RuntimeInvisibleAnnotationsAttribute;
import jdk.internal.classfile.attribute.RuntimeInvisibleParameterAnnotationsAttribute; import java.lang.classfile.attribute.RuntimeInvisibleParameterAnnotationsAttribute;
import jdk.internal.classfile.attribute.RuntimeInvisibleTypeAnnotationsAttribute; import java.lang.classfile.attribute.RuntimeInvisibleTypeAnnotationsAttribute;
import jdk.internal.classfile.attribute.RuntimeVisibleAnnotationsAttribute; import java.lang.classfile.attribute.RuntimeVisibleAnnotationsAttribute;
import jdk.internal.classfile.attribute.RuntimeVisibleParameterAnnotationsAttribute; import java.lang.classfile.attribute.RuntimeVisibleParameterAnnotationsAttribute;
import jdk.internal.classfile.attribute.RuntimeVisibleTypeAnnotationsAttribute; import java.lang.classfile.attribute.RuntimeVisibleTypeAnnotationsAttribute;
import jdk.internal.classfile.attribute.SignatureAttribute; import java.lang.classfile.attribute.SignatureAttribute;
import jdk.internal.classfile.attribute.SourceDebugExtensionAttribute; import java.lang.classfile.attribute.SourceDebugExtensionAttribute;
import jdk.internal.classfile.attribute.SourceFileAttribute; import java.lang.classfile.attribute.SourceFileAttribute;
import jdk.internal.classfile.attribute.SourceIDAttribute; import java.lang.classfile.attribute.SourceIDAttribute;
import jdk.internal.classfile.attribute.StackMapTableAttribute; import java.lang.classfile.attribute.StackMapTableAttribute;
import jdk.internal.classfile.attribute.SyntheticAttribute; import java.lang.classfile.attribute.SyntheticAttribute;
import jdk.internal.classfile.constantpool.Utf8Entry; import java.lang.classfile.constantpool.Utf8Entry;
import jdk.internal.classfile.impl.AbstractAttributeMapper; import jdk.internal.classfile.impl.AbstractAttributeMapper;
import jdk.internal.classfile.impl.BoundAttribute; import jdk.internal.classfile.impl.BoundAttribute;
import jdk.internal.classfile.impl.CodeImpl; import jdk.internal.classfile.impl.CodeImpl;
import jdk.internal.classfile.impl.AbstractPoolEntry; import jdk.internal.classfile.impl.AbstractPoolEntry;
import jdk.internal.classfile.impl.StackMapDecoder; import jdk.internal.classfile.impl.StackMapDecoder;
import jdk.internal.javac.PreviewFeature;
/** /**
* Attribute mappers for standard classfile attributes. * Attribute mappers for standard classfile attributes.
* *
* @see AttributeMapper * @see AttributeMapper
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public class Attributes { public class Attributes {
/** AnnotationDefault */ /** AnnotationDefault */
@ -167,10 +171,10 @@ public class Attributes {
/** RuntimeInvisibleAnnotations */ /** RuntimeInvisibleAnnotations */
public static final String NAME_RUNTIME_INVISIBLE_ANNOTATIONS = "RuntimeInvisibleAnnotations"; public static final String NAME_RUNTIME_INVISIBLE_ANNOTATIONS = "RuntimeInvisibleAnnotations";
/** RuntimeInvisibleTypeAnnotations */ /** RuntimeInvisibleParameterAnnotations */
public static final String NAME_RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS = "RuntimeInvisibleParameterAnnotations"; public static final String NAME_RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS = "RuntimeInvisibleParameterAnnotations";
/** */ /** RuntimeInvisibleTypeAnnotations */
public static final String NAME_RUNTIME_INVISIBLE_TYPE_ANNOTATIONS = "RuntimeInvisibleTypeAnnotations"; public static final String NAME_RUNTIME_INVISIBLE_TYPE_ANNOTATIONS = "RuntimeInvisibleTypeAnnotations";
/** RuntimeVisibleAnnotations */ /** RuntimeVisibleAnnotations */
@ -205,7 +209,7 @@ public class Attributes {
/** Attribute mapper for the {@code AnnotationDefault} attribute */ /** Attribute mapper for the {@code AnnotationDefault} attribute */
public static final AttributeMapper<AnnotationDefaultAttribute> public static final AttributeMapper<AnnotationDefaultAttribute>
ANNOTATION_DEFAULT = new AbstractAttributeMapper<>(NAME_ANNOTATION_DEFAULT, Classfile.JAVA_5_VERSION) { ANNOTATION_DEFAULT = new AbstractAttributeMapper<>(NAME_ANNOTATION_DEFAULT) {
@Override @Override
public AnnotationDefaultAttribute readAttribute(AttributedElement e, ClassReader cf, int p) { public AnnotationDefaultAttribute readAttribute(AttributedElement e, ClassReader cf, int p) {
return new BoundAttribute.BoundAnnotationDefaultAttr(cf, this, p); return new BoundAttribute.BoundAnnotationDefaultAttr(cf, this, p);
@ -224,7 +228,7 @@ public class Attributes {
/** Attribute mapper for the {@code BootstrapMethods} attribute */ /** Attribute mapper for the {@code BootstrapMethods} attribute */
public static final AttributeMapper<BootstrapMethodsAttribute> public static final AttributeMapper<BootstrapMethodsAttribute>
BOOTSTRAP_METHODS = new AbstractAttributeMapper<>(NAME_BOOTSTRAP_METHODS, Classfile.JAVA_17_VERSION) { BOOTSTRAP_METHODS = new AbstractAttributeMapper<>(NAME_BOOTSTRAP_METHODS) {
@Override @Override
public BootstrapMethodsAttribute readAttribute(AttributedElement e, ClassReader cf, int p) { public BootstrapMethodsAttribute readAttribute(AttributedElement e, ClassReader cf, int p) {
return new BoundAttribute.BoundBootstrapMethodsAttribute(cf, this, p); return new BoundAttribute.BoundBootstrapMethodsAttribute(cf, this, p);
@ -243,7 +247,7 @@ public class Attributes {
/** Attribute mapper for the {@code CharacterRangeTable} attribute */ /** Attribute mapper for the {@code CharacterRangeTable} attribute */
public static final AttributeMapper<CharacterRangeTableAttribute> public static final AttributeMapper<CharacterRangeTableAttribute>
CHARACTER_RANGE_TABLE = new AbstractAttributeMapper<>(NAME_CHARACTER_RANGE_TABLE, true, Classfile.JAVA_4_VERSION) { CHARACTER_RANGE_TABLE = new AbstractAttributeMapper<>(NAME_CHARACTER_RANGE_TABLE, true) {
@Override @Override
public CharacterRangeTableAttribute readAttribute(AttributedElement e, ClassReader cf, int p) { public CharacterRangeTableAttribute readAttribute(AttributedElement e, ClassReader cf, int p) {
return new BoundAttribute.BoundCharacterRangeTableAttribute(cf, this, p); return new BoundAttribute.BoundCharacterRangeTableAttribute(cf, this, p);
@ -347,7 +351,7 @@ public class Attributes {
/** Attribute mapper for the {@code EnclosingMethod} attribute */ /** Attribute mapper for the {@code EnclosingMethod} attribute */
public static final AttributeMapper<EnclosingMethodAttribute> public static final AttributeMapper<EnclosingMethodAttribute>
ENCLOSING_METHOD = new AbstractAttributeMapper<>(NAME_ENCLOSING_METHOD, Classfile.JAVA_5_VERSION) { ENCLOSING_METHOD = new AbstractAttributeMapper<>(NAME_ENCLOSING_METHOD) {
@Override @Override
public EnclosingMethodAttribute readAttribute(AttributedElement e, ClassReader cf, int p) { public EnclosingMethodAttribute readAttribute(AttributedElement e, ClassReader cf, int p) {
return new BoundAttribute.BoundEnclosingMethodAttribute(cf, this, p); return new BoundAttribute.BoundEnclosingMethodAttribute(cf, this, p);
@ -463,7 +467,7 @@ public class Attributes {
/** Attribute mapper for the {@code LocalVariableTypeTable} attribute */ /** Attribute mapper for the {@code LocalVariableTypeTable} attribute */
public static final AttributeMapper<LocalVariableTypeTableAttribute> public static final AttributeMapper<LocalVariableTypeTableAttribute>
LOCAL_VARIABLE_TYPE_TABLE = new AbstractAttributeMapper<>(NAME_LOCAL_VARIABLE_TYPE_TABLE, true, Classfile.JAVA_5_VERSION) { LOCAL_VARIABLE_TYPE_TABLE = new AbstractAttributeMapper<>(NAME_LOCAL_VARIABLE_TYPE_TABLE, true) {
@Override @Override
public LocalVariableTypeTableAttribute readAttribute(AttributedElement e, ClassReader cf, int p) { public LocalVariableTypeTableAttribute readAttribute(AttributedElement e, ClassReader cf, int p) {
return new BoundAttribute.BoundLocalVariableTypeTableAttribute(e, cf, this, p); return new BoundAttribute.BoundLocalVariableTypeTableAttribute(e, cf, this, p);
@ -490,7 +494,7 @@ public class Attributes {
/** Attribute mapper for the {@code MethodParameters} attribute */ /** Attribute mapper for the {@code MethodParameters} attribute */
public static final AttributeMapper<MethodParametersAttribute> public static final AttributeMapper<MethodParametersAttribute>
METHOD_PARAMETERS = new AbstractAttributeMapper<>(NAME_METHOD_PARAMETERS, Classfile.JAVA_8_VERSION) { METHOD_PARAMETERS = new AbstractAttributeMapper<>(NAME_METHOD_PARAMETERS) {
@Override @Override
public MethodParametersAttribute readAttribute(AttributedElement e, ClassReader cf, int p) { public MethodParametersAttribute readAttribute(AttributedElement e, ClassReader cf, int p) {
return new BoundAttribute.BoundMethodParametersAttribute(cf, this, p); return new BoundAttribute.BoundMethodParametersAttribute(cf, this, p);
@ -514,7 +518,7 @@ public class Attributes {
/** Attribute mapper for the {@code Module} attribute */ /** Attribute mapper for the {@code Module} attribute */
public static final AttributeMapper<ModuleAttribute> public static final AttributeMapper<ModuleAttribute>
MODULE = new AbstractAttributeMapper<>(NAME_MODULE, Classfile.JAVA_9_VERSION) { MODULE = new AbstractAttributeMapper<>(NAME_MODULE) {
@Override @Override
public ModuleAttribute readAttribute(AttributedElement e, ClassReader cf, int p) { public ModuleAttribute readAttribute(AttributedElement e, ClassReader cf, int p) {
return new BoundAttribute.BoundModuleAttribute(cf, this, p); return new BoundAttribute.BoundModuleAttribute(cf, this, p);
@ -559,7 +563,7 @@ public class Attributes {
/** Attribute mapper for the {@code ModuleHashes} attribute */ /** Attribute mapper for the {@code ModuleHashes} attribute */
public static final AttributeMapper<ModuleHashesAttribute> public static final AttributeMapper<ModuleHashesAttribute>
MODULE_HASHES = new AbstractAttributeMapper<>(NAME_MODULE_HASHES, Classfile.JAVA_9_VERSION) { MODULE_HASHES = new AbstractAttributeMapper<>(NAME_MODULE_HASHES) {
@Override @Override
public ModuleHashesAttribute readAttribute(AttributedElement e, ClassReader cf, int p) { public ModuleHashesAttribute readAttribute(AttributedElement e, ClassReader cf, int p) {
return new BoundAttribute.BoundModuleHashesAttribute(cf, this, p); return new BoundAttribute.BoundModuleHashesAttribute(cf, this, p);
@ -585,7 +589,7 @@ public class Attributes {
/** Attribute mapper for the {@code ModuleMainClass} attribute */ /** Attribute mapper for the {@code ModuleMainClass} attribute */
public static final AttributeMapper<ModuleMainClassAttribute> public static final AttributeMapper<ModuleMainClassAttribute>
MODULE_MAIN_CLASS = new AbstractAttributeMapper<>(NAME_MODULE_MAIN_CLASS, Classfile.JAVA_9_VERSION) { MODULE_MAIN_CLASS = new AbstractAttributeMapper<>(NAME_MODULE_MAIN_CLASS) {
@Override @Override
public ModuleMainClassAttribute readAttribute(AttributedElement e, ClassReader cf, int p) { public ModuleMainClassAttribute readAttribute(AttributedElement e, ClassReader cf, int p) {
return new BoundAttribute.BoundModuleMainClassAttribute(cf, this, p); return new BoundAttribute.BoundModuleMainClassAttribute(cf, this, p);
@ -604,7 +608,7 @@ public class Attributes {
/** Attribute mapper for the {@code ModulePackages} attribute */ /** Attribute mapper for the {@code ModulePackages} attribute */
public static final AttributeMapper<ModulePackagesAttribute> public static final AttributeMapper<ModulePackagesAttribute>
MODULE_PACKAGES = new AbstractAttributeMapper<>(NAME_MODULE_PACKAGES, Classfile.JAVA_9_VERSION) { MODULE_PACKAGES = new AbstractAttributeMapper<>(NAME_MODULE_PACKAGES) {
@Override @Override
public ModulePackagesAttribute readAttribute(AttributedElement e, ClassReader cf, int p) { public ModulePackagesAttribute readAttribute(AttributedElement e, ClassReader cf, int p) {
return new BoundAttribute.BoundModulePackagesAttribute(cf, this, p); return new BoundAttribute.BoundModulePackagesAttribute(cf, this, p);
@ -623,7 +627,7 @@ public class Attributes {
/** Attribute mapper for the {@code ModuleResolution} attribute */ /** Attribute mapper for the {@code ModuleResolution} attribute */
public static final AttributeMapper<ModuleResolutionAttribute> public static final AttributeMapper<ModuleResolutionAttribute>
MODULE_RESOLUTION = new AbstractAttributeMapper<>(NAME_MODULE_RESOLUTION, Classfile.JAVA_9_VERSION) { MODULE_RESOLUTION = new AbstractAttributeMapper<>(NAME_MODULE_RESOLUTION) {
@Override @Override
public ModuleResolutionAttribute readAttribute(AttributedElement e, ClassReader cf, int p) { public ModuleResolutionAttribute readAttribute(AttributedElement e, ClassReader cf, int p) {
return new BoundAttribute.BoundModuleResolutionAttribute(cf, this, p); return new BoundAttribute.BoundModuleResolutionAttribute(cf, this, p);
@ -642,7 +646,7 @@ public class Attributes {
/** Attribute mapper for the {@code ModuleTarget} attribute */ /** Attribute mapper for the {@code ModuleTarget} attribute */
public static final AttributeMapper<ModuleTargetAttribute> public static final AttributeMapper<ModuleTargetAttribute>
MODULE_TARGET = new AbstractAttributeMapper<>(NAME_MODULE_TARGET, Classfile.JAVA_9_VERSION) { MODULE_TARGET = new AbstractAttributeMapper<>(NAME_MODULE_TARGET) {
@Override @Override
public ModuleTargetAttribute readAttribute(AttributedElement e, ClassReader cf, int p) { public ModuleTargetAttribute readAttribute(AttributedElement e, ClassReader cf, int p) {
return new BoundAttribute.BoundModuleTargetAttribute(cf, this, p); return new BoundAttribute.BoundModuleTargetAttribute(cf, this, p);
@ -661,7 +665,7 @@ public class Attributes {
/** Attribute mapper for the {@code NestHost} attribute */ /** Attribute mapper for the {@code NestHost} attribute */
public static final AttributeMapper<NestHostAttribute> public static final AttributeMapper<NestHostAttribute>
NEST_HOST = new AbstractAttributeMapper<>(NAME_NEST_HOST, Classfile.JAVA_11_VERSION) { NEST_HOST = new AbstractAttributeMapper<>(NAME_NEST_HOST) {
@Override @Override
public NestHostAttribute readAttribute(AttributedElement e, ClassReader cf, int p) { public NestHostAttribute readAttribute(AttributedElement e, ClassReader cf, int p) {
return new BoundAttribute.BoundNestHostAttribute(cf, this, p); return new BoundAttribute.BoundNestHostAttribute(cf, this, p);
@ -680,7 +684,7 @@ public class Attributes {
/** Attribute mapper for the {@code NestMembers} attribute */ /** Attribute mapper for the {@code NestMembers} attribute */
public static final AttributeMapper<NestMembersAttribute> public static final AttributeMapper<NestMembersAttribute>
NEST_MEMBERS = new AbstractAttributeMapper<>(NAME_NEST_MEMBERS, Classfile.JAVA_11_VERSION) { NEST_MEMBERS = new AbstractAttributeMapper<>(NAME_NEST_MEMBERS) {
@Override @Override
public NestMembersAttribute readAttribute(AttributedElement e, ClassReader cf, int p) { public NestMembersAttribute readAttribute(AttributedElement e, ClassReader cf, int p) {
return new BoundAttribute.BoundNestMembersAttribute(cf, this, p); return new BoundAttribute.BoundNestMembersAttribute(cf, this, p);
@ -699,7 +703,7 @@ public class Attributes {
/** Attribute mapper for the {@code PermittedSubclasses} attribute */ /** Attribute mapper for the {@code PermittedSubclasses} attribute */
public static final AttributeMapper<PermittedSubclassesAttribute> public static final AttributeMapper<PermittedSubclassesAttribute>
PERMITTED_SUBCLASSES = new AbstractAttributeMapper<>(NAME_PERMITTED_SUBCLASSES, Classfile.JAVA_15_VERSION) { PERMITTED_SUBCLASSES = new AbstractAttributeMapper<>(NAME_PERMITTED_SUBCLASSES) {
@Override @Override
public PermittedSubclassesAttribute readAttribute(AttributedElement e, ClassReader cf, int p) { public PermittedSubclassesAttribute readAttribute(AttributedElement e, ClassReader cf, int p) {
return new BoundAttribute.BoundPermittedSubclassesAttribute(cf, this, p); return new BoundAttribute.BoundPermittedSubclassesAttribute(cf, this, p);
@ -718,7 +722,7 @@ public class Attributes {
/** Attribute mapper for the {@code Record} attribute */ /** Attribute mapper for the {@code Record} attribute */
public static final AttributeMapper<RecordAttribute> public static final AttributeMapper<RecordAttribute>
RECORD = new AbstractAttributeMapper<>(NAME_RECORD, Classfile.JAVA_16_VERSION) { RECORD = new AbstractAttributeMapper<>(NAME_RECORD) {
@Override @Override
public RecordAttribute readAttribute(AttributedElement e, ClassReader cf, int p) { public RecordAttribute readAttribute(AttributedElement e, ClassReader cf, int p) {
return new BoundAttribute.BoundRecordAttribute(cf, this, p); return new BoundAttribute.BoundRecordAttribute(cf, this, p);
@ -743,7 +747,7 @@ public class Attributes {
/** Attribute mapper for the {@code RuntimeInvisibleAnnotations} attribute */ /** Attribute mapper for the {@code RuntimeInvisibleAnnotations} attribute */
public static final AttributeMapper<RuntimeInvisibleAnnotationsAttribute> public static final AttributeMapper<RuntimeInvisibleAnnotationsAttribute>
RUNTIME_INVISIBLE_ANNOTATIONS = new AbstractAttributeMapper<>(NAME_RUNTIME_INVISIBLE_ANNOTATIONS, Classfile.JAVA_5_VERSION) { RUNTIME_INVISIBLE_ANNOTATIONS = new AbstractAttributeMapper<>(NAME_RUNTIME_INVISIBLE_ANNOTATIONS) {
@Override @Override
public RuntimeInvisibleAnnotationsAttribute readAttribute(AttributedElement enclosing, ClassReader cf, int pos) { public RuntimeInvisibleAnnotationsAttribute readAttribute(AttributedElement enclosing, ClassReader cf, int pos) {
return new BoundAttribute.BoundRuntimeInvisibleAnnotationsAttribute(cf, pos); return new BoundAttribute.BoundRuntimeInvisibleAnnotationsAttribute(cf, pos);
@ -762,7 +766,7 @@ public class Attributes {
/** Attribute mapper for the {@code RuntimeInvisibleParameterAnnotations} attribute */ /** Attribute mapper for the {@code RuntimeInvisibleParameterAnnotations} attribute */
public static final AttributeMapper<RuntimeInvisibleParameterAnnotationsAttribute> public static final AttributeMapper<RuntimeInvisibleParameterAnnotationsAttribute>
RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS = new AbstractAttributeMapper<>(NAME_RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS, Classfile.JAVA_5_VERSION) { RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS = new AbstractAttributeMapper<>(NAME_RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS) {
@Override @Override
public RuntimeInvisibleParameterAnnotationsAttribute readAttribute(AttributedElement e, ClassReader cf, int p) { public RuntimeInvisibleParameterAnnotationsAttribute readAttribute(AttributedElement e, ClassReader cf, int p) {
return new BoundAttribute.BoundRuntimeInvisibleParameterAnnotationsAttribute(cf, this, p); return new BoundAttribute.BoundRuntimeInvisibleParameterAnnotationsAttribute(cf, this, p);
@ -784,7 +788,7 @@ public class Attributes {
/** Attribute mapper for the {@code RuntimeInvisibleTypeAnnotations} attribute */ /** Attribute mapper for the {@code RuntimeInvisibleTypeAnnotations} attribute */
public static final AttributeMapper<RuntimeInvisibleTypeAnnotationsAttribute> public static final AttributeMapper<RuntimeInvisibleTypeAnnotationsAttribute>
RUNTIME_INVISIBLE_TYPE_ANNOTATIONS = new AbstractAttributeMapper<>(NAME_RUNTIME_INVISIBLE_TYPE_ANNOTATIONS, Classfile.JAVA_8_VERSION) { RUNTIME_INVISIBLE_TYPE_ANNOTATIONS = new AbstractAttributeMapper<>(NAME_RUNTIME_INVISIBLE_TYPE_ANNOTATIONS) {
@Override @Override
public RuntimeInvisibleTypeAnnotationsAttribute readAttribute(AttributedElement e, ClassReader cf, int p) { public RuntimeInvisibleTypeAnnotationsAttribute readAttribute(AttributedElement e, ClassReader cf, int p) {
return new BoundAttribute.BoundRuntimeInvisibleTypeAnnotationsAttribute(e, cf, this, p); return new BoundAttribute.BoundRuntimeInvisibleTypeAnnotationsAttribute(e, cf, this, p);
@ -803,7 +807,7 @@ public class Attributes {
/** Attribute mapper for the {@code RuntimeVisibleAnnotations} attribute */ /** Attribute mapper for the {@code RuntimeVisibleAnnotations} attribute */
public static final AttributeMapper<RuntimeVisibleAnnotationsAttribute> public static final AttributeMapper<RuntimeVisibleAnnotationsAttribute>
RUNTIME_VISIBLE_ANNOTATIONS = new AbstractAttributeMapper<>(NAME_RUNTIME_VISIBLE_ANNOTATIONS, Classfile.JAVA_5_VERSION) { RUNTIME_VISIBLE_ANNOTATIONS = new AbstractAttributeMapper<>(NAME_RUNTIME_VISIBLE_ANNOTATIONS) {
@Override @Override
public RuntimeVisibleAnnotationsAttribute readAttribute(AttributedElement enclosing, ClassReader cf, int pos) { public RuntimeVisibleAnnotationsAttribute readAttribute(AttributedElement enclosing, ClassReader cf, int pos) {
return new BoundAttribute.BoundRuntimeVisibleAnnotationsAttribute(cf, pos); return new BoundAttribute.BoundRuntimeVisibleAnnotationsAttribute(cf, pos);
@ -822,7 +826,7 @@ public class Attributes {
/** Attribute mapper for the {@code RuntimeVisibleParameterAnnotations} attribute */ /** Attribute mapper for the {@code RuntimeVisibleParameterAnnotations} attribute */
public static final AttributeMapper<RuntimeVisibleParameterAnnotationsAttribute> public static final AttributeMapper<RuntimeVisibleParameterAnnotationsAttribute>
RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS = new AbstractAttributeMapper<>(NAME_RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS, Classfile.JAVA_5_VERSION) { RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS = new AbstractAttributeMapper<>(NAME_RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS) {
@Override @Override
public RuntimeVisibleParameterAnnotationsAttribute readAttribute(AttributedElement e, ClassReader cf, int p) { public RuntimeVisibleParameterAnnotationsAttribute readAttribute(AttributedElement e, ClassReader cf, int p) {
return new BoundAttribute.BoundRuntimeVisibleParameterAnnotationsAttribute(cf, this, p); return new BoundAttribute.BoundRuntimeVisibleParameterAnnotationsAttribute(cf, this, p);
@ -844,7 +848,7 @@ public class Attributes {
/** Attribute mapper for the {@code RuntimeVisibleTypeAnnotations} attribute */ /** Attribute mapper for the {@code RuntimeVisibleTypeAnnotations} attribute */
public static final AttributeMapper<RuntimeVisibleTypeAnnotationsAttribute> public static final AttributeMapper<RuntimeVisibleTypeAnnotationsAttribute>
RUNTIME_VISIBLE_TYPE_ANNOTATIONS = new AbstractAttributeMapper<>(NAME_RUNTIME_VISIBLE_TYPE_ANNOTATIONS, Classfile.JAVA_8_VERSION) { RUNTIME_VISIBLE_TYPE_ANNOTATIONS = new AbstractAttributeMapper<>(NAME_RUNTIME_VISIBLE_TYPE_ANNOTATIONS) {
@Override @Override
public RuntimeVisibleTypeAnnotationsAttribute readAttribute(AttributedElement e, ClassReader cf, int p) { public RuntimeVisibleTypeAnnotationsAttribute readAttribute(AttributedElement e, ClassReader cf, int p) {
return new BoundAttribute.BoundRuntimeVisibleTypeAnnotationsAttribute(e, cf, this, p); return new BoundAttribute.BoundRuntimeVisibleTypeAnnotationsAttribute(e, cf, this, p);
@ -863,7 +867,7 @@ public class Attributes {
/** Attribute mapper for the {@code Signature} attribute */ /** Attribute mapper for the {@code Signature} attribute */
public static final AttributeMapper<SignatureAttribute> public static final AttributeMapper<SignatureAttribute>
SIGNATURE = new AbstractAttributeMapper<>(NAME_SIGNATURE, Classfile.JAVA_5_VERSION) { SIGNATURE = new AbstractAttributeMapper<>(NAME_SIGNATURE) {
@Override @Override
public SignatureAttribute readAttribute(AttributedElement e, ClassReader cf, int p) { public SignatureAttribute readAttribute(AttributedElement e, ClassReader cf, int p) {
return new BoundAttribute.BoundSignatureAttribute(cf, this, p); return new BoundAttribute.BoundSignatureAttribute(cf, this, p);
@ -882,7 +886,7 @@ public class Attributes {
/** Attribute mapper for the {@code SourceDebugExtension} attribute */ /** Attribute mapper for the {@code SourceDebugExtension} attribute */
public static final AttributeMapper<SourceDebugExtensionAttribute> public static final AttributeMapper<SourceDebugExtensionAttribute>
SOURCE_DEBUG_EXTENSION = new AbstractAttributeMapper<>(NAME_SOURCE_DEBUG_EXTENSION, Classfile.JAVA_5_VERSION) { SOURCE_DEBUG_EXTENSION = new AbstractAttributeMapper<>(NAME_SOURCE_DEBUG_EXTENSION) {
@Override @Override
public SourceDebugExtensionAttribute readAttribute(AttributedElement e, ClassReader cf, int p) { public SourceDebugExtensionAttribute readAttribute(AttributedElement e, ClassReader cf, int p) {
return new BoundAttribute.BoundSourceDebugExtensionAttribute(cf, this, p); return new BoundAttribute.BoundSourceDebugExtensionAttribute(cf, this, p);
@ -939,7 +943,7 @@ public class Attributes {
/** Attribute mapper for the {@code StackMapTable} attribute */ /** Attribute mapper for the {@code StackMapTable} attribute */
public static final AttributeMapper<StackMapTableAttribute> public static final AttributeMapper<StackMapTableAttribute>
STACK_MAP_TABLE = new AbstractAttributeMapper<>(NAME_STACK_MAP_TABLE, Classfile.JAVA_6_VERSION) { STACK_MAP_TABLE = new AbstractAttributeMapper<>(NAME_STACK_MAP_TABLE) {
@Override @Override
public StackMapTableAttribute readAttribute(AttributedElement e, ClassReader cf, int p) { public StackMapTableAttribute readAttribute(AttributedElement e, ClassReader cf, int p) {
return new BoundAttribute.BoundStackMapTableAttribute((CodeImpl)e, cf, this, p); return new BoundAttribute.BoundStackMapTableAttribute((CodeImpl)e, cf, this, p);

View file

@ -23,21 +23,25 @@
* questions. * questions.
*/ */
package jdk.internal.classfile; package java.lang.classfile;
import java.util.List; import java.util.List;
import jdk.internal.classfile.constantpool.ConstantPool; import java.lang.classfile.constantpool.ConstantPool;
import jdk.internal.classfile.constantpool.LoadableConstantEntry; import java.lang.classfile.constantpool.LoadableConstantEntry;
import jdk.internal.classfile.constantpool.MethodHandleEntry; import java.lang.classfile.constantpool.MethodHandleEntry;
import jdk.internal.classfile.impl.BootstrapMethodEntryImpl; import jdk.internal.classfile.impl.BootstrapMethodEntryImpl;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models an entry in the bootstrap method table. The bootstrap method table * Models an entry in the bootstrap method table. The bootstrap method table
* is stored in the {@code BootstrapMethods} attribute, but is modeled by * is stored in the {@code BootstrapMethods} attribute, but is modeled by
* the {@link ConstantPool}, since the bootstrap method table is logically * the {@link ConstantPool}, since the bootstrap method table is logically
* part of the constant pool. * part of the constant pool.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface BootstrapMethodEntry public sealed interface BootstrapMethodEntry
extends WritableElement<BootstrapMethodEntry> extends WritableElement<BootstrapMethodEntry>
permits BootstrapMethodEntryImpl { permits BootstrapMethodEntryImpl {

View file

@ -22,21 +22,25 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
package jdk.internal.classfile; package java.lang.classfile;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.util.List; import java.util.List;
import jdk.internal.classfile.constantpool.ConstantPool; import java.lang.classfile.constantpool.ConstantPool;
import jdk.internal.classfile.constantpool.ConstantPoolBuilder; import java.lang.classfile.constantpool.ConstantPoolBuilder;
import jdk.internal.classfile.constantpool.PoolEntry; import java.lang.classfile.constantpool.PoolEntry;
import jdk.internal.classfile.impl.BufWriterImpl; import jdk.internal.classfile.impl.BufWriterImpl;
import jdk.internal.javac.PreviewFeature;
/** /**
* Supports writing portions of a classfile to a growable buffer. Method * Supports writing portions of a classfile to a growable buffer. Methods
* are provided to write various standard entities (e.g., {@code u2}, {@code u4}) * are provided to write various standard entities (e.g., {@code u2}, {@code u4})
* to the end of the buffer, as well as to create constant pool entries. * to the end of the buffer, as well as to create constant pool entries.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface BufWriter public sealed interface BufWriter
permits BufWriterImpl { permits BufWriterImpl {

View file

@ -23,7 +23,7 @@
* questions. * questions.
*/ */
package jdk.internal.classfile; package java.lang.classfile;
import java.lang.constant.ClassDesc; import java.lang.constant.ClassDesc;
@ -33,25 +33,29 @@ import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.function.Consumer; import java.util.function.Consumer;
import jdk.internal.classfile.constantpool.ClassEntry; import java.lang.classfile.constantpool.ClassEntry;
import jdk.internal.classfile.constantpool.Utf8Entry; import java.lang.classfile.constantpool.Utf8Entry;
import jdk.internal.classfile.impl.ChainedClassBuilder; import jdk.internal.classfile.impl.ChainedClassBuilder;
import jdk.internal.classfile.impl.DirectClassBuilder; import jdk.internal.classfile.impl.DirectClassBuilder;
import jdk.internal.classfile.impl.Util; import jdk.internal.classfile.impl.Util;
import java.lang.reflect.AccessFlag; import java.lang.reflect.AccessFlag;
import jdk.internal.classfile.attribute.CodeAttribute; import java.lang.classfile.attribute.CodeAttribute;
import jdk.internal.javac.PreviewFeature;
/** /**
* A builder for classfiles. Builders are not created directly; they are passed * A builder for classfiles. Builders are not created directly; they are passed
* to handlers by methods such as {@link Classfile#build(ClassDesc, Consumer)} * to handlers by methods such as {@link ClassFile#build(ClassDesc, Consumer)}
* or to class transforms. The elements of a classfile can be specified * or to class transforms. The elements of a classfile can be specified
* abstractly (by passing a {@link ClassElement} to {@link #with(ClassfileElement)}) * abstractly (by passing a {@link ClassElement} to {@link #with(ClassFileElement)})
* or concretely by calling the various {@code withXxx} methods. * or concretely by calling the various {@code withXxx} methods.
* *
* @see ClassTransform * @see ClassTransform
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface ClassBuilder public sealed interface ClassBuilder
extends ClassfileBuilder<ClassElement, ClassBuilder> extends ClassFileBuilder<ClassElement, ClassBuilder>
permits ChainedClassBuilder, DirectClassBuilder { permits ChainedClassBuilder, DirectClassBuilder {
/** /**
@ -67,7 +71,7 @@ public sealed interface ClassBuilder
* @return this builder * @return this builder
*/ */
default ClassBuilder withVersion(int major, int minor) { default ClassBuilder withVersion(int major, int minor) {
return with(ClassfileVersion.of(major, minor)); return with(ClassFileVersion.of(major, minor));
} }
/** /**
@ -101,6 +105,7 @@ public sealed interface ClassBuilder
* Sets the superclass of this class. * Sets the superclass of this class.
* @param desc the superclass * @param desc the superclass
* @return this builder * @return this builder
* @throws IllegalArgumentException if {@code desc} represents a primitive type
*/ */
default ClassBuilder withSuperclass(ClassDesc desc) { default ClassBuilder withSuperclass(ClassDesc desc) {
return withSuperclass(constantPool().classEntry(desc)); return withSuperclass(constantPool().classEntry(desc));

View file

@ -22,39 +22,44 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
package jdk.internal.classfile; package java.lang.classfile;
import jdk.internal.classfile.attribute.CompilationIDAttribute; import java.lang.classfile.attribute.CompilationIDAttribute;
import jdk.internal.classfile.attribute.DeprecatedAttribute; import java.lang.classfile.attribute.DeprecatedAttribute;
import jdk.internal.classfile.attribute.EnclosingMethodAttribute; import java.lang.classfile.attribute.EnclosingMethodAttribute;
import jdk.internal.classfile.attribute.InnerClassesAttribute; import java.lang.classfile.attribute.InnerClassesAttribute;
import jdk.internal.classfile.attribute.ModuleAttribute; import java.lang.classfile.attribute.ModuleAttribute;
import jdk.internal.classfile.attribute.ModuleHashesAttribute; import java.lang.classfile.attribute.ModuleHashesAttribute;
import jdk.internal.classfile.attribute.ModuleMainClassAttribute; import java.lang.classfile.attribute.ModuleMainClassAttribute;
import jdk.internal.classfile.attribute.ModulePackagesAttribute; import java.lang.classfile.attribute.ModulePackagesAttribute;
import jdk.internal.classfile.attribute.ModuleResolutionAttribute; import java.lang.classfile.attribute.ModuleResolutionAttribute;
import jdk.internal.classfile.attribute.ModuleTargetAttribute; import java.lang.classfile.attribute.ModuleTargetAttribute;
import jdk.internal.classfile.attribute.NestHostAttribute; import java.lang.classfile.attribute.NestHostAttribute;
import jdk.internal.classfile.attribute.NestMembersAttribute; import java.lang.classfile.attribute.NestMembersAttribute;
import jdk.internal.classfile.attribute.PermittedSubclassesAttribute; import java.lang.classfile.attribute.PermittedSubclassesAttribute;
import jdk.internal.classfile.attribute.RecordAttribute; import java.lang.classfile.attribute.RecordAttribute;
import jdk.internal.classfile.attribute.RuntimeInvisibleAnnotationsAttribute; import java.lang.classfile.attribute.RuntimeInvisibleAnnotationsAttribute;
import jdk.internal.classfile.attribute.RuntimeInvisibleTypeAnnotationsAttribute; import java.lang.classfile.attribute.RuntimeInvisibleTypeAnnotationsAttribute;
import jdk.internal.classfile.attribute.RuntimeVisibleAnnotationsAttribute; import java.lang.classfile.attribute.RuntimeVisibleAnnotationsAttribute;
import jdk.internal.classfile.attribute.RuntimeVisibleTypeAnnotationsAttribute; import java.lang.classfile.attribute.RuntimeVisibleTypeAnnotationsAttribute;
import jdk.internal.classfile.attribute.SignatureAttribute; import java.lang.classfile.attribute.SignatureAttribute;
import jdk.internal.classfile.attribute.SourceDebugExtensionAttribute; import java.lang.classfile.attribute.SourceDebugExtensionAttribute;
import jdk.internal.classfile.attribute.SourceFileAttribute; import java.lang.classfile.attribute.SourceFileAttribute;
import jdk.internal.classfile.attribute.SourceIDAttribute; import java.lang.classfile.attribute.SourceIDAttribute;
import jdk.internal.classfile.attribute.SyntheticAttribute; import java.lang.classfile.attribute.SyntheticAttribute;
import jdk.internal.classfile.attribute.UnknownAttribute; import java.lang.classfile.attribute.UnknownAttribute;
import jdk.internal.javac.PreviewFeature;
/** /**
* A {@link ClassfileElement} that can appear when traversing the elements * A marker interface for elements that can appear when traversing
* of a {@link ClassModel} or be presented to a {@link ClassBuilder}. * a {@link ClassModel} or be presented to a {@link ClassBuilder}.
*
* @sealedGraph
* @since 22
*/ */
public sealed interface ClassElement extends ClassfileElement @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
permits AccessFlags, Superclass, Interfaces, ClassfileVersion, public sealed interface ClassElement extends ClassFileElement
permits AccessFlags, Superclass, Interfaces, ClassFileVersion,
FieldModel, MethodModel, FieldModel, MethodModel,
CustomAttribute, CompilationIDAttribute, DeprecatedAttribute, CustomAttribute, CompilationIDAttribute, DeprecatedAttribute,
EnclosingMethodAttribute, InnerClassesAttribute, EnclosingMethodAttribute, InnerClassesAttribute,

View file

@ -22,31 +22,36 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
package jdk.internal.classfile; package java.lang.classfile;
import java.lang.constant.ClassDesc; import java.lang.constant.ClassDesc;
import java.util.function.Consumer; import java.util.function.Consumer;
import jdk.internal.classfile.constantpool.ConstantPool; import java.lang.classfile.constantpool.ConstantPool;
import jdk.internal.classfile.constantpool.ConstantPoolBuilder; import java.lang.classfile.constantpool.ConstantPoolBuilder;
import jdk.internal.javac.PreviewFeature;
/** /**
* A builder for a classfile or portion of a classfile. Builders are rarely * A builder for a classfile or portion of a classfile. Builders are rarely
* created directly; they are passed to handlers by methods such as * created directly; they are passed to handlers by methods such as
* {@link Classfile#build(ClassDesc, Consumer)} or to transforms. * {@link ClassFile#build(ClassDesc, Consumer)} or to transforms.
* Elements of the newly built entity can be specified * Elements of the newly built entity can be specified
* abstractly (by passing a {@link ClassfileElement} to {@link #with(ClassfileElement)} * abstractly (by passing a {@link ClassFileElement} to {@link #with(ClassFileElement)}
* or concretely by calling the various {@code withXxx} methods. * or concretely by calling the various {@code withXxx} methods.
* *
* @param <E> the element type * @param <E> the element type
* @param <B> the builder type * @param <B> the builder type
* @see ClassfileTransform * @see ClassFileTransform
*
* @sealedGraph
* @since 22
*/ */
public sealed interface ClassfileBuilder<E extends ClassfileElement, B extends ClassfileBuilder<E, B>> @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface ClassFileBuilder<E extends ClassFileElement, B extends ClassFileBuilder<E, B>>
extends Consumer<E> permits ClassBuilder, FieldBuilder, MethodBuilder, CodeBuilder { extends Consumer<E> permits ClassBuilder, FieldBuilder, MethodBuilder, CodeBuilder {
/** /**
* Integrate the {@link ClassfileElement} into the entity being built. * Integrate the {@link ClassFileElement} into the entity being built.
* @param e the element * @param e the element
*/ */
@Override @Override
@ -55,7 +60,7 @@ public sealed interface ClassfileBuilder<E extends ClassfileElement, B extends C
} }
/** /**
* Integrate the {@link ClassfileElement} into the entity being built. * Integrate the {@link ClassFileElement} into the entity being built.
* @param e the element * @param e the element
* @return this builder * @return this builder
*/ */
@ -79,7 +84,7 @@ public sealed interface ClassfileBuilder<E extends ClassfileElement, B extends C
* @param model the model to transform * @param model the model to transform
* @param transform the transform to apply * @param transform the transform to apply
*/ */
default void transform(CompoundElement<E> model, ClassfileTransform<?, E, B> transform) { default void transform(CompoundElement<E> model, ClassFileTransform<?, E, B> transform) {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
B builder = (B) this; B builder = (B) this;
var resolved = transform.resolve(builder); var resolved = transform.resolve(builder);

View file

@ -22,7 +22,9 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
package jdk.internal.classfile; package java.lang.classfile;
import jdk.internal.javac.PreviewFeature;
/** /**
* Immutable model for a portion of (or the entirety of) a classfile. Elements * Immutable model for a portion of (or the entirety of) a classfile. Elements
@ -31,8 +33,12 @@ package jdk.internal.classfile;
* themselves contain their own child elements will implement {@link * themselves contain their own child elements will implement {@link
* CompoundElement}. Elements specific to various locations in the classfile * CompoundElement}. Elements specific to various locations in the classfile
* will implement {@link ClassElement}, {@link MethodElement}, etc. * will implement {@link ClassElement}, {@link MethodElement}, etc.
*
* @sealedGraph
* @since 22
*/ */
public sealed interface ClassfileElement @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface ClassFileElement
permits AttributedElement, CompoundElement, WritableElement, permits AttributedElement, CompoundElement, WritableElement,
ClassElement, CodeElement, FieldElement, MethodElement { ClassElement, CodeElement, FieldElement, MethodElement {
} }

View file

@ -22,33 +22,34 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
package jdk.internal.classfile; package java.lang.classfile;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.function.Supplier; import java.util.function.Supplier;
import jdk.internal.classfile.attribute.RuntimeVisibleAnnotationsAttribute; import java.lang.classfile.attribute.RuntimeVisibleAnnotationsAttribute;
import jdk.internal.javac.PreviewFeature;
/** /**
* A transformation on streams of elements. Transforms are used during * A transformation on streams of elements. Transforms are used during
* transformation of classfile entities; a transform is provided to a method like * transformation of classfile entities; a transform is provided to a method like
* {@link Classfile#transform(ClassModel, ClassTransform)}, and the elements of the class, * {@link ClassFile#transform(ClassModel, ClassTransform)}, and the elements of the class,
* along with a builder, are presented to the transform. * along with a builder, are presented to the transform.
* *
* <p>The subtypes of {@linkplain * <p>The subtypes of {@linkplain
* ClassfileTransform} (e.g., {@link ClassTransform}) are functional interfaces * ClassFileTransform} (e.g., {@link ClassTransform}) are functional interfaces
* that accept an element and a corresponding builder. Since any element can be * that accept an element and a corresponding builder. Since any element can be
* reproduced on the builder via {@link ClassBuilder#with(ClassfileElement)}, a * reproduced on the builder via {@link ClassBuilder#with(ClassFileElement)}, a
* transform can easily leave elements in place, remove them, replace them, or * transform can easily leave elements in place, remove them, replace them, or
* augment them with other elements. This enables localized transforms to be * augment them with other elements. This enables localized transforms to be
* represented concisely. * represented concisely.
* *
* <p>Transforms also have an {@link #atEnd(ClassfileBuilder)} method, for * <p>Transforms also have an {@link #atEnd(ClassFileBuilder)} method, for
* which the default implementation does nothing, so that a transform can * which the default implementation does nothing, so that a transform can
* perform additional building after the stream of elements is exhausted. * perform additional building after the stream of elements is exhausted.
* *
* <p>Transforms can be chained together via the {@link * <p>Transforms can be chained together via the {@link
* #andThen(ClassfileTransform)} method, so that the output of one becomes the * #andThen(ClassFileTransform)} method, so that the output of one becomes the
* input to another. This allows smaller units of transformation to be captured * input to another. This allows smaller units of transformation to be captured
* and reused. * and reused.
* *
@ -56,7 +57,7 @@ import jdk.internal.classfile.attribute.RuntimeVisibleAnnotationsAttribute;
* annotation on a class may watch for the {@link RuntimeVisibleAnnotationsAttribute} * annotation on a class may watch for the {@link RuntimeVisibleAnnotationsAttribute}
* element and transform it if found, but if it is not found, will generate a * element and transform it if found, but if it is not found, will generate a
* {@linkplain RuntimeVisibleAnnotationsAttribute} element containing the * {@linkplain RuntimeVisibleAnnotationsAttribute} element containing the
* injected annotation from the {@linkplain #atEnd(ClassfileBuilder)} handler. * injected annotation from the {@linkplain #atEnd(ClassFileBuilder)} handler.
* To do this, the transform must accumulate some state during the traversal so * To do this, the transform must accumulate some state during the traversal so
* that the end handler knows what to do. If such a transform is to be reused, * that the end handler knows what to do. If such a transform is to be reused,
* its state must be reset for each traversal; this will happen automatically if * its state must be reset for each traversal; this will happen automatically if
@ -71,17 +72,21 @@ import jdk.internal.classfile.attribute.RuntimeVisibleAnnotationsAttribute;
* @param <C> the transform type * @param <C> the transform type
* @param <E> the element type * @param <E> the element type
* @param <B> the builder type * @param <B> the builder type
*
* @sealedGraph
* @since 22
*/ */
public sealed interface ClassfileTransform< @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
C extends ClassfileTransform<C, E, B>, public sealed interface ClassFileTransform<
E extends ClassfileElement, C extends ClassFileTransform<C, E, B>,
B extends ClassfileBuilder<E, B>> E extends ClassFileElement,
B extends ClassFileBuilder<E, B>>
permits ClassTransform, FieldTransform, MethodTransform, CodeTransform { permits ClassTransform, FieldTransform, MethodTransform, CodeTransform {
/** /**
* Transform an element by taking the appropriate actions on the builder. * Transform an element by taking the appropriate actions on the builder.
* Used when transforming a classfile entity (class, method, field, method * Used when transforming a classfile entity (class, method, field, method
* body.) If no transformation is desired, the element can be presented to * body.) If no transformation is desired, the element can be presented to
* {@link B#with(ClassfileElement)}. If the element is to be dropped, no * {@link B#with(ClassFileElement)}. If the element is to be dropped, no
* action is required. * action is required.
* *
* @param builder the builder for the new entity * @param builder the builder for the new entity
@ -92,7 +97,7 @@ public sealed interface ClassfileTransform<
/** /**
* Take any final action during transformation of a classfile entity. Called * Take any final action during transformation of a classfile entity. Called
* after all elements of the class are presented to {@link * after all elements of the class are presented to {@link
* #accept(ClassfileBuilder, ClassfileElement)}. * #accept(ClassFileBuilder, ClassFileElement)}.
* *
* @param builder the builder for the new entity * @param builder the builder for the new entity
* @implSpec The default implementation does nothing. * @implSpec The default implementation does nothing.
@ -103,7 +108,7 @@ public sealed interface ClassfileTransform<
/** /**
* Take any preliminary action during transformation of a classfile entity. * Take any preliminary action during transformation of a classfile entity.
* Called before any elements of the class are presented to {@link * Called before any elements of the class are presented to {@link
* #accept(ClassfileBuilder, ClassfileElement)}. * #accept(ClassFileBuilder, ClassFileElement)}.
* *
* @param builder the builder for the new entity * @param builder the builder for the new entity
* @implSpec The default implementation does nothing. * @implSpec The default implementation does nothing.
@ -125,8 +130,11 @@ public sealed interface ClassfileTransform<
* the implementation to perform transformation. * the implementation to perform transformation.
* *
* @param <E> the element type * @param <E> the element type
*
* @since 22
*/ */
interface ResolvedTransform<E extends ClassfileElement> { @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
interface ResolvedTransform<E extends ClassFileElement> {
/** /**
* {@return a {@link Consumer} to receive elements} * {@return a {@link Consumer} to receive elements}
*/ */
@ -151,7 +159,7 @@ public sealed interface ClassfileTransform<
* *
* <p>This method is a low-level method that should rarely be used by * <p>This method is a low-level method that should rarely be used by
* user code; most of the time, user code should prefer * user code; most of the time, user code should prefer
* {@link ClassfileBuilder#transform(CompoundElement, ClassfileTransform)}, * {@link ClassFileBuilder#transform(CompoundElement, ClassFileTransform)},
* which resolves the transform and executes it on the current builder. * which resolves the transform and executes it on the current builder.
* *
* @param builder the builder to bind to * @param builder the builder to bind to

View file

@ -22,18 +22,22 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
package jdk.internal.classfile; package java.lang.classfile;
import jdk.internal.classfile.impl.ClassfileVersionImpl; import jdk.internal.classfile.impl.ClassFileVersionImpl;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models the classfile version information for a class. Delivered as a {@link * Models the classfile version information for a class. Delivered as a {@link
* jdk.internal.classfile.ClassElement} when traversing the elements of a {@link * java.lang.classfile.ClassElement} when traversing the elements of a {@link
* ClassModel}. * ClassModel}.
*
* @since 22
*/ */
public sealed interface ClassfileVersion @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface ClassFileVersion
extends ClassElement extends ClassElement
permits ClassfileVersionImpl { permits ClassFileVersionImpl {
/** /**
* {@return the major classfile version} * {@return the major classfile version}
*/ */
@ -45,11 +49,11 @@ public sealed interface ClassfileVersion
int minorVersion(); int minorVersion();
/** /**
* {@return a {@link ClassfileVersion} element} * {@return a {@link ClassFileVersion} element}
* @param majorVersion the major classfile version * @param majorVersion the major classfile version
* @param minorVersion the minor classfile version * @param minorVersion the minor classfile version
*/ */
static ClassfileVersion of(int majorVersion, int minorVersion) { static ClassFileVersion of(int majorVersion, int minorVersion) {
return new ClassfileVersionImpl(majorVersion, minorVersion); return new ClassFileVersionImpl(majorVersion, minorVersion);
} }
} }

View file

@ -22,7 +22,7 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
package jdk.internal.classfile; package java.lang.classfile;
import java.io.InputStream; import java.io.InputStream;
import java.lang.constant.ClassDesc; import java.lang.constant.ClassDesc;
@ -39,11 +39,15 @@ import jdk.internal.classfile.impl.ClassHierarchyImpl.StaticClassHierarchyResolv
import jdk.internal.classfile.impl.Util; import jdk.internal.classfile.impl.Util;
import static java.lang.constant.ConstantDescs.CD_Object; import static java.lang.constant.ConstantDescs.CD_Object;
import jdk.internal.javac.PreviewFeature;
/** /**
* Provides class hierarchy information for generating correct stack maps * Provides class hierarchy information for generating correct stack maps
* during code building. * during code building.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
@FunctionalInterface @FunctionalInterface
public interface ClassHierarchyResolver { public interface ClassHierarchyResolver {
@ -65,7 +69,10 @@ public interface ClassHierarchyResolver {
/** /**
* Information about a resolved class. * Information about a resolved class.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
sealed interface ClassHierarchyInfo permits ClassHierarchyImpl.ClassHierarchyInfoImpl { sealed interface ClassHierarchyInfo permits ClassHierarchyImpl.ClassHierarchyInfoImpl {
/** /**
@ -94,6 +101,9 @@ public interface ClassHierarchyResolver {
* *
* @param other the other resolver * @param other the other resolver
* @return the chained resolver * @return the chained resolver
*
* @implSpec The default implementation returns resolver implemented to ask
* other resolver in cases where this resolver returns {@code null}.
*/ */
default ClassHierarchyResolver orElse(ClassHierarchyResolver other) { default ClassHierarchyResolver orElse(ClassHierarchyResolver other) {
return new ClassHierarchyResolver() { return new ClassHierarchyResolver() {
@ -115,6 +125,12 @@ public interface ClassHierarchyResolver {
* *
* @param cacheFactory the factory for the cache * @param cacheFactory the factory for the cache
* @return the ClassHierarchyResolver with caching * @return the ClassHierarchyResolver with caching
*
* @implSpec The default implementation returns resolver holding an instance
* of the cache map provided by the {@code cacheFactory}. It asks
* the cache map always first and fills the cache map with all
* resolved and also unresolved class info. The cache map may refuse
* {@code null} keys and values.
*/ */
default ClassHierarchyResolver cached(Supplier<Map<ClassDesc, ClassHierarchyInfo>> cacheFactory) { default ClassHierarchyResolver cached(Supplier<Map<ClassDesc, ClassHierarchyInfo>> cacheFactory) {
return new ClassHierarchyImpl.CachedClassHierarchyResolver(this, cacheFactory.get()); return new ClassHierarchyImpl.CachedClassHierarchyResolver(this, cacheFactory.get());
@ -127,6 +143,9 @@ public interface ClassHierarchyResolver {
* {@snippet file="PackageSnippets.java" region="lookup-class-hierarchy-resolver"} * {@snippet file="PackageSnippets.java" region="lookup-class-hierarchy-resolver"}
* *
* @return the ClassHierarchyResolver * @return the ClassHierarchyResolver
*
* @implSpec The default implementation calls {@link #cached(Supplier)} with
* {@link HashMap} supplier as {@code cacheFactory}.
*/ */
default ClassHierarchyResolver cached() { default ClassHierarchyResolver cached() {
record Factory() implements Supplier<Map<ClassDesc, ClassHierarchyInfo>> { record Factory() implements Supplier<Map<ClassDesc, ClassHierarchyInfo>> {

View file

@ -23,22 +23,26 @@
* questions. * questions.
*/ */
package jdk.internal.classfile; package java.lang.classfile;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.function.Consumer; import java.util.function.Consumer;
import jdk.internal.classfile.constantpool.ClassEntry; import java.lang.classfile.constantpool.ClassEntry;
import jdk.internal.classfile.constantpool.ConstantPool; import java.lang.classfile.constantpool.ConstantPool;
import jdk.internal.classfile.impl.ClassImpl; import jdk.internal.classfile.impl.ClassImpl;
import jdk.internal.classfile.impl.verifier.VerifierImpl; import jdk.internal.classfile.impl.verifier.VerifierImpl;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models a classfile. The contents of the classfile can be traversed via * Models a classfile. The contents of the classfile can be traversed via
* a streaming view (e.g., {@link #elements()}), or via random access (e.g., * a streaming view (e.g., {@link #elements()}), or via random access (e.g.,
* {@link #flags()}), or by freely mixing the two. * {@link #flags()}), or by freely mixing the two.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface ClassModel public sealed interface ClassModel
extends CompoundElement<ClassElement>, AttributedElement extends CompoundElement<ClassElement>, AttributedElement
permits ClassImpl { permits ClassImpl {

View file

@ -22,21 +22,22 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
package jdk.internal.classfile; package java.lang.classfile;
import jdk.internal.classfile.constantpool.ClassEntry; import java.lang.classfile.constantpool.ClassEntry;
import jdk.internal.classfile.constantpool.ConstantPool; import java.lang.classfile.constantpool.ConstantPool;
import jdk.internal.classfile.constantpool.ConstantPoolException; import java.lang.classfile.constantpool.ConstantPoolException;
import jdk.internal.classfile.constantpool.MethodHandleEntry; import java.lang.classfile.constantpool.MethodHandleEntry;
import jdk.internal.classfile.constantpool.ModuleEntry; import java.lang.classfile.constantpool.ModuleEntry;
import jdk.internal.classfile.constantpool.NameAndTypeEntry; import java.lang.classfile.constantpool.NameAndTypeEntry;
import jdk.internal.classfile.constantpool.PackageEntry; import java.lang.classfile.constantpool.PackageEntry;
import jdk.internal.classfile.constantpool.PoolEntry; import java.lang.classfile.constantpool.PoolEntry;
import jdk.internal.classfile.constantpool.Utf8Entry; import java.lang.classfile.constantpool.Utf8Entry;
import jdk.internal.classfile.impl.ClassReaderImpl; import jdk.internal.classfile.impl.ClassReaderImpl;
import java.util.Optional; import java.util.Optional;
import java.util.function.Function; import java.util.function.Function;
import jdk.internal.javac.PreviewFeature;
/** /**
* Supports reading from a classfile. Methods are provided to read data of * Supports reading from a classfile. Methods are provided to read data of
@ -44,7 +45,10 @@ import java.util.function.Function;
* the classfile, copying raw bytes, and reading constant pool entries. * the classfile, copying raw bytes, and reading constant pool entries.
* Encapsulates additional reading context such as mappers for custom attributes * Encapsulates additional reading context such as mappers for custom attributes
* and processing options. * and processing options.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface ClassReader extends ConstantPool public sealed interface ClassReader extends ConstantPool
permits ClassReaderImpl { permits ClassReaderImpl {
@ -52,7 +56,7 @@ public sealed interface ClassReader extends ConstantPool
/** /**
* {@return the table of custom attribute mappers} This is derived from * {@return the table of custom attribute mappers} This is derived from
* the processing option {@link Classfile.AttributeMapperOption}. * the processing option {@link ClassFile.AttributeMapperOption}.
*/ */
Function<Utf8Entry, AttributeMapper<?>> customAttributes(); Function<Utf8Entry, AttributeMapper<?>> customAttributes();
@ -105,6 +109,7 @@ public sealed interface ClassReader extends ConstantPool
/** /**
* {@return the constant pool entry of a given type whose index is given * {@return the constant pool entry of a given type whose index is given
* at the specified offset within the classfile} * at the specified offset within the classfile}
* @param <T> the entry type
* @param offset the offset of the index within the classfile * @param offset the offset of the index within the classfile
* @param cls the entry type * @param cls the entry type
* @throws ConstantPoolException if the index is out of range of the * @throws ConstantPoolException if the index is out of range of the

View file

@ -22,15 +22,19 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
package jdk.internal.classfile; package java.lang.classfile;
import java.util.List; import java.util.List;
import jdk.internal.classfile.impl.SignaturesImpl; import jdk.internal.classfile.impl.SignaturesImpl;
import static java.util.Objects.requireNonNull; import static java.util.Objects.requireNonNull;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models the generic signature of a class file, as defined by {@jvms 4.7.9}. * Models the generic signature of a class file, as defined by {@jvms 4.7.9}.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface ClassSignature public sealed interface ClassSignature
permits SignaturesImpl.ClassSignatureImpl { permits SignaturesImpl.ClassSignatureImpl {
@ -47,7 +51,7 @@ public sealed interface ClassSignature
String signatureString(); String signatureString();
/** /**
* @return class signature * {@return a class signature}
* @param superclassSignature the superclass * @param superclassSignature the superclass
* @param superinterfaceSignatures the interfaces * @param superinterfaceSignatures the interfaces
*/ */
@ -57,7 +61,7 @@ public sealed interface ClassSignature
} }
/** /**
* @return class signature * {@return a class signature}
* @param typeParameters the type parameters * @param typeParameters the type parameters
* @param superclassSignature the superclass * @param superclassSignature the superclass
* @param superinterfaceSignatures the interfaces * @param superinterfaceSignatures the interfaces

View file

@ -22,23 +22,27 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
package jdk.internal.classfile; package java.lang.classfile;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.function.Predicate; import java.util.function.Predicate;
import java.util.function.Supplier; import java.util.function.Supplier;
import jdk.internal.classfile.attribute.CodeAttribute; import java.lang.classfile.attribute.CodeAttribute;
import jdk.internal.classfile.impl.TransformImpl; import jdk.internal.classfile.impl.TransformImpl;
import jdk.internal.javac.PreviewFeature;
/** /**
* A transformation on streams of {@link ClassElement}. * A transformation on streams of {@link ClassElement}.
* *
* @see ClassfileTransform * @see ClassFileTransform
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
@FunctionalInterface @FunctionalInterface
public non-sealed interface ClassTransform public non-sealed interface ClassTransform
extends ClassfileTransform<ClassTransform, ClassElement, ClassBuilder> { extends ClassFileTransform<ClassTransform, ClassElement, ClassBuilder> {
/** /**
* A class transform that sends all elements to the builder. * A class transform that sends all elements to the builder.
@ -156,11 +160,22 @@ public non-sealed interface ClassTransform
return new TransformImpl.ClassFieldTransform(xform, f -> true); return new TransformImpl.ClassFieldTransform(xform, f -> true);
} }
/**
* @implSpec
* The default implementation returns this class transform chained with another
* class transform from the argument. Chaining of two transforms requires to
* involve a chained builder serving as a target builder for this transform
* and also as a source of elements for the downstream transform.
*/
@Override @Override
default ClassTransform andThen(ClassTransform t) { default ClassTransform andThen(ClassTransform t) {
return new TransformImpl.ChainedClassTransform(this, t); return new TransformImpl.ChainedClassTransform(this, t);
} }
/**
* @implSpec The default implementation returns a resolved transform bound
* to the given class builder.
*/
@Override @Override
default ResolvedTransform<ClassElement> resolve(ClassBuilder builder) { default ResolvedTransform<ClassElement> resolve(ClassBuilder builder) {
return new TransformImpl.ResolvedTransformImpl<>(e -> accept(builder, e), return new TransformImpl.ResolvedTransformImpl<>(e -> accept(builder, e),

View file

@ -23,7 +23,7 @@
* questions. * questions.
*/ */
package jdk.internal.classfile; package java.lang.classfile;
import java.lang.constant.ClassDesc; import java.lang.constant.ClassDesc;
import java.lang.constant.ConstantDesc; import java.lang.constant.ConstantDesc;
@ -36,16 +36,16 @@ import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.function.Consumer; import java.util.function.Consumer;
import jdk.internal.classfile.constantpool.ClassEntry; import java.lang.classfile.constantpool.ClassEntry;
import jdk.internal.classfile.constantpool.FieldRefEntry; import java.lang.classfile.constantpool.FieldRefEntry;
import jdk.internal.classfile.constantpool.InterfaceMethodRefEntry; import java.lang.classfile.constantpool.InterfaceMethodRefEntry;
import jdk.internal.classfile.constantpool.InvokeDynamicEntry; import java.lang.classfile.constantpool.InvokeDynamicEntry;
import jdk.internal.classfile.constantpool.LoadableConstantEntry; import java.lang.classfile.constantpool.LoadableConstantEntry;
import jdk.internal.classfile.constantpool.MemberRefEntry; import java.lang.classfile.constantpool.MemberRefEntry;
import jdk.internal.classfile.constantpool.MethodRefEntry; import java.lang.classfile.constantpool.MethodRefEntry;
import jdk.internal.classfile.constantpool.MethodHandleEntry; import java.lang.classfile.constantpool.MethodHandleEntry;
import jdk.internal.classfile.constantpool.NameAndTypeEntry; import java.lang.classfile.constantpool.NameAndTypeEntry;
import jdk.internal.classfile.constantpool.Utf8Entry; import java.lang.classfile.constantpool.Utf8Entry;
import jdk.internal.classfile.impl.BlockCodeBuilderImpl; import jdk.internal.classfile.impl.BlockCodeBuilderImpl;
import jdk.internal.classfile.impl.BytecodeHelpers; import jdk.internal.classfile.impl.BytecodeHelpers;
import jdk.internal.classfile.impl.CatchBuilderImpl; import jdk.internal.classfile.impl.CatchBuilderImpl;
@ -53,53 +53,57 @@ import jdk.internal.classfile.impl.ChainedCodeBuilder;
import jdk.internal.classfile.impl.LabelImpl; import jdk.internal.classfile.impl.LabelImpl;
import jdk.internal.classfile.impl.NonterminalCodeBuilder; import jdk.internal.classfile.impl.NonterminalCodeBuilder;
import jdk.internal.classfile.impl.TerminalCodeBuilder; import jdk.internal.classfile.impl.TerminalCodeBuilder;
import jdk.internal.classfile.instruction.ArrayLoadInstruction; import java.lang.classfile.instruction.ArrayLoadInstruction;
import jdk.internal.classfile.instruction.ArrayStoreInstruction; import java.lang.classfile.instruction.ArrayStoreInstruction;
import jdk.internal.classfile.instruction.BranchInstruction; import java.lang.classfile.instruction.BranchInstruction;
import jdk.internal.classfile.instruction.CharacterRange; import java.lang.classfile.instruction.CharacterRange;
import jdk.internal.classfile.instruction.ConstantInstruction; import java.lang.classfile.instruction.ConstantInstruction;
import jdk.internal.classfile.instruction.ConvertInstruction; import java.lang.classfile.instruction.ConvertInstruction;
import jdk.internal.classfile.instruction.ExceptionCatch; import java.lang.classfile.instruction.ExceptionCatch;
import jdk.internal.classfile.instruction.FieldInstruction; import java.lang.classfile.instruction.FieldInstruction;
import jdk.internal.classfile.instruction.IncrementInstruction; import java.lang.classfile.instruction.IncrementInstruction;
import jdk.internal.classfile.instruction.InvokeDynamicInstruction; import java.lang.classfile.instruction.InvokeDynamicInstruction;
import jdk.internal.classfile.instruction.InvokeInstruction; import java.lang.classfile.instruction.InvokeInstruction;
import jdk.internal.classfile.instruction.LineNumber; import java.lang.classfile.instruction.LineNumber;
import jdk.internal.classfile.instruction.LoadInstruction; import java.lang.classfile.instruction.LoadInstruction;
import jdk.internal.classfile.instruction.LocalVariable; import java.lang.classfile.instruction.LocalVariable;
import jdk.internal.classfile.instruction.LocalVariableType; import java.lang.classfile.instruction.LocalVariableType;
import jdk.internal.classfile.instruction.LookupSwitchInstruction; import java.lang.classfile.instruction.LookupSwitchInstruction;
import jdk.internal.classfile.instruction.MonitorInstruction; import java.lang.classfile.instruction.MonitorInstruction;
import jdk.internal.classfile.instruction.NewMultiArrayInstruction; import java.lang.classfile.instruction.NewMultiArrayInstruction;
import jdk.internal.classfile.instruction.NewObjectInstruction; import java.lang.classfile.instruction.NewObjectInstruction;
import jdk.internal.classfile.instruction.NewPrimitiveArrayInstruction; import java.lang.classfile.instruction.NewPrimitiveArrayInstruction;
import jdk.internal.classfile.instruction.NewReferenceArrayInstruction; import java.lang.classfile.instruction.NewReferenceArrayInstruction;
import jdk.internal.classfile.instruction.NopInstruction; import java.lang.classfile.instruction.NopInstruction;
import jdk.internal.classfile.instruction.OperatorInstruction; import java.lang.classfile.instruction.OperatorInstruction;
import jdk.internal.classfile.instruction.ReturnInstruction; import java.lang.classfile.instruction.ReturnInstruction;
import jdk.internal.classfile.instruction.StackInstruction; import java.lang.classfile.instruction.StackInstruction;
import jdk.internal.classfile.instruction.StoreInstruction; import java.lang.classfile.instruction.StoreInstruction;
import jdk.internal.classfile.instruction.SwitchCase; import java.lang.classfile.instruction.SwitchCase;
import jdk.internal.classfile.instruction.TableSwitchInstruction; import java.lang.classfile.instruction.TableSwitchInstruction;
import jdk.internal.classfile.instruction.ThrowInstruction; import java.lang.classfile.instruction.ThrowInstruction;
import jdk.internal.classfile.instruction.TypeCheckInstruction; import java.lang.classfile.instruction.TypeCheckInstruction;
import static java.util.Objects.requireNonNull; import static java.util.Objects.requireNonNull;
import static jdk.internal.classfile.impl.BytecodeHelpers.handleDescToHandleInfo; import static jdk.internal.classfile.impl.BytecodeHelpers.handleDescToHandleInfo;
import jdk.internal.classfile.impl.TransformingCodeBuilder; import jdk.internal.classfile.impl.TransformingCodeBuilder;
import jdk.internal.javac.PreviewFeature;
/** /**
* A builder for code attributes (method bodies). Builders are not created * A builder for code attributes (method bodies). Builders are not created
* directly; they are passed to handlers by methods such as {@link * directly; they are passed to handlers by methods such as {@link
* MethodBuilder#withCode(Consumer)} or to code transforms. The elements of a * MethodBuilder#withCode(Consumer)} or to code transforms. The elements of a
* code can be specified abstractly, by passing a {@link CodeElement} to {@link * code can be specified abstractly, by passing a {@link CodeElement} to {@link
* #with(ClassfileElement)} or concretely by calling the various {@code withXxx} * #with(ClassFileElement)} or concretely by calling the various {@code withXxx}
* methods. * methods.
* *
* @see CodeTransform * @see CodeTransform
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface CodeBuilder public sealed interface CodeBuilder
extends ClassfileBuilder<CodeElement, CodeBuilder> extends ClassFileBuilder<CodeElement, CodeBuilder>
permits CodeBuilder.BlockCodeBuilder, ChainedCodeBuilder, TerminalCodeBuilder, NonterminalCodeBuilder { permits CodeBuilder.BlockCodeBuilder, ChainedCodeBuilder, TerminalCodeBuilder, NonterminalCodeBuilder {
/** /**
@ -174,7 +178,10 @@ public sealed interface CodeBuilder
/** /**
* A builder for blocks of code. * A builder for blocks of code.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
sealed interface BlockCodeBuilder extends CodeBuilder sealed interface BlockCodeBuilder extends CodeBuilder
permits BlockCodeBuilderImpl { permits BlockCodeBuilderImpl {
/** /**
@ -315,7 +322,10 @@ public sealed interface CodeBuilder
* A builder to add catch blocks. * A builder to add catch blocks.
* *
* @see #trying * @see #trying
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
sealed interface CatchBuilder permits CatchBuilderImpl { sealed interface CatchBuilder permits CatchBuilderImpl {
/** /**
* Adds a catch block that catches an exception of the given type. * Adds a catch block that catches an exception of the given type.
@ -328,7 +338,8 @@ public sealed interface CodeBuilder
* @param catchHandler handler that receives a {@linkplain CodeBuilder} to * @param catchHandler handler that receives a {@linkplain CodeBuilder} to
* generate the body of the catch block. * generate the body of the catch block.
* @return this builder * @return this builder
* @throws IllegalArgumentException if an existing catch block catches an exception of the given type. * @throws IllegalArgumentException if an existing catch block catches an exception of the given type
* or {@code exceptionType} represents a primitive type
* @see #catchingMulti * @see #catchingMulti
* @see #catchingAll * @see #catchingAll
*/ */
@ -582,6 +593,7 @@ public sealed interface CodeBuilder
* Generate an instruction to create a new object * Generate an instruction to create a new object
* @param type the object type * @param type the object type
* @return this builder * @return this builder
* @throws IllegalArgumentException if {@code type} represents a primitive type
*/ */
default CodeBuilder newObjectInstruction(ClassDesc type) { default CodeBuilder newObjectInstruction(ClassDesc type) {
return newObjectInstruction(constantPool().classEntry(type)); return newObjectInstruction(constantPool().classEntry(type));
@ -611,6 +623,7 @@ public sealed interface CodeBuilder
* Generate an instruction to create a new array of reference * Generate an instruction to create a new array of reference
* @param type the component type * @param type the component type
* @return this builder * @return this builder
* @throws IllegalArgumentException if {@code type} represents a primitive type
*/ */
default CodeBuilder newReferenceArrayInstruction(ClassDesc type) { default CodeBuilder newReferenceArrayInstruction(ClassDesc type) {
return newReferenceArrayInstruction(constantPool().classEntry(type)); return newReferenceArrayInstruction(constantPool().classEntry(type));
@ -1005,6 +1018,7 @@ public sealed interface CodeBuilder
* Generate an instruction to create a new array of reference * Generate an instruction to create a new array of reference
* @param className the component type * @param className the component type
* @return this builder * @return this builder
* @throws IllegalArgumentException if {@code className} represents a primitive type
*/ */
default CodeBuilder anewarray(ClassDesc className) { default CodeBuilder anewarray(ClassDesc className) {
return newReferenceArrayInstruction(constantPool().classEntry(className)); return newReferenceArrayInstruction(constantPool().classEntry(className));
@ -1097,6 +1111,7 @@ public sealed interface CodeBuilder
* Generate an instruction to check whether an object is of the given type * Generate an instruction to check whether an object is of the given type
* @param type the object type * @param type the object type
* @return this builder * @return this builder
* @throws IllegalArgumentException if {@code type} represents a primitive type
*/ */
default CodeBuilder checkcast(ClassDesc type) { default CodeBuilder checkcast(ClassDesc type) {
return typeCheckInstruction(Opcode.CHECKCAST, type); return typeCheckInstruction(Opcode.CHECKCAST, type);
@ -1467,6 +1482,7 @@ public sealed interface CodeBuilder
* @param name the field name * @param name the field name
* @param type the field type * @param type the field type
* @return this builder * @return this builder
* @throws IllegalArgumentException if {@code owner} represents a primitive type
*/ */
default CodeBuilder getfield(ClassDesc owner, String name, ClassDesc type) { default CodeBuilder getfield(ClassDesc owner, String name, ClassDesc type) {
return fieldInstruction(Opcode.GETFIELD, owner, name, type); return fieldInstruction(Opcode.GETFIELD, owner, name, type);
@ -1487,6 +1503,7 @@ public sealed interface CodeBuilder
* @param name the field name * @param name the field name
* @param type the field type * @param type the field type
* @return this builder * @return this builder
* @throws IllegalArgumentException if {@code owner} represents a primitive type
*/ */
default CodeBuilder getstatic(ClassDesc owner, String name, ClassDesc type) { default CodeBuilder getstatic(ClassDesc owner, String name, ClassDesc type) {
return fieldInstruction(Opcode.GETSTATIC, owner, name, type); return fieldInstruction(Opcode.GETSTATIC, owner, name, type);
@ -1655,7 +1672,7 @@ public sealed interface CodeBuilder
} }
/** /**
* Generate an instruction to branch if int comparison succeeds * Generate an instruction to branch if reference comparison succeeds
* @param target the branch target * @param target the branch target
* @return this builder * @return this builder
*/ */
@ -1664,7 +1681,7 @@ public sealed interface CodeBuilder
} }
/** /**
* Generate an instruction to branch if int comparison succeeds * Generate an instruction to branch if reference comparison succeeds
* @param target the branch target * @param target the branch target
* @return this builder * @return this builder
*/ */
@ -1846,6 +1863,7 @@ public sealed interface CodeBuilder
* Generate an instruction to determine if an object is of the given type * Generate an instruction to determine if an object is of the given type
* @param target the target type * @param target the target type
* @return this builder * @return this builder
* @throws IllegalArgumentException if {@code target} represents a primitive type
*/ */
default CodeBuilder instanceof_(ClassDesc target) { default CodeBuilder instanceof_(ClassDesc target) {
return typeCheckInstruction(Opcode.INSTANCEOF, constantPool().classEntry(target)); return typeCheckInstruction(Opcode.INSTANCEOF, constantPool().classEntry(target));
@ -1884,6 +1902,7 @@ public sealed interface CodeBuilder
* @param name the method name * @param name the method name
* @param type the method type * @param type the method type
* @return this builder * @return this builder
* @throws IllegalArgumentException if {@code owner} represents a primitive type
*/ */
default CodeBuilder invokeinterface(ClassDesc owner, String name, MethodTypeDesc type) { default CodeBuilder invokeinterface(ClassDesc owner, String name, MethodTypeDesc type) {
return invokeInstruction(Opcode.INVOKEINTERFACE, constantPool().interfaceMethodRefEntry(owner, name, type)); return invokeInstruction(Opcode.INVOKEINTERFACE, constantPool().interfaceMethodRefEntry(owner, name, type));
@ -1916,6 +1935,7 @@ public sealed interface CodeBuilder
* @param name the method name * @param name the method name
* @param type the method type * @param type the method type
* @return this builder * @return this builder
* @throws IllegalArgumentException if {@code owner} represents a primitive type
*/ */
default CodeBuilder invokespecial(ClassDesc owner, String name, MethodTypeDesc type) { default CodeBuilder invokespecial(ClassDesc owner, String name, MethodTypeDesc type) {
return invokeInstruction(Opcode.INVOKESPECIAL, owner, name, type, false); return invokeInstruction(Opcode.INVOKESPECIAL, owner, name, type, false);
@ -1929,6 +1949,7 @@ public sealed interface CodeBuilder
* @param type the method type * @param type the method type
* @param isInterface the interface method invocation indication * @param isInterface the interface method invocation indication
* @return this builder * @return this builder
* @throws IllegalArgumentException if {@code owner} represents a primitive type
*/ */
default CodeBuilder invokespecial(ClassDesc owner, String name, MethodTypeDesc type, boolean isInterface) { default CodeBuilder invokespecial(ClassDesc owner, String name, MethodTypeDesc type, boolean isInterface) {
return invokeInstruction(Opcode.INVOKESPECIAL, owner, name, type, isInterface); return invokeInstruction(Opcode.INVOKESPECIAL, owner, name, type, isInterface);
@ -1958,6 +1979,7 @@ public sealed interface CodeBuilder
* @param name the method name * @param name the method name
* @param type the method type * @param type the method type
* @return this builder * @return this builder
* @throws IllegalArgumentException if {@code owner} represents a primitive type
*/ */
default CodeBuilder invokestatic(ClassDesc owner, String name, MethodTypeDesc type) { default CodeBuilder invokestatic(ClassDesc owner, String name, MethodTypeDesc type) {
return invokeInstruction(Opcode.INVOKESTATIC, owner, name, type, false); return invokeInstruction(Opcode.INVOKESTATIC, owner, name, type, false);
@ -1970,6 +1992,7 @@ public sealed interface CodeBuilder
* @param type the method type * @param type the method type
* @param isInterface the interface method invocation indication * @param isInterface the interface method invocation indication
* @return this builder * @return this builder
* @throws IllegalArgumentException if {@code owner} represents a primitive type
*/ */
default CodeBuilder invokestatic(ClassDesc owner, String name, MethodTypeDesc type, boolean isInterface) { default CodeBuilder invokestatic(ClassDesc owner, String name, MethodTypeDesc type, boolean isInterface) {
return invokeInstruction(Opcode.INVOKESTATIC, owner, name, type, isInterface); return invokeInstruction(Opcode.INVOKESTATIC, owner, name, type, isInterface);
@ -1990,6 +2013,7 @@ public sealed interface CodeBuilder
* @param name the method name * @param name the method name
* @param type the method type * @param type the method type
* @return this builder * @return this builder
* @throws IllegalArgumentException if {@code owner} represents a primitive type
*/ */
default CodeBuilder invokevirtual(ClassDesc owner, String name, MethodTypeDesc type) { default CodeBuilder invokevirtual(ClassDesc owner, String name, MethodTypeDesc type) {
return invokeInstruction(Opcode.INVOKEVIRTUAL, owner, name, type, false); return invokeInstruction(Opcode.INVOKEVIRTUAL, owner, name, type, false);
@ -2316,6 +2340,7 @@ public sealed interface CodeBuilder
* @param array the array type * @param array the array type
* @param dims the number of dimensions * @param dims the number of dimensions
* @return this builder * @return this builder
* @throws IllegalArgumentException if {@code array} represents a primitive type
*/ */
default CodeBuilder multianewarray(ClassDesc array, int dims) { default CodeBuilder multianewarray(ClassDesc array, int dims) {
return newMultidimensionalArrayInstruction(dims, constantPool().classEntry(array)); return newMultidimensionalArrayInstruction(dims, constantPool().classEntry(array));
@ -2334,6 +2359,7 @@ public sealed interface CodeBuilder
* Generate an instruction to create a new object * Generate an instruction to create a new object
* @param clazz the new class type * @param clazz the new class type
* @return this builder * @return this builder
* @throws IllegalArgumentException if {@code clazz} represents a primitive type
*/ */
default CodeBuilder new_(ClassDesc clazz) { default CodeBuilder new_(ClassDesc clazz) {
return newObjectInstruction(constantPool().classEntry(clazz)); return newObjectInstruction(constantPool().classEntry(clazz));
@ -2379,6 +2405,7 @@ public sealed interface CodeBuilder
* @param name the field name * @param name the field name
* @param type the field type * @param type the field type
* @return this builder * @return this builder
* @throws IllegalArgumentException if {@code owner} represents a primitive type
*/ */
default CodeBuilder putfield(ClassDesc owner, String name, ClassDesc type) { default CodeBuilder putfield(ClassDesc owner, String name, ClassDesc type) {
return fieldInstruction(Opcode.PUTFIELD, owner, name, type); return fieldInstruction(Opcode.PUTFIELD, owner, name, type);
@ -2399,6 +2426,7 @@ public sealed interface CodeBuilder
* @param name the field name * @param name the field name
* @param type the field type * @param type the field type
* @return this builder * @return this builder
* @throws IllegalArgumentException if {@code owner} represents a primitive type
*/ */
default CodeBuilder putstatic(ClassDesc owner, String name, ClassDesc type) { default CodeBuilder putstatic(ClassDesc owner, String name, ClassDesc type) {
return fieldInstruction(Opcode.PUTSTATIC, owner, name, type); return fieldInstruction(Opcode.PUTSTATIC, owner, name, type);

View file

@ -22,21 +22,26 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
package jdk.internal.classfile; package java.lang.classfile;
import jdk.internal.classfile.attribute.RuntimeInvisibleTypeAnnotationsAttribute; import java.lang.classfile.attribute.RuntimeInvisibleTypeAnnotationsAttribute;
import jdk.internal.classfile.attribute.RuntimeVisibleTypeAnnotationsAttribute; import java.lang.classfile.attribute.RuntimeVisibleTypeAnnotationsAttribute;
import jdk.internal.classfile.attribute.StackMapTableAttribute; import java.lang.classfile.attribute.StackMapTableAttribute;
import jdk.internal.javac.PreviewFeature;
/** /**
* A {@link ClassfileElement} that can appear when traversing the elements * A marker interface for elements that can appear when traversing
* of a {@link CodeModel} or be presented to a {@link CodeBuilder}. Code elements * a {@link CodeModel} or be presented to a {@link CodeBuilder}. Code elements
* are either an {@link Instruction}, which models an instruction in the body * are either an {@link Instruction}, which models an instruction in the body
* of a method, or a {@link PseudoInstruction}, which models metadata from * of a method, or a {@link PseudoInstruction}, which models metadata from
* the code attribute, such as line number metadata, local variable metadata, * the code attribute, such as line number metadata, local variable metadata,
* exception metadata, label target metadata, etc. * exception metadata, label target metadata, etc.
*
* @sealedGraph
* @since 22
*/ */
public sealed interface CodeElement extends ClassfileElement @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface CodeElement extends ClassFileElement
permits Instruction, PseudoInstruction, permits Instruction, PseudoInstruction,
CustomAttribute, RuntimeVisibleTypeAnnotationsAttribute, RuntimeInvisibleTypeAnnotationsAttribute, CustomAttribute, RuntimeVisibleTypeAnnotationsAttribute, RuntimeInvisibleTypeAnnotationsAttribute,
StackMapTableAttribute { StackMapTableAttribute {

View file

@ -23,21 +23,25 @@
* questions. * questions.
*/ */
package jdk.internal.classfile; package java.lang.classfile;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import jdk.internal.classfile.attribute.CodeAttribute; import java.lang.classfile.attribute.CodeAttribute;
import jdk.internal.classfile.impl.BufferedCodeBuilder; import jdk.internal.classfile.impl.BufferedCodeBuilder;
import jdk.internal.classfile.impl.CodeImpl; import jdk.internal.classfile.impl.CodeImpl;
import jdk.internal.classfile.instruction.ExceptionCatch; import java.lang.classfile.instruction.ExceptionCatch;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models the body of a method (the {@code Code} attribute). The instructions * Models the body of a method (the {@code Code} attribute). The instructions
* of the method body are accessed via a streaming view (e.g., {@link * of the method body are accessed via a streaming view (e.g., {@link
* #elements()}). * #elements()}).
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface CodeModel public sealed interface CodeModel
extends CompoundElement<CodeElement>, AttributedElement, MethodElement extends CompoundElement<CodeElement>, AttributedElement, MethodElement
permits CodeAttribute, BufferedCodeBuilder.Model, CodeImpl { permits CodeAttribute, BufferedCodeBuilder.Model, CodeImpl {

View file

@ -22,21 +22,25 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
package jdk.internal.classfile; package java.lang.classfile;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.function.Supplier; import java.util.function.Supplier;
import jdk.internal.classfile.impl.TransformImpl; import jdk.internal.classfile.impl.TransformImpl;
import jdk.internal.javac.PreviewFeature;
/** /**
* A transformation on streams of {@link CodeElement}. * A transformation on streams of {@link CodeElement}.
* *
* @see ClassfileTransform * @see ClassFileTransform
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
@FunctionalInterface @FunctionalInterface
public non-sealed interface CodeTransform public non-sealed interface CodeTransform
extends ClassfileTransform<CodeTransform, CodeElement, CodeBuilder> { extends ClassFileTransform<CodeTransform, CodeElement, CodeBuilder> {
/** /**
* A code transform that sends all elements to the builder. * A code transform that sends all elements to the builder.
@ -81,11 +85,22 @@ public non-sealed interface CodeTransform
}; };
} }
/**
* @implSpec
* The default implementation returns this code transform chained with another
* code transform from the argument. Chaining of two transforms requires to
* involve a chained builder serving as a target builder for this transform
* and also as a source of elements for the downstream transform.
*/
@Override @Override
default CodeTransform andThen(CodeTransform t) { default CodeTransform andThen(CodeTransform t) {
return new TransformImpl.ChainedCodeTransform(this, t); return new TransformImpl.ChainedCodeTransform(this, t);
} }
/**
* @implSpec The default implementation returns a resolved transform bound
* to the given code builder.
*/
@Override @Override
default ResolvedTransform<CodeElement> resolve(CodeBuilder builder) { default ResolvedTransform<CodeElement> resolve(CodeBuilder builder) {
return new TransformImpl.ResolvedTransformImpl<>(e -> accept(builder, e), return new TransformImpl.ResolvedTransformImpl<>(e -> accept(builder, e),

View file

@ -22,7 +22,7 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
package jdk.internal.classfile; package java.lang.classfile;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
@ -32,18 +32,23 @@ import java.util.Spliterators;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.stream.Stream; import java.util.stream.Stream;
import java.util.stream.StreamSupport; import java.util.stream.StreamSupport;
import jdk.internal.javac.PreviewFeature;
/** /**
* A {@link ClassfileElement} that has complex structure defined in terms of * A {@link ClassFileElement} that has complex structure defined in terms of
* other classfile elements, such as a method, field, method body, or entire * other classfile elements, such as a method, field, method body, or entire
* class. When encountering a {@linkplain CompoundElement}, clients have the * class. When encountering a {@linkplain CompoundElement}, clients have the
* option to treat the element as a single entity (e.g., an entire method) * option to treat the element as a single entity (e.g., an entire method)
* or to traverse the contents of that element with the methods in this class * or to traverse the contents of that element with the methods in this class
* (e.g., {@link #elements()}, {@link #forEachElement(Consumer)}, etc.) * (e.g., {@link #elements()}, {@link #forEachElement(Consumer)}, etc.)
* @param <E> the element type * @param <E> the element type
*
* @sealedGraph
* @since 22
*/ */
public sealed interface CompoundElement<E extends ClassfileElement> @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
extends ClassfileElement, Iterable<E> public sealed interface CompoundElement<E extends ClassFileElement>
extends ClassFileElement, Iterable<E>
permits ClassModel, CodeModel, FieldModel, MethodModel, jdk.internal.classfile.impl.AbstractUnboundModel { permits ClassModel, CodeModel, FieldModel, MethodModel, jdk.internal.classfile.impl.AbstractUnboundModel {
/** /**
* Invoke the provided handler with each element contained in this * Invoke the provided handler with each element contained in this

View file

@ -22,9 +22,9 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
package jdk.internal.classfile; package java.lang.classfile;
import jdk.internal.classfile.impl.UnboundAttribute; import jdk.internal.javac.PreviewFeature;
/** /**
* Models a non-standard attribute of a classfile. Clients should extend * Models a non-standard attribute of a classfile. Clients should extend
@ -32,17 +32,41 @@ import jdk.internal.classfile.impl.UnboundAttribute;
* and provide an {@link AttributeMapper} to mediate between the classfile * and provide an {@link AttributeMapper} to mediate between the classfile
* format and the {@linkplain CustomAttribute} representation. * format and the {@linkplain CustomAttribute} representation.
* @param <T> the custom attribute type * @param <T> the custom attribute type
*
* @since 22
*/ */
@SuppressWarnings("exports") @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public abstract non-sealed class CustomAttribute<T extends CustomAttribute<T>> public abstract non-sealed class CustomAttribute<T extends CustomAttribute<T>>
extends UnboundAttribute.CustomAttribute<T> implements Attribute<T>, CodeElement, ClassElement, MethodElement, FieldElement {
implements CodeElement, ClassElement, MethodElement, FieldElement {
private final AttributeMapper<T> mapper;
/** /**
* Construct a {@linkplain CustomAttribute}. * Construct a {@linkplain CustomAttribute}.
* @param mapper the attribute mapper * @param mapper the attribute mapper
*/ */
protected CustomAttribute(AttributeMapper<T> mapper) { protected CustomAttribute(AttributeMapper<T> mapper) {
super(mapper); this.mapper = mapper;
}
@Override
public final AttributeMapper<T> attributeMapper() {
return mapper;
}
@Override
public final String attributeName() {
return mapper.name();
}
@Override
@SuppressWarnings("unchecked")
public final void writeTo(BufWriter buf) {
mapper.writeAttribute(buf, (T) this);
}
@Override
public String toString() {
return String.format("CustomAttribute[name=%s]", mapper.name());
} }
} }

View file

@ -23,27 +23,31 @@
* questions. * questions.
*/ */
package jdk.internal.classfile; package java.lang.classfile;
import jdk.internal.classfile.constantpool.Utf8Entry; import java.lang.classfile.constantpool.Utf8Entry;
import jdk.internal.classfile.impl.ChainedFieldBuilder; import jdk.internal.classfile.impl.ChainedFieldBuilder;
import jdk.internal.classfile.impl.TerminalFieldBuilder; import jdk.internal.classfile.impl.TerminalFieldBuilder;
import java.lang.reflect.AccessFlag; import java.lang.reflect.AccessFlag;
import java.util.Optional; import java.util.Optional;
import java.util.function.Consumer; import java.util.function.Consumer;
import jdk.internal.javac.PreviewFeature;
/** /**
* A builder for fields. Builders are not created directly; they are passed * A builder for fields. Builders are not created directly; they are passed
* to handlers by methods such as {@link ClassBuilder#withField(Utf8Entry, Utf8Entry, Consumer)} * to handlers by methods such as {@link ClassBuilder#withField(Utf8Entry, Utf8Entry, Consumer)}
* or to field transforms. The elements of a field can be specified * or to field transforms. The elements of a field can be specified
* abstractly (by passing a {@link FieldElement} to {@link #with(ClassfileElement)} * abstractly (by passing a {@link FieldElement} to {@link #with(ClassFileElement)}
* or concretely by calling the various {@code withXxx} methods. * or concretely by calling the various {@code withXxx} methods.
* *
* @see FieldTransform * @see FieldTransform
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface FieldBuilder public sealed interface FieldBuilder
extends ClassfileBuilder<FieldElement, FieldBuilder> extends ClassFileBuilder<FieldElement, FieldBuilder>
permits TerminalFieldBuilder, ChainedFieldBuilder { permits TerminalFieldBuilder, ChainedFieldBuilder {
/** /**

View file

@ -22,23 +22,28 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
package jdk.internal.classfile; package java.lang.classfile;
import jdk.internal.classfile.attribute.ConstantValueAttribute; import java.lang.classfile.attribute.ConstantValueAttribute;
import jdk.internal.classfile.attribute.DeprecatedAttribute; import java.lang.classfile.attribute.DeprecatedAttribute;
import jdk.internal.classfile.attribute.RuntimeInvisibleAnnotationsAttribute; import java.lang.classfile.attribute.RuntimeInvisibleAnnotationsAttribute;
import jdk.internal.classfile.attribute.RuntimeInvisibleTypeAnnotationsAttribute; import java.lang.classfile.attribute.RuntimeInvisibleTypeAnnotationsAttribute;
import jdk.internal.classfile.attribute.RuntimeVisibleAnnotationsAttribute; import java.lang.classfile.attribute.RuntimeVisibleAnnotationsAttribute;
import jdk.internal.classfile.attribute.RuntimeVisibleTypeAnnotationsAttribute; import java.lang.classfile.attribute.RuntimeVisibleTypeAnnotationsAttribute;
import jdk.internal.classfile.attribute.SignatureAttribute; import java.lang.classfile.attribute.SignatureAttribute;
import jdk.internal.classfile.attribute.SyntheticAttribute; import java.lang.classfile.attribute.SyntheticAttribute;
import jdk.internal.classfile.attribute.UnknownAttribute; import java.lang.classfile.attribute.UnknownAttribute;
import jdk.internal.javac.PreviewFeature;
/** /**
* A {@link ClassfileElement} that can appear when traversing the elements * A marker interface for elements that can appear when traversing
* of a {@link FieldModel} or be presented to a {@link FieldBuilder}. * a {@link FieldModel} or be presented to a {@link FieldBuilder}.
*
* @sealedGraph
* @since 22
*/ */
public sealed interface FieldElement extends ClassfileElement @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface FieldElement extends ClassFileElement
permits AccessFlags, permits AccessFlags,
CustomAttribute, ConstantValueAttribute, DeprecatedAttribute, CustomAttribute, ConstantValueAttribute, DeprecatedAttribute,
RuntimeInvisibleAnnotationsAttribute, RuntimeInvisibleTypeAnnotationsAttribute, RuntimeInvisibleAnnotationsAttribute, RuntimeInvisibleTypeAnnotationsAttribute,

View file

@ -23,20 +23,24 @@
* questions. * questions.
*/ */
package jdk.internal.classfile; package java.lang.classfile;
import java.lang.constant.ClassDesc; import java.lang.constant.ClassDesc;
import java.util.Optional; import java.util.Optional;
import jdk.internal.classfile.constantpool.Utf8Entry; import java.lang.classfile.constantpool.Utf8Entry;
import jdk.internal.classfile.impl.BufferedFieldBuilder; import jdk.internal.classfile.impl.BufferedFieldBuilder;
import jdk.internal.classfile.impl.FieldImpl; import jdk.internal.classfile.impl.FieldImpl;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models a field. The contents of the field can be traversed via * Models a field. The contents of the field can be traversed via
* a streaming view (e.g., {@link #elements()}), or via random access (e.g., * a streaming view (e.g., {@link #elements()}), or via random access (e.g.,
* {@link #flags()}), or by freely mixing the two. * {@link #flags()}), or by freely mixing the two.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface FieldModel public sealed interface FieldModel
extends WritableElement<FieldModel>, CompoundElement<FieldElement>, AttributedElement, ClassElement extends WritableElement<FieldModel>, CompoundElement<FieldElement>, AttributedElement, ClassElement
permits BufferedFieldBuilder.Model, FieldImpl { permits BufferedFieldBuilder.Model, FieldImpl {

View file

@ -22,22 +22,26 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
package jdk.internal.classfile; package java.lang.classfile;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.function.Predicate; import java.util.function.Predicate;
import java.util.function.Supplier; import java.util.function.Supplier;
import jdk.internal.classfile.impl.TransformImpl; import jdk.internal.classfile.impl.TransformImpl;
import jdk.internal.javac.PreviewFeature;
/** /**
* A transformation on streams of {@link FieldElement}. * A transformation on streams of {@link FieldElement}.
* *
* @see ClassfileTransform * @see ClassFileTransform
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
@FunctionalInterface @FunctionalInterface
public non-sealed interface FieldTransform public non-sealed interface FieldTransform
extends ClassfileTransform<FieldTransform, FieldElement, FieldBuilder> { extends ClassFileTransform<FieldTransform, FieldElement, FieldBuilder> {
/** /**
* A field transform that sends all elements to the builder. * A field transform that sends all elements to the builder.
@ -96,11 +100,22 @@ public non-sealed interface FieldTransform
}; };
} }
/**
* @implSpec
* The default implementation returns this field transform chained with another
* field transform from the argument. Chaining of two transforms requires to
* involve a chained builder serving as a target builder for this transform
* and also as a source of elements for the downstream transform.
*/
@Override @Override
default FieldTransform andThen(FieldTransform t) { default FieldTransform andThen(FieldTransform t) {
return new TransformImpl.ChainedFieldTransform(this, t); return new TransformImpl.ChainedFieldTransform(this, t);
} }
/**
* @implSpec The default implementation returns a resolved transform bound
* to the given field builder.
*/
@Override @Override
default ResolvedTransform<FieldElement> resolve(FieldBuilder builder) { default ResolvedTransform<FieldElement> resolve(FieldBuilder builder) {
return new TransformImpl.ResolvedTransformImpl<>(e -> accept(builder, e), return new TransformImpl.ResolvedTransformImpl<>(e -> accept(builder, e),

View file

@ -23,38 +23,42 @@
* questions. * questions.
*/ */
package jdk.internal.classfile; package java.lang.classfile;
import jdk.internal.classfile.impl.AbstractInstruction; import jdk.internal.classfile.impl.AbstractInstruction;
import jdk.internal.classfile.instruction.ArrayLoadInstruction; import java.lang.classfile.instruction.ArrayLoadInstruction;
import jdk.internal.classfile.instruction.ArrayStoreInstruction; import java.lang.classfile.instruction.ArrayStoreInstruction;
import jdk.internal.classfile.instruction.BranchInstruction; import java.lang.classfile.instruction.BranchInstruction;
import jdk.internal.classfile.instruction.ConstantInstruction; import java.lang.classfile.instruction.ConstantInstruction;
import jdk.internal.classfile.instruction.ConvertInstruction; import java.lang.classfile.instruction.ConvertInstruction;
import jdk.internal.classfile.instruction.DiscontinuedInstruction; import java.lang.classfile.instruction.DiscontinuedInstruction;
import jdk.internal.classfile.instruction.FieldInstruction; import java.lang.classfile.instruction.FieldInstruction;
import jdk.internal.classfile.instruction.IncrementInstruction; import java.lang.classfile.instruction.IncrementInstruction;
import jdk.internal.classfile.instruction.InvokeDynamicInstruction; import java.lang.classfile.instruction.InvokeDynamicInstruction;
import jdk.internal.classfile.instruction.InvokeInstruction; import java.lang.classfile.instruction.InvokeInstruction;
import jdk.internal.classfile.instruction.LoadInstruction; import java.lang.classfile.instruction.LoadInstruction;
import jdk.internal.classfile.instruction.LookupSwitchInstruction; import java.lang.classfile.instruction.LookupSwitchInstruction;
import jdk.internal.classfile.instruction.MonitorInstruction; import java.lang.classfile.instruction.MonitorInstruction;
import jdk.internal.classfile.instruction.NewMultiArrayInstruction; import java.lang.classfile.instruction.NewMultiArrayInstruction;
import jdk.internal.classfile.instruction.NewObjectInstruction; import java.lang.classfile.instruction.NewObjectInstruction;
import jdk.internal.classfile.instruction.NewPrimitiveArrayInstruction; import java.lang.classfile.instruction.NewPrimitiveArrayInstruction;
import jdk.internal.classfile.instruction.NewReferenceArrayInstruction; import java.lang.classfile.instruction.NewReferenceArrayInstruction;
import jdk.internal.classfile.instruction.NopInstruction; import java.lang.classfile.instruction.NopInstruction;
import jdk.internal.classfile.instruction.OperatorInstruction; import java.lang.classfile.instruction.OperatorInstruction;
import jdk.internal.classfile.instruction.ReturnInstruction; import java.lang.classfile.instruction.ReturnInstruction;
import jdk.internal.classfile.instruction.StackInstruction; import java.lang.classfile.instruction.StackInstruction;
import jdk.internal.classfile.instruction.StoreInstruction; import java.lang.classfile.instruction.StoreInstruction;
import jdk.internal.classfile.instruction.TableSwitchInstruction; import java.lang.classfile.instruction.TableSwitchInstruction;
import jdk.internal.classfile.instruction.ThrowInstruction; import java.lang.classfile.instruction.ThrowInstruction;
import jdk.internal.classfile.instruction.TypeCheckInstruction; import java.lang.classfile.instruction.TypeCheckInstruction;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models an executable instruction in a method body. * Models an executable instruction in a method body.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface Instruction extends CodeElement public sealed interface Instruction extends CodeElement
permits ArrayLoadInstruction, ArrayStoreInstruction, BranchInstruction, permits ArrayLoadInstruction, ArrayStoreInstruction, BranchInstruction,
ConstantInstruction, ConvertInstruction, DiscontinuedInstruction, ConstantInstruction, ConvertInstruction, DiscontinuedInstruction,

View file

@ -22,20 +22,24 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
package jdk.internal.classfile; package java.lang.classfile;
import java.lang.constant.ClassDesc; import java.lang.constant.ClassDesc;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import jdk.internal.classfile.constantpool.ClassEntry; import java.lang.classfile.constantpool.ClassEntry;
import jdk.internal.classfile.impl.InterfacesImpl; import jdk.internal.classfile.impl.InterfacesImpl;
import jdk.internal.classfile.impl.Util; import jdk.internal.classfile.impl.Util;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models the interfaces of a class. Delivered as a {@link * Models the interfaces of a class. Delivered as a {@link
* jdk.internal.classfile.ClassElement} when traversing a {@link ClassModel}. * java.lang.classfile.ClassElement} when traversing a {@link ClassModel}.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface Interfaces public sealed interface Interfaces
extends ClassElement extends ClassElement
permits InterfacesImpl { permits InterfacesImpl {

View file

@ -22,9 +22,10 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
package jdk.internal.classfile; package java.lang.classfile;
import jdk.internal.classfile.impl.LabelImpl; import jdk.internal.classfile.impl.LabelImpl;
import jdk.internal.javac.PreviewFeature;
/** /**
* A marker for a position within the instructions of a method body. The * A marker for a position within the instructions of a method body. The
@ -37,8 +38,11 @@ import jdk.internal.classfile.impl.LabelImpl;
* traversing the elements of a {@linkplain CodeModel}, {@linkplain Label} * traversing the elements of a {@linkplain CodeModel}, {@linkplain Label}
* markers will be delivered at the position to which they correspond. A label * markers will be delivered at the position to which they correspond. A label
* can be bound to the current position within a {@linkplain CodeBuilder} via * can be bound to the current position within a {@linkplain CodeBuilder} via
* {@link CodeBuilder#labelBinding(Label)} or {@link CodeBuilder#with(ClassfileElement)}. * {@link CodeBuilder#labelBinding(Label)} or {@link CodeBuilder#with(ClassFileElement)}.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface Label public sealed interface Label
permits LabelImpl { permits LabelImpl {
} }

View file

@ -23,27 +23,31 @@
* questions. * questions.
*/ */
package jdk.internal.classfile; package java.lang.classfile;
import java.util.Optional; import java.util.Optional;
import java.util.function.Consumer; import java.util.function.Consumer;
import jdk.internal.classfile.constantpool.Utf8Entry; import java.lang.classfile.constantpool.Utf8Entry;
import jdk.internal.classfile.impl.ChainedMethodBuilder; import jdk.internal.classfile.impl.ChainedMethodBuilder;
import jdk.internal.classfile.impl.TerminalMethodBuilder; import jdk.internal.classfile.impl.TerminalMethodBuilder;
import java.lang.reflect.AccessFlag; import java.lang.reflect.AccessFlag;
import jdk.internal.javac.PreviewFeature;
/** /**
* A builder for methods. Builders are not created directly; they are passed * A builder for methods. Builders are not created directly; they are passed
* to handlers by methods such as {@link ClassBuilder#withMethod(Utf8Entry, Utf8Entry, int, Consumer)} * to handlers by methods such as {@link ClassBuilder#withMethod(Utf8Entry, Utf8Entry, int, Consumer)}
* or to method transforms. The elements of a method can be specified * or to method transforms. The elements of a method can be specified
* abstractly (by passing a {@link MethodElement} to {@link #with(ClassfileElement)} * abstractly (by passing a {@link MethodElement} to {@link #with(ClassFileElement)}
* or concretely by calling the various {@code withXxx} methods. * or concretely by calling the various {@code withXxx} methods.
* *
* @see MethodTransform * @see MethodTransform
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface MethodBuilder public sealed interface MethodBuilder
extends ClassfileBuilder<MethodElement, MethodBuilder> extends ClassFileBuilder<MethodElement, MethodBuilder>
permits ChainedMethodBuilder, TerminalMethodBuilder { permits ChainedMethodBuilder, TerminalMethodBuilder {
/** /**

View file

@ -22,28 +22,33 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
package jdk.internal.classfile; package java.lang.classfile;
import jdk.internal.classfile.attribute.AnnotationDefaultAttribute; import java.lang.classfile.attribute.AnnotationDefaultAttribute;
import jdk.internal.classfile.attribute.DeprecatedAttribute; import java.lang.classfile.attribute.DeprecatedAttribute;
import jdk.internal.classfile.attribute.ExceptionsAttribute; import java.lang.classfile.attribute.ExceptionsAttribute;
import jdk.internal.classfile.attribute.MethodParametersAttribute; import java.lang.classfile.attribute.MethodParametersAttribute;
import jdk.internal.classfile.attribute.RuntimeInvisibleAnnotationsAttribute; import java.lang.classfile.attribute.RuntimeInvisibleAnnotationsAttribute;
import jdk.internal.classfile.attribute.RuntimeInvisibleParameterAnnotationsAttribute; import java.lang.classfile.attribute.RuntimeInvisibleParameterAnnotationsAttribute;
import jdk.internal.classfile.attribute.RuntimeInvisibleTypeAnnotationsAttribute; import java.lang.classfile.attribute.RuntimeInvisibleTypeAnnotationsAttribute;
import jdk.internal.classfile.attribute.RuntimeVisibleAnnotationsAttribute; import java.lang.classfile.attribute.RuntimeVisibleAnnotationsAttribute;
import jdk.internal.classfile.attribute.RuntimeVisibleParameterAnnotationsAttribute; import java.lang.classfile.attribute.RuntimeVisibleParameterAnnotationsAttribute;
import jdk.internal.classfile.attribute.RuntimeVisibleTypeAnnotationsAttribute; import java.lang.classfile.attribute.RuntimeVisibleTypeAnnotationsAttribute;
import jdk.internal.classfile.attribute.SignatureAttribute; import java.lang.classfile.attribute.SignatureAttribute;
import jdk.internal.classfile.attribute.SyntheticAttribute; import java.lang.classfile.attribute.SyntheticAttribute;
import jdk.internal.classfile.attribute.UnknownAttribute; import java.lang.classfile.attribute.UnknownAttribute;
import jdk.internal.javac.PreviewFeature;
/** /**
* A {@link ClassfileElement} that can appear when traversing the elements * A marker interface for elements that can appear when traversing
* of a {@link MethodModel} or be presented to a {@link MethodBuilder}. * a {@link MethodModel} or be presented to a {@link MethodBuilder}.
*
* @sealedGraph
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface MethodElement public sealed interface MethodElement
extends ClassfileElement extends ClassFileElement
permits AccessFlags, CodeModel, CustomAttribute, permits AccessFlags, CodeModel, CustomAttribute,
AnnotationDefaultAttribute, DeprecatedAttribute, AnnotationDefaultAttribute, DeprecatedAttribute,
ExceptionsAttribute, MethodParametersAttribute, ExceptionsAttribute, MethodParametersAttribute,

View file

@ -23,20 +23,24 @@
* questions. * questions.
*/ */
package jdk.internal.classfile; package java.lang.classfile;
import java.lang.constant.MethodTypeDesc; import java.lang.constant.MethodTypeDesc;
import java.util.Optional; import java.util.Optional;
import jdk.internal.classfile.constantpool.Utf8Entry; import java.lang.classfile.constantpool.Utf8Entry;
import jdk.internal.classfile.impl.BufferedMethodBuilder; import jdk.internal.classfile.impl.BufferedMethodBuilder;
import jdk.internal.classfile.impl.MethodImpl; import jdk.internal.classfile.impl.MethodImpl;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models a method. The contents of the method can be traversed via * Models a method. The contents of the method can be traversed via
* a streaming view (e.g., {@link #elements()}), or via random access (e.g., * a streaming view (e.g., {@link #elements()}), or via random access (e.g.,
* {@link #flags()}), or by freely mixing the two. * {@link #flags()}), or by freely mixing the two.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface MethodModel public sealed interface MethodModel
extends WritableElement<MethodModel>, CompoundElement<MethodElement>, AttributedElement, ClassElement extends WritableElement<MethodModel>, CompoundElement<MethodElement>, AttributedElement, ClassElement
permits BufferedMethodBuilder.Model, MethodImpl { permits BufferedMethodBuilder.Model, MethodImpl {

View file

@ -22,17 +22,21 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
package jdk.internal.classfile; package java.lang.classfile;
import java.lang.constant.MethodTypeDesc; import java.lang.constant.MethodTypeDesc;
import java.util.List; import java.util.List;
import jdk.internal.classfile.impl.SignaturesImpl; import jdk.internal.classfile.impl.SignaturesImpl;
import static java.util.Objects.requireNonNull; import static java.util.Objects.requireNonNull;
import jdk.internal.classfile.impl.Util; import jdk.internal.classfile.impl.Util;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models the generic signature of a method, as defined by {@jvms 4.7.9}. * Models the generic signature of a method, as defined by {@jvms 4.7.9}.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface MethodSignature public sealed interface MethodSignature
permits SignaturesImpl.MethodSignatureImpl { permits SignaturesImpl.MethodSignatureImpl {
@ -52,7 +56,7 @@ public sealed interface MethodSignature
String signatureString(); String signatureString();
/** /**
* @return method signature for a raw (no generic information) method descriptor * {@return a method signature for a raw (no generic information) method descriptor}
* @param methodDescriptor the method descriptor * @param methodDescriptor the method descriptor
*/ */
public static MethodSignature of(MethodTypeDesc methodDescriptor) { public static MethodSignature of(MethodTypeDesc methodDescriptor) {
@ -66,7 +70,7 @@ public sealed interface MethodSignature
} }
/** /**
* @return method signature * {@return a method signature}
* @param result signature for the return type * @param result signature for the return type
* @param arguments signatures for the method arguments * @param arguments signatures for the method arguments
*/ */
@ -80,7 +84,7 @@ public sealed interface MethodSignature
} }
/** /**
* @return method signature * {@return a method signature}
* @param typeParameters signatures for the type parameters * @param typeParameters signatures for the type parameters
* @param exceptions signatures for the exceptions * @param exceptions signatures for the exceptions
* @param result signature for the return type * @param result signature for the return type

View file

@ -22,22 +22,26 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
package jdk.internal.classfile; package java.lang.classfile;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.function.Predicate; import java.util.function.Predicate;
import java.util.function.Supplier; import java.util.function.Supplier;
import jdk.internal.classfile.impl.TransformImpl; import jdk.internal.classfile.impl.TransformImpl;
import jdk.internal.javac.PreviewFeature;
/** /**
* A transformation on streams of {@link MethodElement}. * A transformation on streams of {@link MethodElement}.
* *
* @see ClassfileTransform * @see ClassFileTransform
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
@FunctionalInterface @FunctionalInterface
public non-sealed interface MethodTransform public non-sealed interface MethodTransform
extends ClassfileTransform<MethodTransform, MethodElement, MethodBuilder> { extends ClassFileTransform<MethodTransform, MethodElement, MethodBuilder> {
/** /**
* A method transform that sends all elements to the builder. * A method transform that sends all elements to the builder.
@ -107,6 +111,10 @@ public non-sealed interface MethodTransform
return new TransformImpl.MethodCodeTransform(xform); return new TransformImpl.MethodCodeTransform(xform);
} }
/**
* @implSpec The default implementation returns a resolved transform bound
* to the given method builder.
*/
@Override @Override
default ResolvedTransform<MethodElement> resolve(MethodBuilder builder) { default ResolvedTransform<MethodElement> resolve(MethodBuilder builder) {
return new TransformImpl.ResolvedTransformImpl<>(e -> accept(builder, e), return new TransformImpl.ResolvedTransformImpl<>(e -> accept(builder, e),
@ -114,6 +122,13 @@ public non-sealed interface MethodTransform
() -> atStart(builder)); () -> atStart(builder));
} }
/**
* @implSpec
* The default implementation returns this method transform chained with another
* method transform from the argument. Chaining of two transforms requires to
* involve a chained builder serving as a target builder for this transform
* and also as a source of elements for the downstream transform.
*/
@Override @Override
default MethodTransform andThen(MethodTransform t) { default MethodTransform andThen(MethodTransform t) {
return new TransformImpl.ChainedMethodTransform(this, t); return new TransformImpl.ChainedMethodTransform(this, t);

View file

@ -22,10 +22,11 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
package jdk.internal.classfile; package java.lang.classfile;
import java.lang.constant.ConstantDesc; import java.lang.constant.ConstantDesc;
import java.lang.constant.ConstantDescs; import java.lang.constant.ConstantDescs;
import jdk.internal.javac.PreviewFeature;
/** /**
* Describes the opcodes of the JVM instruction set, as described in {@jvms 6.5}. * Describes the opcodes of the JVM instruction set, as described in {@jvms 6.5}.
@ -34,654 +35,672 @@ import java.lang.constant.ConstantDescs;
* *
* @see Instruction * @see Instruction
* @see PseudoInstruction * @see PseudoInstruction
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public enum Opcode { public enum Opcode {
/** Do nothing */ /** Do nothing */
NOP(Classfile.NOP, 1, Kind.NOP), NOP(ClassFile.NOP, 1, Kind.NOP),
/** Push null */ /** Push null */
ACONST_NULL(Classfile.ACONST_NULL, 1, Kind.CONSTANT, TypeKind.ReferenceType, 0, ConstantDescs.NULL), ACONST_NULL(ClassFile.ACONST_NULL, 1, Kind.CONSTANT, TypeKind.ReferenceType, 0, ConstantDescs.NULL),
/** Push int constant -1 */ /** Push int constant -1 */
ICONST_M1(Classfile.ICONST_M1, 1, Kind.CONSTANT, TypeKind.IntType, 0, -1), ICONST_M1(ClassFile.ICONST_M1, 1, Kind.CONSTANT, TypeKind.IntType, 0, -1),
/** Push int constant 0 */ /** Push int constant 0 */
ICONST_0(Classfile.ICONST_0, 1, Kind.CONSTANT, TypeKind.IntType, 0, 0), ICONST_0(ClassFile.ICONST_0, 1, Kind.CONSTANT, TypeKind.IntType, 0, 0),
/** Push int constant 1 */ /** Push int constant 1 */
ICONST_1(Classfile.ICONST_1, 1, Kind.CONSTANT, TypeKind.IntType, 0, 1), ICONST_1(ClassFile.ICONST_1, 1, Kind.CONSTANT, TypeKind.IntType, 0, 1),
/** Push int constant 2 */ /** Push int constant 2 */
ICONST_2(Classfile.ICONST_2, 1, Kind.CONSTANT, TypeKind.IntType, 0, 2), ICONST_2(ClassFile.ICONST_2, 1, Kind.CONSTANT, TypeKind.IntType, 0, 2),
/** Push int constant 3 */ /** Push int constant 3 */
ICONST_3(Classfile.ICONST_3, 1, Kind.CONSTANT, TypeKind.IntType, 0, 3), ICONST_3(ClassFile.ICONST_3, 1, Kind.CONSTANT, TypeKind.IntType, 0, 3),
/** Push int constant 4 */ /** Push int constant 4 */
ICONST_4(Classfile.ICONST_4, 1, Kind.CONSTANT, TypeKind.IntType, 0, 4), ICONST_4(ClassFile.ICONST_4, 1, Kind.CONSTANT, TypeKind.IntType, 0, 4),
/** Push int constant 5 */ /** Push int constant 5 */
ICONST_5(Classfile.ICONST_5, 1, Kind.CONSTANT, TypeKind.IntType, 0, 5), ICONST_5(ClassFile.ICONST_5, 1, Kind.CONSTANT, TypeKind.IntType, 0, 5),
/** Push long constant 0 */ /** Push long constant 0 */
LCONST_0(Classfile.LCONST_0, 1, Kind.CONSTANT, TypeKind.LongType, 0, 0L), LCONST_0(ClassFile.LCONST_0, 1, Kind.CONSTANT, TypeKind.LongType, 0, 0L),
/** Push long constant 1 */ /** Push long constant 1 */
LCONST_1(Classfile.LCONST_1, 1, Kind.CONSTANT, TypeKind.LongType, 0, 1L), LCONST_1(ClassFile.LCONST_1, 1, Kind.CONSTANT, TypeKind.LongType, 0, 1L),
/** Push float constant 0 */ /** Push float constant 0 */
FCONST_0(Classfile.FCONST_0, 1, Kind.CONSTANT, TypeKind.FloatType, 0, 0.0f), FCONST_0(ClassFile.FCONST_0, 1, Kind.CONSTANT, TypeKind.FloatType, 0, 0.0f),
/** Push float constant 1 */ /** Push float constant 1 */
FCONST_1(Classfile.FCONST_1, 1, Kind.CONSTANT, TypeKind.FloatType, 0, 1.0f), FCONST_1(ClassFile.FCONST_1, 1, Kind.CONSTANT, TypeKind.FloatType, 0, 1.0f),
/** Push float constant 2 */ /** Push float constant 2 */
FCONST_2(Classfile.FCONST_2, 1, Kind.CONSTANT, TypeKind.FloatType, 0, 2.0f), FCONST_2(ClassFile.FCONST_2, 1, Kind.CONSTANT, TypeKind.FloatType, 0, 2.0f),
/** Push double constant 0 */ /** Push double constant 0 */
DCONST_0(Classfile.DCONST_0, 1, Kind.CONSTANT, TypeKind.DoubleType, 0, 0.0d), DCONST_0(ClassFile.DCONST_0, 1, Kind.CONSTANT, TypeKind.DoubleType, 0, 0.0d),
/** Push double constant 1 */ /** Push double constant 1 */
DCONST_1(Classfile.DCONST_1, 1, Kind.CONSTANT, TypeKind.DoubleType, 0, 1.0d), DCONST_1(ClassFile.DCONST_1, 1, Kind.CONSTANT, TypeKind.DoubleType, 0, 1.0d),
/** Push byte */ /** Push byte */
BIPUSH(Classfile.BIPUSH, 2, Kind.CONSTANT, TypeKind.ByteType), BIPUSH(ClassFile.BIPUSH, 2, Kind.CONSTANT, TypeKind.ByteType),
/** Push short */ /** Push short */
SIPUSH(Classfile.SIPUSH, 3, Kind.CONSTANT, TypeKind.ShortType), SIPUSH(ClassFile.SIPUSH, 3, Kind.CONSTANT, TypeKind.ShortType),
/** Push item from run-time constant pool */ /** Push item from run-time constant pool */
LDC(Classfile.LDC, 2, Kind.CONSTANT), LDC(ClassFile.LDC, 2, Kind.CONSTANT),
/** Push item from run-time constant pool (wide index) */ /** Push item from run-time constant pool (wide index) */
LDC_W(Classfile.LDC_W, 3, Kind.CONSTANT), LDC_W(ClassFile.LDC_W, 3, Kind.CONSTANT),
/** Push long or double from run-time constant pool (wide index) */ /** Push long or double from run-time constant pool (wide index) */
LDC2_W(Classfile.LDC2_W, 3, Kind.CONSTANT), LDC2_W(ClassFile.LDC2_W, 3, Kind.CONSTANT),
/** Load int from local variable */ /** Load int from local variable */
ILOAD(Classfile.ILOAD, 2, Kind.LOAD, TypeKind.IntType, -1), ILOAD(ClassFile.ILOAD, 2, Kind.LOAD, TypeKind.IntType, -1),
/** Load long from local variable */ /** Load long from local variable */
LLOAD(Classfile.LLOAD, 2, Kind.LOAD, TypeKind.LongType, -1), LLOAD(ClassFile.LLOAD, 2, Kind.LOAD, TypeKind.LongType, -1),
/** Load float from local variable */ /** Load float from local variable */
FLOAD(Classfile.FLOAD, 2, Kind.LOAD, TypeKind.FloatType, -1), FLOAD(ClassFile.FLOAD, 2, Kind.LOAD, TypeKind.FloatType, -1),
/** Load double from local variable */ /** Load double from local variable */
DLOAD(Classfile.DLOAD, 2, Kind.LOAD, TypeKind.DoubleType, -1), DLOAD(ClassFile.DLOAD, 2, Kind.LOAD, TypeKind.DoubleType, -1),
/** Load reference from local variable */ /** Load reference from local variable */
ALOAD(Classfile.ALOAD, 2, Kind.LOAD, TypeKind.ReferenceType, -1), ALOAD(ClassFile.ALOAD, 2, Kind.LOAD, TypeKind.ReferenceType, -1),
/** Load int from local variable 0 */ /** Load int from local variable 0 */
ILOAD_0(Classfile.ILOAD_0, 1, Kind.LOAD, TypeKind.IntType, 0), ILOAD_0(ClassFile.ILOAD_0, 1, Kind.LOAD, TypeKind.IntType, 0),
/** Load int from local variable 1 */ /** Load int from local variable 1 */
ILOAD_1(Classfile.ILOAD_1, 1, Kind.LOAD, TypeKind.IntType, 1), ILOAD_1(ClassFile.ILOAD_1, 1, Kind.LOAD, TypeKind.IntType, 1),
/** Load int from local variable 2 */ /** Load int from local variable 2 */
ILOAD_2(Classfile.ILOAD_2, 1, Kind.LOAD, TypeKind.IntType, 2), ILOAD_2(ClassFile.ILOAD_2, 1, Kind.LOAD, TypeKind.IntType, 2),
/** Load int from local variable3 */ /** Load int from local variable3 */
ILOAD_3(Classfile.ILOAD_3, 1, Kind.LOAD, TypeKind.IntType, 3), ILOAD_3(ClassFile.ILOAD_3, 1, Kind.LOAD, TypeKind.IntType, 3),
/** Load long from local variable 0 */ /** Load long from local variable 0 */
LLOAD_0(Classfile.LLOAD_0, 1, Kind.LOAD, TypeKind.LongType, 0), LLOAD_0(ClassFile.LLOAD_0, 1, Kind.LOAD, TypeKind.LongType, 0),
/** Load long from local variable 1 */ /** Load long from local variable 1 */
LLOAD_1(Classfile.LLOAD_1, 1, Kind.LOAD, TypeKind.LongType, 1), LLOAD_1(ClassFile.LLOAD_1, 1, Kind.LOAD, TypeKind.LongType, 1),
/** Load long from local variable 2 */ /** Load long from local variable 2 */
LLOAD_2(Classfile.LLOAD_2, 1, Kind.LOAD, TypeKind.LongType, 2), LLOAD_2(ClassFile.LLOAD_2, 1, Kind.LOAD, TypeKind.LongType, 2),
/** Load long from local variable 3 */ /** Load long from local variable 3 */
LLOAD_3(Classfile.LLOAD_3, 1, Kind.LOAD, TypeKind.LongType, 3), LLOAD_3(ClassFile.LLOAD_3, 1, Kind.LOAD, TypeKind.LongType, 3),
/** Load float from local variable 0 */ /** Load float from local variable 0 */
FLOAD_0(Classfile.FLOAD_0, 1, Kind.LOAD, TypeKind.FloatType, 0), FLOAD_0(ClassFile.FLOAD_0, 1, Kind.LOAD, TypeKind.FloatType, 0),
/** Load float from local variable 1 */ /** Load float from local variable 1 */
FLOAD_1(Classfile.FLOAD_1, 1, Kind.LOAD, TypeKind.FloatType, 1), FLOAD_1(ClassFile.FLOAD_1, 1, Kind.LOAD, TypeKind.FloatType, 1),
/** Load float from local variable 2 */ /** Load float from local variable 2 */
FLOAD_2(Classfile.FLOAD_2, 1, Kind.LOAD, TypeKind.FloatType, 2), FLOAD_2(ClassFile.FLOAD_2, 1, Kind.LOAD, TypeKind.FloatType, 2),
/** Load float from local variable 3 */ /** Load float from local variable 3 */
FLOAD_3(Classfile.FLOAD_3, 1, Kind.LOAD, TypeKind.FloatType, 3), FLOAD_3(ClassFile.FLOAD_3, 1, Kind.LOAD, TypeKind.FloatType, 3),
/** Load double from local variable 0 */ /** Load double from local variable 0 */
DLOAD_0(Classfile.DLOAD_0, 1, Kind.LOAD, TypeKind.DoubleType, 0), DLOAD_0(ClassFile.DLOAD_0, 1, Kind.LOAD, TypeKind.DoubleType, 0),
/** Load double from local variable 1 */ /** Load double from local variable 1 */
DLOAD_1(Classfile.DLOAD_1, 1, Kind.LOAD, TypeKind.DoubleType, 1), DLOAD_1(ClassFile.DLOAD_1, 1, Kind.LOAD, TypeKind.DoubleType, 1),
/** Load double from local variable 2 */ /** Load double from local variable 2 */
DLOAD_2(Classfile.DLOAD_2, 1, Kind.LOAD, TypeKind.DoubleType, 2), DLOAD_2(ClassFile.DLOAD_2, 1, Kind.LOAD, TypeKind.DoubleType, 2),
/** Load double from local variable 3 */ /** Load double from local variable 3 */
DLOAD_3(Classfile.DLOAD_3, 1, Kind.LOAD, TypeKind.DoubleType, 3), DLOAD_3(ClassFile.DLOAD_3, 1, Kind.LOAD, TypeKind.DoubleType, 3),
/** Load reference from local variable 0 */ /** Load reference from local variable 0 */
ALOAD_0(Classfile.ALOAD_0, 1, Kind.LOAD, TypeKind.ReferenceType, 0), ALOAD_0(ClassFile.ALOAD_0, 1, Kind.LOAD, TypeKind.ReferenceType, 0),
/** Load reference from local variable 1 */ /** Load reference from local variable 1 */
ALOAD_1(Classfile.ALOAD_1, 1, Kind.LOAD, TypeKind.ReferenceType, 1), ALOAD_1(ClassFile.ALOAD_1, 1, Kind.LOAD, TypeKind.ReferenceType, 1),
/** Load reference from local variable 2 */ /** Load reference from local variable 2 */
ALOAD_2(Classfile.ALOAD_2, 1, Kind.LOAD, TypeKind.ReferenceType, 2), ALOAD_2(ClassFile.ALOAD_2, 1, Kind.LOAD, TypeKind.ReferenceType, 2),
/** Load reference from local variable 3 */ /** Load reference from local variable 3 */
ALOAD_3(Classfile.ALOAD_3, 1, Kind.LOAD, TypeKind.ReferenceType, 3), ALOAD_3(ClassFile.ALOAD_3, 1, Kind.LOAD, TypeKind.ReferenceType, 3),
/** Load int from array */ /** Load int from array */
IALOAD(Classfile.IALOAD, 1, Kind.ARRAY_LOAD, TypeKind.IntType), IALOAD(ClassFile.IALOAD, 1, Kind.ARRAY_LOAD, TypeKind.IntType),
/** Load long from array */ /** Load long from array */
LALOAD(Classfile.LALOAD, 1, Kind.ARRAY_LOAD, TypeKind.LongType), LALOAD(ClassFile.LALOAD, 1, Kind.ARRAY_LOAD, TypeKind.LongType),
/** Load float from array */ /** Load float from array */
FALOAD(Classfile.FALOAD, 1, Kind.ARRAY_LOAD, TypeKind.FloatType), FALOAD(ClassFile.FALOAD, 1, Kind.ARRAY_LOAD, TypeKind.FloatType),
/** Load double from array */ /** Load double from array */
DALOAD(Classfile.DALOAD, 1, Kind.ARRAY_LOAD, TypeKind.DoubleType), DALOAD(ClassFile.DALOAD, 1, Kind.ARRAY_LOAD, TypeKind.DoubleType),
/** Load reference from array */ /** Load reference from array */
AALOAD(Classfile.AALOAD, 1, Kind.ARRAY_LOAD, TypeKind.ReferenceType), AALOAD(ClassFile.AALOAD, 1, Kind.ARRAY_LOAD, TypeKind.ReferenceType),
/** Load byte from array */ /** Load byte from array */
BALOAD(Classfile.BALOAD, 1, Kind.ARRAY_LOAD, TypeKind.ByteType), BALOAD(ClassFile.BALOAD, 1, Kind.ARRAY_LOAD, TypeKind.ByteType),
/** Load char from array */ /** Load char from array */
CALOAD(Classfile.CALOAD, 1, Kind.ARRAY_LOAD, TypeKind.CharType), CALOAD(ClassFile.CALOAD, 1, Kind.ARRAY_LOAD, TypeKind.CharType),
/** Load short from array */ /** Load short from array */
SALOAD(Classfile.SALOAD, 1, Kind.ARRAY_LOAD, TypeKind.ShortType), SALOAD(ClassFile.SALOAD, 1, Kind.ARRAY_LOAD, TypeKind.ShortType),
/** Store int into local variable */ /** Store int into local variable */
ISTORE(Classfile.ISTORE, 2, Kind.STORE, TypeKind.IntType, -1), ISTORE(ClassFile.ISTORE, 2, Kind.STORE, TypeKind.IntType, -1),
/** Store long into local variable */ /** Store long into local variable */
LSTORE(Classfile.LSTORE, 2, Kind.STORE, TypeKind.LongType, -1), LSTORE(ClassFile.LSTORE, 2, Kind.STORE, TypeKind.LongType, -1),
/** Store float into local variable */ /** Store float into local variable */
FSTORE(Classfile.FSTORE, 2, Kind.STORE, TypeKind.FloatType, -1), FSTORE(ClassFile.FSTORE, 2, Kind.STORE, TypeKind.FloatType, -1),
/** Store double into local variable */ /** Store double into local variable */
DSTORE(Classfile.DSTORE, 2, Kind.STORE, TypeKind.DoubleType, -1), DSTORE(ClassFile.DSTORE, 2, Kind.STORE, TypeKind.DoubleType, -1),
/** Store reference into local variable */ /** Store reference into local variable */
ASTORE(Classfile.ASTORE, 2, Kind.STORE, TypeKind.ReferenceType, -1), ASTORE(ClassFile.ASTORE, 2, Kind.STORE, TypeKind.ReferenceType, -1),
/** Store int into local variable 0 */ /** Store int into local variable 0 */
ISTORE_0(Classfile.ISTORE_0, 1, Kind.STORE, TypeKind.IntType, 0), ISTORE_0(ClassFile.ISTORE_0, 1, Kind.STORE, TypeKind.IntType, 0),
/** Store int into local variable 1 */ /** Store int into local variable 1 */
ISTORE_1(Classfile.ISTORE_1, 1, Kind.STORE, TypeKind.IntType, 1), ISTORE_1(ClassFile.ISTORE_1, 1, Kind.STORE, TypeKind.IntType, 1),
/** Store int into local variable 2 */ /** Store int into local variable 2 */
ISTORE_2(Classfile.ISTORE_2, 1, Kind.STORE, TypeKind.IntType, 2), ISTORE_2(ClassFile.ISTORE_2, 1, Kind.STORE, TypeKind.IntType, 2),
/** Store int into local variable 3 */ /** Store int into local variable 3 */
ISTORE_3(Classfile.ISTORE_3, 1, Kind.STORE, TypeKind.IntType, 3), ISTORE_3(ClassFile.ISTORE_3, 1, Kind.STORE, TypeKind.IntType, 3),
/** Store long into local variable 0 */ /** Store long into local variable 0 */
LSTORE_0(Classfile.LSTORE_0, 1, Kind.STORE, TypeKind.LongType, 0), LSTORE_0(ClassFile.LSTORE_0, 1, Kind.STORE, TypeKind.LongType, 0),
/** Store long into local variable 1 */ /** Store long into local variable 1 */
LSTORE_1(Classfile.LSTORE_1, 1, Kind.STORE, TypeKind.LongType, 1), LSTORE_1(ClassFile.LSTORE_1, 1, Kind.STORE, TypeKind.LongType, 1),
/** Store long into local variable 2 */ /** Store long into local variable 2 */
LSTORE_2(Classfile.LSTORE_2, 1, Kind.STORE, TypeKind.LongType, 2), LSTORE_2(ClassFile.LSTORE_2, 1, Kind.STORE, TypeKind.LongType, 2),
/** Store long into local variable 3 */ /** Store long into local variable 3 */
LSTORE_3(Classfile.LSTORE_3, 1, Kind.STORE, TypeKind.LongType, 3), LSTORE_3(ClassFile.LSTORE_3, 1, Kind.STORE, TypeKind.LongType, 3),
/** Store float into local variable 0 */ /** Store float into local variable 0 */
FSTORE_0(Classfile.FSTORE_0, 1, Kind.STORE, TypeKind.FloatType, 0), FSTORE_0(ClassFile.FSTORE_0, 1, Kind.STORE, TypeKind.FloatType, 0),
/** Store float into local variable 1 */ /** Store float into local variable 1 */
FSTORE_1(Classfile.FSTORE_1, 1, Kind.STORE, TypeKind.FloatType, 1), FSTORE_1(ClassFile.FSTORE_1, 1, Kind.STORE, TypeKind.FloatType, 1),
/** Store float into local variable 2 */ /** Store float into local variable 2 */
FSTORE_2(Classfile.FSTORE_2, 1, Kind.STORE, TypeKind.FloatType, 2), FSTORE_2(ClassFile.FSTORE_2, 1, Kind.STORE, TypeKind.FloatType, 2),
/** Store float into local variable 3 */ /** Store float into local variable 3 */
FSTORE_3(Classfile.FSTORE_3, 1, Kind.STORE, TypeKind.FloatType, 3), FSTORE_3(ClassFile.FSTORE_3, 1, Kind.STORE, TypeKind.FloatType, 3),
/** Store double into local variable 0 */ /** Store double into local variable 0 */
DSTORE_0(Classfile.DSTORE_0, 1, Kind.STORE, TypeKind.DoubleType, 0), DSTORE_0(ClassFile.DSTORE_0, 1, Kind.STORE, TypeKind.DoubleType, 0),
/** Store double into local variable 1 */ /** Store double into local variable 1 */
DSTORE_1(Classfile.DSTORE_1, 1, Kind.STORE, TypeKind.DoubleType, 1), DSTORE_1(ClassFile.DSTORE_1, 1, Kind.STORE, TypeKind.DoubleType, 1),
/** Store double into local variable 2 */ /** Store double into local variable 2 */
DSTORE_2(Classfile.DSTORE_2, 1, Kind.STORE, TypeKind.DoubleType, 2), DSTORE_2(ClassFile.DSTORE_2, 1, Kind.STORE, TypeKind.DoubleType, 2),
/** Store double into local variable 3 */ /** Store double into local variable 3 */
DSTORE_3(Classfile.DSTORE_3, 1, Kind.STORE, TypeKind.DoubleType, 3), DSTORE_3(ClassFile.DSTORE_3, 1, Kind.STORE, TypeKind.DoubleType, 3),
/** Store reference into local variable 0 */ /** Store reference into local variable 0 */
ASTORE_0(Classfile.ASTORE_0, 1, Kind.STORE, TypeKind.ReferenceType, 0), ASTORE_0(ClassFile.ASTORE_0, 1, Kind.STORE, TypeKind.ReferenceType, 0),
/** Store reference into local variable 1 */ /** Store reference into local variable 1 */
ASTORE_1(Classfile.ASTORE_1, 1, Kind.STORE, TypeKind.ReferenceType, 1), ASTORE_1(ClassFile.ASTORE_1, 1, Kind.STORE, TypeKind.ReferenceType, 1),
/** Store reference into local variable 2 */ /** Store reference into local variable 2 */
ASTORE_2(Classfile.ASTORE_2, 1, Kind.STORE, TypeKind.ReferenceType, 2), ASTORE_2(ClassFile.ASTORE_2, 1, Kind.STORE, TypeKind.ReferenceType, 2),
/** Store reference into local variable 3 */ /** Store reference into local variable 3 */
ASTORE_3(Classfile.ASTORE_3, 1, Kind.STORE, TypeKind.ReferenceType, 3), ASTORE_3(ClassFile.ASTORE_3, 1, Kind.STORE, TypeKind.ReferenceType, 3),
/** Store into int array */ /** Store into int array */
IASTORE(Classfile.IASTORE, 1, Kind.ARRAY_STORE, TypeKind.IntType), IASTORE(ClassFile.IASTORE, 1, Kind.ARRAY_STORE, TypeKind.IntType),
/** Store into long array */ /** Store into long array */
LASTORE(Classfile.LASTORE, 1, Kind.ARRAY_STORE, TypeKind.LongType), LASTORE(ClassFile.LASTORE, 1, Kind.ARRAY_STORE, TypeKind.LongType),
/** Store into float array */ /** Store into float array */
FASTORE(Classfile.FASTORE, 1, Kind.ARRAY_STORE, TypeKind.FloatType), FASTORE(ClassFile.FASTORE, 1, Kind.ARRAY_STORE, TypeKind.FloatType),
/** Store into double array */ /** Store into double array */
DASTORE(Classfile.DASTORE, 1, Kind.ARRAY_STORE, TypeKind.DoubleType), DASTORE(ClassFile.DASTORE, 1, Kind.ARRAY_STORE, TypeKind.DoubleType),
/** Store into reference array */ /** Store into reference array */
AASTORE(Classfile.AASTORE, 1, Kind.ARRAY_STORE, TypeKind.ReferenceType), AASTORE(ClassFile.AASTORE, 1, Kind.ARRAY_STORE, TypeKind.ReferenceType),
/** Store into byte array */ /** Store into byte array */
BASTORE(Classfile.BASTORE, 1, Kind.ARRAY_STORE, TypeKind.ByteType), BASTORE(ClassFile.BASTORE, 1, Kind.ARRAY_STORE, TypeKind.ByteType),
/** Store into char array */ /** Store into char array */
CASTORE(Classfile.CASTORE, 1, Kind.ARRAY_STORE, TypeKind.CharType), CASTORE(ClassFile.CASTORE, 1, Kind.ARRAY_STORE, TypeKind.CharType),
/** Store into short array */ /** Store into short array */
SASTORE(Classfile.SASTORE, 1, Kind.ARRAY_STORE, TypeKind.ShortType), SASTORE(ClassFile.SASTORE, 1, Kind.ARRAY_STORE, TypeKind.ShortType),
/** Pop the top operand stack value */ /** Pop the top operand stack value */
POP(Classfile.POP, 1, Kind.STACK), POP(ClassFile.POP, 1, Kind.STACK),
/** Pop the top one or two operand stack values */ /** Pop the top one or two operand stack values */
POP2(Classfile.POP2, 1, Kind.STACK), POP2(ClassFile.POP2, 1, Kind.STACK),
/** Duplicate the top operand stack value */ /** Duplicate the top operand stack value */
DUP(Classfile.DUP, 1, Kind.STACK), DUP(ClassFile.DUP, 1, Kind.STACK),
/** Duplicate the top operand stack value and insert two values down */ /** Duplicate the top operand stack value and insert two values down */
DUP_X1(Classfile.DUP_X1, 1, Kind.STACK), DUP_X1(ClassFile.DUP_X1, 1, Kind.STACK),
/** Duplicate the top operand stack value and insert two or three values down */ /** Duplicate the top operand stack value and insert two or three values down */
DUP_X2(Classfile.DUP_X2, 1, Kind.STACK), DUP_X2(ClassFile.DUP_X2, 1, Kind.STACK),
/** Duplicate the top one or two operand stack values */ /** Duplicate the top one or two operand stack values */
DUP2(Classfile.DUP2, 1, Kind.STACK), DUP2(ClassFile.DUP2, 1, Kind.STACK),
/** Duplicate the top one or two operand stack values and insert two or three values down */ /** Duplicate the top one or two operand stack values and insert two or three values down */
DUP2_X1(Classfile.DUP2_X1, 1, Kind.STACK), DUP2_X1(ClassFile.DUP2_X1, 1, Kind.STACK),
/** Duplicate the top one or two operand stack values and insert two, three, or four values down */ /** Duplicate the top one or two operand stack values and insert two, three, or four values down */
DUP2_X2(Classfile.DUP2_X2, 1, Kind.STACK), DUP2_X2(ClassFile.DUP2_X2, 1, Kind.STACK),
/** Swap the top two operand stack values */ /** Swap the top two operand stack values */
SWAP(Classfile.SWAP, 1, Kind.STACK), SWAP(ClassFile.SWAP, 1, Kind.STACK),
/** Add int */ /** Add int */
IADD(Classfile.IADD, 1, Kind.OPERATOR, TypeKind.IntType), IADD(ClassFile.IADD, 1, Kind.OPERATOR, TypeKind.IntType),
/** Add long */ /** Add long */
LADD(Classfile.LADD, 1, Kind.OPERATOR, TypeKind.LongType), LADD(ClassFile.LADD, 1, Kind.OPERATOR, TypeKind.LongType),
/** Add float */ /** Add float */
FADD(Classfile.FADD, 1, Kind.OPERATOR, TypeKind.FloatType), FADD(ClassFile.FADD, 1, Kind.OPERATOR, TypeKind.FloatType),
/** Add double */ /** Add double */
DADD(Classfile.DADD, 1, Kind.OPERATOR, TypeKind.DoubleType), DADD(ClassFile.DADD, 1, Kind.OPERATOR, TypeKind.DoubleType),
/** Subtract int */ /** Subtract int */
ISUB(Classfile.ISUB, 1, Kind.OPERATOR, TypeKind.IntType), ISUB(ClassFile.ISUB, 1, Kind.OPERATOR, TypeKind.IntType),
/** Subtract long */ /** Subtract long */
LSUB(Classfile.LSUB, 1, Kind.OPERATOR, TypeKind.LongType), LSUB(ClassFile.LSUB, 1, Kind.OPERATOR, TypeKind.LongType),
/** Subtract float */ /** Subtract float */
FSUB(Classfile.FSUB, 1, Kind.OPERATOR, TypeKind.FloatType), FSUB(ClassFile.FSUB, 1, Kind.OPERATOR, TypeKind.FloatType),
/** Subtract double */ /** Subtract double */
DSUB(Classfile.DSUB, 1, Kind.OPERATOR, TypeKind.DoubleType), DSUB(ClassFile.DSUB, 1, Kind.OPERATOR, TypeKind.DoubleType),
/** Multiply int */ /** Multiply int */
IMUL(Classfile.IMUL, 1, Kind.OPERATOR, TypeKind.IntType), IMUL(ClassFile.IMUL, 1, Kind.OPERATOR, TypeKind.IntType),
/** Multiply long */ /** Multiply long */
LMUL(Classfile.LMUL, 1, Kind.OPERATOR, TypeKind.LongType), LMUL(ClassFile.LMUL, 1, Kind.OPERATOR, TypeKind.LongType),
/** Multiply float */ /** Multiply float */
FMUL(Classfile.FMUL, 1, Kind.OPERATOR, TypeKind.FloatType), FMUL(ClassFile.FMUL, 1, Kind.OPERATOR, TypeKind.FloatType),
/** Multiply double */ /** Multiply double */
DMUL(Classfile.DMUL, 1, Kind.OPERATOR, TypeKind.DoubleType), DMUL(ClassFile.DMUL, 1, Kind.OPERATOR, TypeKind.DoubleType),
/** Divide int */ /** Divide int */
IDIV(Classfile.IDIV, 1, Kind.OPERATOR, TypeKind.IntType), IDIV(ClassFile.IDIV, 1, Kind.OPERATOR, TypeKind.IntType),
/** Divide long */ /** Divide long */
LDIV(Classfile.LDIV, 1, Kind.OPERATOR, TypeKind.LongType), LDIV(ClassFile.LDIV, 1, Kind.OPERATOR, TypeKind.LongType),
/** Divide float */ /** Divide float */
FDIV(Classfile.FDIV, 1, Kind.OPERATOR, TypeKind.FloatType), FDIV(ClassFile.FDIV, 1, Kind.OPERATOR, TypeKind.FloatType),
/** Divide double */ /** Divide double */
DDIV(Classfile.DDIV, 1, Kind.OPERATOR, TypeKind.DoubleType), DDIV(ClassFile.DDIV, 1, Kind.OPERATOR, TypeKind.DoubleType),
/** Remainder int */ /** Remainder int */
IREM(Classfile.IREM, 1, Kind.OPERATOR, TypeKind.IntType), IREM(ClassFile.IREM, 1, Kind.OPERATOR, TypeKind.IntType),
/** Remainder long */ /** Remainder long */
LREM(Classfile.LREM, 1, Kind.OPERATOR, TypeKind.LongType), LREM(ClassFile.LREM, 1, Kind.OPERATOR, TypeKind.LongType),
/** Remainder float */ /** Remainder float */
FREM(Classfile.FREM, 1, Kind.OPERATOR, TypeKind.FloatType), FREM(ClassFile.FREM, 1, Kind.OPERATOR, TypeKind.FloatType),
/** Remainder double */ /** Remainder double */
DREM(Classfile.DREM, 1, Kind.OPERATOR, TypeKind.DoubleType), DREM(ClassFile.DREM, 1, Kind.OPERATOR, TypeKind.DoubleType),
/** Negate int */ /** Negate int */
INEG(Classfile.INEG, 1, Kind.OPERATOR, TypeKind.IntType), INEG(ClassFile.INEG, 1, Kind.OPERATOR, TypeKind.IntType),
/** Negate long */ /** Negate long */
LNEG(Classfile.LNEG, 1, Kind.OPERATOR, TypeKind.LongType), LNEG(ClassFile.LNEG, 1, Kind.OPERATOR, TypeKind.LongType),
/** Negate float */ /** Negate float */
FNEG(Classfile.FNEG, 1, Kind.OPERATOR, TypeKind.FloatType), FNEG(ClassFile.FNEG, 1, Kind.OPERATOR, TypeKind.FloatType),
/** Negate double */ /** Negate double */
DNEG(Classfile.DNEG, 1, Kind.OPERATOR, TypeKind.DoubleType), DNEG(ClassFile.DNEG, 1, Kind.OPERATOR, TypeKind.DoubleType),
/** Shift left int */ /** Shift left int */
ISHL(Classfile.ISHL, 1, Kind.OPERATOR, TypeKind.IntType), ISHL(ClassFile.ISHL, 1, Kind.OPERATOR, TypeKind.IntType),
/** Shift left long */ /** Shift left long */
LSHL(Classfile.LSHL, 1, Kind.OPERATOR, TypeKind.LongType), LSHL(ClassFile.LSHL, 1, Kind.OPERATOR, TypeKind.LongType),
/** Shift right int */ /** Shift right int */
ISHR(Classfile.ISHR, 1, Kind.OPERATOR, TypeKind.IntType), ISHR(ClassFile.ISHR, 1, Kind.OPERATOR, TypeKind.IntType),
/** Shift right long */ /** Shift right long */
LSHR(Classfile.LSHR, 1, Kind.OPERATOR, TypeKind.LongType), LSHR(ClassFile.LSHR, 1, Kind.OPERATOR, TypeKind.LongType),
/** Logical shift right int */ /** Logical shift right int */
IUSHR(Classfile.IUSHR, 1, Kind.OPERATOR, TypeKind.IntType), IUSHR(ClassFile.IUSHR, 1, Kind.OPERATOR, TypeKind.IntType),
/** Logical shift right long */ /** Logical shift right long */
LUSHR(Classfile.LUSHR, 1, Kind.OPERATOR, TypeKind.LongType), LUSHR(ClassFile.LUSHR, 1, Kind.OPERATOR, TypeKind.LongType),
/** Boolean AND int */ /** Boolean AND int */
IAND(Classfile.IAND, 1, Kind.OPERATOR, TypeKind.IntType), IAND(ClassFile.IAND, 1, Kind.OPERATOR, TypeKind.IntType),
/** Boolean AND long */ /** Boolean AND long */
LAND(Classfile.LAND, 1, Kind.OPERATOR, TypeKind.LongType), LAND(ClassFile.LAND, 1, Kind.OPERATOR, TypeKind.LongType),
/** Boolean OR int */ /** Boolean OR int */
IOR(Classfile.IOR, 1, Kind.OPERATOR, TypeKind.IntType), IOR(ClassFile.IOR, 1, Kind.OPERATOR, TypeKind.IntType),
/** Boolean OR long */ /** Boolean OR long */
LOR(Classfile.LOR, 1, Kind.OPERATOR, TypeKind.LongType), LOR(ClassFile.LOR, 1, Kind.OPERATOR, TypeKind.LongType),
/** Boolean XOR int */ /** Boolean XOR int */
IXOR(Classfile.IXOR, 1, Kind.OPERATOR, TypeKind.IntType), IXOR(ClassFile.IXOR, 1, Kind.OPERATOR, TypeKind.IntType),
/** Boolean XOR long */ /** Boolean XOR long */
LXOR(Classfile.LXOR, 1, Kind.OPERATOR, TypeKind.LongType), LXOR(ClassFile.LXOR, 1, Kind.OPERATOR, TypeKind.LongType),
/** Increment local variable by constant */ /** Increment local variable by constant */
IINC(Classfile.IINC, 3, Kind.INCREMENT, TypeKind.IntType, -1), IINC(ClassFile.IINC, 3, Kind.INCREMENT, TypeKind.IntType, -1),
/** Convert int to long */ /** Convert int to long */
I2L(Classfile.I2L, 1, Kind.CONVERT, TypeKind.IntType, TypeKind.LongType), I2L(ClassFile.I2L, 1, Kind.CONVERT, TypeKind.IntType, TypeKind.LongType),
/** Convert int to float */ /** Convert int to float */
I2F(Classfile.I2F, 1, Kind.CONVERT, TypeKind.IntType, TypeKind.FloatType), I2F(ClassFile.I2F, 1, Kind.CONVERT, TypeKind.IntType, TypeKind.FloatType),
/** Convert int to double */ /** Convert int to double */
I2D(Classfile.I2D, 1, Kind.CONVERT, TypeKind.IntType, TypeKind.DoubleType), I2D(ClassFile.I2D, 1, Kind.CONVERT, TypeKind.IntType, TypeKind.DoubleType),
/** Convert long to int */ /** Convert long to int */
L2I(Classfile.L2I, 1, Kind.CONVERT, TypeKind.LongType, TypeKind.IntType), L2I(ClassFile.L2I, 1, Kind.CONVERT, TypeKind.LongType, TypeKind.IntType),
/** Convert long to float */ /** Convert long to float */
L2F(Classfile.L2F, 1, Kind.CONVERT, TypeKind.LongType, TypeKind.FloatType), L2F(ClassFile.L2F, 1, Kind.CONVERT, TypeKind.LongType, TypeKind.FloatType),
/** Convert long to double */ /** Convert long to double */
L2D(Classfile.L2D, 1, Kind.CONVERT, TypeKind.LongType, TypeKind.DoubleType), L2D(ClassFile.L2D, 1, Kind.CONVERT, TypeKind.LongType, TypeKind.DoubleType),
/** Convert float to int */ /** Convert float to int */
F2I(Classfile.F2I, 1, Kind.CONVERT, TypeKind.FloatType, TypeKind.IntType), F2I(ClassFile.F2I, 1, Kind.CONVERT, TypeKind.FloatType, TypeKind.IntType),
/** Convert float to long */ /** Convert float to long */
F2L(Classfile.F2L, 1, Kind.CONVERT, TypeKind.FloatType, TypeKind.LongType), F2L(ClassFile.F2L, 1, Kind.CONVERT, TypeKind.FloatType, TypeKind.LongType),
/** Convert float to double */ /** Convert float to double */
F2D(Classfile.F2D, 1, Kind.CONVERT, TypeKind.FloatType, TypeKind.DoubleType), F2D(ClassFile.F2D, 1, Kind.CONVERT, TypeKind.FloatType, TypeKind.DoubleType),
/** Convert double to int */ /** Convert double to int */
D2I(Classfile.D2I, 1, Kind.CONVERT, TypeKind.DoubleType, TypeKind.IntType), D2I(ClassFile.D2I, 1, Kind.CONVERT, TypeKind.DoubleType, TypeKind.IntType),
/** Convert double to long */ /** Convert double to long */
D2L(Classfile.D2L, 1, Kind.CONVERT, TypeKind.DoubleType, TypeKind.LongType), D2L(ClassFile.D2L, 1, Kind.CONVERT, TypeKind.DoubleType, TypeKind.LongType),
/** Convert double to float */ /** Convert double to float */
D2F(Classfile.D2F, 1, Kind.CONVERT, TypeKind.DoubleType, TypeKind.FloatType), D2F(ClassFile.D2F, 1, Kind.CONVERT, TypeKind.DoubleType, TypeKind.FloatType),
/** Convert int to byte */ /** Convert int to byte */
I2B(Classfile.I2B, 1, Kind.CONVERT, TypeKind.IntType, TypeKind.ByteType), I2B(ClassFile.I2B, 1, Kind.CONVERT, TypeKind.IntType, TypeKind.ByteType),
/** Convert int to char */ /** Convert int to char */
I2C(Classfile.I2C, 1, Kind.CONVERT, TypeKind.IntType, TypeKind.CharType), I2C(ClassFile.I2C, 1, Kind.CONVERT, TypeKind.IntType, TypeKind.CharType),
/** Convert int to short */ /** Convert int to short */
I2S(Classfile.I2S, 1, Kind.CONVERT, TypeKind.IntType, TypeKind.ShortType), I2S(ClassFile.I2S, 1, Kind.CONVERT, TypeKind.IntType, TypeKind.ShortType),
/** Compare long */ /** Compare long */
LCMP(Classfile.LCMP, 1, Kind.OPERATOR, TypeKind.LongType), LCMP(ClassFile.LCMP, 1, Kind.OPERATOR, TypeKind.LongType),
/** Compare float */ /** Compare float */
FCMPL(Classfile.FCMPL, 1, Kind.OPERATOR, TypeKind.FloatType), FCMPL(ClassFile.FCMPL, 1, Kind.OPERATOR, TypeKind.FloatType),
/** Compare float */ /** Compare float */
FCMPG(Classfile.FCMPG, 1, Kind.OPERATOR, TypeKind.FloatType), FCMPG(ClassFile.FCMPG, 1, Kind.OPERATOR, TypeKind.FloatType),
/** Compare double */ /** Compare double */
DCMPL(Classfile.DCMPL, 1, Kind.OPERATOR, TypeKind.DoubleType), DCMPL(ClassFile.DCMPL, 1, Kind.OPERATOR, TypeKind.DoubleType),
/** Compare double */ /** Compare double */
DCMPG(Classfile.DCMPG, 1, Kind.OPERATOR, TypeKind.DoubleType), DCMPG(ClassFile.DCMPG, 1, Kind.OPERATOR, TypeKind.DoubleType),
/** Branch if int comparison with zero succeeds */ /** Branch if int comparison with zero succeeds */
IFEQ(Classfile.IFEQ, 3, Kind.BRANCH, TypeKind.IntType), IFEQ(ClassFile.IFEQ, 3, Kind.BRANCH, TypeKind.IntType),
/** Branch if int comparison with zero succeeds */ /** Branch if int comparison with zero succeeds */
IFNE(Classfile.IFNE, 3, Kind.BRANCH, TypeKind.IntType), IFNE(ClassFile.IFNE, 3, Kind.BRANCH, TypeKind.IntType),
/** Branch if int comparison with zero succeeds */ /** Branch if int comparison with zero succeeds */
IFLT(Classfile.IFLT, 3, Kind.BRANCH, TypeKind.IntType), IFLT(ClassFile.IFLT, 3, Kind.BRANCH, TypeKind.IntType),
/** Branch if int comparison with zero succeeds */ /** Branch if int comparison with zero succeeds */
IFGE(Classfile.IFGE, 3, Kind.BRANCH, TypeKind.IntType), IFGE(ClassFile.IFGE, 3, Kind.BRANCH, TypeKind.IntType),
/** Branch if int comparison with zero succeeds */ /** Branch if int comparison with zero succeeds */
IFGT(Classfile.IFGT, 3, Kind.BRANCH, TypeKind.IntType), IFGT(ClassFile.IFGT, 3, Kind.BRANCH, TypeKind.IntType),
/** Branch if int comparison with zero succeeds */ /** Branch if int comparison with zero succeeds */
IFLE(Classfile.IFLE, 3, Kind.BRANCH, TypeKind.IntType), IFLE(ClassFile.IFLE, 3, Kind.BRANCH, TypeKind.IntType),
/** Branch if int comparison succeeds */ /** Branch if int comparison succeeds */
IF_ICMPEQ(Classfile.IF_ICMPEQ, 3, Kind.BRANCH, TypeKind.IntType), IF_ICMPEQ(ClassFile.IF_ICMPEQ, 3, Kind.BRANCH, TypeKind.IntType),
/** Branch if int comparison succeeds */ /** Branch if int comparison succeeds */
IF_ICMPNE(Classfile.IF_ICMPNE, 3, Kind.BRANCH, TypeKind.IntType), IF_ICMPNE(ClassFile.IF_ICMPNE, 3, Kind.BRANCH, TypeKind.IntType),
/** Branch if int comparison succeeds */ /** Branch if int comparison succeeds */
IF_ICMPLT(Classfile.IF_ICMPLT, 3, Kind.BRANCH, TypeKind.IntType), IF_ICMPLT(ClassFile.IF_ICMPLT, 3, Kind.BRANCH, TypeKind.IntType),
/** Branch if int comparison succeeds */ /** Branch if int comparison succeeds */
IF_ICMPGE(Classfile.IF_ICMPGE, 3, Kind.BRANCH, TypeKind.IntType), IF_ICMPGE(ClassFile.IF_ICMPGE, 3, Kind.BRANCH, TypeKind.IntType),
/** Branch if int comparison succeeds */ /** Branch if int comparison succeeds */
IF_ICMPGT(Classfile.IF_ICMPGT, 3, Kind.BRANCH, TypeKind.IntType), IF_ICMPGT(ClassFile.IF_ICMPGT, 3, Kind.BRANCH, TypeKind.IntType),
/** Branch if int comparison succeeds */ /** Branch if int comparison succeeds */
IF_ICMPLE(Classfile.IF_ICMPLE, 3, Kind.BRANCH, TypeKind.IntType), IF_ICMPLE(ClassFile.IF_ICMPLE, 3, Kind.BRANCH, TypeKind.IntType),
/** Branch if reference comparison succeeds */ /** Branch if reference comparison succeeds */
IF_ACMPEQ(Classfile.IF_ACMPEQ, 3, Kind.BRANCH, TypeKind.ReferenceType), IF_ACMPEQ(ClassFile.IF_ACMPEQ, 3, Kind.BRANCH, TypeKind.ReferenceType),
/** Branch if reference comparison succeeds */ /** Branch if reference comparison succeeds */
IF_ACMPNE(Classfile.IF_ACMPNE, 3, Kind.BRANCH, TypeKind.ReferenceType), IF_ACMPNE(ClassFile.IF_ACMPNE, 3, Kind.BRANCH, TypeKind.ReferenceType),
/** Branch always */ /** Branch always */
GOTO(Classfile.GOTO, 3, Kind.BRANCH, TypeKind.VoidType), GOTO(ClassFile.GOTO, 3, Kind.BRANCH, TypeKind.VoidType),
/** Jump subroutine */ /**
JSR(Classfile.JSR, 3, Kind.DISCONTINUED_JSR), * Jump subroutine is discontinued opcode
* @see java.lang.classfile.instruction.DiscontinuedInstruction
*/
JSR(ClassFile.JSR, 3, Kind.DISCONTINUED_JSR),
/** Return from subroutine */ /**
RET(Classfile.RET, 2, Kind.DISCONTINUED_RET), * Return from subroutine is discontinued opcode
* @see java.lang.classfile.instruction.DiscontinuedInstruction
*/
RET(ClassFile.RET, 2, Kind.DISCONTINUED_RET),
/** Access jump table by index and jump */ /** Access jump table by index and jump */
TABLESWITCH(Classfile.TABLESWITCH, -1, Kind.TABLE_SWITCH), TABLESWITCH(ClassFile.TABLESWITCH, -1, Kind.TABLE_SWITCH),
/** Access jump table by key match and jump */ /** Access jump table by key match and jump */
LOOKUPSWITCH(Classfile.LOOKUPSWITCH, -1, Kind.LOOKUP_SWITCH), LOOKUPSWITCH(ClassFile.LOOKUPSWITCH, -1, Kind.LOOKUP_SWITCH),
/** Return int from method */ /** Return int from method */
IRETURN(Classfile.IRETURN, 1, Kind.RETURN, TypeKind.IntType), IRETURN(ClassFile.IRETURN, 1, Kind.RETURN, TypeKind.IntType),
/** Return long from method */ /** Return long from method */
LRETURN(Classfile.LRETURN, 1, Kind.RETURN, TypeKind.LongType), LRETURN(ClassFile.LRETURN, 1, Kind.RETURN, TypeKind.LongType),
/** Return float from method */ /** Return float from method */
FRETURN(Classfile.FRETURN, 1, Kind.RETURN, TypeKind.FloatType), FRETURN(ClassFile.FRETURN, 1, Kind.RETURN, TypeKind.FloatType),
/** Return double from method */ /** Return double from method */
DRETURN(Classfile.DRETURN, 1, Kind.RETURN, TypeKind.DoubleType), DRETURN(ClassFile.DRETURN, 1, Kind.RETURN, TypeKind.DoubleType),
/** Return reference from method */ /** Return reference from method */
ARETURN(Classfile.ARETURN, 1, Kind.RETURN, TypeKind.ReferenceType), ARETURN(ClassFile.ARETURN, 1, Kind.RETURN, TypeKind.ReferenceType),
/** Return void from method */ /** Return void from method */
RETURN(Classfile.RETURN, 1, Kind.RETURN, TypeKind.VoidType), RETURN(ClassFile.RETURN, 1, Kind.RETURN, TypeKind.VoidType),
/** Get static field from class */ /** Get static field from class */
GETSTATIC(Classfile.GETSTATIC, 3, Kind.FIELD_ACCESS), GETSTATIC(ClassFile.GETSTATIC, 3, Kind.FIELD_ACCESS),
/** Set static field in class */ /** Set static field in class */
PUTSTATIC(Classfile.PUTSTATIC, 3, Kind.FIELD_ACCESS), PUTSTATIC(ClassFile.PUTSTATIC, 3, Kind.FIELD_ACCESS),
/** Fetch field from object */ /** Fetch field from object */
GETFIELD(Classfile.GETFIELD, 3, Kind.FIELD_ACCESS), GETFIELD(ClassFile.GETFIELD, 3, Kind.FIELD_ACCESS),
/** Set field in object */ /** Set field in object */
PUTFIELD(Classfile.PUTFIELD, 3, Kind.FIELD_ACCESS), PUTFIELD(ClassFile.PUTFIELD, 3, Kind.FIELD_ACCESS),
/** Invoke instance method; dispatch based on class */ /** Invoke instance method; dispatch based on class */
INVOKEVIRTUAL(Classfile.INVOKEVIRTUAL, 3, Kind.INVOKE), INVOKEVIRTUAL(ClassFile.INVOKEVIRTUAL, 3, Kind.INVOKE),
/** /**
* Invoke instance method; direct invocation of instance initialization * Invoke instance method; direct invocation of instance initialization
* methods and methods of the current class and its supertypes * methods and methods of the current class and its supertypes
*/ */
INVOKESPECIAL(Classfile.INVOKESPECIAL, 3, Kind.INVOKE), INVOKESPECIAL(ClassFile.INVOKESPECIAL, 3, Kind.INVOKE),
/** Invoke a class (static) method */ /** Invoke a class (static) method */
INVOKESTATIC(Classfile.INVOKESTATIC, 3, Kind.INVOKE), INVOKESTATIC(ClassFile.INVOKESTATIC, 3, Kind.INVOKE),
/** Invoke interface method */ /** Invoke interface method */
INVOKEINTERFACE(Classfile.INVOKEINTERFACE, 5, Kind.INVOKE), INVOKEINTERFACE(ClassFile.INVOKEINTERFACE, 5, Kind.INVOKE),
/** Invoke a dynamically-computed call site */ /** Invoke a dynamically-computed call site */
INVOKEDYNAMIC(Classfile.INVOKEDYNAMIC, 5, Kind.INVOKE_DYNAMIC), INVOKEDYNAMIC(ClassFile.INVOKEDYNAMIC, 5, Kind.INVOKE_DYNAMIC),
/** Create new object */ /** Create new object */
NEW(Classfile.NEW, 3, Kind.NEW_OBJECT), NEW(ClassFile.NEW, 3, Kind.NEW_OBJECT),
/** Create new array */ /** Create new array */
NEWARRAY(Classfile.NEWARRAY, 2, Kind.NEW_PRIMITIVE_ARRAY), NEWARRAY(ClassFile.NEWARRAY, 2, Kind.NEW_PRIMITIVE_ARRAY),
/** Create new array of reference */ /** Create new array of reference */
ANEWARRAY(Classfile.ANEWARRAY, 3, Kind.NEW_REF_ARRAY), ANEWARRAY(ClassFile.ANEWARRAY, 3, Kind.NEW_REF_ARRAY),
/** Get length of array */ /** Get length of array */
ARRAYLENGTH(Classfile.ARRAYLENGTH, 1, Kind.OPERATOR, TypeKind.IntType), ARRAYLENGTH(ClassFile.ARRAYLENGTH, 1, Kind.OPERATOR, TypeKind.IntType),
/** Throw exception or error */ /** Throw exception or error */
ATHROW(Classfile.ATHROW, 1, Kind.THROW_EXCEPTION), ATHROW(ClassFile.ATHROW, 1, Kind.THROW_EXCEPTION),
/** Check whether object is of given type */ /** Check whether object is of given type */
CHECKCAST(Classfile.CHECKCAST, 3, Kind.TYPE_CHECK), CHECKCAST(ClassFile.CHECKCAST, 3, Kind.TYPE_CHECK),
/** Determine if object is of given type */ /** Determine if object is of given type */
INSTANCEOF(Classfile.INSTANCEOF, 3, Kind.TYPE_CHECK), INSTANCEOF(ClassFile.INSTANCEOF, 3, Kind.TYPE_CHECK),
/** Enter monitor for object */ /** Enter monitor for object */
MONITORENTER(Classfile.MONITORENTER, 1, Kind.MONITOR), MONITORENTER(ClassFile.MONITORENTER, 1, Kind.MONITOR),
/** Exit monitor for object */ /** Exit monitor for object */
MONITOREXIT(Classfile.MONITOREXIT, 1, Kind.MONITOR), MONITOREXIT(ClassFile.MONITOREXIT, 1, Kind.MONITOR),
/** Create new multidimensional array */ /** Create new multidimensional array */
MULTIANEWARRAY(Classfile.MULTIANEWARRAY, 4, Kind.NEW_MULTI_ARRAY), MULTIANEWARRAY(ClassFile.MULTIANEWARRAY, 4, Kind.NEW_MULTI_ARRAY),
/** Branch if reference is null */ /** Branch if reference is null */
IFNULL(Classfile.IFNULL, 3, Kind.BRANCH, TypeKind.ReferenceType), IFNULL(ClassFile.IFNULL, 3, Kind.BRANCH, TypeKind.ReferenceType),
/** Branch if reference not null */ /** Branch if reference not null */
IFNONNULL(Classfile.IFNONNULL, 3, Kind.BRANCH, TypeKind.IntType), IFNONNULL(ClassFile.IFNONNULL, 3, Kind.BRANCH, TypeKind.IntType),
/** Branch always (wide index) */ /** Branch always (wide index) */
GOTO_W(Classfile.GOTO_W, 5, Kind.BRANCH, TypeKind.VoidType), GOTO_W(ClassFile.GOTO_W, 5, Kind.BRANCH, TypeKind.VoidType),
/** Jump subroutine (wide index) */ /**
JSR_W(Classfile.JSR_W, 5, Kind.DISCONTINUED_JSR), * Jump subroutine (wide index) is discontinued opcode
* @see java.lang.classfile.instruction.DiscontinuedInstruction
*/
JSR_W(ClassFile.JSR_W, 5, Kind.DISCONTINUED_JSR),
/** Load int from local variable (wide index) */ /** Load int from local variable (wide index) */
ILOAD_W((Classfile.WIDE << 8) | Classfile.ILOAD, 4, Kind.LOAD, TypeKind.IntType, -1), ILOAD_W((ClassFile.WIDE << 8) | ClassFile.ILOAD, 4, Kind.LOAD, TypeKind.IntType, -1),
/** Load long from local variable (wide index) */ /** Load long from local variable (wide index) */
LLOAD_W((Classfile.WIDE << 8) | Classfile.LLOAD, 4, Kind.LOAD, TypeKind.LongType, -1), LLOAD_W((ClassFile.WIDE << 8) | ClassFile.LLOAD, 4, Kind.LOAD, TypeKind.LongType, -1),
/** Load float from local variable (wide index) */ /** Load float from local variable (wide index) */
FLOAD_W((Classfile.WIDE << 8) | Classfile.FLOAD, 4, Kind.LOAD, TypeKind.FloatType, -1), FLOAD_W((ClassFile.WIDE << 8) | ClassFile.FLOAD, 4, Kind.LOAD, TypeKind.FloatType, -1),
/** Load double from local variable (wide index) */ /** Load double from local variable (wide index) */
DLOAD_W((Classfile.WIDE << 8) | Classfile.DLOAD, 4, Kind.LOAD, TypeKind.DoubleType, -1), DLOAD_W((ClassFile.WIDE << 8) | ClassFile.DLOAD, 4, Kind.LOAD, TypeKind.DoubleType, -1),
/** Load reference from local variable (wide index) */ /** Load reference from local variable (wide index) */
ALOAD_W((Classfile.WIDE << 8) | Classfile.ALOAD, 4, Kind.LOAD, TypeKind.ReferenceType, -1), ALOAD_W((ClassFile.WIDE << 8) | ClassFile.ALOAD, 4, Kind.LOAD, TypeKind.ReferenceType, -1),
/** Store int into local variable (wide index) */ /** Store int into local variable (wide index) */
ISTORE_W((Classfile.WIDE << 8) | Classfile.ISTORE, 4, Kind.STORE, TypeKind.IntType, -1), ISTORE_W((ClassFile.WIDE << 8) | ClassFile.ISTORE, 4, Kind.STORE, TypeKind.IntType, -1),
/** Store long into local variable (wide index) */ /** Store long into local variable (wide index) */
LSTORE_W((Classfile.WIDE << 8) | Classfile.LSTORE, 4, Kind.STORE, TypeKind.LongType, -1), LSTORE_W((ClassFile.WIDE << 8) | ClassFile.LSTORE, 4, Kind.STORE, TypeKind.LongType, -1),
/** Store float into local variable (wide index) */ /** Store float into local variable (wide index) */
FSTORE_W((Classfile.WIDE << 8) | Classfile.FSTORE, 4, Kind.STORE, TypeKind.FloatType, -1), FSTORE_W((ClassFile.WIDE << 8) | ClassFile.FSTORE, 4, Kind.STORE, TypeKind.FloatType, -1),
/** Store double into local variable (wide index) */ /** Store double into local variable (wide index) */
DSTORE_W((Classfile.WIDE << 8) | Classfile.DSTORE, 4, Kind.STORE, TypeKind.DoubleType, -1), DSTORE_W((ClassFile.WIDE << 8) | ClassFile.DSTORE, 4, Kind.STORE, TypeKind.DoubleType, -1),
/** Store reference into local variable (wide index) */ /** Store reference into local variable (wide index) */
ASTORE_W((Classfile.WIDE << 8) | Classfile.ASTORE, 4, Kind.STORE, TypeKind.ReferenceType, -1), ASTORE_W((ClassFile.WIDE << 8) | ClassFile.ASTORE, 4, Kind.STORE, TypeKind.ReferenceType, -1),
/** Return from subroutine (wide index) */ /**
RET_W((Classfile.WIDE << 8) | Classfile.RET, 4, Kind.DISCONTINUED_RET), * Return from subroutine (wide index) is discontinued opcode
* @see java.lang.classfile.instruction.DiscontinuedInstruction
*/
RET_W((ClassFile.WIDE << 8) | ClassFile.RET, 4, Kind.DISCONTINUED_RET),
/** Increment local variable by constant (wide index) */ /** Increment local variable by constant (wide index) */
IINC_W((Classfile.WIDE << 8) | Classfile.IINC, 6, Kind.INCREMENT, TypeKind.IntType, -1); IINC_W((ClassFile.WIDE << 8) | ClassFile.IINC, 6, Kind.INCREMENT, TypeKind.IntType, -1);
/** /**
* Kinds of opcodes. * Kinds of opcodes.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public static enum Kind { public static enum Kind {
/** /**
@ -1042,6 +1061,7 @@ public enum Opcode {
* *
* @see Opcode#JSR * @see Opcode#JSR
* @see Opcode#JSR_W * @see Opcode#JSR_W
* @see java.lang.classfile.instruction.DiscontinuedInstruction
*/ */
DISCONTINUED_JSR, DISCONTINUED_JSR,
@ -1050,6 +1070,7 @@ public enum Opcode {
* *
* @see Opcode#RET * @see Opcode#RET
* @see Opcode#RET_W * @see Opcode#RET_W
* @see java.lang.classfile.instruction.DiscontinuedInstruction
*/ */
DISCONTINUED_RET; DISCONTINUED_RET;
} }

View file

@ -22,16 +22,17 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
package jdk.internal.classfile; package java.lang.classfile;
import jdk.internal.classfile.attribute.CodeAttribute; import java.lang.classfile.attribute.CodeAttribute;
import jdk.internal.classfile.instruction.CharacterRange; import java.lang.classfile.instruction.CharacterRange;
import jdk.internal.classfile.instruction.ExceptionCatch; import java.lang.classfile.instruction.ExceptionCatch;
import jdk.internal.classfile.instruction.LabelTarget; import java.lang.classfile.instruction.LabelTarget;
import jdk.internal.classfile.instruction.LineNumber; import java.lang.classfile.instruction.LineNumber;
import jdk.internal.classfile.instruction.LocalVariable; import java.lang.classfile.instruction.LocalVariable;
import jdk.internal.classfile.instruction.LocalVariableType; import java.lang.classfile.instruction.LocalVariableType;
import jdk.internal.classfile.impl.AbstractPseudoInstruction; import jdk.internal.classfile.impl.AbstractPseudoInstruction;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models metadata about a {@link CodeAttribute}, such as entries in the * Models metadata about a {@link CodeAttribute}, such as entries in the
@ -39,8 +40,11 @@ import jdk.internal.classfile.impl.AbstractPseudoInstruction;
* between instructions and labels. Pseudo-instructions are delivered as part * between instructions and labels. Pseudo-instructions are delivered as part
* of the element stream of a {@link CodeModel}. Delivery of some * of the element stream of a {@link CodeModel}. Delivery of some
* pseudo-instructions can be disabled by modifying the value of classfile * pseudo-instructions can be disabled by modifying the value of classfile
* options (e.g., {@link Classfile.DebugElementsOption}). * options (e.g., {@link ClassFile.DebugElementsOption}).
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface PseudoInstruction public sealed interface PseudoInstruction
extends CodeElement extends CodeElement
permits CharacterRange, ExceptionCatch, LabelTarget, LineNumber, LocalVariable, LocalVariableType, AbstractPseudoInstruction { permits CharacterRange, ExceptionCatch, LabelTarget, LineNumber, LocalVariable, LocalVariableType, AbstractPseudoInstruction {

View file

@ -22,7 +22,7 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
package jdk.internal.classfile; package java.lang.classfile;
import java.lang.constant.ClassDesc; import java.lang.constant.ClassDesc;
import jdk.internal.classfile.impl.SignaturesImpl; import jdk.internal.classfile.impl.SignaturesImpl;
@ -31,10 +31,15 @@ import java.util.List;
import static java.util.Objects.requireNonNull; import static java.util.Objects.requireNonNull;
import java.util.Optional; import java.util.Optional;
import jdk.internal.classfile.impl.Util; import jdk.internal.classfile.impl.Util;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models generic Java type signatures, as defined in {@jvms 4.7.9.1}. * Models generic Java type signatures, as defined in {@jvms 4.7.9.1}.
*
* @sealedGraph
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface Signature { public sealed interface Signature {
/** {@return the raw signature string} */ /** {@return the raw signature string} */
@ -50,8 +55,8 @@ public sealed interface Signature {
} }
/** /**
* {@return a Java type signature}
* @param classDesc the symbolic description of the Java type * @param classDesc the symbolic description of the Java type
* @return Java type signature
*/ */
public static Signature of(ClassDesc classDesc) { public static Signature of(ClassDesc classDesc) {
requireNonNull(classDesc); requireNonNull(classDesc);
@ -64,7 +69,10 @@ public sealed interface Signature {
/** /**
* Models the signature of a primitive type or void * Models the signature of a primitive type or void
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface BaseTypeSig extends Signature public sealed interface BaseTypeSig extends Signature
permits SignaturesImpl.BaseTypeSigImpl { permits SignaturesImpl.BaseTypeSigImpl {
@ -97,7 +105,11 @@ public sealed interface Signature {
/** /**
* Models the signature of a reference type, which may be a class, interface, * Models the signature of a reference type, which may be a class, interface,
* type variable, or array type. * type variable, or array type.
*
* @sealedGraph
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface RefTypeSig public sealed interface RefTypeSig
extends Signature extends Signature
permits ArrayTypeSig, ClassTypeSig, TypeVarSig { permits ArrayTypeSig, ClassTypeSig, TypeVarSig {
@ -105,7 +117,10 @@ public sealed interface Signature {
/** /**
* Models the signature of a possibly-parameterized class or interface type. * Models the signature of a possibly-parameterized class or interface type.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface ClassTypeSig public sealed interface ClassTypeSig
extends RefTypeSig, ThrowableSig extends RefTypeSig, ThrowableSig
permits SignaturesImpl.ClassTypeSigImpl { permits SignaturesImpl.ClassTypeSigImpl {
@ -169,14 +184,20 @@ public sealed interface Signature {
/** /**
* Models the type argument. * Models the type argument.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface TypeArg public sealed interface TypeArg
permits SignaturesImpl.TypeArgImpl { permits SignaturesImpl.TypeArgImpl {
/** /**
* Indicator for whether a wildcard has default bound, no bound, * Indicator for whether a wildcard has default bound, no bound,
* an upper bound, or a lower bound * an upper bound, or a lower bound
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public enum WildcardIndicator { public enum WildcardIndicator {
/** /**
@ -252,7 +273,10 @@ public sealed interface Signature {
/** /**
* Models the signature of a type variable. * Models the signature of a type variable.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface TypeVarSig public sealed interface TypeVarSig
extends RefTypeSig, ThrowableSig extends RefTypeSig, ThrowableSig
permits SignaturesImpl.TypeVarSigImpl { permits SignaturesImpl.TypeVarSigImpl {
@ -271,7 +295,10 @@ public sealed interface Signature {
/** /**
* Models the signature of an array type. * Models the signature of an array type.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface ArrayTypeSig public sealed interface ArrayTypeSig
extends RefTypeSig extends RefTypeSig
permits SignaturesImpl.ArrayTypeSigImpl { permits SignaturesImpl.ArrayTypeSigImpl {
@ -304,7 +331,10 @@ public sealed interface Signature {
/** /**
* Models a signature for a type parameter of a generic class or method. * Models a signature for a type parameter of a generic class or method.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface TypeParam public sealed interface TypeParam
permits SignaturesImpl.TypeParamImpl { permits SignaturesImpl.TypeParamImpl {
@ -346,7 +376,11 @@ public sealed interface Signature {
/** /**
* Models a signature for a throwable type. * Models a signature for a throwable type.
*
* @sealedGraph
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface ThrowableSig extends Signature { public sealed interface ThrowableSig extends Signature {
} }
} }

View file

@ -22,15 +22,19 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
package jdk.internal.classfile; package java.lang.classfile;
import jdk.internal.classfile.constantpool.ClassEntry; import java.lang.classfile.constantpool.ClassEntry;
import jdk.internal.classfile.impl.SuperclassImpl; import jdk.internal.classfile.impl.SuperclassImpl;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models the superclass of a class. Delivered as a {@link * Models the superclass of a class. Delivered as a {@link
* jdk.internal.classfile.ClassElement} when traversing a {@link ClassModel}. * java.lang.classfile.ClassElement} when traversing a {@link ClassModel}.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface Superclass public sealed interface Superclass
extends ClassElement extends ClassElement
permits SuperclassImpl { permits SuperclassImpl {

View file

@ -23,54 +23,61 @@
* questions. * questions.
*/ */
package jdk.internal.classfile; package java.lang.classfile;
import java.lang.constant.ClassDesc; import java.lang.constant.ClassDesc;
import java.util.List; import java.util.List;
import jdk.internal.classfile.attribute.RuntimeInvisibleTypeAnnotationsAttribute; import java.lang.classfile.attribute.RuntimeInvisibleTypeAnnotationsAttribute;
import jdk.internal.classfile.attribute.RuntimeVisibleTypeAnnotationsAttribute; import java.lang.classfile.attribute.RuntimeVisibleTypeAnnotationsAttribute;
import jdk.internal.classfile.constantpool.Utf8Entry; import java.lang.classfile.constantpool.Utf8Entry;
import jdk.internal.classfile.impl.TargetInfoImpl; import jdk.internal.classfile.impl.TargetInfoImpl;
import jdk.internal.classfile.impl.UnboundAttribute; import jdk.internal.classfile.impl.UnboundAttribute;
import static jdk.internal.classfile.Classfile.TAT_CAST; import static java.lang.classfile.ClassFile.TAT_CAST;
import static jdk.internal.classfile.Classfile.TAT_CLASS_EXTENDS; import static java.lang.classfile.ClassFile.TAT_CLASS_EXTENDS;
import static jdk.internal.classfile.Classfile.TAT_CLASS_TYPE_PARAMETER; import static java.lang.classfile.ClassFile.TAT_CLASS_TYPE_PARAMETER;
import static jdk.internal.classfile.Classfile.TAT_CLASS_TYPE_PARAMETER_BOUND; import static java.lang.classfile.ClassFile.TAT_CLASS_TYPE_PARAMETER_BOUND;
import static jdk.internal.classfile.Classfile.TAT_CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT; import static java.lang.classfile.ClassFile.TAT_CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT;
import static jdk.internal.classfile.Classfile.TAT_CONSTRUCTOR_REFERENCE; import static java.lang.classfile.ClassFile.TAT_CONSTRUCTOR_REFERENCE;
import static jdk.internal.classfile.Classfile.TAT_CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT; import static java.lang.classfile.ClassFile.TAT_CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT;
import static jdk.internal.classfile.Classfile.TAT_EXCEPTION_PARAMETER; import static java.lang.classfile.ClassFile.TAT_EXCEPTION_PARAMETER;
import static jdk.internal.classfile.Classfile.TAT_FIELD; import static java.lang.classfile.ClassFile.TAT_FIELD;
import static jdk.internal.classfile.Classfile.TAT_INSTANCEOF; import static java.lang.classfile.ClassFile.TAT_INSTANCEOF;
import static jdk.internal.classfile.Classfile.TAT_LOCAL_VARIABLE; import static java.lang.classfile.ClassFile.TAT_LOCAL_VARIABLE;
import static jdk.internal.classfile.Classfile.TAT_METHOD_FORMAL_PARAMETER; import static java.lang.classfile.ClassFile.TAT_METHOD_FORMAL_PARAMETER;
import static jdk.internal.classfile.Classfile.TAT_METHOD_INVOCATION_TYPE_ARGUMENT; import static java.lang.classfile.ClassFile.TAT_METHOD_INVOCATION_TYPE_ARGUMENT;
import static jdk.internal.classfile.Classfile.TAT_METHOD_RECEIVER; import static java.lang.classfile.ClassFile.TAT_METHOD_RECEIVER;
import static jdk.internal.classfile.Classfile.TAT_METHOD_REFERENCE; import static java.lang.classfile.ClassFile.TAT_METHOD_REFERENCE;
import static jdk.internal.classfile.Classfile.TAT_METHOD_REFERENCE_TYPE_ARGUMENT; import static java.lang.classfile.ClassFile.TAT_METHOD_REFERENCE_TYPE_ARGUMENT;
import static jdk.internal.classfile.Classfile.TAT_METHOD_RETURN; import static java.lang.classfile.ClassFile.TAT_METHOD_RETURN;
import static jdk.internal.classfile.Classfile.TAT_METHOD_TYPE_PARAMETER; import static java.lang.classfile.ClassFile.TAT_METHOD_TYPE_PARAMETER;
import static jdk.internal.classfile.Classfile.TAT_METHOD_TYPE_PARAMETER_BOUND; import static java.lang.classfile.ClassFile.TAT_METHOD_TYPE_PARAMETER_BOUND;
import static jdk.internal.classfile.Classfile.TAT_NEW; import static java.lang.classfile.ClassFile.TAT_NEW;
import static jdk.internal.classfile.Classfile.TAT_RESOURCE_VARIABLE; import static java.lang.classfile.ClassFile.TAT_RESOURCE_VARIABLE;
import static jdk.internal.classfile.Classfile.TAT_THROWS; import static java.lang.classfile.ClassFile.TAT_THROWS;
import jdk.internal.classfile.impl.TemporaryConstantPool; import jdk.internal.classfile.impl.TemporaryConstantPool;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models an annotation on a type use, as defined in {@jvms 4.7.19} and {@jvms 4.7.20}. * Models an annotation on a type use, as defined in {@jvms 4.7.19} and {@jvms 4.7.20}.
* *
* @see RuntimeVisibleTypeAnnotationsAttribute * @see RuntimeVisibleTypeAnnotationsAttribute
* @see RuntimeInvisibleTypeAnnotationsAttribute * @see RuntimeInvisibleTypeAnnotationsAttribute
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface TypeAnnotation public sealed interface TypeAnnotation
extends Annotation extends Annotation
permits UnboundAttribute.UnboundTypeAnnotation { permits UnboundAttribute.UnboundTypeAnnotation {
/** /**
* The kind of target on which the annotation appears, as defined in {@jvms 4.7.20.1}. * The kind of target on which the annotation appears, as defined in {@jvms 4.7.20.1}.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public enum TargetType { public enum TargetType {
/** For annotations on a class type parameter declaration. */ /** For annotations on a class type parameter declaration. */
CLASS_TYPE_PARAMETER(TAT_CLASS_TYPE_PARAMETER, 1), CLASS_TYPE_PARAMETER(TAT_CLASS_TYPE_PARAMETER, 1),
@ -228,7 +235,11 @@ public sealed interface TypeAnnotation
/** /**
* Specifies which type in a declaration or expression is being annotated. * Specifies which type in a declaration or expression is being annotated.
*
* @sealedGraph
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
sealed interface TargetInfo { sealed interface TargetInfo {
/** /**
@ -392,9 +403,9 @@ public sealed interface TypeAnnotation
/** /**
* {@return a target for annotations on the type in an instanceof expression or a new expression, * {@return a target for annotations on the type in an instanceof expression or a new expression,
* or the type before the :: in a method reference expression} * or the type before the :: in a method reference expression}
* {@param targetType {@link TargetType#INSTANCEOF}, {@link TargetType#NEW}, * @param targetType {@link TargetType#INSTANCEOF}, {@link TargetType#NEW},
* {@link TargetType#CONSTRUCTOR_REFERENCE}, * {@link TargetType#CONSTRUCTOR_REFERENCE},
* or {@link TargetType#METHOD_REFERENCE}} * or {@link TargetType#METHOD_REFERENCE}
* @param target the code label corresponding to the instruction * @param target the code label corresponding to the instruction
*/ */
static OffsetTarget ofOffset(TargetType targetType, Label target) { static OffsetTarget ofOffset(TargetType targetType, Label target) {
@ -438,10 +449,10 @@ public sealed interface TypeAnnotation
* or on the i'th type argument in the explicit type argument list for any of the following: * or on the i'th type argument in the explicit type argument list for any of the following:
* a new expression, an explicit constructor invocation statement, a method invocation expression, * a new expression, an explicit constructor invocation statement, a method invocation expression,
* or a method reference expression} * or a method reference expression}
* {@param targetType {@link TargetType#CAST}, {@link TargetType#CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT}, * @param targetType {@link TargetType#CAST}, {@link TargetType#CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT},
* {@link TargetType#METHOD_INVOCATION_TYPE_ARGUMENT}, * {@link TargetType#METHOD_INVOCATION_TYPE_ARGUMENT},
* {@link TargetType#CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT}, * {@link TargetType#CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT},
* or {@link TargetType#METHOD_REFERENCE_TYPE_ARGUMENT}} * or {@link TargetType#METHOD_REFERENCE_TYPE_ARGUMENT}
* @param target the code label corresponding to the instruction * @param target the code label corresponding to the instruction
* @param typeArgumentIndex specifies which type in the cast operator or argument is annotated * @param typeArgumentIndex specifies which type in the cast operator or argument is annotated
*/ */
@ -503,7 +514,10 @@ public sealed interface TypeAnnotation
* Indicates that an annotation appears on the declaration of the i'th type * Indicates that an annotation appears on the declaration of the i'th type
* parameter of a generic class, generic interface, generic method, or * parameter of a generic class, generic interface, generic method, or
* generic constructor. * generic constructor.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
sealed interface TypeParameterTarget extends TargetInfo sealed interface TypeParameterTarget extends TargetInfo
permits TargetInfoImpl.TypeParameterTargetImpl { permits TargetInfoImpl.TypeParameterTargetImpl {
@ -519,7 +533,10 @@ public sealed interface TypeAnnotation
/** /**
* Indicates that an annotation appears on a type in the extends or implements * Indicates that an annotation appears on a type in the extends or implements
* clause of a class or interface declaration. * clause of a class or interface declaration.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
sealed interface SupertypeTarget extends TargetInfo sealed interface SupertypeTarget extends TargetInfo
permits TargetInfoImpl.SupertypeTargetImpl { permits TargetInfoImpl.SupertypeTargetImpl {
@ -540,7 +557,10 @@ public sealed interface TypeAnnotation
* Indicates that an annotation appears on the i'th bound of the j'th * Indicates that an annotation appears on the i'th bound of the j'th
* type parameter declaration of a generic class, interface, method, or * type parameter declaration of a generic class, interface, method, or
* constructor. * constructor.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
sealed interface TypeParameterBoundTarget extends TargetInfo sealed interface TypeParameterBoundTarget extends TargetInfo
permits TargetInfoImpl.TypeParameterBoundTargetImpl { permits TargetInfoImpl.TypeParameterBoundTargetImpl {
@ -563,7 +583,10 @@ public sealed interface TypeAnnotation
* Indicates that an annotation appears on either the type in a field * Indicates that an annotation appears on either the type in a field
* declaration, the return type of a method, the type of a newly constructed * declaration, the return type of a method, the type of a newly constructed
* object, or the receiver type of a method or constructor. * object, or the receiver type of a method or constructor.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
sealed interface EmptyTarget extends TargetInfo sealed interface EmptyTarget extends TargetInfo
permits TargetInfoImpl.EmptyTargetImpl { permits TargetInfoImpl.EmptyTargetImpl {
} }
@ -571,7 +594,10 @@ public sealed interface TypeAnnotation
/** /**
* Indicates that an annotation appears on the type in a formal parameter * Indicates that an annotation appears on the type in a formal parameter
* declaration of a method, constructor, or lambda expression. * declaration of a method, constructor, or lambda expression.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
sealed interface FormalParameterTarget extends TargetInfo sealed interface FormalParameterTarget extends TargetInfo
permits TargetInfoImpl.FormalParameterTargetImpl { permits TargetInfoImpl.FormalParameterTargetImpl {
@ -587,7 +613,10 @@ public sealed interface TypeAnnotation
/** /**
* Indicates that an annotation appears on the i'th type in the throws * Indicates that an annotation appears on the i'th type in the throws
* clause of a method or constructor declaration. * clause of a method or constructor declaration.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
sealed interface ThrowsTarget extends TargetInfo sealed interface ThrowsTarget extends TargetInfo
permits TargetInfoImpl.ThrowsTargetImpl { permits TargetInfoImpl.ThrowsTargetImpl {
@ -596,7 +625,7 @@ public sealed interface TypeAnnotation
* Exceptions attribute of the method_info structure enclosing the * Exceptions attribute of the method_info structure enclosing the
* RuntimeVisibleTypeAnnotations attribute. * RuntimeVisibleTypeAnnotations attribute.
* *
* @return the index into the list jdk.internal.classfile.attribute.ExceptionsAttribute.exceptions() * @return the index into the list java.lang.classfile.attribute.ExceptionsAttribute.exceptions()
*/ */
int throwsTargetIndex(); int throwsTargetIndex();
} }
@ -604,12 +633,15 @@ public sealed interface TypeAnnotation
/** /**
* Indicates that an annotation appears on the type in a local variable declaration, * Indicates that an annotation appears on the type in a local variable declaration,
* including a variable declared as a resource in a try-with-resources statement. * including a variable declared as a resource in a try-with-resources statement.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
sealed interface LocalVarTarget extends TargetInfo sealed interface LocalVarTarget extends TargetInfo
permits TargetInfoImpl.LocalVarTargetImpl { permits TargetInfoImpl.LocalVarTargetImpl {
/** /**
* @return the table of local variable location/indices. * {@return the table of local variable location/indices.}
*/ */
List<LocalVarTargetInfo> table(); List<LocalVarTargetInfo> table();
} }
@ -618,7 +650,10 @@ public sealed interface TypeAnnotation
* Indicates a range of code array offsets within which a local variable * Indicates a range of code array offsets within which a local variable
* has a value, and the index into the local variable array of the current * has a value, and the index into the local variable array of the current
* frame at which that local variable can be found. * frame at which that local variable can be found.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
sealed interface LocalVarTargetInfo sealed interface LocalVarTargetInfo
permits TargetInfoImpl.LocalVarTargetInfoImpl { permits TargetInfoImpl.LocalVarTargetInfoImpl {
@ -662,7 +697,10 @@ public sealed interface TypeAnnotation
/** /**
* Indicates that an annotation appears on the i'th type in an exception parameter * Indicates that an annotation appears on the i'th type in an exception parameter
* declaration. * declaration.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
sealed interface CatchTarget extends TargetInfo sealed interface CatchTarget extends TargetInfo
permits TargetInfoImpl.CatchTargetImpl { permits TargetInfoImpl.CatchTargetImpl {
@ -678,7 +716,10 @@ public sealed interface TypeAnnotation
/** /**
* Indicates that an annotation appears on either the type in an instanceof expression * Indicates that an annotation appears on either the type in an instanceof expression
* or a new expression, or the type before the :: in a method reference expression. * or a new expression, or the type before the :: in a method reference expression.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
sealed interface OffsetTarget extends TargetInfo sealed interface OffsetTarget extends TargetInfo
permits TargetInfoImpl.OffsetTargetImpl { permits TargetInfoImpl.OffsetTargetImpl {
@ -697,7 +738,10 @@ public sealed interface TypeAnnotation
* expression, or on the i'th type argument in the explicit type argument list for any of the following: a new * expression, or on the i'th type argument in the explicit type argument list for any of the following: a new
* expression, an explicit constructor invocation statement, a method invocation expression, or a method reference * expression, an explicit constructor invocation statement, a method invocation expression, or a method reference
* expression. * expression.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
sealed interface TypeArgumentTarget extends TargetInfo sealed interface TypeArgumentTarget extends TargetInfo
permits TargetInfoImpl.TypeArgumentTargetImpl { permits TargetInfoImpl.TypeArgumentTargetImpl {
@ -730,13 +774,19 @@ public sealed interface TypeAnnotation
/** /**
* JVMS: Type_path structure identifies which part of the type is annotated, * JVMS: Type_path structure identifies which part of the type is annotated,
* as defined in {@jvms 4.7.20.2} * as defined in {@jvms 4.7.20.2}
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
sealed interface TypePathComponent sealed interface TypePathComponent
permits UnboundAttribute.TypePathComponentImpl { permits UnboundAttribute.TypePathComponentImpl {
/** /**
* Type path kind, as defined in {@jvms 4.7.20.2} * Type path kind, as defined in {@jvms 4.7.20.2}
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public enum Kind { public enum Kind {
/** Annotation is deeper in an array type */ /** Annotation is deeper in an array type */

View file

@ -23,13 +23,17 @@
* questions. * questions.
*/ */
package jdk.internal.classfile; package java.lang.classfile;
import java.lang.invoke.TypeDescriptor; import java.lang.invoke.TypeDescriptor;
import jdk.internal.javac.PreviewFeature;
/** /**
* Describes the types that can be part of a field or method descriptor. * Describes the types that can be part of a field or method descriptor.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public enum TypeKind { public enum TypeKind {
/** the primitive type byte */ /** the primitive type byte */
ByteType("byte", "B", 8), ByteType("byte", "B", 8),

View file

@ -22,20 +22,25 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
package jdk.internal.classfile; package java.lang.classfile;
import jdk.internal.classfile.constantpool.ConstantPoolBuilder; import java.lang.classfile.constantpool.ConstantPoolBuilder;
import jdk.internal.classfile.constantpool.PoolEntry; import java.lang.classfile.constantpool.PoolEntry;
import jdk.internal.classfile.impl.DirectFieldBuilder; import jdk.internal.classfile.impl.DirectFieldBuilder;
import jdk.internal.classfile.impl.DirectMethodBuilder; import jdk.internal.classfile.impl.DirectMethodBuilder;
import jdk.internal.javac.PreviewFeature;
/** /**
* A classfile element that can encode itself as a stream of bytes in the * A classfile element that can encode itself as a stream of bytes in the
* encoding expected by the classfile format. * encoding expected by the classfile format.
* *
* @param <T> the type of the entity * @param <T> the type of the entity
*
* @sealedGraph
* @since 22
*/ */
public sealed interface WritableElement<T> extends ClassfileElement @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface WritableElement<T> extends ClassFileElement
permits Annotation, AnnotationElement, AnnotationValue, Attribute, permits Annotation, AnnotationElement, AnnotationValue, Attribute,
PoolEntry, BootstrapMethodEntry, FieldModel, MethodModel, PoolEntry, BootstrapMethodEntry, FieldModel, MethodModel,
ConstantPoolBuilder, DirectFieldBuilder, DirectMethodBuilder { ConstantPoolBuilder, DirectFieldBuilder, DirectMethodBuilder {

View file

@ -23,14 +23,15 @@
* questions. * questions.
*/ */
package jdk.internal.classfile.attribute; package java.lang.classfile.attribute;
import jdk.internal.classfile.AnnotationValue; import java.lang.classfile.AnnotationValue;
import jdk.internal.classfile.Attribute; import java.lang.classfile.Attribute;
import jdk.internal.classfile.MethodElement; import java.lang.classfile.MethodElement;
import jdk.internal.classfile.MethodModel; import java.lang.classfile.MethodModel;
import jdk.internal.classfile.impl.BoundAttribute; import jdk.internal.classfile.impl.BoundAttribute;
import jdk.internal.classfile.impl.UnboundAttribute; import jdk.internal.classfile.impl.UnboundAttribute;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models the {@code AnnotationDefault} attribute {@jvms 4.7.22}, which can * Models the {@code AnnotationDefault} attribute {@jvms 4.7.22}, which can
@ -41,7 +42,12 @@ import jdk.internal.classfile.impl.UnboundAttribute;
* The attribute does not permit multiple instances in a given location. * The attribute does not permit multiple instances in a given location.
* Subsequent occurrence of the attribute takes precedence during the attributed * Subsequent occurrence of the attribute takes precedence during the attributed
* element build or transformation. * element build or transformation.
* <p>
* The attribute was introduced in the Java SE Platform version 5.0.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface AnnotationDefaultAttribute public sealed interface AnnotationDefaultAttribute
extends Attribute<AnnotationDefaultAttribute>, MethodElement extends Attribute<AnnotationDefaultAttribute>, MethodElement
permits BoundAttribute.BoundAnnotationDefaultAttr, permits BoundAttribute.BoundAnnotationDefaultAttr,

View file

@ -23,15 +23,16 @@
* questions. * questions.
*/ */
package jdk.internal.classfile.attribute; package java.lang.classfile.attribute;
import java.util.List; import java.util.List;
import jdk.internal.classfile.Attribute; import java.lang.classfile.Attribute;
import jdk.internal.classfile.BootstrapMethodEntry; import java.lang.classfile.BootstrapMethodEntry;
import jdk.internal.classfile.constantpool.ConstantPool; import java.lang.classfile.constantpool.ConstantPool;
import jdk.internal.classfile.impl.BoundAttribute; import jdk.internal.classfile.impl.BoundAttribute;
import jdk.internal.classfile.impl.UnboundAttribute; import jdk.internal.classfile.impl.UnboundAttribute;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models the {@code BootstrapMethods} attribute {@jvms 4.7.23}, which serves as * Models the {@code BootstrapMethods} attribute {@jvms 4.7.23}, which serves as
@ -41,7 +42,12 @@ import jdk.internal.classfile.impl.UnboundAttribute;
* The attribute does not permit multiple instances in a given location. * The attribute does not permit multiple instances in a given location.
* Subsequent occurrence of the attribute takes precedence during the attributed * Subsequent occurrence of the attribute takes precedence during the attributed
* element build or transformation. * element build or transformation.
* <p>
* The attribute was introduced in the Java SE Platform version 7.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface BootstrapMethodsAttribute public sealed interface BootstrapMethodsAttribute
extends Attribute<BootstrapMethodsAttribute> extends Attribute<BootstrapMethodsAttribute>
permits BoundAttribute.BoundBootstrapMethodsAttribute, permits BoundAttribute.BoundBootstrapMethodsAttribute,

View file

@ -22,13 +22,17 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
package jdk.internal.classfile.attribute; package java.lang.classfile.attribute;
import jdk.internal.classfile.impl.UnboundAttribute; import jdk.internal.classfile.impl.UnboundAttribute;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models a single character range in the {@link CharacterRangeTableAttribute}. * Models a single character range in the {@link CharacterRangeTableAttribute}.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface CharacterRangeInfo public sealed interface CharacterRangeInfo
permits UnboundAttribute.UnboundCharacterRangeInfo { permits UnboundAttribute.UnboundCharacterRangeInfo {
@ -66,17 +70,17 @@ public sealed interface CharacterRangeInfo
* The value of the flags item describes the kind of range. Multiple flags * The value of the flags item describes the kind of range. Multiple flags
* may be set within flags. * may be set within flags.
* <ul> * <ul>
* <li>{@link jdk.internal.classfile.Classfile#CRT_STATEMENT} Range is a Statement * <li>{@link java.lang.classfile.ClassFile#CRT_STATEMENT} Range is a Statement
* (except ExpressionStatement), StatementExpression {@jls 14.8}, as well as each * (except ExpressionStatement), StatementExpression {@jls 14.8}, as well as each
* VariableDeclaratorId = VariableInitializer of * VariableDeclaratorId = VariableInitializer of
* LocalVariableDeclarationStatement {@jls 14.4} or FieldDeclaration {@jls 8.3} in the * LocalVariableDeclarationStatement {@jls 14.4} or FieldDeclaration {@jls 8.3} in the
* grammar. * grammar.
* <li>{@link jdk.internal.classfile.Classfile#CRT_BLOCK} Range is a Block in the * <li>{@link java.lang.classfile.ClassFile#CRT_BLOCK} Range is a Block in the
* grammar. * grammar.
* <li>{@link jdk.internal.classfile.Classfile#CRT_ASSIGNMENT} Range is an assignment * <li>{@link java.lang.classfile.ClassFile#CRT_ASSIGNMENT} Range is an assignment
* expression - Expression1 AssignmentOperator Expression1 in the grammar as * expression - Expression1 AssignmentOperator Expression1 in the grammar as
* well as increment and decrement expressions (both prefix and postfix). * well as increment and decrement expressions (both prefix and postfix).
* <li>{@link jdk.internal.classfile.Classfile#CRT_FLOW_CONTROLLER} An expression * <li>{@link java.lang.classfile.ClassFile#CRT_FLOW_CONTROLLER} An expression
* whose value will effect control flow. {@code Flowcon} in the following: * whose value will effect control flow. {@code Flowcon} in the following:
* <pre> * <pre>
* if ( Flowcon ) Statement [else Statement] * if ( Flowcon ) Statement [else Statement]
@ -88,7 +92,7 @@ public sealed interface CharacterRangeInfo
* Flowcon &amp;&amp; Expression3 * Flowcon &amp;&amp; Expression3
* Flowcon ? Expression : Expression1 * Flowcon ? Expression : Expression1
* </pre> * </pre>
* <li>{@link jdk.internal.classfile.Classfile#CRT_FLOW_TARGET} Statement or * <li>{@link java.lang.classfile.ClassFile#CRT_FLOW_TARGET} Statement or
* expression effected by a CRT_FLOW_CONTROLLER. {@code Flowtarg} in the following: * expression effected by a CRT_FLOW_CONTROLLER. {@code Flowtarg} in the following:
* <pre> * <pre>
* if ( Flowcon ) Flowtarg [else Flowtarg] * if ( Flowcon ) Flowtarg [else Flowtarg]
@ -99,11 +103,11 @@ public sealed interface CharacterRangeInfo
* Flowcon &amp;&amp; Flowtarg * Flowcon &amp;&amp; Flowtarg
* Flowcon ? Flowtarg : Flowtarg * Flowcon ? Flowtarg : Flowtarg
* </pre> * </pre>
* <li>{@link jdk.internal.classfile.Classfile#CRT_INVOKE} Method invocation. For * <li>{@link java.lang.classfile.ClassFile#CRT_INVOKE} Method invocation. For
* example: Identifier Arguments. * example: Identifier Arguments.
* <li>{@link jdk.internal.classfile.Classfile#CRT_CREATE} New object creation. For * <li>{@link java.lang.classfile.ClassFile#CRT_CREATE} New object creation. For
* example: new Creator. * example: new Creator.
* <li>{@link jdk.internal.classfile.Classfile#CRT_BRANCH_TRUE} A condition encoded * <li>{@link java.lang.classfile.ClassFile#CRT_BRANCH_TRUE} A condition encoded
* in the branch instruction immediately contained in the code range for * in the branch instruction immediately contained in the code range for
* this item is not inverted towards the corresponding branch condition in * this item is not inverted towards the corresponding branch condition in
* the source code. I.e. actual jump occurs if and only if the the source * the source code. I.e. actual jump occurs if and only if the the source
@ -115,7 +119,7 @@ public sealed interface CharacterRangeInfo
* if&lt;cond&gt;, ifnonull, ifnull or goto. CRT_BRANCH_TRUE and * if&lt;cond&gt;, ifnonull, ifnull or goto. CRT_BRANCH_TRUE and
* CRT_BRANCH_FALSE are special kinds of entries that can be used to * CRT_BRANCH_FALSE are special kinds of entries that can be used to
* determine what branch of a condition was chosen during the runtime. * determine what branch of a condition was chosen during the runtime.
* <li>{@link jdk.internal.classfile.Classfile#CRT_BRANCH_FALSE} A condition encoded * <li>{@link java.lang.classfile.ClassFile#CRT_BRANCH_FALSE} A condition encoded
* in the branch instruction immediately contained in the code range for * in the branch instruction immediately contained in the code range for
* this item is inverted towards the corresponding branch condition in the * this item is inverted towards the corresponding branch condition in the
* source code. I.e. actual jump occurs if and only if the the source code * source code. I.e. actual jump occurs if and only if the the source code

View file

@ -23,13 +23,14 @@
* questions. * questions.
*/ */
package jdk.internal.classfile.attribute; package java.lang.classfile.attribute;
import java.util.List; import java.util.List;
import jdk.internal.classfile.Attribute; import java.lang.classfile.Attribute;
import jdk.internal.classfile.impl.BoundAttribute; import jdk.internal.classfile.impl.BoundAttribute;
import jdk.internal.classfile.impl.UnboundAttribute; import jdk.internal.classfile.impl.UnboundAttribute;
import jdk.internal.javac.PreviewFeature;
/** /**
* The CharacterRangeTable attribute is an optional variable-length attribute in * The CharacterRangeTable attribute is an optional variable-length attribute in
@ -56,7 +57,10 @@ import jdk.internal.classfile.impl.UnboundAttribute;
* index range. The character range entries may appear in any order. * index range. The character range entries may appear in any order.
* <p> * <p>
* The attribute permits multiple instances in a given location. * The attribute permits multiple instances in a given location.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface CharacterRangeTableAttribute public sealed interface CharacterRangeTableAttribute
extends Attribute<CharacterRangeTableAttribute> extends Attribute<CharacterRangeTableAttribute>
permits BoundAttribute.BoundCharacterRangeTableAttribute, permits BoundAttribute.BoundCharacterRangeTableAttribute,

View file

@ -23,23 +23,27 @@
* questions. * questions.
*/ */
package jdk.internal.classfile.attribute; package java.lang.classfile.attribute;
import jdk.internal.classfile.Attribute; import java.lang.classfile.Attribute;
import jdk.internal.classfile.CodeModel; import java.lang.classfile.CodeModel;
import jdk.internal.classfile.Label; import java.lang.classfile.Label;
import jdk.internal.classfile.impl.BoundAttribute; import jdk.internal.classfile.impl.BoundAttribute;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models the {@code Code} attribute {@jvms 4.7.3}, appears on non-native, * Models the {@code Code} attribute {@jvms 4.7.3}, appears on non-native,
* non-abstract methods and contains the bytecode of the method body. Delivered * non-abstract methods and contains the bytecode of the method body. Delivered
* as a {@link jdk.internal.classfile.MethodElement} when traversing the elements of a * as a {@link java.lang.classfile.MethodElement} when traversing the elements of a
* {@link jdk.internal.classfile.MethodModel}. * {@link java.lang.classfile.MethodModel}.
* <p> * <p>
* The attribute does not permit multiple instances in a given location. * The attribute does not permit multiple instances in a given location.
* Subsequent occurrence of the attribute takes precedence during the attributed * Subsequent occurrence of the attribute takes precedence during the attributed
* element build or transformation. * element build or transformation.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface CodeAttribute extends Attribute<CodeAttribute>, CodeModel public sealed interface CodeAttribute extends Attribute<CodeAttribute>, CodeModel
permits BoundAttribute.BoundCodeAttribute { permits BoundAttribute.BoundCodeAttribute {

View file

@ -23,25 +23,29 @@
* questions. * questions.
*/ */
package jdk.internal.classfile.attribute; package java.lang.classfile.attribute;
import jdk.internal.classfile.Attribute; import java.lang.classfile.Attribute;
import jdk.internal.classfile.ClassElement; import java.lang.classfile.ClassElement;
import jdk.internal.classfile.constantpool.Utf8Entry; import java.lang.classfile.constantpool.Utf8Entry;
import jdk.internal.classfile.impl.BoundAttribute; import jdk.internal.classfile.impl.BoundAttribute;
import jdk.internal.classfile.impl.TemporaryConstantPool; import jdk.internal.classfile.impl.TemporaryConstantPool;
import jdk.internal.classfile.impl.UnboundAttribute; import jdk.internal.classfile.impl.UnboundAttribute;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models the {@code CompilationID} attribute (@@@ need reference), which can * Models the {@code CompilationID} attribute (@@@ need reference), which can
* appear on classes and records the compilation time of the class. Delivered * appear on classes and records the compilation time of the class. Delivered
* as a {@link jdk.internal.classfile.ClassElement} when traversing the elements of * as a {@link java.lang.classfile.ClassElement} when traversing the elements of
* a {@link jdk.internal.classfile.ClassModel}. * a {@link java.lang.classfile.ClassModel}.
* <p> * <p>
* The attribute does not permit multiple instances in a given location. * The attribute does not permit multiple instances in a given location.
* Subsequent occurrence of the attribute takes precedence during the attributed * Subsequent occurrence of the attribute takes precedence during the attributed
* element build or transformation. * element build or transformation.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface CompilationIDAttribute public sealed interface CompilationIDAttribute
extends Attribute<CompilationIDAttribute>, ClassElement extends Attribute<CompilationIDAttribute>, ClassElement
permits BoundAttribute.BoundCompilationIDAttribute, permits BoundAttribute.BoundCompilationIDAttribute,

View file

@ -22,26 +22,30 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
package jdk.internal.classfile.attribute; package java.lang.classfile.attribute;
import java.lang.constant.ConstantDesc; import java.lang.constant.ConstantDesc;
import jdk.internal.classfile.Attribute; import java.lang.classfile.Attribute;
import jdk.internal.classfile.FieldElement; import java.lang.classfile.FieldElement;
import jdk.internal.classfile.constantpool.ConstantValueEntry; import java.lang.classfile.constantpool.ConstantValueEntry;
import jdk.internal.classfile.impl.BoundAttribute; import jdk.internal.classfile.impl.BoundAttribute;
import jdk.internal.classfile.impl.TemporaryConstantPool; import jdk.internal.classfile.impl.TemporaryConstantPool;
import jdk.internal.classfile.impl.UnboundAttribute; import jdk.internal.classfile.impl.UnboundAttribute;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models the {@code ConstantValue} attribute {@jvms 4.7.2}, which can appear on * Models the {@code ConstantValue} attribute {@jvms 4.7.2}, which can appear on
* fields and indicates that the field's value is a constant. Delivered as a * fields and indicates that the field's value is a constant. Delivered as a
* {@link jdk.internal.classfile.FieldElement} when traversing the elements of a * {@link java.lang.classfile.FieldElement} when traversing the elements of a
* {@link jdk.internal.classfile.FieldModel}. * {@link java.lang.classfile.FieldModel}.
* <p> * <p>
* The attribute does not permit multiple instances in a given location. * The attribute does not permit multiple instances in a given location.
* Subsequent occurrence of the attribute takes precedence during the attributed * Subsequent occurrence of the attribute takes precedence during the attributed
* element build or transformation. * element build or transformation.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface ConstantValueAttribute public sealed interface ConstantValueAttribute
extends Attribute<ConstantValueAttribute>, FieldElement extends Attribute<ConstantValueAttribute>, FieldElement
permits BoundAttribute.BoundConstantValueAttribute, permits BoundAttribute.BoundConstantValueAttribute,

View file

@ -22,14 +22,15 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
package jdk.internal.classfile.attribute; package java.lang.classfile.attribute;
import jdk.internal.classfile.Attribute; import java.lang.classfile.Attribute;
import jdk.internal.classfile.ClassElement; import java.lang.classfile.ClassElement;
import jdk.internal.classfile.FieldElement; import java.lang.classfile.FieldElement;
import jdk.internal.classfile.MethodElement; import java.lang.classfile.MethodElement;
import jdk.internal.classfile.impl.BoundAttribute; import jdk.internal.classfile.impl.BoundAttribute;
import jdk.internal.classfile.impl.UnboundAttribute; import jdk.internal.classfile.impl.UnboundAttribute;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models the {@code Deprecated} attribute {@jvms 4.7.15}, which can appear on * Models the {@code Deprecated} attribute {@jvms 4.7.15}, which can appear on
@ -38,7 +39,10 @@ import jdk.internal.classfile.impl.UnboundAttribute;
* of a corresponding model. * of a corresponding model.
* <p> * <p>
* The attribute permits multiple instances in a given location. * The attribute permits multiple instances in a given location.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface DeprecatedAttribute public sealed interface DeprecatedAttribute
extends Attribute<DeprecatedAttribute>, extends Attribute<DeprecatedAttribute>,
ClassElement, MethodElement, FieldElement ClassElement, MethodElement, FieldElement

View file

@ -22,32 +22,38 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
package jdk.internal.classfile.attribute; package java.lang.classfile.attribute;
import java.lang.constant.ClassDesc; import java.lang.constant.ClassDesc;
import java.lang.constant.MethodTypeDesc; import java.lang.constant.MethodTypeDesc;
import java.util.Optional; import java.util.Optional;
import jdk.internal.classfile.Attribute; import java.lang.classfile.Attribute;
import jdk.internal.classfile.ClassElement; import java.lang.classfile.ClassElement;
import jdk.internal.classfile.constantpool.ClassEntry; import java.lang.classfile.constantpool.ClassEntry;
import jdk.internal.classfile.constantpool.NameAndTypeEntry; import java.lang.classfile.constantpool.NameAndTypeEntry;
import jdk.internal.classfile.constantpool.Utf8Entry; import java.lang.classfile.constantpool.Utf8Entry;
import jdk.internal.classfile.impl.BoundAttribute; import jdk.internal.classfile.impl.BoundAttribute;
import jdk.internal.classfile.impl.TemporaryConstantPool; import jdk.internal.classfile.impl.TemporaryConstantPool;
import jdk.internal.classfile.impl.UnboundAttribute; import jdk.internal.classfile.impl.UnboundAttribute;
import jdk.internal.classfile.impl.Util; import jdk.internal.classfile.impl.Util;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models the {@code EnclosingMethod} attribute {@jvms 4.7.7}, which can appear * Models the {@code EnclosingMethod} attribute {@jvms 4.7.7}, which can appear
* on classes, and indicates that the class is a local or anonymous class. * 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 * Delivered as a {@link ClassElement} when traversing the elements of a {@link
* jdk.internal.classfile.ClassModel}. * java.lang.classfile.ClassModel}.
* <p> * <p>
* The attribute does not permit multiple instances in a given location. * The attribute does not permit multiple instances in a given location.
* Subsequent occurrence of the attribute takes precedence during the attributed * Subsequent occurrence of the attribute takes precedence during the attributed
* element build or transformation. * element build or transformation.
* <p>
* The attribute was introduced in the Java SE Platform version 5.0.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface EnclosingMethodAttribute public sealed interface EnclosingMethodAttribute
extends Attribute<EnclosingMethodAttribute>, ClassElement extends Attribute<EnclosingMethodAttribute>, ClassElement
permits BoundAttribute.BoundEnclosingMethodAttribute, permits BoundAttribute.BoundEnclosingMethodAttribute,
@ -92,7 +98,8 @@ public sealed interface EnclosingMethodAttribute
/** /**
* {@return an {@code EnclosingMethod} attribute} * {@return an {@code EnclosingMethod} attribute}
* @param className the class name * @param className the class name
* @param method the name and type of the enclosing method * @param method the name and type of the enclosing method or {@code empty} if
* the class is not immediately enclosed by a method or constructor
*/ */
static EnclosingMethodAttribute of(ClassEntry className, static EnclosingMethodAttribute of(ClassEntry className,
Optional<NameAndTypeEntry> method) { Optional<NameAndTypeEntry> method) {
@ -102,8 +109,11 @@ public sealed interface EnclosingMethodAttribute
/** /**
* {@return an {@code EnclosingMethod} attribute} * {@return an {@code EnclosingMethod} attribute}
* @param className the class name * @param className the class name
* @param methodName the name of the enclosing method * @param methodName the name of the enclosing method or {@code empty} if
* @param methodType the type of the enclosing method * the class is not immediately enclosed by a method or constructor
* @param methodType the type of the enclosing method or {@code empty} if
* the class is not immediately enclosed by a method or constructor
* @throws IllegalArgumentException if {@code className} represents a primitive type
*/ */
static EnclosingMethodAttribute of(ClassDesc className, static EnclosingMethodAttribute of(ClassDesc className,
Optional<String> methodName, Optional<String> methodName,

View file

@ -22,29 +22,33 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
package jdk.internal.classfile.attribute; package java.lang.classfile.attribute;
import java.lang.constant.ClassDesc; import java.lang.constant.ClassDesc;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import jdk.internal.classfile.Attribute; import java.lang.classfile.Attribute;
import jdk.internal.classfile.constantpool.ClassEntry; import java.lang.classfile.constantpool.ClassEntry;
import jdk.internal.classfile.MethodElement; import java.lang.classfile.MethodElement;
import jdk.internal.classfile.impl.BoundAttribute; import jdk.internal.classfile.impl.BoundAttribute;
import jdk.internal.classfile.impl.UnboundAttribute; import jdk.internal.classfile.impl.UnboundAttribute;
import jdk.internal.classfile.impl.Util; import jdk.internal.classfile.impl.Util;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models the {@code Exceptions} attribute {@jvms 4.7.5}, which can appear on * Models the {@code Exceptions} attribute {@jvms 4.7.5}, which can appear on
* methods, and records the exceptions declared to be thrown by this method. * methods, and records the exceptions declared to be thrown by this method.
* Delivered as a {@link MethodElement} when traversing the elements of a * Delivered as a {@link MethodElement} when traversing the elements of a
* {@link jdk.internal.classfile.MethodModel}. * {@link java.lang.classfile.MethodModel}.
* <p> * <p>
* The attribute does not permit multiple instances in a given location. * The attribute does not permit multiple instances in a given location.
* Subsequent occurrence of the attribute takes precedence during the attributed * Subsequent occurrence of the attribute takes precedence during the attributed
* element build or transformation. * element build or transformation.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface ExceptionsAttribute public sealed interface ExceptionsAttribute
extends Attribute<ExceptionsAttribute>, MethodElement extends Attribute<ExceptionsAttribute>, MethodElement
permits BoundAttribute.BoundExceptionsAttribute, permits BoundAttribute.BoundExceptionsAttribute,

View file

@ -22,23 +22,27 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
package jdk.internal.classfile.attribute; package java.lang.classfile.attribute;
import java.lang.constant.ClassDesc; import java.lang.constant.ClassDesc;
import java.util.Optional; import java.util.Optional;
import java.util.Set; import java.util.Set;
import jdk.internal.classfile.constantpool.ClassEntry; import java.lang.classfile.constantpool.ClassEntry;
import jdk.internal.classfile.constantpool.Utf8Entry; import java.lang.classfile.constantpool.Utf8Entry;
import java.lang.reflect.AccessFlag; import java.lang.reflect.AccessFlag;
import jdk.internal.classfile.impl.TemporaryConstantPool; import jdk.internal.classfile.impl.TemporaryConstantPool;
import jdk.internal.classfile.impl.UnboundAttribute; import jdk.internal.classfile.impl.UnboundAttribute;
import jdk.internal.classfile.impl.Util; import jdk.internal.classfile.impl.Util;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models a single inner class in the {@link InnerClassesAttribute}. * Models a single inner class in the {@link InnerClassesAttribute}.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface InnerClassInfo public sealed interface InnerClassInfo
permits UnboundAttribute.UnboundInnerClassInfo { permits UnboundAttribute.UnboundInnerClassInfo {
@ -98,6 +102,7 @@ public sealed interface InnerClassInfo
* @param outerClass the class containing the inner class, if any * @param outerClass the class containing the inner class, if any
* @param innerName the name of the inner class, if it is not anonymous * @param innerName the name of the inner class, if it is not anonymous
* @param flags the inner class access flags * @param flags the inner class access flags
* @throws IllegalArgumentException if {@code innerClass} or {@code outerClass} represents a primitive type
*/ */
static InnerClassInfo of(ClassDesc innerClass, Optional<ClassDesc> outerClass, Optional<String> innerName, int flags) { static InnerClassInfo of(ClassDesc innerClass, Optional<ClassDesc> outerClass, Optional<String> innerName, int flags) {
return new UnboundAttribute.UnboundInnerClassInfo(TemporaryConstantPool.INSTANCE.classEntry(innerClass), return new UnboundAttribute.UnboundInnerClassInfo(TemporaryConstantPool.INSTANCE.classEntry(innerClass),
@ -112,6 +117,7 @@ public sealed interface InnerClassInfo
* @param outerClass the class containing the inner class, if any * @param outerClass the class containing the inner class, if any
* @param innerName the name of the inner class, if it is not anonymous * @param innerName the name of the inner class, if it is not anonymous
* @param flags the inner class access flags * @param flags the inner class access flags
* @throws IllegalArgumentException if {@code innerClass} or {@code outerClass} represents a primitive type
*/ */
static InnerClassInfo of(ClassDesc innerClass, Optional<ClassDesc> outerClass, Optional<String> innerName, AccessFlag... flags) { static InnerClassInfo of(ClassDesc innerClass, Optional<ClassDesc> outerClass, Optional<String> innerName, AccessFlag... flags) {
return of(innerClass, outerClass, innerName, Util.flagsToBits(AccessFlag.Location.INNER_CLASS, flags)); return of(innerClass, outerClass, innerName, Util.flagsToBits(AccessFlag.Location.INNER_CLASS, flags));

View file

@ -23,25 +23,29 @@
* questions. * questions.
*/ */
package jdk.internal.classfile.attribute; package java.lang.classfile.attribute;
import java.util.List; import java.util.List;
import jdk.internal.classfile.Attribute; import java.lang.classfile.Attribute;
import jdk.internal.classfile.ClassElement; import java.lang.classfile.ClassElement;
import jdk.internal.classfile.impl.BoundAttribute; import jdk.internal.classfile.impl.BoundAttribute;
import jdk.internal.classfile.impl.UnboundAttribute; import jdk.internal.classfile.impl.UnboundAttribute;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models the {@code InnerClasses} attribute {@jvms 4.7.6}, which can * Models the {@code InnerClasses} attribute {@jvms 4.7.6}, which can
* appear on classes, and records which classes referenced by this classfile * appear on classes, and records which classes referenced by this classfile
* are inner classes. Delivered as a {@link jdk.internal.classfile.ClassElement} when * are inner classes. Delivered as a {@link java.lang.classfile.ClassElement} when
* traversing the elements of a {@link jdk.internal.classfile.ClassModel}. * traversing the elements of a {@link java.lang.classfile.ClassModel}.
* <p> * <p>
* The attribute does not permit multiple instances in a given location. * The attribute does not permit multiple instances in a given location.
* Subsequent occurrence of the attribute takes precedence during the attributed * Subsequent occurrence of the attribute takes precedence during the attributed
* element build or transformation. * element build or transformation.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface InnerClassesAttribute public sealed interface InnerClassesAttribute
extends Attribute<InnerClassesAttribute>, ClassElement extends Attribute<InnerClassesAttribute>, ClassElement
permits BoundAttribute.BoundInnerClassesAttribute, permits BoundAttribute.BoundInnerClassesAttribute,

View file

@ -22,13 +22,17 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
package jdk.internal.classfile.attribute; package java.lang.classfile.attribute;
import jdk.internal.classfile.impl.UnboundAttribute; import jdk.internal.classfile.impl.UnboundAttribute;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models a single line number in the {@link LineNumberTableAttribute}. * Models a single line number in the {@link LineNumberTableAttribute}.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface LineNumberInfo public sealed interface LineNumberInfo
permits UnboundAttribute.UnboundLineNumberInfo { permits UnboundAttribute.UnboundLineNumberInfo {

View file

@ -22,24 +22,28 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
package jdk.internal.classfile.attribute; package java.lang.classfile.attribute;
import java.util.List; import java.util.List;
import jdk.internal.classfile.Attribute; import java.lang.classfile.Attribute;
import jdk.internal.classfile.impl.BoundAttribute; import jdk.internal.classfile.impl.BoundAttribute;
import jdk.internal.classfile.impl.UnboundAttribute; import jdk.internal.classfile.impl.UnboundAttribute;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models the {@code LineNumberTable} attribute {@jvms 4.7.12}, which can appear * Models the {@code LineNumberTable} attribute {@jvms 4.7.12}, which can appear
* on a {@code Code} attribute, and records the mapping between indexes into * on a {@code Code} attribute, and records the mapping between indexes into
* the code table and line numbers in the source file. * the code table and line numbers in the source file.
* Delivered as a {@link jdk.internal.classfile.instruction.LineNumber} when traversing the * Delivered as a {@link java.lang.classfile.instruction.LineNumber} when traversing the
* elements of a {@link jdk.internal.classfile.CodeModel}, according to the setting of the * elements of a {@link java.lang.classfile.CodeModel}, according to the setting of the
* {@link jdk.internal.classfile.Classfile.LineNumbersOption} option. * {@link java.lang.classfile.ClassFile.LineNumbersOption} option.
* <p> * <p>
* The attribute permits multiple instances in a given location. * The attribute permits multiple instances in a given location.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface LineNumberTableAttribute public sealed interface LineNumberTableAttribute
extends Attribute<LineNumberTableAttribute> extends Attribute<LineNumberTableAttribute>
permits BoundAttribute.BoundLineNumberTableAttribute, permits BoundAttribute.BoundLineNumberTableAttribute,

View file

@ -22,16 +22,20 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
package jdk.internal.classfile.attribute; package java.lang.classfile.attribute;
import java.lang.constant.ClassDesc; import java.lang.constant.ClassDesc;
import jdk.internal.classfile.constantpool.Utf8Entry; import java.lang.classfile.constantpool.Utf8Entry;
import jdk.internal.classfile.impl.BoundLocalVariable; import jdk.internal.classfile.impl.BoundLocalVariable;
import jdk.internal.classfile.impl.UnboundAttribute; import jdk.internal.classfile.impl.UnboundAttribute;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models a single local variable in the {@link LocalVariableTableAttribute}. * Models a single local variable in the {@link LocalVariableTableAttribute}.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface LocalVariableInfo public sealed interface LocalVariableInfo
permits UnboundAttribute.UnboundLocalVariableInfo, BoundLocalVariable { permits UnboundAttribute.UnboundLocalVariableInfo, BoundLocalVariable {

View file

@ -22,24 +22,28 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
package jdk.internal.classfile.attribute; package java.lang.classfile.attribute;
import jdk.internal.classfile.Attribute; import java.lang.classfile.Attribute;
import jdk.internal.classfile.impl.BoundAttribute; import jdk.internal.classfile.impl.BoundAttribute;
import jdk.internal.classfile.impl.UnboundAttribute; import jdk.internal.classfile.impl.UnboundAttribute;
import java.util.List; import java.util.List;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models the {@code LocalVariableTable} attribute {@jvms 4.7.13}, which can appear * Models the {@code LocalVariableTable} attribute {@jvms 4.7.13}, which can appear
* on a {@code Code} attribute, and records debug information about local * on a {@code Code} attribute, and records debug information about local
* variables. * variables.
* Delivered as a {@link jdk.internal.classfile.instruction.LocalVariable} when traversing the * Delivered as a {@link java.lang.classfile.instruction.LocalVariable} when traversing the
* elements of a {@link jdk.internal.classfile.CodeModel}, according to the setting of the * elements of a {@link java.lang.classfile.CodeModel}, according to the setting of the
* {@link jdk.internal.classfile.Classfile.DebugElementsOption} option. * {@link java.lang.classfile.ClassFile.DebugElementsOption} option.
* <p> * <p>
* The attribute permits multiple instances in a given location. * The attribute permits multiple instances in a given location.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface LocalVariableTableAttribute public sealed interface LocalVariableTableAttribute
extends Attribute<LocalVariableTableAttribute> extends Attribute<LocalVariableTableAttribute>
permits BoundAttribute.BoundLocalVariableTableAttribute, UnboundAttribute.UnboundLocalVariableTableAttribute { permits BoundAttribute.BoundLocalVariableTableAttribute, UnboundAttribute.UnboundLocalVariableTableAttribute {

View file

@ -22,15 +22,19 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
package jdk.internal.classfile.attribute; package java.lang.classfile.attribute;
import jdk.internal.classfile.constantpool.Utf8Entry; import java.lang.classfile.constantpool.Utf8Entry;
import jdk.internal.classfile.impl.BoundLocalVariableType; import jdk.internal.classfile.impl.BoundLocalVariableType;
import jdk.internal.classfile.impl.UnboundAttribute; import jdk.internal.classfile.impl.UnboundAttribute;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models a single local variable in the {@link LocalVariableTypeTableAttribute}. * Models a single local variable in the {@link LocalVariableTypeTableAttribute}.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface LocalVariableTypeInfo public sealed interface LocalVariableTypeInfo
permits UnboundAttribute.UnboundLocalVariableTypeInfo, BoundLocalVariableType { permits UnboundAttribute.UnboundLocalVariableTypeInfo, BoundLocalVariableType {

View file

@ -23,24 +23,30 @@
* questions. * questions.
*/ */
package jdk.internal.classfile.attribute; package java.lang.classfile.attribute;
import jdk.internal.classfile.Attribute; import java.lang.classfile.Attribute;
import jdk.internal.classfile.impl.BoundAttribute; import jdk.internal.classfile.impl.BoundAttribute;
import jdk.internal.classfile.impl.UnboundAttribute; import jdk.internal.classfile.impl.UnboundAttribute;
import java.util.List; import java.util.List;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models the {@code LocalVariableTypeTable} attribute {@jvms 4.7.14}, which can appear * Models the {@code LocalVariableTypeTable} attribute {@jvms 4.7.14}, which can appear
* on a {@code Code} attribute, and records debug information about local * on a {@code Code} attribute, and records debug information about local
* variables. * variables.
* Delivered as a {@link jdk.internal.classfile.instruction.LocalVariable} when traversing the * Delivered as a {@link java.lang.classfile.instruction.LocalVariable} when traversing the
* elements of a {@link jdk.internal.classfile.CodeModel}, according to the setting of the * elements of a {@link java.lang.classfile.CodeModel}, according to the setting of the
* {@link jdk.internal.classfile.Classfile.LineNumbersOption} option. * {@link java.lang.classfile.ClassFile.LineNumbersOption} option.
* <p> * <p>
* The attribute permits multiple instances in a given location. * The attribute permits multiple instances in a given location.
* <p>
* The attribute was introduced in the Java SE Platform version 5.0.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface LocalVariableTypeTableAttribute public sealed interface LocalVariableTypeTableAttribute
extends Attribute<LocalVariableTypeTableAttribute> extends Attribute<LocalVariableTypeTableAttribute>
permits BoundAttribute.BoundLocalVariableTypeTableAttribute, UnboundAttribute.UnboundLocalVariableTypeTableAttribute { permits BoundAttribute.BoundLocalVariableTypeTableAttribute, UnboundAttribute.UnboundLocalVariableTypeTableAttribute {

View file

@ -22,21 +22,25 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
package jdk.internal.classfile.attribute; package java.lang.classfile.attribute;
import java.util.Optional; import java.util.Optional;
import java.util.Set; import java.util.Set;
import jdk.internal.classfile.constantpool.Utf8Entry; import java.lang.classfile.constantpool.Utf8Entry;
import java.lang.reflect.AccessFlag; import java.lang.reflect.AccessFlag;
import jdk.internal.classfile.Classfile; import java.lang.classfile.ClassFile;
import jdk.internal.classfile.impl.TemporaryConstantPool; import jdk.internal.classfile.impl.TemporaryConstantPool;
import jdk.internal.classfile.impl.UnboundAttribute; import jdk.internal.classfile.impl.UnboundAttribute;
import jdk.internal.classfile.impl.Util; import jdk.internal.classfile.impl.Util;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models a single method parameter in the {@link MethodParametersAttribute}. * Models a single method parameter in the {@link MethodParametersAttribute}.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface MethodParameterInfo public sealed interface MethodParameterInfo
permits UnboundAttribute.UnboundMethodParameterInfo { permits UnboundAttribute.UnboundMethodParameterInfo {
/** /**
@ -48,8 +52,8 @@ public sealed interface MethodParameterInfo
/** /**
* Parameter access flags for this parameter, as a bit mask. Valid * Parameter access flags for this parameter, as a bit mask. Valid
* parameter flags include {@link Classfile#ACC_FINAL}, * parameter flags include {@link ClassFile#ACC_FINAL},
* {@link Classfile#ACC_SYNTHETIC}, and {@link Classfile#ACC_MANDATED}. * {@link ClassFile#ACC_SYNTHETIC}, and {@link ClassFile#ACC_MANDATED}.
* *
* @return the access flags, as a bit mask * @return the access flags, as a bit mask
*/ */

View file

@ -23,25 +23,31 @@
* questions. * questions.
*/ */
package jdk.internal.classfile.attribute; package java.lang.classfile.attribute;
import java.util.List; import java.util.List;
import jdk.internal.classfile.Attribute; import java.lang.classfile.Attribute;
import jdk.internal.classfile.MethodElement; import java.lang.classfile.MethodElement;
import jdk.internal.classfile.impl.BoundAttribute; import jdk.internal.classfile.impl.BoundAttribute;
import jdk.internal.classfile.impl.UnboundAttribute; import jdk.internal.classfile.impl.UnboundAttribute;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models the {@code MethodParameters} attribute {@jvms 4.7.24}, which can * Models the {@code MethodParameters} attribute {@jvms 4.7.24}, which can
* appear on methods, and records optional information about the method's * appear on methods, and records optional information about the method's
* parameters. Delivered as a {@link jdk.internal.classfile.MethodElement} when * parameters. Delivered as a {@link java.lang.classfile.MethodElement} when
* traversing the elements of a {@link jdk.internal.classfile.MethodModel}. * traversing the elements of a {@link java.lang.classfile.MethodModel}.
* <p> * <p>
* The attribute does not permit multiple instances in a given location. * The attribute does not permit multiple instances in a given location.
* Subsequent occurrence of the attribute takes precedence during the attributed * Subsequent occurrence of the attribute takes precedence during the attributed
* element build or transformation. * element build or transformation.
* <p>
* The attribute was introduced in the Java SE Platform version 8.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface MethodParametersAttribute public sealed interface MethodParametersAttribute
extends Attribute<MethodParametersAttribute>, MethodElement extends Attribute<MethodParametersAttribute>, MethodElement
permits BoundAttribute.BoundMethodParametersAttribute, permits BoundAttribute.BoundMethodParametersAttribute,

View file

@ -22,15 +22,15 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
package jdk.internal.classfile.attribute; package java.lang.classfile.attribute;
import java.lang.constant.ClassDesc; import java.lang.constant.ClassDesc;
import java.util.Collection; import java.util.Collection;
import jdk.internal.classfile.Attribute; import java.lang.classfile.Attribute;
import jdk.internal.classfile.ClassElement; import java.lang.classfile.ClassElement;
import jdk.internal.classfile.constantpool.ClassEntry; import java.lang.classfile.constantpool.ClassEntry;
import jdk.internal.classfile.constantpool.ModuleEntry; import java.lang.classfile.constantpool.ModuleEntry;
import jdk.internal.classfile.constantpool.Utf8Entry; import java.lang.classfile.constantpool.Utf8Entry;
import jdk.internal.classfile.impl.BoundAttribute; import jdk.internal.classfile.impl.BoundAttribute;
import jdk.internal.classfile.impl.UnboundAttribute; import jdk.internal.classfile.impl.UnboundAttribute;
@ -43,18 +43,23 @@ import java.lang.constant.ModuleDesc;
import java.lang.constant.PackageDesc; import java.lang.constant.PackageDesc;
import jdk.internal.classfile.impl.ModuleAttributeBuilderImpl; import jdk.internal.classfile.impl.ModuleAttributeBuilderImpl;
import jdk.internal.classfile.impl.Util; import jdk.internal.classfile.impl.Util;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models the {@code Module} attribute {@jvms 4.7.25}, which can * Models the {@code Module} attribute {@jvms 4.7.25}, which can
* appear on classes that represent module descriptors. * appear on classes that represent module descriptors.
* Delivered as a {@link jdk.internal.classfile.ClassElement} when * Delivered as a {@link java.lang.classfile.ClassElement} when
* traversing the elements of a {@link jdk.internal.classfile.ClassModel}. * traversing the elements of a {@link java.lang.classfile.ClassModel}.
* <p> * <p>
* The attribute does not permit multiple instances in a given location. * The attribute does not permit multiple instances in a given location.
* Subsequent occurrence of the attribute takes precedence during the attributed * Subsequent occurrence of the attribute takes precedence during the attributed
* element build or transformation. * element build or transformation.
* <p>
* The attribute was introduced in the Java SE Platform version 9.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface ModuleAttribute public sealed interface ModuleAttribute
extends Attribute<ModuleAttribute>, ClassElement extends Attribute<ModuleAttribute>, ClassElement
permits BoundAttribute.BoundModuleAttribute, UnboundAttribute.UnboundModuleAttribute { permits BoundAttribute.BoundModuleAttribute, UnboundAttribute.UnboundModuleAttribute {
@ -166,7 +171,10 @@ public sealed interface ModuleAttribute
/** /**
* A builder for module attributes. * A builder for module attributes.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface ModuleAttributeBuilder public sealed interface ModuleAttributeBuilder
permits ModuleAttributeBuilderImpl { permits ModuleAttributeBuilderImpl {
@ -255,7 +263,7 @@ public sealed interface ModuleAttribute
ModuleAttributeBuilder exports(ModuleExportInfo exports); ModuleAttributeBuilder exports(ModuleExportInfo exports);
/** /**
* * Opens package
* @param pkge the opened package * @param pkge the opened package
* @param opensFlagsMask the open package flags * @param opensFlagsMask the open package flags
* @param opensToModules the modules to open to * @param opensToModules the modules to open to
@ -264,7 +272,7 @@ public sealed interface ModuleAttribute
ModuleAttributeBuilder opens(PackageDesc pkge, int opensFlagsMask, ModuleDesc... opensToModules); ModuleAttributeBuilder opens(PackageDesc pkge, int opensFlagsMask, ModuleDesc... opensToModules);
/** /**
* * Opens package
* @param pkge the opened package * @param pkge the opened package
* @param opensFlags the open package flags * @param opensFlags the open package flags
* @param opensToModules the modules to open to * @param opensToModules the modules to open to
@ -285,6 +293,7 @@ public sealed interface ModuleAttribute
* Declares use of a service * Declares use of a service
* @param service the service class used * @param service the service class used
* @return this builder * @return this builder
* @throws IllegalArgumentException if {@code service} represents a primitive type
*/ */
ModuleAttributeBuilder uses(ClassDesc service); ModuleAttributeBuilder uses(ClassDesc service);
@ -300,6 +309,7 @@ public sealed interface ModuleAttribute
* @param service the service class provided * @param service the service class provided
* @param implClasses the implementation classes * @param implClasses the implementation classes
* @return this builder * @return this builder
* @throws IllegalArgumentException if {@code service} or any of the {@code implClasses} represents a primitive type
*/ */
ModuleAttributeBuilder provides(ClassDesc service, ClassDesc... implClasses); ModuleAttributeBuilder provides(ClassDesc service, ClassDesc... implClasses);

View file

@ -22,26 +22,30 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
package jdk.internal.classfile.attribute; package java.lang.classfile.attribute;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import jdk.internal.classfile.constantpool.ModuleEntry; import java.lang.classfile.constantpool.ModuleEntry;
import jdk.internal.classfile.constantpool.PackageEntry; import java.lang.classfile.constantpool.PackageEntry;
import java.lang.constant.ModuleDesc; import java.lang.constant.ModuleDesc;
import java.lang.constant.PackageDesc; import java.lang.constant.PackageDesc;
import java.lang.reflect.AccessFlag; import java.lang.reflect.AccessFlag;
import jdk.internal.classfile.Classfile; import java.lang.classfile.ClassFile;
import jdk.internal.classfile.impl.TemporaryConstantPool; import jdk.internal.classfile.impl.TemporaryConstantPool;
import jdk.internal.classfile.impl.UnboundAttribute; import jdk.internal.classfile.impl.UnboundAttribute;
import jdk.internal.classfile.impl.Util; import jdk.internal.classfile.impl.Util;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models a single "exports" declaration in the {@link ModuleAttribute}. * Models a single "exports" declaration in the {@link ModuleAttribute}.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface ModuleExportInfo public sealed interface ModuleExportInfo
permits UnboundAttribute.UnboundModuleExportInfo { permits UnboundAttribute.UnboundModuleExportInfo {
@ -52,8 +56,8 @@ public sealed interface ModuleExportInfo
/** /**
* {@return the flags associated with this export declaration, as a bit mask} * {@return the flags associated with this export declaration, as a bit mask}
* Valid flags include {@link Classfile#ACC_SYNTHETIC} and * Valid flags include {@link ClassFile#ACC_SYNTHETIC} and
* {@link Classfile#ACC_MANDATED}. * {@link ClassFile#ACC_MANDATED}.
*/ */
int exportsFlagsMask(); int exportsFlagsMask();

View file

@ -22,16 +22,20 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
package jdk.internal.classfile.attribute; package java.lang.classfile.attribute;
import jdk.internal.classfile.constantpool.ModuleEntry; import java.lang.classfile.constantpool.ModuleEntry;
import java.lang.constant.ModuleDesc; import java.lang.constant.ModuleDesc;
import jdk.internal.classfile.impl.TemporaryConstantPool; import jdk.internal.classfile.impl.TemporaryConstantPool;
import jdk.internal.classfile.impl.UnboundAttribute; import jdk.internal.classfile.impl.UnboundAttribute;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models hash information for a single module in the {@link ModuleHashesAttribute}. * Models hash information for a single module in the {@link ModuleHashesAttribute}.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface ModuleHashInfo public sealed interface ModuleHashInfo
permits UnboundAttribute.UnboundModuleHashInfo { permits UnboundAttribute.UnboundModuleHashInfo {

View file

@ -23,24 +23,25 @@
* questions. * questions.
*/ */
package jdk.internal.classfile.attribute; package java.lang.classfile.attribute;
import jdk.internal.classfile.Attribute; import java.lang.classfile.Attribute;
import jdk.internal.classfile.ClassElement; import java.lang.classfile.ClassElement;
import java.util.List; import java.util.List;
import jdk.internal.classfile.constantpool.Utf8Entry; import java.lang.classfile.constantpool.Utf8Entry;
import jdk.internal.classfile.impl.BoundAttribute; import jdk.internal.classfile.impl.BoundAttribute;
import jdk.internal.classfile.impl.TemporaryConstantPool; import jdk.internal.classfile.impl.TemporaryConstantPool;
import jdk.internal.classfile.impl.UnboundAttribute; import jdk.internal.classfile.impl.UnboundAttribute;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models the {@code ModuleHashes} attribute, which can * Models the {@code ModuleHashes} attribute, which can
* appear on classes that represent module descriptors. This is a JDK-specific * appear on classes that represent module descriptors. This is a JDK-specific
* attribute, which captures the hashes of a set of co-delivered modules. * attribute, which captures the hashes of a set of co-delivered modules.
* Delivered as a {@link jdk.internal.classfile.ClassElement} when * Delivered as a {@link java.lang.classfile.ClassElement} when
* traversing the elements of a {@link jdk.internal.classfile.ClassModel}. * traversing the elements of a {@link java.lang.classfile.ClassModel}.
* *
* <p>The specification of the {@code ModuleHashes} attribute is: * <p>The specification of the {@code ModuleHashes} attribute is:
* <pre> {@code * <pre> {@code
@ -67,7 +68,10 @@ import jdk.internal.classfile.impl.UnboundAttribute;
* The attribute does not permit multiple instances in a given location. * The attribute does not permit multiple instances in a given location.
* Subsequent occurrence of the attribute takes precedence during the attributed * Subsequent occurrence of the attribute takes precedence during the attributed
* element build or transformation. * element build or transformation.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface ModuleHashesAttribute public sealed interface ModuleHashesAttribute
extends Attribute<ModuleHashesAttribute>, ClassElement extends Attribute<ModuleHashesAttribute>, ClassElement
permits BoundAttribute.BoundModuleHashesAttribute, UnboundAttribute.UnboundModuleHashesAttribute { permits BoundAttribute.BoundModuleHashesAttribute, UnboundAttribute.UnboundModuleHashesAttribute {

View file

@ -23,26 +23,32 @@
* questions. * questions.
*/ */
package jdk.internal.classfile.attribute; package java.lang.classfile.attribute;
import java.lang.constant.ClassDesc; import java.lang.constant.ClassDesc;
import jdk.internal.classfile.Attribute; import java.lang.classfile.Attribute;
import jdk.internal.classfile.ClassElement; import java.lang.classfile.ClassElement;
import jdk.internal.classfile.constantpool.ClassEntry; import java.lang.classfile.constantpool.ClassEntry;
import jdk.internal.classfile.impl.BoundAttribute; import jdk.internal.classfile.impl.BoundAttribute;
import jdk.internal.classfile.impl.TemporaryConstantPool; import jdk.internal.classfile.impl.TemporaryConstantPool;
import jdk.internal.classfile.impl.UnboundAttribute; import jdk.internal.classfile.impl.UnboundAttribute;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models the {@code ModuleMainClass} attribute {@jvms 4.7.27}, which can * Models the {@code ModuleMainClass} attribute {@jvms 4.7.27}, which can
* appear on classes that represent module descriptors. * appear on classes that represent module descriptors.
* Delivered as a {@link jdk.internal.classfile.ClassElement} when * Delivered as a {@link java.lang.classfile.ClassElement} when
* traversing the elements of a {@link jdk.internal.classfile.ClassModel}. * traversing the elements of a {@link java.lang.classfile.ClassModel}.
* <p> * <p>
* The attribute does not permit multiple instances in a given location. * The attribute does not permit multiple instances in a given location.
* Subsequent occurrence of the attribute takes precedence during the attributed * Subsequent occurrence of the attribute takes precedence during the attributed
* element build or transformation. * element build or transformation.
* <p>
* The attribute was introduced in the Java SE Platform version 9.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface ModuleMainClassAttribute public sealed interface ModuleMainClassAttribute
extends Attribute<ModuleMainClassAttribute>, ClassElement extends Attribute<ModuleMainClassAttribute>, ClassElement
permits BoundAttribute.BoundModuleMainClassAttribute, UnboundAttribute.UnboundModuleMainClassAttribute { permits BoundAttribute.BoundModuleMainClassAttribute, UnboundAttribute.UnboundModuleMainClassAttribute {
@ -63,6 +69,7 @@ public sealed interface ModuleMainClassAttribute
/** /**
* {@return a {@code ModuleMainClass} attribute} * {@return a {@code ModuleMainClass} attribute}
* @param mainClass the main class * @param mainClass the main class
* @throws IllegalArgumentException if {@code mainClass} represents a primitive type
*/ */
static ModuleMainClassAttribute of(ClassDesc mainClass) { static ModuleMainClassAttribute of(ClassDesc mainClass) {
return new UnboundAttribute.UnboundModuleMainClassAttribute(TemporaryConstantPool.INSTANCE.classEntry(mainClass)); return new UnboundAttribute.UnboundModuleMainClassAttribute(TemporaryConstantPool.INSTANCE.classEntry(mainClass));

View file

@ -22,14 +22,14 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
package jdk.internal.classfile.attribute; package java.lang.classfile.attribute;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import jdk.internal.classfile.constantpool.ModuleEntry; import java.lang.classfile.constantpool.ModuleEntry;
import jdk.internal.classfile.constantpool.PackageEntry; import java.lang.classfile.constantpool.PackageEntry;
import java.lang.constant.ModuleDesc; import java.lang.constant.ModuleDesc;
import java.lang.constant.PackageDesc; import java.lang.constant.PackageDesc;
import java.lang.reflect.AccessFlag; import java.lang.reflect.AccessFlag;
@ -37,10 +37,14 @@ import java.lang.reflect.AccessFlag;
import jdk.internal.classfile.impl.TemporaryConstantPool; import jdk.internal.classfile.impl.TemporaryConstantPool;
import jdk.internal.classfile.impl.UnboundAttribute; import jdk.internal.classfile.impl.UnboundAttribute;
import jdk.internal.classfile.impl.Util; import jdk.internal.classfile.impl.Util;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models a single "opens" declaration in the {@link ModuleAttribute}. * Models a single "opens" declaration in the {@link ModuleAttribute}.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface ModuleOpenInfo public sealed interface ModuleOpenInfo
permits UnboundAttribute.UnboundModuleOpenInfo { permits UnboundAttribute.UnboundModuleOpenInfo {
@ -51,8 +55,8 @@ public sealed interface ModuleOpenInfo
/** /**
* {@return the flags associated with this open declaration, as a bit mask} * {@return the flags associated with this open declaration, as a bit mask}
* Valid flags include {@link jdk.internal.classfile.Classfile#ACC_SYNTHETIC} and * Valid flags include {@link java.lang.classfile.ClassFile#ACC_SYNTHETIC} and
* {@link jdk.internal.classfile.Classfile#ACC_MANDATED} * {@link java.lang.classfile.ClassFile#ACC_MANDATED}
*/ */
int opensFlagsMask(); int opensFlagsMask();

View file

@ -22,30 +22,36 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
package jdk.internal.classfile.attribute; package java.lang.classfile.attribute;
import jdk.internal.classfile.Attribute; import java.lang.classfile.Attribute;
import jdk.internal.classfile.ClassElement; import java.lang.classfile.ClassElement;
import jdk.internal.classfile.impl.BoundAttribute; import jdk.internal.classfile.impl.BoundAttribute;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import jdk.internal.classfile.constantpool.PackageEntry; import java.lang.classfile.constantpool.PackageEntry;
import java.lang.constant.PackageDesc; import java.lang.constant.PackageDesc;
import jdk.internal.classfile.impl.TemporaryConstantPool; import jdk.internal.classfile.impl.TemporaryConstantPool;
import jdk.internal.classfile.impl.UnboundAttribute; import jdk.internal.classfile.impl.UnboundAttribute;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models the {@code ModulePackages} attribute {@jvms 4.7.26}, which can * Models the {@code ModulePackages} attribute {@jvms 4.7.26}, which can
* appear on classes that represent module descriptors. * appear on classes that represent module descriptors.
* Delivered as a {@link jdk.internal.classfile.ClassElement} when * Delivered as a {@link java.lang.classfile.ClassElement} when
* traversing the elements of a {@link jdk.internal.classfile.ClassModel}. * traversing the elements of a {@link java.lang.classfile.ClassModel}.
* <p> * <p>
* The attribute does not permit multiple instances in a given location. * The attribute does not permit multiple instances in a given location.
* Subsequent occurrence of the attribute takes precedence during the attributed * Subsequent occurrence of the attribute takes precedence during the attributed
* element build or transformation. * element build or transformation.
* <p>
* The attribute was introduced in the Java SE Platform version 9.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface ModulePackagesAttribute public sealed interface ModulePackagesAttribute
extends Attribute<ModulePackagesAttribute>, ClassElement extends Attribute<ModulePackagesAttribute>, ClassElement
permits BoundAttribute.BoundModulePackagesAttribute, permits BoundAttribute.BoundModulePackagesAttribute,

View file

@ -22,20 +22,24 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
package jdk.internal.classfile.attribute; package java.lang.classfile.attribute;
import java.lang.constant.ClassDesc; import java.lang.constant.ClassDesc;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import jdk.internal.classfile.constantpool.ClassEntry; import java.lang.classfile.constantpool.ClassEntry;
import jdk.internal.classfile.impl.TemporaryConstantPool; import jdk.internal.classfile.impl.TemporaryConstantPool;
import jdk.internal.classfile.impl.UnboundAttribute; import jdk.internal.classfile.impl.UnboundAttribute;
import jdk.internal.classfile.impl.Util; import jdk.internal.classfile.impl.Util;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models a single "provides" declaration in the {@link ModuleAttribute}. * Models a single "provides" declaration in the {@link ModuleAttribute}.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface ModuleProvideInfo public sealed interface ModuleProvideInfo
permits UnboundAttribute.UnboundModuleProvideInfo { permits UnboundAttribute.UnboundModuleProvideInfo {
@ -73,6 +77,7 @@ public sealed interface ModuleProvideInfo
* {@return a service provision description} * {@return a service provision description}
* @param provides the service class interface * @param provides the service class interface
* @param providesWith the service class implementations * @param providesWith the service class implementations
* @throws IllegalArgumentException if {@code provides} represents a primitive type
*/ */
static ModuleProvideInfo of(ClassDesc provides, static ModuleProvideInfo of(ClassDesc provides,
List<ClassDesc> providesWith) { List<ClassDesc> providesWith) {
@ -83,6 +88,7 @@ public sealed interface ModuleProvideInfo
* {@return a service provision description} * {@return a service provision description}
* @param provides the service class interface * @param provides the service class interface
* @param providesWith the service class implementations * @param providesWith the service class implementations
* @throws IllegalArgumentException if {@code provides} or any of {@code providesWith} represents a primitive type
*/ */
static ModuleProvideInfo of(ClassDesc provides, static ModuleProvideInfo of(ClassDesc provides,
ClassDesc... providesWith) { ClassDesc... providesWith) {

View file

@ -22,23 +22,27 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
package jdk.internal.classfile.attribute; package java.lang.classfile.attribute;
import java.util.Collection; import java.util.Collection;
import java.util.Optional; import java.util.Optional;
import java.util.Set; import java.util.Set;
import jdk.internal.classfile.constantpool.ModuleEntry; import java.lang.classfile.constantpool.ModuleEntry;
import jdk.internal.classfile.constantpool.Utf8Entry; import java.lang.classfile.constantpool.Utf8Entry;
import java.lang.reflect.AccessFlag; import java.lang.reflect.AccessFlag;
import java.lang.constant.ModuleDesc; import java.lang.constant.ModuleDesc;
import jdk.internal.classfile.impl.TemporaryConstantPool; import jdk.internal.classfile.impl.TemporaryConstantPool;
import jdk.internal.classfile.impl.UnboundAttribute; import jdk.internal.classfile.impl.UnboundAttribute;
import jdk.internal.classfile.impl.Util; import jdk.internal.classfile.impl.Util;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models a single "requires" declaration in the {@link ModuleAttribute}. * Models a single "requires" declaration in the {@link ModuleAttribute}.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface ModuleRequireInfo public sealed interface ModuleRequireInfo
permits UnboundAttribute.UnboundModuleRequiresInfo { permits UnboundAttribute.UnboundModuleRequiresInfo {
@ -49,10 +53,10 @@ public sealed interface ModuleRequireInfo
/** /**
* {@return the flags associated with this require declaration, as a bit mask} * {@return the flags associated with this require declaration, as a bit mask}
* Valid flags include {@link jdk.internal.classfile.Classfile#ACC_TRANSITIVE}, * Valid flags include {@link java.lang.classfile.ClassFile#ACC_TRANSITIVE},
* {@link jdk.internal.classfile.Classfile#ACC_STATIC_PHASE}, * {@link java.lang.classfile.ClassFile#ACC_STATIC_PHASE},
* {@link jdk.internal.classfile.Classfile#ACC_SYNTHETIC} and * {@link java.lang.classfile.ClassFile#ACC_SYNTHETIC} and
* {@link jdk.internal.classfile.Classfile#ACC_MANDATED} * {@link java.lang.classfile.ClassFile#ACC_MANDATED}
*/ */
int requiresFlagsMask(); int requiresFlagsMask();

View file

@ -23,19 +23,20 @@
* questions. * questions.
*/ */
package jdk.internal.classfile.attribute; package java.lang.classfile.attribute;
import jdk.internal.classfile.Attribute; import java.lang.classfile.Attribute;
import jdk.internal.classfile.ClassElement; import java.lang.classfile.ClassElement;
import jdk.internal.classfile.impl.BoundAttribute; import jdk.internal.classfile.impl.BoundAttribute;
import jdk.internal.classfile.impl.UnboundAttribute; import jdk.internal.classfile.impl.UnboundAttribute;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models the {@code ModuleResolution} attribute, which can * Models the {@code ModuleResolution} attribute, which can
* appear on classes that represent module descriptors. This is a JDK-specific * appear on classes that represent module descriptors. This is a JDK-specific
* * attribute, which captures resolution metadata for modules. * * attribute, which captures resolution metadata for modules.
* Delivered as a {@link jdk.internal.classfile.ClassElement} when * Delivered as a {@link java.lang.classfile.ClassElement} when
* traversing the elements of a {@link jdk.internal.classfile.ClassModel}. * traversing the elements of a {@link java.lang.classfile.ClassModel}.
* *
* <p>The specification of the {@code ModuleResolution} attribute is: * <p>The specification of the {@code ModuleResolution} attribute is:
* <pre> {@code * <pre> {@code
@ -60,7 +61,10 @@ import jdk.internal.classfile.impl.UnboundAttribute;
* The attribute does not permit multiple instances in a given location. * The attribute does not permit multiple instances in a given location.
* Subsequent occurrence of the attribute takes precedence during the attributed * Subsequent occurrence of the attribute takes precedence during the attributed
* element build or transformation. * element build or transformation.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface ModuleResolutionAttribute public sealed interface ModuleResolutionAttribute
extends Attribute<ModuleResolutionAttribute>, ClassElement extends Attribute<ModuleResolutionAttribute>, ClassElement
permits BoundAttribute.BoundModuleResolutionAttribute, UnboundAttribute.UnboundModuleResolutionAttribute { permits BoundAttribute.BoundModuleResolutionAttribute, UnboundAttribute.UnboundModuleResolutionAttribute {
@ -68,7 +72,7 @@ public sealed interface ModuleResolutionAttribute
/** /**
* The value of the resolution_flags item is a mask of flags used to denote * The value of the resolution_flags item is a mask of flags used to denote
* properties of module resolution. The flags are as follows: * properties of module resolution. The flags are as follows:
* * <pre> {@code
* // Optional * // Optional
* 0x0001 (DO_NOT_RESOLVE_BY_DEFAULT) * 0x0001 (DO_NOT_RESOLVE_BY_DEFAULT)
* *
@ -76,6 +80,7 @@ public sealed interface ModuleResolutionAttribute
* 0x0002 (WARN_DEPRECATED) * 0x0002 (WARN_DEPRECATED)
* 0x0004 (WARN_DEPRECATED_FOR_REMOVAL) * 0x0004 (WARN_DEPRECATED_FOR_REMOVAL)
* 0x0008 (WARN_INCUBATING) * 0x0008 (WARN_INCUBATING)
* } </pre>
* @return the module resolution flags * @return the module resolution flags
*/ */
int resolutionFlags(); int resolutionFlags();

View file

@ -23,21 +23,22 @@
* questions. * questions.
*/ */
package jdk.internal.classfile.attribute; package java.lang.classfile.attribute;
import jdk.internal.classfile.Attribute; import java.lang.classfile.Attribute;
import jdk.internal.classfile.ClassElement; import java.lang.classfile.ClassElement;
import jdk.internal.classfile.constantpool.Utf8Entry; import java.lang.classfile.constantpool.Utf8Entry;
import jdk.internal.classfile.impl.BoundAttribute; import jdk.internal.classfile.impl.BoundAttribute;
import jdk.internal.classfile.impl.TemporaryConstantPool; import jdk.internal.classfile.impl.TemporaryConstantPool;
import jdk.internal.classfile.impl.UnboundAttribute; import jdk.internal.classfile.impl.UnboundAttribute;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models the {@code ModuleTarget} attribute, which can * Models the {@code ModuleTarget} attribute, which can
* appear on classes that represent module descriptors. This is a JDK-specific * appear on classes that represent module descriptors. This is a JDK-specific
* attribute, which captures constraints on the target platform. * attribute, which captures constraints on the target platform.
* Delivered as a {@link jdk.internal.classfile.ClassElement} when * Delivered as a {@link java.lang.classfile.ClassElement} when
* traversing the elements of a {@link jdk.internal.classfile.ClassModel}. * traversing the elements of a {@link java.lang.classfile.ClassModel}.
* *
* <p>The specification of the {@code ModuleTarget} attribute is: * <p>The specification of the {@code ModuleTarget} attribute is:
* <pre> {@code * <pre> {@code
@ -55,7 +56,10 @@ import jdk.internal.classfile.impl.UnboundAttribute;
* The attribute does not permit multiple instances in a given location. * The attribute does not permit multiple instances in a given location.
* Subsequent occurrence of the attribute takes precedence during the attributed * Subsequent occurrence of the attribute takes precedence during the attributed
* element build or transformation. * element build or transformation.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface ModuleTargetAttribute public sealed interface ModuleTargetAttribute
extends Attribute<ModuleTargetAttribute>, ClassElement extends Attribute<ModuleTargetAttribute>, ClassElement
permits BoundAttribute.BoundModuleTargetAttribute, UnboundAttribute.UnboundModuleTargetAttribute { permits BoundAttribute.BoundModuleTargetAttribute, UnboundAttribute.UnboundModuleTargetAttribute {

View file

@ -23,26 +23,32 @@
* questions. * questions.
*/ */
package jdk.internal.classfile.attribute; package java.lang.classfile.attribute;
import java.lang.constant.ClassDesc; import java.lang.constant.ClassDesc;
import jdk.internal.classfile.Attribute; import java.lang.classfile.Attribute;
import jdk.internal.classfile.ClassElement; import java.lang.classfile.ClassElement;
import jdk.internal.classfile.constantpool.ClassEntry; import java.lang.classfile.constantpool.ClassEntry;
import jdk.internal.classfile.impl.BoundAttribute; import jdk.internal.classfile.impl.BoundAttribute;
import jdk.internal.classfile.impl.TemporaryConstantPool; import jdk.internal.classfile.impl.TemporaryConstantPool;
import jdk.internal.classfile.impl.UnboundAttribute; import jdk.internal.classfile.impl.UnboundAttribute;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models the {@code NestHost} attribute {@jvms 4.7.28}, which can * Models the {@code NestHost} attribute {@jvms 4.7.28}, which can
* appear on classes to indicate that this class is a member of a nest. * appear on classes to indicate that this class is a member of a nest.
* Delivered as a {@link jdk.internal.classfile.ClassElement} when * Delivered as a {@link java.lang.classfile.ClassElement} when
* traversing the elements of a {@link jdk.internal.classfile.ClassModel}. * traversing the elements of a {@link java.lang.classfile.ClassModel}.
* <p> * <p>
* The attribute does not permit multiple instances in a given location. * The attribute does not permit multiple instances in a given location.
* Subsequent occurrence of the attribute takes precedence during the attributed * Subsequent occurrence of the attribute takes precedence during the attributed
* element build or transformation. * element build or transformation.
* <p>
* The attribute was introduced in the Java SE Platform version 11.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface NestHostAttribute extends Attribute<NestHostAttribute>, ClassElement public sealed interface NestHostAttribute extends Attribute<NestHostAttribute>, ClassElement
permits BoundAttribute.BoundNestHostAttribute, permits BoundAttribute.BoundNestHostAttribute,
UnboundAttribute.UnboundNestHostAttribute { UnboundAttribute.UnboundNestHostAttribute {
@ -63,6 +69,7 @@ public sealed interface NestHostAttribute extends Attribute<NestHostAttribute>,
/** /**
* {@return a {@code NestHost} attribute} * {@return a {@code NestHost} attribute}
* @param nestHost the host class of the nest * @param nestHost the host class of the nest
* @throws IllegalArgumentException if {@code nestHost} represents a primitive type
*/ */
static NestHostAttribute of(ClassDesc nestHost) { static NestHostAttribute of(ClassDesc nestHost) {
return of(TemporaryConstantPool.INSTANCE.classEntry(nestHost)); return of(TemporaryConstantPool.INSTANCE.classEntry(nestHost));

View file

@ -22,29 +22,35 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
package jdk.internal.classfile.attribute; package java.lang.classfile.attribute;
import java.lang.constant.ClassDesc; import java.lang.constant.ClassDesc;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import jdk.internal.classfile.Attribute; import java.lang.classfile.Attribute;
import jdk.internal.classfile.ClassElement; import java.lang.classfile.ClassElement;
import jdk.internal.classfile.constantpool.ClassEntry; import java.lang.classfile.constantpool.ClassEntry;
import jdk.internal.classfile.impl.BoundAttribute; import jdk.internal.classfile.impl.BoundAttribute;
import jdk.internal.classfile.impl.UnboundAttribute; import jdk.internal.classfile.impl.UnboundAttribute;
import jdk.internal.classfile.impl.Util; import jdk.internal.classfile.impl.Util;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models the {@code NestMembers} attribute {@jvms 4.7.29}, which can * Models the {@code NestMembers} attribute {@jvms 4.7.29}, which can
* appear on classes to indicate that this class is the host of a nest. * appear on classes to indicate that this class is the host of a nest.
* Delivered as a {@link jdk.internal.classfile.ClassElement} when * Delivered as a {@link java.lang.classfile.ClassElement} when
* traversing the elements of a {@link jdk.internal.classfile.ClassModel}. * traversing the elements of a {@link java.lang.classfile.ClassModel}.
* <p> * <p>
* The attribute does not permit multiple instances in a given location. * The attribute does not permit multiple instances in a given location.
* Subsequent occurrence of the attribute takes precedence during the attributed * Subsequent occurrence of the attribute takes precedence during the attributed
* element build or transformation. * element build or transformation.
* <p>
* The attribute was introduced in the Java SE Platform version 11.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface NestMembersAttribute extends Attribute<NestMembersAttribute>, ClassElement public sealed interface NestMembersAttribute extends Attribute<NestMembersAttribute>, ClassElement
permits BoundAttribute.BoundNestMembersAttribute, UnboundAttribute.UnboundNestMembersAttribute { permits BoundAttribute.BoundNestMembersAttribute, UnboundAttribute.UnboundNestMembersAttribute {

View file

@ -22,29 +22,35 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
package jdk.internal.classfile.attribute; package java.lang.classfile.attribute;
import java.lang.constant.ClassDesc; import java.lang.constant.ClassDesc;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import jdk.internal.classfile.Attribute; import java.lang.classfile.Attribute;
import jdk.internal.classfile.ClassElement; import java.lang.classfile.ClassElement;
import jdk.internal.classfile.constantpool.ClassEntry; import java.lang.classfile.constantpool.ClassEntry;
import jdk.internal.classfile.impl.BoundAttribute; import jdk.internal.classfile.impl.BoundAttribute;
import jdk.internal.classfile.impl.UnboundAttribute; import jdk.internal.classfile.impl.UnboundAttribute;
import jdk.internal.classfile.impl.Util; import jdk.internal.classfile.impl.Util;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models the {@code PermittedSubclasses} attribute {@jvms 4.7.31}, which can * Models the {@code PermittedSubclasses} attribute {@jvms 4.7.31}, which can
* appear on classes to indicate which classes may extend this class. * appear on classes to indicate which classes may extend this class.
* Delivered as a {@link jdk.internal.classfile.ClassElement} when * Delivered as a {@link java.lang.classfile.ClassElement} when
* traversing the elements of a {@link jdk.internal.classfile.ClassModel}. * traversing the elements of a {@link java.lang.classfile.ClassModel}.
* <p> * <p>
* The attribute does not permit multiple instances in a given location. * The attribute does not permit multiple instances in a given location.
* Subsequent occurrence of the attribute takes precedence during the attributed * Subsequent occurrence of the attribute takes precedence during the attributed
* element build or transformation. * element build or transformation.
* <p>
* The attribute was introduced in the Java SE Platform version 17.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface PermittedSubclassesAttribute public sealed interface PermittedSubclassesAttribute
extends Attribute<PermittedSubclassesAttribute>, ClassElement extends Attribute<PermittedSubclassesAttribute>, ClassElement
permits BoundAttribute.BoundPermittedSubclassesAttribute, UnboundAttribute.UnboundPermittedSubclassesAttribute { permits BoundAttribute.BoundPermittedSubclassesAttribute, UnboundAttribute.UnboundPermittedSubclassesAttribute {

View file

@ -23,25 +23,31 @@
* questions. * questions.
*/ */
package jdk.internal.classfile.attribute; package java.lang.classfile.attribute;
import java.util.List; import java.util.List;
import jdk.internal.classfile.Attribute; import java.lang.classfile.Attribute;
import jdk.internal.classfile.ClassElement; import java.lang.classfile.ClassElement;
import jdk.internal.classfile.impl.BoundAttribute; import jdk.internal.classfile.impl.BoundAttribute;
import jdk.internal.classfile.impl.UnboundAttribute; import jdk.internal.classfile.impl.UnboundAttribute;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models the {@code Record} attribute {@jvms 4.7.30}, which can * Models the {@code Record} attribute {@jvms 4.7.30}, which can
* appear on classes to indicate that this class is a record class. * appear on classes to indicate that this class is a record class.
* Delivered as a {@link jdk.internal.classfile.ClassElement} when * Delivered as a {@link java.lang.classfile.ClassElement} when
* traversing the elements of a {@link jdk.internal.classfile.ClassModel}. * traversing the elements of a {@link java.lang.classfile.ClassModel}.
* <p> * <p>
* The attribute does not permit multiple instances in a given location. * The attribute does not permit multiple instances in a given location.
* Subsequent occurrence of the attribute takes precedence during the attributed * Subsequent occurrence of the attribute takes precedence during the attributed
* element build or transformation. * element build or transformation.
* <p>
* The attribute was introduced in the Java SE Platform version 16.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface RecordAttribute extends Attribute<RecordAttribute>, ClassElement public sealed interface RecordAttribute extends Attribute<RecordAttribute>, ClassElement
permits BoundAttribute.BoundRecordAttribute, UnboundAttribute.UnboundRecordAttribute { permits BoundAttribute.BoundRecordAttribute, UnboundAttribute.UnboundRecordAttribute {

View file

@ -22,21 +22,25 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
package jdk.internal.classfile.attribute; package java.lang.classfile.attribute;
import java.lang.constant.ClassDesc; import java.lang.constant.ClassDesc;
import java.util.List; import java.util.List;
import jdk.internal.classfile.Attribute; import java.lang.classfile.Attribute;
import jdk.internal.classfile.AttributedElement; import java.lang.classfile.AttributedElement;
import jdk.internal.classfile.constantpool.Utf8Entry; import java.lang.classfile.constantpool.Utf8Entry;
import jdk.internal.classfile.impl.BoundRecordComponentInfo; import jdk.internal.classfile.impl.BoundRecordComponentInfo;
import jdk.internal.classfile.impl.TemporaryConstantPool; import jdk.internal.classfile.impl.TemporaryConstantPool;
import jdk.internal.classfile.impl.UnboundAttribute; import jdk.internal.classfile.impl.UnboundAttribute;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models a single record component in the {@link jdk.internal.classfile.attribute.RecordAttribute}. * Models a single record component in the {@link java.lang.classfile.attribute.RecordAttribute}.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface RecordComponentInfo public sealed interface RecordComponentInfo
extends AttributedElement extends AttributedElement
permits BoundRecordComponentInfo, UnboundAttribute.UnboundRecordComponentInfo { permits BoundRecordComponentInfo, UnboundAttribute.UnboundRecordComponentInfo {

View file

@ -23,24 +23,30 @@
* questions. * questions.
*/ */
package jdk.internal.classfile.attribute; package java.lang.classfile.attribute;
import jdk.internal.classfile.*; import java.lang.classfile.*;
import jdk.internal.classfile.impl.BoundAttribute; import jdk.internal.classfile.impl.BoundAttribute;
import jdk.internal.classfile.impl.UnboundAttribute; import jdk.internal.classfile.impl.UnboundAttribute;
import java.util.List; import java.util.List;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models the {@code RuntimeInvisibleAnnotations} attribute {@jvms 4.7.17}, which * Models the {@code RuntimeInvisibleAnnotations} attribute {@jvms 4.7.17}, which
* can appear on classes, methods, and fields. Delivered as a * can appear on classes, methods, and fields. Delivered as a
* {@link jdk.internal.classfile.ClassElement}, {@link jdk.internal.classfile.FieldElement}, or * {@link java.lang.classfile.ClassElement}, {@link java.lang.classfile.FieldElement}, or
* {@link jdk.internal.classfile.MethodElement} when traversing the corresponding model type. * {@link java.lang.classfile.MethodElement} when traversing the corresponding model type.
* <p> * <p>
* The attribute does not permit multiple instances in a given location. * The attribute does not permit multiple instances in a given location.
* Subsequent occurrence of the attribute takes precedence during the attributed * Subsequent occurrence of the attribute takes precedence during the attributed
* element build or transformation. * element build or transformation.
* <p>
* The attribute was introduced in the Java SE Platform version 5.0.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface RuntimeInvisibleAnnotationsAttribute public sealed interface RuntimeInvisibleAnnotationsAttribute
extends Attribute<RuntimeInvisibleAnnotationsAttribute>, extends Attribute<RuntimeInvisibleAnnotationsAttribute>,
ClassElement, MethodElement, FieldElement ClassElement, MethodElement, FieldElement

View file

@ -23,26 +23,32 @@
* questions. * questions.
*/ */
package jdk.internal.classfile.attribute; package java.lang.classfile.attribute;
import java.util.List; import java.util.List;
import jdk.internal.classfile.Annotation; import java.lang.classfile.Annotation;
import jdk.internal.classfile.Attribute; import java.lang.classfile.Attribute;
import jdk.internal.classfile.MethodElement; import java.lang.classfile.MethodElement;
import jdk.internal.classfile.MethodModel; import java.lang.classfile.MethodModel;
import jdk.internal.classfile.impl.BoundAttribute; import jdk.internal.classfile.impl.BoundAttribute;
import jdk.internal.classfile.impl.UnboundAttribute; import jdk.internal.classfile.impl.UnboundAttribute;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models the {@code RuntimeInvisibleParameterAnnotations} attribute * Models the {@code RuntimeInvisibleParameterAnnotations} attribute
* {@jvms 4.7.19}, which can appear on methods. Delivered as a {@link * {@jvms 4.7.19}, which can appear on methods. Delivered as a {@link
* jdk.internal.classfile.MethodElement} when traversing a {@link MethodModel}. * java.lang.classfile.MethodElement} when traversing a {@link MethodModel}.
* <p> * <p>
* The attribute does not permit multiple instances in a given location. * The attribute does not permit multiple instances in a given location.
* Subsequent occurrence of the attribute takes precedence during the attributed * Subsequent occurrence of the attribute takes precedence during the attributed
* element build or transformation. * element build or transformation.
* <p>
* The attribute was introduced in the Java SE Platform version 5.0.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface RuntimeInvisibleParameterAnnotationsAttribute public sealed interface RuntimeInvisibleParameterAnnotationsAttribute
extends Attribute<RuntimeInvisibleParameterAnnotationsAttribute>, MethodElement extends Attribute<RuntimeInvisibleParameterAnnotationsAttribute>, MethodElement
permits BoundAttribute.BoundRuntimeInvisibleParameterAnnotationsAttribute, permits BoundAttribute.BoundRuntimeInvisibleParameterAnnotationsAttribute,

View file

@ -23,30 +23,36 @@
* questions. * questions.
*/ */
package jdk.internal.classfile.attribute; package java.lang.classfile.attribute;
import java.util.List; import java.util.List;
import jdk.internal.classfile.Attribute; import java.lang.classfile.Attribute;
import jdk.internal.classfile.ClassElement; import java.lang.classfile.ClassElement;
import jdk.internal.classfile.CodeElement; import java.lang.classfile.CodeElement;
import jdk.internal.classfile.FieldElement; import java.lang.classfile.FieldElement;
import jdk.internal.classfile.MethodElement; import java.lang.classfile.MethodElement;
import jdk.internal.classfile.TypeAnnotation; import java.lang.classfile.TypeAnnotation;
import jdk.internal.classfile.impl.BoundAttribute; import jdk.internal.classfile.impl.BoundAttribute;
import jdk.internal.classfile.impl.UnboundAttribute; import jdk.internal.classfile.impl.UnboundAttribute;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models the {@code RuntimeInvisibleTypeAnnotations} attribute {@jvms 4.7.21}, which * Models the {@code RuntimeInvisibleTypeAnnotations} attribute {@jvms 4.7.21}, which
* can appear on classes, methods, fields, and code attributes. Delivered as a * can appear on classes, methods, fields, and code attributes. Delivered as a
* {@link jdk.internal.classfile.ClassElement}, {@link jdk.internal.classfile.FieldElement}, * {@link java.lang.classfile.ClassElement}, {@link java.lang.classfile.FieldElement},
* {@link jdk.internal.classfile.MethodElement}, or {@link CodeElement} when traversing * {@link java.lang.classfile.MethodElement}, or {@link CodeElement} when traversing
* the corresponding model type. * the corresponding model type.
* <p> * <p>
* The attribute does not permit multiple instances in a given location. * The attribute does not permit multiple instances in a given location.
* Subsequent occurrence of the attribute takes precedence during the attributed * Subsequent occurrence of the attribute takes precedence during the attributed
* element build or transformation. * element build or transformation.
* <p>
* The attribute was introduced in the Java SE Platform version 8.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface RuntimeInvisibleTypeAnnotationsAttribute public sealed interface RuntimeInvisibleTypeAnnotationsAttribute
extends Attribute<RuntimeInvisibleTypeAnnotationsAttribute>, extends Attribute<RuntimeInvisibleTypeAnnotationsAttribute>,
ClassElement, MethodElement, FieldElement, CodeElement ClassElement, MethodElement, FieldElement, CodeElement

View file

@ -23,24 +23,30 @@
* questions. * questions.
*/ */
package jdk.internal.classfile.attribute; package java.lang.classfile.attribute;
import jdk.internal.classfile.*; import java.lang.classfile.*;
import jdk.internal.classfile.impl.BoundAttribute; import jdk.internal.classfile.impl.BoundAttribute;
import jdk.internal.classfile.impl.UnboundAttribute; import jdk.internal.classfile.impl.UnboundAttribute;
import java.util.List; import java.util.List;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models the {@code RuntimeVisibleAnnotations} attribute {@jvms 4.7.16}, which * Models the {@code RuntimeVisibleAnnotations} attribute {@jvms 4.7.16}, which
* can appear on classes, methods, and fields. Delivered as a * can appear on classes, methods, and fields. Delivered as a
* {@link jdk.internal.classfile.ClassElement}, {@link jdk.internal.classfile.FieldElement}, or * {@link java.lang.classfile.ClassElement}, {@link java.lang.classfile.FieldElement}, or
* {@link jdk.internal.classfile.MethodElement} when traversing the corresponding model type. * {@link java.lang.classfile.MethodElement} when traversing the corresponding model type.
* <p> * <p>
* The attribute does not permit multiple instances in a given location. * The attribute does not permit multiple instances in a given location.
* Subsequent occurrence of the attribute takes precedence during the attributed * Subsequent occurrence of the attribute takes precedence during the attributed
* element build or transformation. * element build or transformation.
* <p>
* The attribute was introduced in the Java SE Platform version 5.0.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface RuntimeVisibleAnnotationsAttribute public sealed interface RuntimeVisibleAnnotationsAttribute
extends Attribute<RuntimeVisibleAnnotationsAttribute>, extends Attribute<RuntimeVisibleAnnotationsAttribute>,
ClassElement, MethodElement, FieldElement ClassElement, MethodElement, FieldElement

View file

@ -23,26 +23,32 @@
* questions. * questions.
*/ */
package jdk.internal.classfile.attribute; package java.lang.classfile.attribute;
import java.util.List; import java.util.List;
import jdk.internal.classfile.Annotation; import java.lang.classfile.Annotation;
import jdk.internal.classfile.Attribute; import java.lang.classfile.Attribute;
import jdk.internal.classfile.MethodElement; import java.lang.classfile.MethodElement;
import jdk.internal.classfile.MethodModel; import java.lang.classfile.MethodModel;
import jdk.internal.classfile.impl.BoundAttribute; import jdk.internal.classfile.impl.BoundAttribute;
import jdk.internal.classfile.impl.UnboundAttribute; import jdk.internal.classfile.impl.UnboundAttribute;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models the {@code RuntimeVisibleParameterAnnotations} attribute {@jvms 4.7.18}, which * Models the {@code RuntimeVisibleParameterAnnotations} attribute {@jvms 4.7.18}, which
* can appear on methods. Delivered as a {@link jdk.internal.classfile.MethodElement} * can appear on methods. Delivered as a {@link java.lang.classfile.MethodElement}
* when traversing a {@link MethodModel}. * when traversing a {@link MethodModel}.
* *
* @apiNote The attribute does not permit multiple instances in a given location. * @apiNote The attribute does not permit multiple instances in a given location.
* Subsequent occurrence of the attribute takes precedence during the attributed * Subsequent occurrence of the attribute takes precedence during the attributed
* element build or transformation. * element build or transformation.
* <p>
* The attribute was introduced in the Java SE Platform version 5.0.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface RuntimeVisibleParameterAnnotationsAttribute public sealed interface RuntimeVisibleParameterAnnotationsAttribute
extends Attribute<RuntimeVisibleParameterAnnotationsAttribute>, MethodElement extends Attribute<RuntimeVisibleParameterAnnotationsAttribute>, MethodElement
permits BoundAttribute.BoundRuntimeVisibleParameterAnnotationsAttribute, permits BoundAttribute.BoundRuntimeVisibleParameterAnnotationsAttribute,

View file

@ -23,30 +23,36 @@
* questions. * questions.
*/ */
package jdk.internal.classfile.attribute; package java.lang.classfile.attribute;
import java.util.List; import java.util.List;
import jdk.internal.classfile.Attribute; import java.lang.classfile.Attribute;
import jdk.internal.classfile.ClassElement; import java.lang.classfile.ClassElement;
import jdk.internal.classfile.CodeElement; import java.lang.classfile.CodeElement;
import jdk.internal.classfile.FieldElement; import java.lang.classfile.FieldElement;
import jdk.internal.classfile.MethodElement; import java.lang.classfile.MethodElement;
import jdk.internal.classfile.TypeAnnotation; import java.lang.classfile.TypeAnnotation;
import jdk.internal.classfile.impl.BoundAttribute; import jdk.internal.classfile.impl.BoundAttribute;
import jdk.internal.classfile.impl.UnboundAttribute; import jdk.internal.classfile.impl.UnboundAttribute;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models the {@code RuntimeVisibleTypeAnnotations} attribute {@jvms 4.7.20}, which * Models the {@code RuntimeVisibleTypeAnnotations} attribute {@jvms 4.7.20}, which
* can appear on classes, methods, fields, and code attributes. Delivered as a * can appear on classes, methods, fields, and code attributes. Delivered as a
* {@link jdk.internal.classfile.ClassElement}, {@link jdk.internal.classfile.FieldElement}, * {@link java.lang.classfile.ClassElement}, {@link java.lang.classfile.FieldElement},
* {@link jdk.internal.classfile.MethodElement}, or {@link CodeElement} when traversing * {@link java.lang.classfile.MethodElement}, or {@link CodeElement} when traversing
* the corresponding model type. * the corresponding model type.
* <p> * <p>
* The attribute does not permit multiple instances in a given location. * The attribute does not permit multiple instances in a given location.
* Subsequent occurrence of the attribute takes precedence during the attributed * Subsequent occurrence of the attribute takes precedence during the attributed
* element build or transformation. * element build or transformation.
* <p>
* The attribute was introduced in the Java SE Platform version 8.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface RuntimeVisibleTypeAnnotationsAttribute public sealed interface RuntimeVisibleTypeAnnotationsAttribute
extends Attribute<RuntimeVisibleTypeAnnotationsAttribute>, extends Attribute<RuntimeVisibleTypeAnnotationsAttribute>,
ClassElement, MethodElement, FieldElement, CodeElement ClassElement, MethodElement, FieldElement, CodeElement

View file

@ -23,31 +23,37 @@
* questions. * questions.
*/ */
package jdk.internal.classfile.attribute; package java.lang.classfile.attribute;
import jdk.internal.classfile.Attribute; import java.lang.classfile.Attribute;
import jdk.internal.classfile.ClassElement; import java.lang.classfile.ClassElement;
import jdk.internal.classfile.ClassSignature; import java.lang.classfile.ClassSignature;
import jdk.internal.classfile.FieldElement; import java.lang.classfile.FieldElement;
import jdk.internal.classfile.MethodElement; import java.lang.classfile.MethodElement;
import jdk.internal.classfile.constantpool.Utf8Entry; import java.lang.classfile.constantpool.Utf8Entry;
import jdk.internal.classfile.impl.BoundAttribute; import jdk.internal.classfile.impl.BoundAttribute;
import jdk.internal.classfile.MethodSignature; import java.lang.classfile.MethodSignature;
import jdk.internal.classfile.Signature; import java.lang.classfile.Signature;
import jdk.internal.classfile.impl.TemporaryConstantPool; import jdk.internal.classfile.impl.TemporaryConstantPool;
import jdk.internal.classfile.impl.UnboundAttribute; import jdk.internal.classfile.impl.UnboundAttribute;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models the {@code Signature} attribute {@jvms 4.7.9}, which * Models the {@code Signature} attribute {@jvms 4.7.9}, which
* can appear on classes, methods, or fields. Delivered as a * can appear on classes, methods, or fields. Delivered as a
* {@link jdk.internal.classfile.ClassElement}, {@link jdk.internal.classfile.FieldElement}, or * {@link java.lang.classfile.ClassElement}, {@link java.lang.classfile.FieldElement}, or
* {@link jdk.internal.classfile.MethodElement} when traversing * {@link java.lang.classfile.MethodElement} when traversing
* the corresponding model type. * the corresponding model type.
* <p> * <p>
* The attribute does not permit multiple instances in a given location. * The attribute does not permit multiple instances in a given location.
* Subsequent occurrence of the attribute takes precedence during the attributed * Subsequent occurrence of the attribute takes precedence during the attributed
* element build or transformation. * element build or transformation.
* <p>
* The attribute was introduced in the Java SE Platform version 5.0.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface SignatureAttribute public sealed interface SignatureAttribute
extends Attribute<SignatureAttribute>, extends Attribute<SignatureAttribute>,
ClassElement, MethodElement, FieldElement ClassElement, MethodElement, FieldElement

View file

@ -23,22 +23,28 @@
* questions. * questions.
*/ */
package jdk.internal.classfile.attribute; package java.lang.classfile.attribute;
import jdk.internal.classfile.Attribute; import java.lang.classfile.Attribute;
import jdk.internal.classfile.ClassElement; import java.lang.classfile.ClassElement;
import jdk.internal.classfile.impl.BoundAttribute; import jdk.internal.classfile.impl.BoundAttribute;
import jdk.internal.classfile.impl.UnboundAttribute; import jdk.internal.classfile.impl.UnboundAttribute;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models the {@code SourceDebugExtension} attribute. * Models the {@code SourceDebugExtension} attribute.
* Delivered as a {@link jdk.internal.classfile.ClassElement} when traversing the elements of * Delivered as a {@link java.lang.classfile.ClassElement} when traversing the elements of
* a {@link jdk.internal.classfile.ClassModel}. * a {@link java.lang.classfile.ClassModel}.
* <p> * <p>
* The attribute does not permit multiple instances in a given location. * The attribute does not permit multiple instances in a given location.
* Subsequent occurrence of the attribute takes precedence during the attributed * Subsequent occurrence of the attribute takes precedence during the attributed
* element build or transformation. * element build or transformation.
* <p>
* The attribute was introduced in the Java SE Platform version 5.0.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface SourceDebugExtensionAttribute public sealed interface SourceDebugExtensionAttribute
extends Attribute<SourceDebugExtensionAttribute>, ClassElement extends Attribute<SourceDebugExtensionAttribute>, ClassElement
permits BoundAttribute.BoundSourceDebugExtensionAttribute, UnboundAttribute.UnboundSourceDebugExtensionAttribute { permits BoundAttribute.BoundSourceDebugExtensionAttribute, UnboundAttribute.UnboundSourceDebugExtensionAttribute {

View file

@ -23,25 +23,29 @@
* questions. * questions.
*/ */
package jdk.internal.classfile.attribute; package java.lang.classfile.attribute;
import jdk.internal.classfile.Attribute; import java.lang.classfile.Attribute;
import jdk.internal.classfile.ClassElement; import java.lang.classfile.ClassElement;
import jdk.internal.classfile.ClassModel; import java.lang.classfile.ClassModel;
import jdk.internal.classfile.constantpool.Utf8Entry; import java.lang.classfile.constantpool.Utf8Entry;
import jdk.internal.classfile.impl.BoundAttribute; import jdk.internal.classfile.impl.BoundAttribute;
import jdk.internal.classfile.impl.TemporaryConstantPool; import jdk.internal.classfile.impl.TemporaryConstantPool;
import jdk.internal.classfile.impl.UnboundAttribute; import jdk.internal.classfile.impl.UnboundAttribute;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models the {@code SourceFile} attribute {@jvms 4.7.10}, which * Models the {@code SourceFile} attribute {@jvms 4.7.10}, which
* can appear on classes. Delivered as a {@link jdk.internal.classfile.ClassElement} * can appear on classes. Delivered as a {@link java.lang.classfile.ClassElement}
* when traversing a {@link ClassModel}. * when traversing a {@link ClassModel}.
* <p> * <p>
* The attribute does not permit multiple instances in a given location. * The attribute does not permit multiple instances in a given location.
* Subsequent occurrence of the attribute takes precedence during the attributed * Subsequent occurrence of the attribute takes precedence during the attributed
* element build or transformation. * element build or transformation.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface SourceFileAttribute public sealed interface SourceFileAttribute
extends Attribute<SourceFileAttribute>, ClassElement extends Attribute<SourceFileAttribute>, ClassElement
permits BoundAttribute.BoundSourceFileAttribute, UnboundAttribute.UnboundSourceFileAttribute { permits BoundAttribute.BoundSourceFileAttribute, UnboundAttribute.UnboundSourceFileAttribute {

View file

@ -23,25 +23,29 @@
* questions. * questions.
*/ */
package jdk.internal.classfile.attribute; package java.lang.classfile.attribute;
import jdk.internal.classfile.Attribute; import java.lang.classfile.Attribute;
import jdk.internal.classfile.ClassElement; import java.lang.classfile.ClassElement;
import jdk.internal.classfile.ClassModel; import java.lang.classfile.ClassModel;
import jdk.internal.classfile.constantpool.Utf8Entry; import java.lang.classfile.constantpool.Utf8Entry;
import jdk.internal.classfile.impl.BoundAttribute; import jdk.internal.classfile.impl.BoundAttribute;
import jdk.internal.classfile.impl.TemporaryConstantPool; import jdk.internal.classfile.impl.TemporaryConstantPool;
import jdk.internal.classfile.impl.UnboundAttribute; import jdk.internal.classfile.impl.UnboundAttribute;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models the {@code SourceID} attribute, which can * Models the {@code SourceID} attribute, which can
* appear on classes. Delivered as a {@link jdk.internal.classfile.ClassElement} when * appear on classes. Delivered as a {@link java.lang.classfile.ClassElement} when
* traversing a {@link ClassModel}. * traversing a {@link ClassModel}.
* <p> * <p>
* The attribute does not permit multiple instances in a given location. * The attribute does not permit multiple instances in a given location.
* Subsequent occurrence of the attribute takes precedence during the attributed * Subsequent occurrence of the attribute takes precedence during the attributed
* element build or transformation. * element build or transformation.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface SourceIDAttribute public sealed interface SourceIDAttribute
extends Attribute<SourceIDAttribute>, ClassElement extends Attribute<SourceIDAttribute>, ClassElement
permits BoundAttribute.BoundSourceIDAttribute, UnboundAttribute.UnboundSourceIDAttribute { permits BoundAttribute.BoundSourceIDAttribute, UnboundAttribute.UnboundSourceIDAttribute {

View file

@ -23,20 +23,24 @@
* questions. * questions.
*/ */
package jdk.internal.classfile.attribute; package java.lang.classfile.attribute;
import java.lang.constant.ClassDesc; import java.lang.constant.ClassDesc;
import java.util.List; import java.util.List;
import jdk.internal.classfile.Label; import java.lang.classfile.Label;
import jdk.internal.classfile.constantpool.ClassEntry; import java.lang.classfile.constantpool.ClassEntry;
import jdk.internal.classfile.impl.StackMapDecoder; import jdk.internal.classfile.impl.StackMapDecoder;
import jdk.internal.classfile.impl.TemporaryConstantPool; import jdk.internal.classfile.impl.TemporaryConstantPool;
import static jdk.internal.classfile.Classfile.*; import static java.lang.classfile.ClassFile.*;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models stack map frame of {@code StackMapTable} attribute {@jvms 4.7.4}. * Models stack map frame of {@code StackMapTable} attribute {@jvms 4.7.4}.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface StackMapFrameInfo public sealed interface StackMapFrameInfo
permits StackMapDecoder.StackMapFrameImpl { permits StackMapDecoder.StackMapFrameImpl {
@ -75,7 +79,10 @@ public sealed interface StackMapFrameInfo
/** /**
* The type of a stack value. * The type of a stack value.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
sealed interface VerificationTypeInfo { sealed interface VerificationTypeInfo {
/** /**
@ -86,7 +93,10 @@ public sealed interface StackMapFrameInfo
/** /**
* A simple stack value. * A simple stack value.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public enum SimpleVerificationTypeInfo implements VerificationTypeInfo { public enum SimpleVerificationTypeInfo implements VerificationTypeInfo {
/** verification type top */ /** verification type top */
@ -125,7 +135,10 @@ public sealed interface StackMapFrameInfo
/** /**
* A stack value for an object type. * A stack value for an object type.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
sealed interface ObjectVerificationTypeInfo extends VerificationTypeInfo sealed interface ObjectVerificationTypeInfo extends VerificationTypeInfo
permits StackMapDecoder.ObjectVerificationTypeInfoImpl { permits StackMapDecoder.ObjectVerificationTypeInfoImpl {
@ -140,6 +153,7 @@ public sealed interface StackMapFrameInfo
/** /**
* {@return a new object verification type info} * {@return a new object verification type info}
* @param classDesc the class of the object * @param classDesc the class of the object
* @throws IllegalArgumentException if {@code classDesc} represents a primitive type
*/ */
public static ObjectVerificationTypeInfo of(ClassDesc classDesc) { public static ObjectVerificationTypeInfo of(ClassDesc classDesc) {
return of(TemporaryConstantPool.INSTANCE.classEntry(classDesc)); return of(TemporaryConstantPool.INSTANCE.classEntry(classDesc));
@ -160,7 +174,10 @@ public sealed interface StackMapFrameInfo
/** /**
* An uninitialized stack value. * An uninitialized stack value.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
sealed interface UninitializedVerificationTypeInfo extends VerificationTypeInfo sealed interface UninitializedVerificationTypeInfo extends VerificationTypeInfo
permits StackMapDecoder.UninitializedVerificationTypeInfoImpl { permits StackMapDecoder.UninitializedVerificationTypeInfoImpl {

View file

@ -23,14 +23,15 @@
* questions. * questions.
*/ */
package jdk.internal.classfile.attribute; package java.lang.classfile.attribute;
import java.util.List; import java.util.List;
import jdk.internal.classfile.Attribute; import java.lang.classfile.Attribute;
import jdk.internal.classfile.CodeElement; import java.lang.classfile.CodeElement;
import jdk.internal.classfile.impl.BoundAttribute; import jdk.internal.classfile.impl.BoundAttribute;
import jdk.internal.classfile.impl.UnboundAttribute; import jdk.internal.classfile.impl.UnboundAttribute;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models the {@code StackMapTable} attribute {@jvms 4.7.4}, which can appear * Models the {@code StackMapTable} attribute {@jvms 4.7.4}, which can appear
@ -39,7 +40,12 @@ import jdk.internal.classfile.impl.UnboundAttribute;
* The attribute does not permit multiple instances in a given location. * The attribute does not permit multiple instances in a given location.
* Subsequent occurrence of the attribute takes precedence during the attributed * Subsequent occurrence of the attribute takes precedence during the attributed
* element build or transformation. * element build or transformation.
* <p>
* The attribute was introduced in the Java SE Platform version 6.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface StackMapTableAttribute public sealed interface StackMapTableAttribute
extends Attribute<StackMapTableAttribute>, CodeElement extends Attribute<StackMapTableAttribute>, CodeElement
permits BoundAttribute.BoundStackMapTableAttribute, UnboundAttribute.UnboundStackMapTableAttribute { permits BoundAttribute.BoundStackMapTableAttribute, UnboundAttribute.UnboundStackMapTableAttribute {

View file

@ -23,14 +23,15 @@
* questions. * questions.
*/ */
package jdk.internal.classfile.attribute; package java.lang.classfile.attribute;
import jdk.internal.classfile.Attribute; import java.lang.classfile.Attribute;
import jdk.internal.classfile.ClassElement; import java.lang.classfile.ClassElement;
import jdk.internal.classfile.FieldElement; import java.lang.classfile.FieldElement;
import jdk.internal.classfile.MethodElement; import java.lang.classfile.MethodElement;
import jdk.internal.classfile.impl.BoundAttribute; import jdk.internal.classfile.impl.BoundAttribute;
import jdk.internal.classfile.impl.UnboundAttribute; import jdk.internal.classfile.impl.UnboundAttribute;
import jdk.internal.javac.PreviewFeature;
/** /**
* Models the {@code Synthetic} attribute {@jvms 4.7.8}, which can appear on * Models the {@code Synthetic} attribute {@jvms 4.7.8}, which can appear on
@ -39,7 +40,10 @@ import jdk.internal.classfile.impl.UnboundAttribute;
* of a corresponding model. * of a corresponding model.
* <p> * <p>
* The attribute permits multiple instances in a given location. * The attribute permits multiple instances in a given location.
*
* @since 22
*/ */
@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
public sealed interface SyntheticAttribute public sealed interface SyntheticAttribute
extends Attribute<SyntheticAttribute>, extends Attribute<SyntheticAttribute>,
ClassElement, MethodElement, FieldElement ClassElement, MethodElement, FieldElement

Some files were not shown because too many files have changed in this diff Show more