< prev index next >

src/hotspot/share/classfile/classFileParser.cpp

Print this page




3469       parse_classfile_sourcefile_attribute(cfs, CHECK);
3470     } else if (tag == vmSymbols::tag_source_debug_extension()) {
3471       // Check for SourceDebugExtension tag
3472       if (parsed_source_debug_ext_annotations_exist) {
3473           classfile_parse_error(
3474             "Multiple SourceDebugExtension attributes in class file %s", CHECK);
3475       }
3476       parsed_source_debug_ext_annotations_exist = true;
3477       parse_classfile_source_debug_extension_attribute(cfs, (int)attribute_length, CHECK);
3478     } else if (tag == vmSymbols::tag_inner_classes()) {
3479       // Check for InnerClasses tag
3480       if (parsed_innerclasses_attribute) {
3481         classfile_parse_error("Multiple InnerClasses attributes in class file %s", CHECK);
3482       } else {
3483         parsed_innerclasses_attribute = true;
3484       }
3485       inner_classes_attribute_start = cfs->current();
3486       inner_classes_attribute_length = attribute_length;
3487       cfs->skip_u1(inner_classes_attribute_length, CHECK);
3488     } else if (tag == vmSymbols::tag_value_types()) {


3489       // Check for ValueTypes tag
3490       if (parsed_value_types_attribute) {
3491         classfile_parse_error("Multiple ValueTypes attributes in class file %s", CHECK);
3492       } else {
3493         parsed_value_types_attribute = true;
3494       }
3495       value_types_attribute_start = cfs->current();
3496       value_types_attribute_length = attribute_length;
3497       cfs->skip_u1(value_types_attribute_length, CHECK);

3498     } else if (tag == vmSymbols::tag_synthetic()) {
3499       // Check for Synthetic tag
3500       // Shouldn't we check that the synthetic flags wasn't already set? - not required in spec
3501       if (attribute_length != 0) {
3502         classfile_parse_error(
3503           "Invalid Synthetic classfile attribute length %u in class file %s",
3504           attribute_length, CHECK);
3505       }
3506       parse_classfile_synthetic_attribute(CHECK);
3507     } else if (tag == vmSymbols::tag_deprecated()) {
3508       // Check for Deprecatd tag - 4276120
3509       if (attribute_length != 0) {
3510         classfile_parse_error(
3511           "Invalid Deprecated classfile attribute length %u in class file %s",
3512           attribute_length, CHECK);
3513       }
3514     } else if (_major_version >= JAVA_1_5_VERSION) {
3515       if (tag == vmSymbols::tag_signature()) {
3516         if (_generic_signature_index != 0) {
3517           classfile_parse_error(


4684     }
4685     assert(v == ik->has_vanilla_constructor(), "inconsistent has_vanilla_constructor");
4686 #endif
4687   }
4688 
4689   // If it cannot be fast-path allocated, set a bit in the layout helper.
4690   // See documentation of InstanceKlass::can_be_fastpath_allocated().
4691   assert(ik->size_helper() > 0, "layout_helper is initialized");
4692   if ((!RegisterFinalizersAtInit && ik->has_finalizer())
4693       || ik->is_abstract() || ik->is_interface()
4694       || (ik->name() == vmSymbols::java_lang_Class() && ik->class_loader() == NULL)
4695       || ik->size_helper() >= FastAllocateSizeLimit) {
4696     // Forbid fast-path allocation.
4697     const jint lh = Klass::instance_layout_helper(ik->size_helper(), true);
4698     ik->set_layout_helper(lh);
4699   }
4700 }
4701 
4702 bool ClassFileParser::supports_value_types() const {
4703   // Value types are only supported by class file version 55 and later
4704   return _major_version >= JAVA_11_VERSION;
4705 }
4706 
4707 // Attach super classes and interface classes to class loader data
4708 static void record_defined_class_dependencies(const InstanceKlass* defined_klass,
4709                                               TRAPS) {
4710   assert(defined_klass != NULL, "invariant");
4711 
4712   ClassLoaderData* const defining_loader_data = defined_klass->class_loader_data();
4713   if (defining_loader_data->is_the_null_class_loader_data()) {
4714       // Dependencies to null class loader data are implicit.
4715       return;
4716   } else {
4717     // add super class dependency
4718     Klass* const super = defined_klass->super();
4719     if (super != NULL) {
4720       defining_loader_data->record_dependency(super);
4721     }
4722 
4723     // add super interface dependencies
4724     const Array<Klass*>* const local_interfaces = defined_klass->local_interfaces();




3469       parse_classfile_sourcefile_attribute(cfs, CHECK);
3470     } else if (tag == vmSymbols::tag_source_debug_extension()) {
3471       // Check for SourceDebugExtension tag
3472       if (parsed_source_debug_ext_annotations_exist) {
3473           classfile_parse_error(
3474             "Multiple SourceDebugExtension attributes in class file %s", CHECK);
3475       }
3476       parsed_source_debug_ext_annotations_exist = true;
3477       parse_classfile_source_debug_extension_attribute(cfs, (int)attribute_length, CHECK);
3478     } else if (tag == vmSymbols::tag_inner_classes()) {
3479       // Check for InnerClasses tag
3480       if (parsed_innerclasses_attribute) {
3481         classfile_parse_error("Multiple InnerClasses attributes in class file %s", CHECK);
3482       } else {
3483         parsed_innerclasses_attribute = true;
3484       }
3485       inner_classes_attribute_start = cfs->current();
3486       inner_classes_attribute_length = attribute_length;
3487       cfs->skip_u1(inner_classes_attribute_length, CHECK);
3488     } else if (tag == vmSymbols::tag_value_types()) {
3489       // Ignore ValueTypes attribute unless value type support is enabled.
3490       if (supports_value_types())  {
3491         // Check for ValueTypes tag
3492         if (parsed_value_types_attribute) {
3493           classfile_parse_error("Multiple ValueTypes attributes in class file %s", CHECK);
3494         } else {
3495           parsed_value_types_attribute = true;
3496         }
3497         value_types_attribute_start = cfs->current();
3498         value_types_attribute_length = attribute_length;
3499       }
3500       cfs->skip_u1(attribute_length, CHECK);
3501     } else if (tag == vmSymbols::tag_synthetic()) {
3502       // Check for Synthetic tag
3503       // Shouldn't we check that the synthetic flags wasn't already set? - not required in spec
3504       if (attribute_length != 0) {
3505         classfile_parse_error(
3506           "Invalid Synthetic classfile attribute length %u in class file %s",
3507           attribute_length, CHECK);
3508       }
3509       parse_classfile_synthetic_attribute(CHECK);
3510     } else if (tag == vmSymbols::tag_deprecated()) {
3511       // Check for Deprecatd tag - 4276120
3512       if (attribute_length != 0) {
3513         classfile_parse_error(
3514           "Invalid Deprecated classfile attribute length %u in class file %s",
3515           attribute_length, CHECK);
3516       }
3517     } else if (_major_version >= JAVA_1_5_VERSION) {
3518       if (tag == vmSymbols::tag_signature()) {
3519         if (_generic_signature_index != 0) {
3520           classfile_parse_error(


4687     }
4688     assert(v == ik->has_vanilla_constructor(), "inconsistent has_vanilla_constructor");
4689 #endif
4690   }
4691 
4692   // If it cannot be fast-path allocated, set a bit in the layout helper.
4693   // See documentation of InstanceKlass::can_be_fastpath_allocated().
4694   assert(ik->size_helper() > 0, "layout_helper is initialized");
4695   if ((!RegisterFinalizersAtInit && ik->has_finalizer())
4696       || ik->is_abstract() || ik->is_interface()
4697       || (ik->name() == vmSymbols::java_lang_Class() && ik->class_loader() == NULL)
4698       || ik->size_helper() >= FastAllocateSizeLimit) {
4699     // Forbid fast-path allocation.
4700     const jint lh = Klass::instance_layout_helper(ik->size_helper(), true);
4701     ik->set_layout_helper(lh);
4702   }
4703 }
4704 
4705 bool ClassFileParser::supports_value_types() const {
4706   // Value types are only supported by class file version 55 and later
4707   return EnableValhalla && _major_version >= JAVA_11_VERSION;
4708 }
4709 
4710 // Attach super classes and interface classes to class loader data
4711 static void record_defined_class_dependencies(const InstanceKlass* defined_klass,
4712                                               TRAPS) {
4713   assert(defined_klass != NULL, "invariant");
4714 
4715   ClassLoaderData* const defining_loader_data = defined_klass->class_loader_data();
4716   if (defining_loader_data->is_the_null_class_loader_data()) {
4717       // Dependencies to null class loader data are implicit.
4718       return;
4719   } else {
4720     // add super class dependency
4721     Klass* const super = defined_klass->super();
4722     if (super != NULL) {
4723       defining_loader_data->record_dependency(super);
4724     }
4725 
4726     // add super interface dependencies
4727     const Array<Klass*>* const local_interfaces = defined_klass->local_interfaces();


< prev index next >