< prev index next >

src/share/vm/classfile/classFileParser.cpp

Print this page




1249 
1250       constantvalue_index = cfs->get_u2(CHECK);
1251       if (_need_verify) {
1252         verify_constantvalue(cp, constantvalue_index, signature_index, CHECK);
1253       }
1254     } else if (attribute_name == vmSymbols::tag_synthetic()) {
1255       if (attribute_length != 0) {
1256         classfile_parse_error(
1257           "Invalid Synthetic field attribute length %u in class file %s",
1258           attribute_length, CHECK);
1259       }
1260       is_synthetic = true;
1261     } else if (attribute_name == vmSymbols::tag_deprecated()) { // 4276120
1262       if (attribute_length != 0) {
1263         classfile_parse_error(
1264           "Invalid Deprecated field attribute length %u in class file %s",
1265           attribute_length, CHECK);
1266       }
1267     } else if (_major_version >= JAVA_1_5_VERSION) {
1268       if (attribute_name == vmSymbols::tag_signature()) {




1269         if (attribute_length != 2) {
1270           classfile_parse_error(
1271             "Wrong size %u for field's Signature attribute in class file %s",
1272             attribute_length, CHECK);
1273         }
1274         generic_signature_index = parse_generic_signature_attribute(cfs, CHECK);
1275       } else if (attribute_name == vmSymbols::tag_runtime_visible_annotations()) {
1276         if (runtime_visible_annotations != NULL) {
1277           classfile_parse_error(
1278             "Multiple RuntimeVisibleAnnotations attributes for field in class file %s", CHECK);
1279         }
1280         runtime_visible_annotations_length = attribute_length;
1281         runtime_visible_annotations = cfs->get_u1_buffer();
1282         assert(runtime_visible_annotations != NULL, "null visible annotations");
1283         cfs->guarantee_more(runtime_visible_annotations_length, CHECK);
1284         parse_annotations(cp,
1285                           runtime_visible_annotations,
1286                           runtime_visible_annotations_length,
1287                           parsed_annotations,
1288                           _loader_data,


2570       cfs->skip_u2_fast(method_parameters_length);
2571       // ignore this attribute if it cannot be reflected
2572       if (!SystemDictionary::Parameter_klass_loaded())
2573         method_parameters_length = -1;
2574     } else if (method_attribute_name == vmSymbols::tag_synthetic()) {
2575       if (method_attribute_length != 0) {
2576         classfile_parse_error(
2577           "Invalid Synthetic method attribute length %u in class file %s",
2578           method_attribute_length, CHECK_NULL);
2579       }
2580       // Should we check that there hasn't already been a synthetic attribute?
2581       access_flags.set_is_synthetic();
2582     } else if (method_attribute_name == vmSymbols::tag_deprecated()) { // 4276120
2583       if (method_attribute_length != 0) {
2584         classfile_parse_error(
2585           "Invalid Deprecated method attribute length %u in class file %s",
2586           method_attribute_length, CHECK_NULL);
2587       }
2588     } else if (_major_version >= JAVA_1_5_VERSION) {
2589       if (method_attribute_name == vmSymbols::tag_signature()) {





2590         if (method_attribute_length != 2) {
2591           classfile_parse_error(
2592             "Invalid Signature attribute length %u in class file %s",
2593             method_attribute_length, CHECK_NULL);
2594         }
2595         generic_signature_index = parse_generic_signature_attribute(cfs, CHECK_NULL);
2596       } else if (method_attribute_name == vmSymbols::tag_runtime_visible_annotations()) {
2597         if (runtime_visible_annotations != NULL) {
2598           classfile_parse_error(
2599             "Multiple RuntimeVisibleAnnotations attributes for method in class file %s",
2600             CHECK_NULL);
2601         }
2602         runtime_visible_annotations_length = method_attribute_length;
2603         runtime_visible_annotations = cfs->get_u1_buffer();
2604         assert(runtime_visible_annotations != NULL, "null visible annotations");
2605         cfs->guarantee_more(runtime_visible_annotations_length, CHECK_NULL);
2606         parse_annotations(cp,
2607                           runtime_visible_annotations,
2608                           runtime_visible_annotations_length,
2609                           &parsed_annotations,


3217                      "Bad length on BootstrapMethods in class file %s",
3218                      CHECK);
3219 }
3220 
3221 void ClassFileParser::parse_classfile_attributes(const ClassFileStream* const cfs,
3222                                                  ConstantPool* cp,
3223                  ClassFileParser::ClassAnnotationCollector* parsed_annotations,
3224                                                  TRAPS) {
3225   assert(cfs != NULL, "invariant");
3226   assert(cp != NULL, "invariant");
3227   assert(parsed_annotations != NULL, "invariant");
3228 
3229   // Set inner classes attribute to default sentinel
3230   _inner_classes = Universe::the_empty_short_array();
3231   cfs->guarantee_more(2, CHECK);  // attributes_count
3232   u2 attributes_count = cfs->get_u2_fast();
3233   bool parsed_sourcefile_attribute = false;
3234   bool parsed_innerclasses_attribute = false;
3235   bool parsed_enclosingmethod_attribute = false;
3236   bool parsed_bootstrap_methods_attribute = false;

3237   const u1* runtime_visible_annotations = NULL;
3238   int runtime_visible_annotations_length = 0;
3239   const u1* runtime_invisible_annotations = NULL;
3240   int runtime_invisible_annotations_length = 0;
3241   const u1* runtime_visible_type_annotations = NULL;
3242   int runtime_visible_type_annotations_length = 0;
3243   const u1* runtime_invisible_type_annotations = NULL;
3244   int runtime_invisible_type_annotations_length = 0;
3245   bool runtime_invisible_type_annotations_exists = false;
3246   bool runtime_invisible_annotations_exists = false;
3247   bool parsed_source_debug_ext_annotations_exist = false;
3248   const u1* inner_classes_attribute_start = NULL;
3249   u4  inner_classes_attribute_length = 0;
3250   u2  enclosing_method_class_index = 0;
3251   u2  enclosing_method_method_index = 0;
3252   // Iterate over attributes
3253   while (attributes_count--) {
3254     cfs->guarantee_more(6, CHECK);  // attribute_name_index, attribute_length
3255     const u2 attribute_name_index = cfs->get_u2_fast();
3256     const u4 attribute_length = cfs->get_u4_fast();


3289       inner_classes_attribute_length = attribute_length;
3290       cfs->skip_u1(inner_classes_attribute_length, CHECK);
3291     } else if (tag == vmSymbols::tag_synthetic()) {
3292       // Check for Synthetic tag
3293       // Shouldn't we check that the synthetic flags wasn't already set? - not required in spec
3294       if (attribute_length != 0) {
3295         classfile_parse_error(
3296           "Invalid Synthetic classfile attribute length %u in class file %s",
3297           attribute_length, CHECK);
3298       }
3299       parse_classfile_synthetic_attribute(CHECK);
3300     } else if (tag == vmSymbols::tag_deprecated()) {
3301       // Check for Deprecatd tag - 4276120
3302       if (attribute_length != 0) {
3303         classfile_parse_error(
3304           "Invalid Deprecated classfile attribute length %u in class file %s",
3305           attribute_length, CHECK);
3306       }
3307     } else if (_major_version >= JAVA_1_5_VERSION) {
3308       if (tag == vmSymbols::tag_signature()) {




3309         if (attribute_length != 2) {
3310           classfile_parse_error(
3311             "Wrong Signature attribute length %u in class file %s",
3312             attribute_length, CHECK);
3313         }

3314         parse_classfile_signature_attribute(cfs, CHECK);
3315       } else if (tag == vmSymbols::tag_runtime_visible_annotations()) {
3316         if (runtime_visible_annotations != NULL) {
3317           classfile_parse_error(
3318             "Multiple RuntimeVisibleAnnotations attributes in class file %s", CHECK);
3319         }
3320         runtime_visible_annotations_length = attribute_length;
3321         runtime_visible_annotations = cfs->get_u1_buffer();
3322         assert(runtime_visible_annotations != NULL, "null visible annotations");
3323         cfs->guarantee_more(runtime_visible_annotations_length, CHECK);
3324         parse_annotations(cp,
3325                           runtime_visible_annotations,
3326                           runtime_visible_annotations_length,
3327                           parsed_annotations,
3328                           _loader_data,
3329                           CHECK);
3330         cfs->skip_u1_fast(runtime_visible_annotations_length);
3331       } else if (tag == vmSymbols::tag_runtime_invisible_annotations()) {
3332         if (runtime_invisible_annotations_exists) {
3333           classfile_parse_error(




1249 
1250       constantvalue_index = cfs->get_u2(CHECK);
1251       if (_need_verify) {
1252         verify_constantvalue(cp, constantvalue_index, signature_index, CHECK);
1253       }
1254     } else if (attribute_name == vmSymbols::tag_synthetic()) {
1255       if (attribute_length != 0) {
1256         classfile_parse_error(
1257           "Invalid Synthetic field attribute length %u in class file %s",
1258           attribute_length, CHECK);
1259       }
1260       is_synthetic = true;
1261     } else if (attribute_name == vmSymbols::tag_deprecated()) { // 4276120
1262       if (attribute_length != 0) {
1263         classfile_parse_error(
1264           "Invalid Deprecated field attribute length %u in class file %s",
1265           attribute_length, CHECK);
1266       }
1267     } else if (_major_version >= JAVA_1_5_VERSION) {
1268       if (attribute_name == vmSymbols::tag_signature()) {
1269         if (generic_signature_index != 0) {
1270           classfile_parse_error(
1271             "Multiple Signature attributes for field in class file %s", CHECK);
1272         }
1273         if (attribute_length != 2) {
1274           classfile_parse_error(
1275             "Wrong size %u for field's Signature attribute in class file %s",
1276             attribute_length, CHECK);
1277         }
1278         generic_signature_index = parse_generic_signature_attribute(cfs, CHECK);
1279       } else if (attribute_name == vmSymbols::tag_runtime_visible_annotations()) {
1280         if (runtime_visible_annotations != NULL) {
1281           classfile_parse_error(
1282             "Multiple RuntimeVisibleAnnotations attributes for field in class file %s", CHECK);
1283         }
1284         runtime_visible_annotations_length = attribute_length;
1285         runtime_visible_annotations = cfs->get_u1_buffer();
1286         assert(runtime_visible_annotations != NULL, "null visible annotations");
1287         cfs->guarantee_more(runtime_visible_annotations_length, CHECK);
1288         parse_annotations(cp,
1289                           runtime_visible_annotations,
1290                           runtime_visible_annotations_length,
1291                           parsed_annotations,
1292                           _loader_data,


2574       cfs->skip_u2_fast(method_parameters_length);
2575       // ignore this attribute if it cannot be reflected
2576       if (!SystemDictionary::Parameter_klass_loaded())
2577         method_parameters_length = -1;
2578     } else if (method_attribute_name == vmSymbols::tag_synthetic()) {
2579       if (method_attribute_length != 0) {
2580         classfile_parse_error(
2581           "Invalid Synthetic method attribute length %u in class file %s",
2582           method_attribute_length, CHECK_NULL);
2583       }
2584       // Should we check that there hasn't already been a synthetic attribute?
2585       access_flags.set_is_synthetic();
2586     } else if (method_attribute_name == vmSymbols::tag_deprecated()) { // 4276120
2587       if (method_attribute_length != 0) {
2588         classfile_parse_error(
2589           "Invalid Deprecated method attribute length %u in class file %s",
2590           method_attribute_length, CHECK_NULL);
2591       }
2592     } else if (_major_version >= JAVA_1_5_VERSION) {
2593       if (method_attribute_name == vmSymbols::tag_signature()) {
2594         if (generic_signature_index != 0) {
2595           classfile_parse_error(
2596             "Multiple Signature attributes for method in class file %s",
2597             CHECK_NULL);
2598         }
2599         if (method_attribute_length != 2) {
2600           classfile_parse_error(
2601             "Invalid Signature attribute length %u in class file %s",
2602             method_attribute_length, CHECK_NULL);
2603         }
2604         generic_signature_index = parse_generic_signature_attribute(cfs, CHECK_NULL);
2605       } else if (method_attribute_name == vmSymbols::tag_runtime_visible_annotations()) {
2606         if (runtime_visible_annotations != NULL) {
2607           classfile_parse_error(
2608             "Multiple RuntimeVisibleAnnotations attributes for method in class file %s",
2609             CHECK_NULL);
2610         }
2611         runtime_visible_annotations_length = method_attribute_length;
2612         runtime_visible_annotations = cfs->get_u1_buffer();
2613         assert(runtime_visible_annotations != NULL, "null visible annotations");
2614         cfs->guarantee_more(runtime_visible_annotations_length, CHECK_NULL);
2615         parse_annotations(cp,
2616                           runtime_visible_annotations,
2617                           runtime_visible_annotations_length,
2618                           &parsed_annotations,


3226                      "Bad length on BootstrapMethods in class file %s",
3227                      CHECK);
3228 }
3229 
3230 void ClassFileParser::parse_classfile_attributes(const ClassFileStream* const cfs,
3231                                                  ConstantPool* cp,
3232                  ClassFileParser::ClassAnnotationCollector* parsed_annotations,
3233                                                  TRAPS) {
3234   assert(cfs != NULL, "invariant");
3235   assert(cp != NULL, "invariant");
3236   assert(parsed_annotations != NULL, "invariant");
3237 
3238   // Set inner classes attribute to default sentinel
3239   _inner_classes = Universe::the_empty_short_array();
3240   cfs->guarantee_more(2, CHECK);  // attributes_count
3241   u2 attributes_count = cfs->get_u2_fast();
3242   bool parsed_sourcefile_attribute = false;
3243   bool parsed_innerclasses_attribute = false;
3244   bool parsed_enclosingmethod_attribute = false;
3245   bool parsed_bootstrap_methods_attribute = false;
3246   bool signature_exists = false;
3247   const u1* runtime_visible_annotations = NULL;
3248   int runtime_visible_annotations_length = 0;
3249   const u1* runtime_invisible_annotations = NULL;
3250   int runtime_invisible_annotations_length = 0;
3251   const u1* runtime_visible_type_annotations = NULL;
3252   int runtime_visible_type_annotations_length = 0;
3253   const u1* runtime_invisible_type_annotations = NULL;
3254   int runtime_invisible_type_annotations_length = 0;
3255   bool runtime_invisible_type_annotations_exists = false;
3256   bool runtime_invisible_annotations_exists = false;
3257   bool parsed_source_debug_ext_annotations_exist = false;
3258   const u1* inner_classes_attribute_start = NULL;
3259   u4  inner_classes_attribute_length = 0;
3260   u2  enclosing_method_class_index = 0;
3261   u2  enclosing_method_method_index = 0;
3262   // Iterate over attributes
3263   while (attributes_count--) {
3264     cfs->guarantee_more(6, CHECK);  // attribute_name_index, attribute_length
3265     const u2 attribute_name_index = cfs->get_u2_fast();
3266     const u4 attribute_length = cfs->get_u4_fast();


3299       inner_classes_attribute_length = attribute_length;
3300       cfs->skip_u1(inner_classes_attribute_length, CHECK);
3301     } else if (tag == vmSymbols::tag_synthetic()) {
3302       // Check for Synthetic tag
3303       // Shouldn't we check that the synthetic flags wasn't already set? - not required in spec
3304       if (attribute_length != 0) {
3305         classfile_parse_error(
3306           "Invalid Synthetic classfile attribute length %u in class file %s",
3307           attribute_length, CHECK);
3308       }
3309       parse_classfile_synthetic_attribute(CHECK);
3310     } else if (tag == vmSymbols::tag_deprecated()) {
3311       // Check for Deprecatd tag - 4276120
3312       if (attribute_length != 0) {
3313         classfile_parse_error(
3314           "Invalid Deprecated classfile attribute length %u in class file %s",
3315           attribute_length, CHECK);
3316       }
3317     } else if (_major_version >= JAVA_1_5_VERSION) {
3318       if (tag == vmSymbols::tag_signature()) {
3319         if (signature_exists) {
3320           classfile_parse_error(
3321             "Multiple Signature attributes in class file %s", CHECK);
3322         }
3323         if (attribute_length != 2) {
3324           classfile_parse_error(
3325             "Wrong Signature attribute length %u in class file %s",
3326             attribute_length, CHECK);
3327         }
3328         signature_exists = true;
3329         parse_classfile_signature_attribute(cfs, CHECK);
3330       } else if (tag == vmSymbols::tag_runtime_visible_annotations()) {
3331         if (runtime_visible_annotations != NULL) {
3332           classfile_parse_error(
3333             "Multiple RuntimeVisibleAnnotations attributes in class file %s", CHECK);
3334         }
3335         runtime_visible_annotations_length = attribute_length;
3336         runtime_visible_annotations = cfs->get_u1_buffer();
3337         assert(runtime_visible_annotations != NULL, "null visible annotations");
3338         cfs->guarantee_more(runtime_visible_annotations_length, CHECK);
3339         parse_annotations(cp,
3340                           runtime_visible_annotations,
3341                           runtime_visible_annotations_length,
3342                           parsed_annotations,
3343                           _loader_data,
3344                           CHECK);
3345         cfs->skip_u1_fast(runtime_visible_annotations_length);
3346       } else if (tag == vmSymbols::tag_runtime_invisible_annotations()) {
3347         if (runtime_invisible_annotations_exists) {
3348           classfile_parse_error(


< prev index next >