hotspot/src/share/vm/classfile/classFileParser.cpp
changeset 19954 1642109d1a2c
parent 19681 1b35da7b1d85
child 19957 04a38bb9ba15
equal deleted inserted replaced
19953:bcb70cd411bc 19954:1642109d1a2c
   886   int runtime_invisible_annotations_length = 0;
   886   int runtime_invisible_annotations_length = 0;
   887   u1* runtime_visible_type_annotations = NULL;
   887   u1* runtime_visible_type_annotations = NULL;
   888   int runtime_visible_type_annotations_length = 0;
   888   int runtime_visible_type_annotations_length = 0;
   889   u1* runtime_invisible_type_annotations = NULL;
   889   u1* runtime_invisible_type_annotations = NULL;
   890   int runtime_invisible_type_annotations_length = 0;
   890   int runtime_invisible_type_annotations_length = 0;
       
   891   bool runtime_invisible_type_annotations_exists = false;
   891   while (attributes_count--) {
   892   while (attributes_count--) {
   892     cfs->guarantee_more(6, CHECK);  // attribute_name_index, attribute_length
   893     cfs->guarantee_more(6, CHECK);  // attribute_name_index, attribute_length
   893     u2 attribute_name_index = cfs->get_u2_fast();
   894     u2 attribute_name_index = cfs->get_u2_fast();
   894     u4 attribute_length = cfs->get_u4_fast();
   895     u4 attribute_length = cfs->get_u4_fast();
   895     check_property(valid_symbol_at(attribute_name_index),
   896     check_property(valid_symbol_at(attribute_name_index),
   944         runtime_invisible_annotations_length = attribute_length;
   945         runtime_invisible_annotations_length = attribute_length;
   945         runtime_invisible_annotations = cfs->get_u1_buffer();
   946         runtime_invisible_annotations = cfs->get_u1_buffer();
   946         assert(runtime_invisible_annotations != NULL, "null invisible annotations");
   947         assert(runtime_invisible_annotations != NULL, "null invisible annotations");
   947         cfs->skip_u1(runtime_invisible_annotations_length, CHECK);
   948         cfs->skip_u1(runtime_invisible_annotations_length, CHECK);
   948       } else if (attribute_name == vmSymbols::tag_runtime_visible_type_annotations()) {
   949       } else if (attribute_name == vmSymbols::tag_runtime_visible_type_annotations()) {
       
   950         if (runtime_visible_type_annotations != NULL) {
       
   951           classfile_parse_error(
       
   952             "Multiple RuntimeVisibleTypeAnnotations attributes for field in class file %s", CHECK);
       
   953         }
   949         runtime_visible_type_annotations_length = attribute_length;
   954         runtime_visible_type_annotations_length = attribute_length;
   950         runtime_visible_type_annotations = cfs->get_u1_buffer();
   955         runtime_visible_type_annotations = cfs->get_u1_buffer();
   951         assert(runtime_visible_type_annotations != NULL, "null visible type annotations");
   956         assert(runtime_visible_type_annotations != NULL, "null visible type annotations");
   952         cfs->skip_u1(runtime_visible_type_annotations_length, CHECK);
   957         cfs->skip_u1(runtime_visible_type_annotations_length, CHECK);
   953       } else if (PreserveAllAnnotations && attribute_name == vmSymbols::tag_runtime_invisible_type_annotations()) {
   958       } else if (attribute_name == vmSymbols::tag_runtime_invisible_type_annotations()) {
   954         runtime_invisible_type_annotations_length = attribute_length;
   959         if (runtime_invisible_type_annotations_exists) {
   955         runtime_invisible_type_annotations = cfs->get_u1_buffer();
   960           classfile_parse_error(
   956         assert(runtime_invisible_type_annotations != NULL, "null invisible type annotations");
   961             "Multiple RuntimeInvisibleTypeAnnotations attributes for field in class file %s", CHECK);
   957         cfs->skip_u1(runtime_invisible_type_annotations_length, CHECK);
   962         } else {
       
   963           runtime_invisible_type_annotations_exists = true;
       
   964         }
       
   965         if (PreserveAllAnnotations) {
       
   966           runtime_invisible_type_annotations_length = attribute_length;
       
   967           runtime_invisible_type_annotations = cfs->get_u1_buffer();
       
   968           assert(runtime_invisible_type_annotations != NULL, "null invisible type annotations");
       
   969         }
       
   970         cfs->skip_u1(attribute_length, CHECK);
   958       } else {
   971       } else {
   959         cfs->skip_u1(attribute_length, CHECK);  // Skip unknown attributes
   972         cfs->skip_u1(attribute_length, CHECK);  // Skip unknown attributes
   960       }
   973       }
   961     } else {
   974     } else {
   962       cfs->skip_u1(attribute_length, CHECK);  // Skip unknown attributes
   975       cfs->skip_u1(attribute_length, CHECK);  // Skip unknown attributes
  2058   int runtime_invisible_parameter_annotations_length = 0;
  2071   int runtime_invisible_parameter_annotations_length = 0;
  2059   u1* runtime_visible_type_annotations = NULL;
  2072   u1* runtime_visible_type_annotations = NULL;
  2060   int runtime_visible_type_annotations_length = 0;
  2073   int runtime_visible_type_annotations_length = 0;
  2061   u1* runtime_invisible_type_annotations = NULL;
  2074   u1* runtime_invisible_type_annotations = NULL;
  2062   int runtime_invisible_type_annotations_length = 0;
  2075   int runtime_invisible_type_annotations_length = 0;
       
  2076   bool runtime_invisible_type_annotations_exists = false;
  2063   u1* annotation_default = NULL;
  2077   u1* annotation_default = NULL;
  2064   int annotation_default_length = 0;
  2078   int annotation_default_length = 0;
  2065 
  2079 
  2066   // Parse code and exceptions attribute
  2080   // Parse code and exceptions attribute
  2067   u2 method_attributes_count = cfs->get_u2_fast();
  2081   u2 method_attributes_count = cfs->get_u2_fast();
  2314         annotation_default_length = method_attribute_length;
  2328         annotation_default_length = method_attribute_length;
  2315         annotation_default = cfs->get_u1_buffer();
  2329         annotation_default = cfs->get_u1_buffer();
  2316         assert(annotation_default != NULL, "null annotation default");
  2330         assert(annotation_default != NULL, "null annotation default");
  2317         cfs->skip_u1(annotation_default_length, CHECK_(nullHandle));
  2331         cfs->skip_u1(annotation_default_length, CHECK_(nullHandle));
  2318       } else if (method_attribute_name == vmSymbols::tag_runtime_visible_type_annotations()) {
  2332       } else if (method_attribute_name == vmSymbols::tag_runtime_visible_type_annotations()) {
       
  2333         if (runtime_visible_type_annotations != NULL) {
       
  2334           classfile_parse_error(
       
  2335             "Multiple RuntimeVisibleTypeAnnotations attributes for method in class file %s",
       
  2336             CHECK_(nullHandle));
       
  2337         }
  2319         runtime_visible_type_annotations_length = method_attribute_length;
  2338         runtime_visible_type_annotations_length = method_attribute_length;
  2320         runtime_visible_type_annotations = cfs->get_u1_buffer();
  2339         runtime_visible_type_annotations = cfs->get_u1_buffer();
  2321         assert(runtime_visible_type_annotations != NULL, "null visible type annotations");
  2340         assert(runtime_visible_type_annotations != NULL, "null visible type annotations");
  2322         // No need for the VM to parse Type annotations
  2341         // No need for the VM to parse Type annotations
  2323         cfs->skip_u1(runtime_visible_type_annotations_length, CHECK_(nullHandle));
  2342         cfs->skip_u1(runtime_visible_type_annotations_length, CHECK_(nullHandle));
  2324       } else if (PreserveAllAnnotations && method_attribute_name == vmSymbols::tag_runtime_invisible_type_annotations()) {
  2343       } else if (method_attribute_name == vmSymbols::tag_runtime_invisible_type_annotations()) {
  2325         runtime_invisible_type_annotations_length = method_attribute_length;
  2344         if (runtime_invisible_type_annotations_exists) {
  2326         runtime_invisible_type_annotations = cfs->get_u1_buffer();
  2345           classfile_parse_error(
  2327         assert(runtime_invisible_type_annotations != NULL, "null invisible type annotations");
  2346             "Multiple RuntimeInvisibleTypeAnnotations attributes for method in class file %s",
  2328         cfs->skip_u1(runtime_invisible_type_annotations_length, CHECK_(nullHandle));
  2347             CHECK_(nullHandle));
       
  2348         } else {
       
  2349           runtime_invisible_type_annotations_exists = true;
       
  2350         }
       
  2351         if (PreserveAllAnnotations) {
       
  2352           runtime_invisible_type_annotations_length = method_attribute_length;
       
  2353           runtime_invisible_type_annotations = cfs->get_u1_buffer();
       
  2354           assert(runtime_invisible_type_annotations != NULL, "null invisible type annotations");
       
  2355         }
       
  2356         cfs->skip_u1(method_attribute_length, CHECK_(nullHandle));
  2329       } else {
  2357       } else {
  2330         // Skip unknown attributes
  2358         // Skip unknown attributes
  2331         cfs->skip_u1(method_attribute_length, CHECK_(nullHandle));
  2359         cfs->skip_u1(method_attribute_length, CHECK_(nullHandle));
  2332       }
  2360       }
  2333     } else {
  2361     } else {
  2816   int runtime_invisible_annotations_length = 0;
  2844   int runtime_invisible_annotations_length = 0;
  2817   u1* runtime_visible_type_annotations = NULL;
  2845   u1* runtime_visible_type_annotations = NULL;
  2818   int runtime_visible_type_annotations_length = 0;
  2846   int runtime_visible_type_annotations_length = 0;
  2819   u1* runtime_invisible_type_annotations = NULL;
  2847   u1* runtime_invisible_type_annotations = NULL;
  2820   int runtime_invisible_type_annotations_length = 0;
  2848   int runtime_invisible_type_annotations_length = 0;
       
  2849   bool runtime_invisible_type_annotations_exists = false;
  2821   u1* inner_classes_attribute_start = NULL;
  2850   u1* inner_classes_attribute_start = NULL;
  2822   u4  inner_classes_attribute_length = 0;
  2851   u4  inner_classes_attribute_length = 0;
  2823   u2  enclosing_method_class_index = 0;
  2852   u2  enclosing_method_class_index = 0;
  2824   u2  enclosing_method_method_index = 0;
  2853   u2  enclosing_method_method_index = 0;
  2825   // Iterate over attributes
  2854   // Iterate over attributes
  2919         if (parsed_bootstrap_methods_attribute)
  2948         if (parsed_bootstrap_methods_attribute)
  2920           classfile_parse_error("Multiple BootstrapMethods attributes in class file %s", CHECK);
  2949           classfile_parse_error("Multiple BootstrapMethods attributes in class file %s", CHECK);
  2921         parsed_bootstrap_methods_attribute = true;
  2950         parsed_bootstrap_methods_attribute = true;
  2922         parse_classfile_bootstrap_methods_attribute(attribute_length, CHECK);
  2951         parse_classfile_bootstrap_methods_attribute(attribute_length, CHECK);
  2923       } else if (tag == vmSymbols::tag_runtime_visible_type_annotations()) {
  2952       } else if (tag == vmSymbols::tag_runtime_visible_type_annotations()) {
       
  2953         if (runtime_visible_type_annotations != NULL) {
       
  2954           classfile_parse_error(
       
  2955             "Multiple RuntimeVisibleTypeAnnotations attributes in class file %s", CHECK);
       
  2956         }
  2924         runtime_visible_type_annotations_length = attribute_length;
  2957         runtime_visible_type_annotations_length = attribute_length;
  2925         runtime_visible_type_annotations = cfs->get_u1_buffer();
  2958         runtime_visible_type_annotations = cfs->get_u1_buffer();
  2926         assert(runtime_visible_type_annotations != NULL, "null visible type annotations");
  2959         assert(runtime_visible_type_annotations != NULL, "null visible type annotations");
  2927         // No need for the VM to parse Type annotations
  2960         // No need for the VM to parse Type annotations
  2928         cfs->skip_u1(runtime_visible_type_annotations_length, CHECK);
  2961         cfs->skip_u1(runtime_visible_type_annotations_length, CHECK);
  2929       } else if (PreserveAllAnnotations && tag == vmSymbols::tag_runtime_invisible_type_annotations()) {
  2962       } else if (tag == vmSymbols::tag_runtime_invisible_type_annotations()) {
  2930         runtime_invisible_type_annotations_length = attribute_length;
  2963         if (runtime_invisible_type_annotations_exists) {
  2931         runtime_invisible_type_annotations = cfs->get_u1_buffer();
  2964           classfile_parse_error(
  2932         assert(runtime_invisible_type_annotations != NULL, "null invisible type annotations");
  2965             "Multiple RuntimeInvisibleTypeAnnotations attributes in class file %s", CHECK);
  2933         cfs->skip_u1(runtime_invisible_type_annotations_length, CHECK);
  2966         } else {
       
  2967           runtime_invisible_type_annotations_exists = true;
       
  2968         }
       
  2969         if (PreserveAllAnnotations) {
       
  2970           runtime_invisible_type_annotations_length = attribute_length;
       
  2971           runtime_invisible_type_annotations = cfs->get_u1_buffer();
       
  2972           assert(runtime_invisible_type_annotations != NULL, "null invisible type annotations");
       
  2973         }
       
  2974         cfs->skip_u1(attribute_length, CHECK);
  2934       } else {
  2975       } else {
  2935         // Unknown attribute
  2976         // Unknown attribute
  2936         cfs->skip_u1(attribute_length, CHECK);
  2977         cfs->skip_u1(attribute_length, CHECK);
  2937       }
  2978       }
  2938     } else {
  2979     } else {