< prev index next >

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

Print this page

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

  67 import java.lang.classfile.attribute.RecordAttribute;
  68 import java.lang.classfile.attribute.RecordComponentInfo;
  69 import java.lang.classfile.attribute.RuntimeInvisibleAnnotationsAttribute;
  70 import java.lang.classfile.attribute.RuntimeInvisibleParameterAnnotationsAttribute;
  71 import java.lang.classfile.attribute.RuntimeInvisibleTypeAnnotationsAttribute;
  72 import java.lang.classfile.attribute.RuntimeVisibleAnnotationsAttribute;
  73 import java.lang.classfile.attribute.RuntimeVisibleParameterAnnotationsAttribute;
  74 import java.lang.classfile.attribute.RuntimeVisibleTypeAnnotationsAttribute;
  75 import java.lang.classfile.attribute.SignatureAttribute;
  76 import java.lang.classfile.attribute.SourceDebugExtensionAttribute;
  77 import java.lang.classfile.attribute.SourceFileAttribute;
  78 import java.lang.classfile.attribute.SourceIDAttribute;
  79 import java.lang.classfile.attribute.StackMapTableAttribute;
  80 import java.lang.classfile.attribute.SyntheticAttribute;
  81 import java.lang.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;

 148     public static final String NAME_MODULE_MAIN_CLASS = "ModuleMainClass";
 149 
 150     /** ModulePackages */
 151     public static final String NAME_MODULE_PACKAGES = "ModulePackages";
 152 
 153     /** ModuleResolution */
 154     public static final String NAME_MODULE_RESOLUTION = "ModuleResolution";
 155 
 156     /** ModuleTarget */
 157     public static final String NAME_MODULE_TARGET = "ModuleTarget";
 158 
 159     /** NestHost */
 160     public static final String NAME_NEST_HOST = "NestHost";
 161 
 162     /** NestMembers */
 163     public static final String NAME_NEST_MEMBERS = "NestMembers";
 164 
 165     /** PermittedSubclasses */
 166     public static final String NAME_PERMITTED_SUBCLASSES = "PermittedSubclasses";
 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     /** RuntimeInvisibleParameterAnnotations */
 175     public static final String NAME_RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS = "RuntimeInvisibleParameterAnnotations";
 176 
 177     /** RuntimeInvisibleTypeAnnotations */
 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) {
 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 Record} attribute */
 724     public static final AttributeMapper<RecordAttribute>
 725             RECORD = new AbstractAttributeMapper<>(NAME_RECORD) {
 726                 @Override
 727                 public RecordAttribute readAttribute(AttributedElement e, ClassReader cf, int p) {
 728                     return new BoundAttribute.BoundRecordAttribute(cf, this, p);
 729                 }
 730 
 731                 @Override
 732                 protected void writeBody(BufWriter buf, RecordAttribute attr) {
 733                     List<RecordComponentInfo> components = attr.components();
 734                     buf.writeU2(components.size());
 735                     for (RecordComponentInfo info : components) {
 736                         buf.writeIndex(info.name());
 737                         buf.writeIndex(info.descriptor());
 738                         buf.writeList(info.attributes());
 739                     }
 740                 }
 741 
 742                 @Override

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

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

  47 import java.lang.classfile.attribute.LocalVariableInfo;
  48 import java.lang.classfile.attribute.LocalVariableTableAttribute;
  49 import java.lang.classfile.attribute.LocalVariableTypeInfo;
  50 import java.lang.classfile.attribute.LocalVariableTypeTableAttribute;
  51 import java.lang.classfile.attribute.MethodParameterInfo;
  52 import java.lang.classfile.attribute.MethodParametersAttribute;
  53 import java.lang.classfile.attribute.ModuleAttribute;
  54 import java.lang.classfile.attribute.ModuleExportInfo;
  55 import java.lang.classfile.attribute.ModuleHashInfo;
  56 import java.lang.classfile.attribute.ModuleHashesAttribute;
  57 import java.lang.classfile.attribute.ModuleMainClassAttribute;
  58 import java.lang.classfile.attribute.ModuleOpenInfo;
  59 import java.lang.classfile.attribute.ModulePackagesAttribute;
  60 import java.lang.classfile.attribute.ModuleProvideInfo;
  61 import java.lang.classfile.attribute.ModuleRequireInfo;
  62 import java.lang.classfile.attribute.ModuleResolutionAttribute;
  63 import java.lang.classfile.attribute.ModuleTargetAttribute;
  64 import java.lang.classfile.attribute.NestHostAttribute;
  65 import java.lang.classfile.attribute.NestMembersAttribute;
  66 import java.lang.classfile.attribute.PermittedSubclassesAttribute;
  67 import java.lang.classfile.attribute.PreloadAttribute;
  68 import java.lang.classfile.attribute.RecordAttribute;
  69 import java.lang.classfile.attribute.RecordComponentInfo;
  70 import java.lang.classfile.attribute.RuntimeInvisibleAnnotationsAttribute;
  71 import java.lang.classfile.attribute.RuntimeInvisibleParameterAnnotationsAttribute;
  72 import java.lang.classfile.attribute.RuntimeInvisibleTypeAnnotationsAttribute;
  73 import java.lang.classfile.attribute.RuntimeVisibleAnnotationsAttribute;
  74 import java.lang.classfile.attribute.RuntimeVisibleParameterAnnotationsAttribute;
  75 import java.lang.classfile.attribute.RuntimeVisibleTypeAnnotationsAttribute;
  76 import java.lang.classfile.attribute.SignatureAttribute;
  77 import java.lang.classfile.attribute.SourceDebugExtensionAttribute;
  78 import java.lang.classfile.attribute.SourceFileAttribute;
  79 import java.lang.classfile.attribute.SourceIDAttribute;
  80 import java.lang.classfile.attribute.StackMapTableAttribute;
  81 import java.lang.classfile.attribute.SyntheticAttribute;
  82 import java.lang.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;

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

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

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