langtools/src/jdk.jdeps/share/classes/com/sun/tools/classfile/Annotation.java
changeset 31505 98c52b994430
parent 30846 2b3f379840f0
child 38831 f1ebdf22497b
equal deleted inserted replaced
31302:f66c18528472 31505:98c52b994430
   129         Primitive_element_value(ClassReader cr, int tag) throws IOException {
   129         Primitive_element_value(ClassReader cr, int tag) throws IOException {
   130             super(tag);
   130             super(tag);
   131             const_value_index = cr.readUnsignedShort();
   131             const_value_index = cr.readUnsignedShort();
   132         }
   132         }
   133 
   133 
       
   134         public Primitive_element_value(int const_value_index, int tag) {
       
   135             super(tag);
       
   136             this.const_value_index = const_value_index;
       
   137         }
       
   138 
   134         @Override
   139         @Override
   135         public int length() {
   140         public int length() {
   136             return 2;
   141             return 2;
   137         }
   142         }
   138 
   143 
   149             super(tag);
   154             super(tag);
   150             type_name_index = cr.readUnsignedShort();
   155             type_name_index = cr.readUnsignedShort();
   151             const_name_index = cr.readUnsignedShort();
   156             const_name_index = cr.readUnsignedShort();
   152         }
   157         }
   153 
   158 
       
   159         public Enum_element_value(int type_name_index, int const_name_index, int tag) {
       
   160             super(tag);
       
   161             this.type_name_index = type_name_index;
       
   162             this.const_name_index = const_name_index;
       
   163         }
       
   164 
   154         @Override
   165         @Override
   155         public int length() {
   166         public int length() {
   156             return 4;
   167             return 4;
   157         }
   168         }
   158 
   169 
   168         Class_element_value(ClassReader cr, int tag) throws IOException {
   179         Class_element_value(ClassReader cr, int tag) throws IOException {
   169             super(tag);
   180             super(tag);
   170             class_info_index = cr.readUnsignedShort();
   181             class_info_index = cr.readUnsignedShort();
   171         }
   182         }
   172 
   183 
       
   184         public Class_element_value(int class_info_index, int tag) {
       
   185             super(tag);
       
   186             this.class_info_index = class_info_index;
       
   187         }
       
   188 
   173         @Override
   189         @Override
   174         public int length() {
   190         public int length() {
   175             return 2;
   191             return 2;
   176         }
   192         }
   177 
   193 
   185     public static class Annotation_element_value extends element_value {
   201     public static class Annotation_element_value extends element_value {
   186         Annotation_element_value(ClassReader cr, int tag)
   202         Annotation_element_value(ClassReader cr, int tag)
   187                 throws IOException, InvalidAnnotation {
   203                 throws IOException, InvalidAnnotation {
   188             super(tag);
   204             super(tag);
   189             annotation_value = new Annotation(cr);
   205             annotation_value = new Annotation(cr);
       
   206         }
       
   207 
       
   208         public Annotation_element_value(Annotation annotation_value, int tag) {
       
   209             super(tag);
       
   210             this.annotation_value = annotation_value;
   190         }
   211         }
   191 
   212 
   192         @Override
   213         @Override
   193         public int length() {
   214         public int length() {
   194             return annotation_value.length();
   215             return annotation_value.length();
   209             values = new element_value[num_values];
   230             values = new element_value[num_values];
   210             for (int i = 0; i < values.length; i++)
   231             for (int i = 0; i < values.length; i++)
   211                 values[i] = element_value.read(cr);
   232                 values[i] = element_value.read(cr);
   212         }
   233         }
   213 
   234 
       
   235         public Array_element_value(element_value[] values, int tag) {
       
   236             super(tag);
       
   237             this.num_values = values.length;
       
   238             this.values = values;
       
   239         }
       
   240 
   214         @Override
   241         @Override
   215         public int length() {
   242         public int length() {
   216             int n = 2;
   243             int n = 2;
   217             for (int i = 0; i < values.length; i++)
   244             for (int i = 0; i < values.length; i++)
   218                 n += values[i].length();
   245                 n += values[i].length();
   232                 throws IOException, InvalidAnnotation {
   259                 throws IOException, InvalidAnnotation {
   233             element_name_index = cr.readUnsignedShort();
   260             element_name_index = cr.readUnsignedShort();
   234             value = element_value.read(cr);
   261             value = element_value.read(cr);
   235         }
   262         }
   236 
   263 
       
   264         public element_value_pair(int element_name_index, element_value value) {
       
   265             this.element_name_index = element_name_index;
       
   266             this.value = value;
       
   267         }
       
   268 
   237         public int length() {
   269         public int length() {
   238             return 2 + value.length();
   270             return 2 + value.length();
   239         }
   271         }
   240 
   272 
   241         public final int element_name_index;
   273         public final int element_name_index;