< prev index next >

src/java.base/share/classes/jdk/internal/classfile/Attributes.java

Print this page

  47 import jdk.internal.classfile.attribute.LocalVariableInfo;
  48 import jdk.internal.classfile.attribute.LocalVariableTableAttribute;
  49 import jdk.internal.classfile.attribute.LocalVariableTypeInfo;
  50 import jdk.internal.classfile.attribute.LocalVariableTypeTableAttribute;
  51 import jdk.internal.classfile.attribute.MethodParameterInfo;
  52 import jdk.internal.classfile.attribute.MethodParametersAttribute;
  53 import jdk.internal.classfile.attribute.ModuleAttribute;
  54 import jdk.internal.classfile.attribute.ModuleExportInfo;
  55 import jdk.internal.classfile.attribute.ModuleHashInfo;
  56 import jdk.internal.classfile.attribute.ModuleHashesAttribute;
  57 import jdk.internal.classfile.attribute.ModuleMainClassAttribute;
  58 import jdk.internal.classfile.attribute.ModuleOpenInfo;
  59 import jdk.internal.classfile.attribute.ModulePackagesAttribute;
  60 import jdk.internal.classfile.attribute.ModuleProvideInfo;
  61 import jdk.internal.classfile.attribute.ModuleRequireInfo;
  62 import jdk.internal.classfile.attribute.ModuleResolutionAttribute;
  63 import jdk.internal.classfile.attribute.ModuleTargetAttribute;
  64 import jdk.internal.classfile.attribute.NestHostAttribute;
  65 import jdk.internal.classfile.attribute.NestMembersAttribute;
  66 import jdk.internal.classfile.attribute.PermittedSubclassesAttribute;

  67 import jdk.internal.classfile.attribute.RecordAttribute;
  68 import jdk.internal.classfile.attribute.RecordComponentInfo;
  69 import jdk.internal.classfile.attribute.RuntimeInvisibleAnnotationsAttribute;
  70 import jdk.internal.classfile.attribute.RuntimeInvisibleParameterAnnotationsAttribute;
  71 import jdk.internal.classfile.attribute.RuntimeInvisibleTypeAnnotationsAttribute;
  72 import jdk.internal.classfile.attribute.RuntimeVisibleAnnotationsAttribute;
  73 import jdk.internal.classfile.attribute.RuntimeVisibleParameterAnnotationsAttribute;
  74 import jdk.internal.classfile.attribute.RuntimeVisibleTypeAnnotationsAttribute;
  75 import jdk.internal.classfile.attribute.SignatureAttribute;
  76 import jdk.internal.classfile.attribute.SourceDebugExtensionAttribute;
  77 import jdk.internal.classfile.attribute.SourceFileAttribute;
  78 import jdk.internal.classfile.attribute.SourceIDAttribute;
  79 import jdk.internal.classfile.attribute.StackMapTableAttribute;
  80 import jdk.internal.classfile.attribute.SyntheticAttribute;
  81 import jdk.internal.classfile.constantpool.Utf8Entry;
  82 import jdk.internal.classfile.impl.AbstractAttributeMapper;
  83 import jdk.internal.classfile.impl.BoundAttribute;
  84 import jdk.internal.classfile.impl.CodeImpl;
  85 import jdk.internal.classfile.impl.AbstractPoolEntry;
  86 import jdk.internal.classfile.impl.StackMapDecoder;

 144     public static final String NAME_MODULE_MAIN_CLASS = "ModuleMainClass";
 145 
 146     /** ModulePackages */
 147     public static final String NAME_MODULE_PACKAGES = "ModulePackages";
 148 
 149     /** ModuleResolution */
 150     public static final String NAME_MODULE_RESOLUTION = "ModuleResolution";
 151 
 152     /** ModuleTarget */
 153     public static final String NAME_MODULE_TARGET = "ModuleTarget";
 154 
 155     /** NestHost */
 156     public static final String NAME_NEST_HOST = "NestHost";
 157 
 158     /** NestMembers */
 159     public static final String NAME_NEST_MEMBERS = "NestMembers";
 160 
 161     /** PermittedSubclasses */
 162     public static final String NAME_PERMITTED_SUBCLASSES = "PermittedSubclasses";
 163 



 164     /** Record */
 165     public static final String NAME_RECORD = "Record";
 166 
 167     /** RuntimeInvisibleAnnotations */
 168     public static final String NAME_RUNTIME_INVISIBLE_ANNOTATIONS = "RuntimeInvisibleAnnotations";
 169 
 170     /** RuntimeInvisibleTypeAnnotations */
 171     public static final String NAME_RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS = "RuntimeInvisibleParameterAnnotations";
 172 
 173     /**  */
 174     public static final String NAME_RUNTIME_INVISIBLE_TYPE_ANNOTATIONS = "RuntimeInvisibleTypeAnnotations";
 175 
 176     /** RuntimeVisibleAnnotations */
 177     public static final String NAME_RUNTIME_VISIBLE_ANNOTATIONS = "RuntimeVisibleAnnotations";
 178 
 179     /** RuntimeVisibleParameterAnnotations */
 180     public static final String NAME_RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS = "RuntimeVisibleParameterAnnotations";
 181 
 182     /** RuntimeVisibleTypeAnnotations */
 183     public static final String NAME_RUNTIME_VISIBLE_TYPE_ANNOTATIONS = "RuntimeVisibleTypeAnnotations";

 699 
 700     /** Attribute mapper for the {@code PermittedSubclasses} attribute */
 701     public static final AttributeMapper<PermittedSubclassesAttribute>
 702             PERMITTED_SUBCLASSES = new AbstractAttributeMapper<>(NAME_PERMITTED_SUBCLASSES, Classfile.JAVA_15_VERSION) {
 703                 @Override
 704                 public PermittedSubclassesAttribute readAttribute(AttributedElement e, ClassReader cf, int p) {
 705                     return new BoundAttribute.BoundPermittedSubclassesAttribute(cf, this, p);
 706                 }
 707 
 708                 @Override
 709                 protected void writeBody(BufWriter buf, PermittedSubclassesAttribute attr) {
 710                     buf.writeListIndices(attr.permittedSubclasses());
 711                 }
 712 
 713                 @Override
 714                 public AttributeMapper.AttributeStability stability() {
 715                     return AttributeStability.CP_REFS;
 716                 }
 717             };
 718 



















 719     /** Attribute mapper for the {@code Record} attribute */
 720     public static final AttributeMapper<RecordAttribute>
 721             RECORD = new AbstractAttributeMapper<>(NAME_RECORD, Classfile.JAVA_16_VERSION) {
 722                 @Override
 723                 public RecordAttribute readAttribute(AttributedElement e, ClassReader cf, int p) {
 724                     return new BoundAttribute.BoundRecordAttribute(cf, this, p);
 725                 }
 726 
 727                 @Override
 728                 protected void writeBody(BufWriter buf, RecordAttribute attr) {
 729                     List<RecordComponentInfo> components = attr.components();
 730                     buf.writeU2(components.size());
 731                     for (RecordComponentInfo info : components) {
 732                         buf.writeIndex(info.name());
 733                         buf.writeIndex(info.descriptor());
 734                         buf.writeList(info.attributes());
 735                     }
 736                 }
 737 
 738                 @Override

 995             CODE,
 996             COMPILATION_ID,
 997             CONSTANT_VALUE,
 998             DEPRECATED,
 999             ENCLOSING_METHOD,
1000             EXCEPTIONS,
1001             INNER_CLASSES,
1002             LINE_NUMBER_TABLE,
1003             LOCAL_VARIABLE_TABLE,
1004             LOCAL_VARIABLE_TYPE_TABLE,
1005             METHOD_PARAMETERS,
1006             MODULE,
1007             MODULE_HASHES,
1008             MODULE_MAIN_CLASS,
1009             MODULE_PACKAGES,
1010             MODULE_RESOLUTION,
1011             MODULE_TARGET,
1012             NEST_HOST,
1013             NEST_MEMBERS,
1014             PERMITTED_SUBCLASSES,

1015             RECORD,
1016             RUNTIME_INVISIBLE_ANNOTATIONS,
1017             RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS,
1018             RUNTIME_INVISIBLE_TYPE_ANNOTATIONS,
1019             RUNTIME_VISIBLE_ANNOTATIONS,
1020             RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS,
1021             RUNTIME_VISIBLE_TYPE_ANNOTATIONS,
1022             SIGNATURE,
1023             SOURCE_DEBUG_EXTENSION,
1024             SOURCE_FILE,
1025             SOURCE_ID,
1026             STACK_MAP_TABLE,
1027             SYNTHETIC);
1028 
1029     private static final Map<Utf8Entry, AttributeMapper<?>> _ATTR_MAP;
1030     //no lambdas here as this is on critical JDK boostrap path
1031     static {
1032         var map = new HashMap<Utf8Entry, AttributeMapper<?>>(64);
1033         for (var am : PREDEFINED_ATTRIBUTES) {
1034             map.put(AbstractPoolEntry.rawUtf8EntryFromStandardAttributeName(am.name()), am);

  47 import jdk.internal.classfile.attribute.LocalVariableInfo;
  48 import jdk.internal.classfile.attribute.LocalVariableTableAttribute;
  49 import jdk.internal.classfile.attribute.LocalVariableTypeInfo;
  50 import jdk.internal.classfile.attribute.LocalVariableTypeTableAttribute;
  51 import jdk.internal.classfile.attribute.MethodParameterInfo;
  52 import jdk.internal.classfile.attribute.MethodParametersAttribute;
  53 import jdk.internal.classfile.attribute.ModuleAttribute;
  54 import jdk.internal.classfile.attribute.ModuleExportInfo;
  55 import jdk.internal.classfile.attribute.ModuleHashInfo;
  56 import jdk.internal.classfile.attribute.ModuleHashesAttribute;
  57 import jdk.internal.classfile.attribute.ModuleMainClassAttribute;
  58 import jdk.internal.classfile.attribute.ModuleOpenInfo;
  59 import jdk.internal.classfile.attribute.ModulePackagesAttribute;
  60 import jdk.internal.classfile.attribute.ModuleProvideInfo;
  61 import jdk.internal.classfile.attribute.ModuleRequireInfo;
  62 import jdk.internal.classfile.attribute.ModuleResolutionAttribute;
  63 import jdk.internal.classfile.attribute.ModuleTargetAttribute;
  64 import jdk.internal.classfile.attribute.NestHostAttribute;
  65 import jdk.internal.classfile.attribute.NestMembersAttribute;
  66 import jdk.internal.classfile.attribute.PermittedSubclassesAttribute;
  67 import jdk.internal.classfile.attribute.PreloadAttribute;
  68 import jdk.internal.classfile.attribute.RecordAttribute;
  69 import jdk.internal.classfile.attribute.RecordComponentInfo;
  70 import jdk.internal.classfile.attribute.RuntimeInvisibleAnnotationsAttribute;
  71 import jdk.internal.classfile.attribute.RuntimeInvisibleParameterAnnotationsAttribute;
  72 import jdk.internal.classfile.attribute.RuntimeInvisibleTypeAnnotationsAttribute;
  73 import jdk.internal.classfile.attribute.RuntimeVisibleAnnotationsAttribute;
  74 import jdk.internal.classfile.attribute.RuntimeVisibleParameterAnnotationsAttribute;
  75 import jdk.internal.classfile.attribute.RuntimeVisibleTypeAnnotationsAttribute;
  76 import jdk.internal.classfile.attribute.SignatureAttribute;
  77 import jdk.internal.classfile.attribute.SourceDebugExtensionAttribute;
  78 import jdk.internal.classfile.attribute.SourceFileAttribute;
  79 import jdk.internal.classfile.attribute.SourceIDAttribute;
  80 import jdk.internal.classfile.attribute.StackMapTableAttribute;
  81 import jdk.internal.classfile.attribute.SyntheticAttribute;
  82 import jdk.internal.classfile.constantpool.Utf8Entry;
  83 import jdk.internal.classfile.impl.AbstractAttributeMapper;
  84 import jdk.internal.classfile.impl.BoundAttribute;
  85 import jdk.internal.classfile.impl.CodeImpl;
  86 import jdk.internal.classfile.impl.AbstractPoolEntry;
  87 import jdk.internal.classfile.impl.StackMapDecoder;

 145     public static final String NAME_MODULE_MAIN_CLASS = "ModuleMainClass";
 146 
 147     /** ModulePackages */
 148     public static final String NAME_MODULE_PACKAGES = "ModulePackages";
 149 
 150     /** ModuleResolution */
 151     public static final String NAME_MODULE_RESOLUTION = "ModuleResolution";
 152 
 153     /** ModuleTarget */
 154     public static final String NAME_MODULE_TARGET = "ModuleTarget";
 155 
 156     /** NestHost */
 157     public static final String NAME_NEST_HOST = "NestHost";
 158 
 159     /** NestMembers */
 160     public static final String NAME_NEST_MEMBERS = "NestMembers";
 161 
 162     /** PermittedSubclasses */
 163     public static final String NAME_PERMITTED_SUBCLASSES = "PermittedSubclasses";
 164 
 165     /** Preload */
 166     public static final String NAME_PRELOAD = "Preload";
 167 
 168     /** Record */
 169     public static final String NAME_RECORD = "Record";
 170 
 171     /** RuntimeInvisibleAnnotations */
 172     public static final String NAME_RUNTIME_INVISIBLE_ANNOTATIONS = "RuntimeInvisibleAnnotations";
 173 
 174     /** RuntimeInvisibleTypeAnnotations */
 175     public static final String NAME_RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS = "RuntimeInvisibleParameterAnnotations";
 176 
 177     /**  */
 178     public static final String NAME_RUNTIME_INVISIBLE_TYPE_ANNOTATIONS = "RuntimeInvisibleTypeAnnotations";
 179 
 180     /** RuntimeVisibleAnnotations */
 181     public static final String NAME_RUNTIME_VISIBLE_ANNOTATIONS = "RuntimeVisibleAnnotations";
 182 
 183     /** RuntimeVisibleParameterAnnotations */
 184     public static final String NAME_RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS = "RuntimeVisibleParameterAnnotations";
 185 
 186     /** RuntimeVisibleTypeAnnotations */
 187     public static final String NAME_RUNTIME_VISIBLE_TYPE_ANNOTATIONS = "RuntimeVisibleTypeAnnotations";

 703 
 704     /** Attribute mapper for the {@code PermittedSubclasses} attribute */
 705     public static final AttributeMapper<PermittedSubclassesAttribute>
 706             PERMITTED_SUBCLASSES = new AbstractAttributeMapper<>(NAME_PERMITTED_SUBCLASSES, Classfile.JAVA_15_VERSION) {
 707                 @Override
 708                 public PermittedSubclassesAttribute readAttribute(AttributedElement e, ClassReader cf, int p) {
 709                     return new BoundAttribute.BoundPermittedSubclassesAttribute(cf, this, p);
 710                 }
 711 
 712                 @Override
 713                 protected void writeBody(BufWriter buf, PermittedSubclassesAttribute attr) {
 714                     buf.writeListIndices(attr.permittedSubclasses());
 715                 }
 716 
 717                 @Override
 718                 public AttributeMapper.AttributeStability stability() {
 719                     return AttributeStability.CP_REFS;
 720                 }
 721             };
 722 
 723     /** Attribute mapper for the {@code Preload} attribute */
 724     public static final AttributeMapper<PreloadAttribute>
 725             PRELOAD = new AbstractAttributeMapper<>(NAME_PRELOAD, Classfile.JAVA_21_VERSION) {
 726                 @Override
 727                 public PreloadAttribute readAttribute(AttributedElement e, ClassReader cf, int p) {
 728                     return new BoundAttribute.BoundPreloadAttribute(cf, this, p);
 729                 }
 730 
 731                 @Override
 732                 protected void writeBody(BufWriter buf, PreloadAttribute attr) {
 733                     buf.writeListIndices(attr.preloads());
 734                 }
 735 
 736                 @Override
 737                 public AttributeMapper.AttributeStability stability() {
 738                     return AttributeStability.CP_REFS;
 739                 }
 740             };
 741 
 742     /** Attribute mapper for the {@code Record} attribute */
 743     public static final AttributeMapper<RecordAttribute>
 744             RECORD = new AbstractAttributeMapper<>(NAME_RECORD, Classfile.JAVA_16_VERSION) {
 745                 @Override
 746                 public RecordAttribute readAttribute(AttributedElement e, ClassReader cf, int p) {
 747                     return new BoundAttribute.BoundRecordAttribute(cf, this, p);
 748                 }
 749 
 750                 @Override
 751                 protected void writeBody(BufWriter buf, RecordAttribute attr) {
 752                     List<RecordComponentInfo> components = attr.components();
 753                     buf.writeU2(components.size());
 754                     for (RecordComponentInfo info : components) {
 755                         buf.writeIndex(info.name());
 756                         buf.writeIndex(info.descriptor());
 757                         buf.writeList(info.attributes());
 758                     }
 759                 }
 760 
 761                 @Override

1018             CODE,
1019             COMPILATION_ID,
1020             CONSTANT_VALUE,
1021             DEPRECATED,
1022             ENCLOSING_METHOD,
1023             EXCEPTIONS,
1024             INNER_CLASSES,
1025             LINE_NUMBER_TABLE,
1026             LOCAL_VARIABLE_TABLE,
1027             LOCAL_VARIABLE_TYPE_TABLE,
1028             METHOD_PARAMETERS,
1029             MODULE,
1030             MODULE_HASHES,
1031             MODULE_MAIN_CLASS,
1032             MODULE_PACKAGES,
1033             MODULE_RESOLUTION,
1034             MODULE_TARGET,
1035             NEST_HOST,
1036             NEST_MEMBERS,
1037             PERMITTED_SUBCLASSES,
1038             PRELOAD,
1039             RECORD,
1040             RUNTIME_INVISIBLE_ANNOTATIONS,
1041             RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS,
1042             RUNTIME_INVISIBLE_TYPE_ANNOTATIONS,
1043             RUNTIME_VISIBLE_ANNOTATIONS,
1044             RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS,
1045             RUNTIME_VISIBLE_TYPE_ANNOTATIONS,
1046             SIGNATURE,
1047             SOURCE_DEBUG_EXTENSION,
1048             SOURCE_FILE,
1049             SOURCE_ID,
1050             STACK_MAP_TABLE,
1051             SYNTHETIC);
1052 
1053     private static final Map<Utf8Entry, AttributeMapper<?>> _ATTR_MAP;
1054     //no lambdas here as this is on critical JDK boostrap path
1055     static {
1056         var map = new HashMap<Utf8Entry, AttributeMapper<?>>(64);
1057         for (var am : PREDEFINED_ATTRIBUTES) {
1058             map.put(AbstractPoolEntry.rawUtf8EntryFromStandardAttributeName(am.name()), am);
< prev index next >