< prev index next >

src/java.base/share/classes/java/lang/classfile/Attribute.java

Print this page

 18  * 2 along with this work; if not, write to the Free Software Foundation,
 19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 20  *
 21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 22  * or visit www.oracle.com if you need additional information or have any
 23  * questions.
 24  */
 25 package java.lang.classfile;
 26 
 27 import java.lang.classfile.attribute.AnnotationDefaultAttribute;
 28 import java.lang.classfile.attribute.BootstrapMethodsAttribute;
 29 import java.lang.classfile.attribute.CharacterRangeTableAttribute;
 30 import java.lang.classfile.attribute.CodeAttribute;
 31 import java.lang.classfile.attribute.CompilationIDAttribute;
 32 import java.lang.classfile.attribute.ConstantValueAttribute;
 33 import java.lang.classfile.attribute.DeprecatedAttribute;
 34 import java.lang.classfile.attribute.EnclosingMethodAttribute;
 35 import java.lang.classfile.attribute.ExceptionsAttribute;
 36 import java.lang.classfile.attribute.InnerClassesAttribute;
 37 import java.lang.classfile.attribute.LineNumberTableAttribute;

 38 import java.lang.classfile.attribute.LocalVariableTableAttribute;
 39 import java.lang.classfile.attribute.LocalVariableTypeTableAttribute;
 40 import java.lang.classfile.attribute.MethodParametersAttribute;
 41 import java.lang.classfile.attribute.ModuleAttribute;
 42 import java.lang.classfile.attribute.ModuleHashesAttribute;
 43 import java.lang.classfile.attribute.ModuleMainClassAttribute;
 44 import java.lang.classfile.attribute.ModulePackagesAttribute;
 45 import java.lang.classfile.attribute.ModuleResolutionAttribute;
 46 import java.lang.classfile.attribute.ModuleTargetAttribute;
 47 import java.lang.classfile.attribute.NestHostAttribute;
 48 import java.lang.classfile.attribute.NestMembersAttribute;
 49 import java.lang.classfile.attribute.PermittedSubclassesAttribute;
 50 import java.lang.classfile.attribute.RecordAttribute;
 51 import java.lang.classfile.attribute.RuntimeInvisibleAnnotationsAttribute;
 52 import java.lang.classfile.attribute.RuntimeInvisibleParameterAnnotationsAttribute;
 53 import java.lang.classfile.attribute.RuntimeInvisibleTypeAnnotationsAttribute;
 54 import java.lang.classfile.attribute.RuntimeVisibleAnnotationsAttribute;
 55 import java.lang.classfile.attribute.RuntimeVisibleParameterAnnotationsAttribute;
 56 import java.lang.classfile.attribute.RuntimeVisibleTypeAnnotationsAttribute;
 57 import java.lang.classfile.attribute.SignatureAttribute;

 68 /**
 69  * Models a classfile attribute (JVMS {@jvms 4.7}).  Many, though not all, subtypes of
 70  * {@linkplain Attribute} will implement {@link ClassElement}, {@link
 71  * MethodElement}, {@link FieldElement}, or {@link CodeElement}; attributes that
 72  * are also elements will be delivered when traversing the elements of the
 73  * corresponding model type. Additionally, all attributes are accessible
 74  * directly from the corresponding model type through {@link
 75  * AttributedElement#findAttribute(AttributeMapper)}.
 76  * @param <A> the attribute type
 77  *
 78  * @sealedGraph
 79  * @since 22
 80  */
 81 @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
 82 public sealed interface Attribute<A extends Attribute<A>>
 83         extends ClassFileElement
 84         permits AnnotationDefaultAttribute, BootstrapMethodsAttribute,
 85                 CharacterRangeTableAttribute, CodeAttribute, CompilationIDAttribute,
 86                 ConstantValueAttribute, DeprecatedAttribute, EnclosingMethodAttribute,
 87                 ExceptionsAttribute, InnerClassesAttribute, LineNumberTableAttribute,
 88                 LocalVariableTableAttribute, LocalVariableTypeTableAttribute,
 89                 MethodParametersAttribute, ModuleAttribute, ModuleHashesAttribute,
 90                 ModuleMainClassAttribute, ModulePackagesAttribute, ModuleResolutionAttribute,
 91                 ModuleTargetAttribute, NestHostAttribute, NestMembersAttribute,
 92                 PermittedSubclassesAttribute,
 93                 RecordAttribute, RuntimeInvisibleAnnotationsAttribute,
 94                 RuntimeInvisibleParameterAnnotationsAttribute, RuntimeInvisibleTypeAnnotationsAttribute,
 95                 RuntimeVisibleAnnotationsAttribute, RuntimeVisibleParameterAnnotationsAttribute,
 96                 RuntimeVisibleTypeAnnotationsAttribute, SignatureAttribute,
 97                 SourceDebugExtensionAttribute, SourceFileAttribute, SourceIDAttribute,
 98                 StackMapTableAttribute, SyntheticAttribute,
 99                 UnknownAttribute, BoundAttribute, UnboundAttribute, CustomAttribute {
100     /**
101      * {@return the name of the attribute}
102      */
103     String attributeName();
104 
105     /**
106      * {@return the {@link AttributeMapper} associated with this attribute}
107      */
108     AttributeMapper<A> attributeMapper();

 18  * 2 along with this work; if not, write to the Free Software Foundation,
 19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 20  *
 21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 22  * or visit www.oracle.com if you need additional information or have any
 23  * questions.
 24  */
 25 package java.lang.classfile;
 26 
 27 import java.lang.classfile.attribute.AnnotationDefaultAttribute;
 28 import java.lang.classfile.attribute.BootstrapMethodsAttribute;
 29 import java.lang.classfile.attribute.CharacterRangeTableAttribute;
 30 import java.lang.classfile.attribute.CodeAttribute;
 31 import java.lang.classfile.attribute.CompilationIDAttribute;
 32 import java.lang.classfile.attribute.ConstantValueAttribute;
 33 import java.lang.classfile.attribute.DeprecatedAttribute;
 34 import java.lang.classfile.attribute.EnclosingMethodAttribute;
 35 import java.lang.classfile.attribute.ExceptionsAttribute;
 36 import java.lang.classfile.attribute.InnerClassesAttribute;
 37 import java.lang.classfile.attribute.LineNumberTableAttribute;
 38 import java.lang.classfile.attribute.LoadableDescriptorsAttribute;
 39 import java.lang.classfile.attribute.LocalVariableTableAttribute;
 40 import java.lang.classfile.attribute.LocalVariableTypeTableAttribute;
 41 import java.lang.classfile.attribute.MethodParametersAttribute;
 42 import java.lang.classfile.attribute.ModuleAttribute;
 43 import java.lang.classfile.attribute.ModuleHashesAttribute;
 44 import java.lang.classfile.attribute.ModuleMainClassAttribute;
 45 import java.lang.classfile.attribute.ModulePackagesAttribute;
 46 import java.lang.classfile.attribute.ModuleResolutionAttribute;
 47 import java.lang.classfile.attribute.ModuleTargetAttribute;
 48 import java.lang.classfile.attribute.NestHostAttribute;
 49 import java.lang.classfile.attribute.NestMembersAttribute;
 50 import java.lang.classfile.attribute.PermittedSubclassesAttribute;
 51 import java.lang.classfile.attribute.RecordAttribute;
 52 import java.lang.classfile.attribute.RuntimeInvisibleAnnotationsAttribute;
 53 import java.lang.classfile.attribute.RuntimeInvisibleParameterAnnotationsAttribute;
 54 import java.lang.classfile.attribute.RuntimeInvisibleTypeAnnotationsAttribute;
 55 import java.lang.classfile.attribute.RuntimeVisibleAnnotationsAttribute;
 56 import java.lang.classfile.attribute.RuntimeVisibleParameterAnnotationsAttribute;
 57 import java.lang.classfile.attribute.RuntimeVisibleTypeAnnotationsAttribute;
 58 import java.lang.classfile.attribute.SignatureAttribute;

 69 /**
 70  * Models a classfile attribute (JVMS {@jvms 4.7}).  Many, though not all, subtypes of
 71  * {@linkplain Attribute} will implement {@link ClassElement}, {@link
 72  * MethodElement}, {@link FieldElement}, or {@link CodeElement}; attributes that
 73  * are also elements will be delivered when traversing the elements of the
 74  * corresponding model type. Additionally, all attributes are accessible
 75  * directly from the corresponding model type through {@link
 76  * AttributedElement#findAttribute(AttributeMapper)}.
 77  * @param <A> the attribute type
 78  *
 79  * @sealedGraph
 80  * @since 22
 81  */
 82 @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API)
 83 public sealed interface Attribute<A extends Attribute<A>>
 84         extends ClassFileElement
 85         permits AnnotationDefaultAttribute, BootstrapMethodsAttribute,
 86                 CharacterRangeTableAttribute, CodeAttribute, CompilationIDAttribute,
 87                 ConstantValueAttribute, DeprecatedAttribute, EnclosingMethodAttribute,
 88                 ExceptionsAttribute, InnerClassesAttribute, LineNumberTableAttribute,
 89                 LoadableDescriptorsAttribute, LocalVariableTableAttribute, LocalVariableTypeTableAttribute,
 90                 MethodParametersAttribute, ModuleAttribute, ModuleHashesAttribute,
 91                 ModuleMainClassAttribute, ModulePackagesAttribute, ModuleResolutionAttribute,
 92                 ModuleTargetAttribute, NestHostAttribute, NestMembersAttribute,
 93                 PermittedSubclassesAttribute,
 94                 RecordAttribute, RuntimeInvisibleAnnotationsAttribute,
 95                 RuntimeInvisibleParameterAnnotationsAttribute, RuntimeInvisibleTypeAnnotationsAttribute,
 96                 RuntimeVisibleAnnotationsAttribute, RuntimeVisibleParameterAnnotationsAttribute,
 97                 RuntimeVisibleTypeAnnotationsAttribute, SignatureAttribute,
 98                 SourceDebugExtensionAttribute, SourceFileAttribute, SourceIDAttribute,
 99                 StackMapTableAttribute, SyntheticAttribute,
100                 UnknownAttribute, BoundAttribute, UnboundAttribute, CustomAttribute {
101     /**
102      * {@return the name of the attribute}
103      */
104     String attributeName();
105 
106     /**
107      * {@return the {@link AttributeMapper} associated with this attribute}
108      */
109     AttributeMapper<A> attributeMapper();
< prev index next >