src/share/vm/classfile/classFileParser.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File 8000740 Sdiff src/share/vm/classfile

src/share/vm/classfile/classFileParser.cpp

Print this page




 799       valid_cp_range(interface_index, cp->length()) &&
 800       is_klass_reference(cp, interface_index),
 801       "Interface name has bad constant pool index %u in class file %s",
 802       interface_index, CHECK_NULL);
 803     if (cp->tag_at(interface_index).is_klass()) {
 804       interf = KlassHandle(THREAD, cp->resolved_klass_at(interface_index));
 805     } else {
 806       Symbol*  unresolved_klass  = cp->klass_name_at(interface_index);
 807 
 808       // Don't need to check legal name because it's checked when parsing constant pool.
 809       // But need to make sure it's not an array type.
 810       guarantee_property(unresolved_klass->byte_at(0) != JVM_SIGNATURE_ARRAY,
 811                          "Bad interface name in class file %s", CHECK_NULL);
 812       Handle class_loader(THREAD, loader_data->class_loader());
 813 
 814       // Call resolve_super so classcircularity is checked
 815       Klass* k = SystemDictionary::resolve_super_or_fail(class_name,
 816                     unresolved_klass, class_loader, protection_domain,
 817                     false, CHECK_NULL);
 818       interf = KlassHandle(THREAD, k);
 819 
 820       if (LinkWellKnownClasses)  // my super type is well known to me
 821         cp->klass_at_put(interface_index, interf()); // eagerly resolve
 822     }
 823 
 824     if (!Klass::cast(interf())->is_interface()) {
 825       THROW_MSG_(vmSymbols::java_lang_IncompatibleClassChangeError(), "Implementing class", NULL);
 826     }
 827     interfaces->at_put(index, interf());
 828   }
 829 
 830   if (!_need_verify || length <= 1) {
 831     return interfaces;
 832   }
 833 
 834   // Check if there's any duplicates in interfaces
 835   ResourceMark rm(THREAD);
 836   NameSigHash** interface_names = NEW_RESOURCE_ARRAY_IN_THREAD(
 837     THREAD, NameSigHash*, HASH_ROW_SIZE);
 838   initialize_hashtable(interface_names);
 839   bool dup = false;
 840   {
 841     debug_only(No_Safepoint_Verifier nsv;)


3180 
3181     // We check super class after class file is parsed and format is checked
3182     if (super_class_index > 0 && super_klass.is_null()) {
3183       Symbol*  sk  = cp->klass_name_at(super_class_index);
3184       if (access_flags.is_interface()) {
3185         // Before attempting to resolve the superclass, check for class format
3186         // errors not checked yet.
3187         guarantee_property(sk == vmSymbols::java_lang_Object(),
3188                            "Interfaces must have java.lang.Object as superclass in class file %s",
3189                            CHECK_(nullHandle));
3190       }
3191       Klass* k = SystemDictionary::resolve_super_or_fail(class_name,
3192                                                            sk,
3193                                                            class_loader,
3194                                                            protection_domain,
3195                                                            true,
3196                                                            CHECK_(nullHandle));
3197 
3198       KlassHandle kh (THREAD, k);
3199       super_klass = instanceKlassHandle(THREAD, kh());
3200       if (LinkWellKnownClasses)  // my super class is well known to me
3201         cp->klass_at_put(super_class_index, super_klass()); // eagerly resolve
3202     }
3203     if (super_klass.not_null()) {
3204       if (super_klass->is_interface()) {
3205         ResourceMark rm(THREAD);
3206         Exceptions::fthrow(
3207           THREAD_AND_LOCATION,
3208           vmSymbols::java_lang_IncompatibleClassChangeError(),
3209           "class %s has interface %s as super class",
3210           class_name->as_klass_external_name(),
3211           super_klass->external_name()
3212         );
3213         return nullHandle;
3214       }
3215       // Make sure super class is not final
3216       if (super_klass->is_final()) {
3217         THROW_MSG_(vmSymbols::java_lang_VerifyError(), "Cannot inherit from final class", nullHandle);
3218       }
3219     }
3220 
3221     // Compute the transitive list of all unique interfaces implemented by this class


3627     this_klass->set_has_nonstatic_fields(has_nonstatic_fields);
3628     this_klass->set_static_oop_field_count(fac.count[STATIC_OOP]);
3629     cp->set_pool_holder(this_klass());
3630     error_handler.set_in_error(false);   // turn off error handler for cp
3631     this_klass->set_constants(cp());
3632     this_klass->set_local_interfaces(local_interfaces);
3633     this_klass->set_fields(fields, java_fields_count);
3634     this_klass->set_methods(methods);
3635     if (has_final_method) {
3636       this_klass->set_has_final_method();
3637     }
3638     this_klass->set_method_ordering(method_ordering);
3639     // The InstanceKlass::_methods_jmethod_ids cache and the
3640     // InstanceKlass::_methods_cached_itable_indices cache are
3641     // both managed on the assumption that the initial cache
3642     // size is equal to the number of methods in the class. If
3643     // that changes, then InstanceKlass::idnum_can_increment()
3644     // has to be changed accordingly.
3645     this_klass->set_initial_method_idnum(methods->length());
3646     this_klass->set_name(cp->klass_name_at(this_class_index));
3647     if (LinkWellKnownClasses || is_anonymous())  // I am well known to myself
3648       cp->klass_at_put(this_class_index, this_klass()); // eagerly resolve
3649 
3650     if (fields_annotations != NULL ||
3651         methods_annotations != NULL ||
3652         methods_parameter_annotations != NULL ||
3653         methods_default_annotations != NULL) {
3654       // Allocate an annotation type if needed.
3655       Annotations* anno = Annotations::allocate(loader_data,
3656                             fields_annotations, methods_annotations,
3657                             methods_parameter_annotations,
3658                             methods_default_annotations, CHECK_(nullHandle));
3659       this_klass->set_annotations(anno);
3660     } else {
3661       this_klass->set_annotations(NULL);
3662     }
3663 
3664 
3665     this_klass->set_minor_version(minor_version);
3666     this_klass->set_major_version(major_version);
3667 




 799       valid_cp_range(interface_index, cp->length()) &&
 800       is_klass_reference(cp, interface_index),
 801       "Interface name has bad constant pool index %u in class file %s",
 802       interface_index, CHECK_NULL);
 803     if (cp->tag_at(interface_index).is_klass()) {
 804       interf = KlassHandle(THREAD, cp->resolved_klass_at(interface_index));
 805     } else {
 806       Symbol*  unresolved_klass  = cp->klass_name_at(interface_index);
 807 
 808       // Don't need to check legal name because it's checked when parsing constant pool.
 809       // But need to make sure it's not an array type.
 810       guarantee_property(unresolved_klass->byte_at(0) != JVM_SIGNATURE_ARRAY,
 811                          "Bad interface name in class file %s", CHECK_NULL);
 812       Handle class_loader(THREAD, loader_data->class_loader());
 813 
 814       // Call resolve_super so classcircularity is checked
 815       Klass* k = SystemDictionary::resolve_super_or_fail(class_name,
 816                     unresolved_klass, class_loader, protection_domain,
 817                     false, CHECK_NULL);
 818       interf = KlassHandle(THREAD, k);



 819     }
 820 
 821     if (!Klass::cast(interf())->is_interface()) {
 822       THROW_MSG_(vmSymbols::java_lang_IncompatibleClassChangeError(), "Implementing class", NULL);
 823     }
 824     interfaces->at_put(index, interf());
 825   }
 826 
 827   if (!_need_verify || length <= 1) {
 828     return interfaces;
 829   }
 830 
 831   // Check if there's any duplicates in interfaces
 832   ResourceMark rm(THREAD);
 833   NameSigHash** interface_names = NEW_RESOURCE_ARRAY_IN_THREAD(
 834     THREAD, NameSigHash*, HASH_ROW_SIZE);
 835   initialize_hashtable(interface_names);
 836   bool dup = false;
 837   {
 838     debug_only(No_Safepoint_Verifier nsv;)


3177 
3178     // We check super class after class file is parsed and format is checked
3179     if (super_class_index > 0 && super_klass.is_null()) {
3180       Symbol*  sk  = cp->klass_name_at(super_class_index);
3181       if (access_flags.is_interface()) {
3182         // Before attempting to resolve the superclass, check for class format
3183         // errors not checked yet.
3184         guarantee_property(sk == vmSymbols::java_lang_Object(),
3185                            "Interfaces must have java.lang.Object as superclass in class file %s",
3186                            CHECK_(nullHandle));
3187       }
3188       Klass* k = SystemDictionary::resolve_super_or_fail(class_name,
3189                                                            sk,
3190                                                            class_loader,
3191                                                            protection_domain,
3192                                                            true,
3193                                                            CHECK_(nullHandle));
3194 
3195       KlassHandle kh (THREAD, k);
3196       super_klass = instanceKlassHandle(THREAD, kh());


3197     }
3198     if (super_klass.not_null()) {
3199       if (super_klass->is_interface()) {
3200         ResourceMark rm(THREAD);
3201         Exceptions::fthrow(
3202           THREAD_AND_LOCATION,
3203           vmSymbols::java_lang_IncompatibleClassChangeError(),
3204           "class %s has interface %s as super class",
3205           class_name->as_klass_external_name(),
3206           super_klass->external_name()
3207         );
3208         return nullHandle;
3209       }
3210       // Make sure super class is not final
3211       if (super_klass->is_final()) {
3212         THROW_MSG_(vmSymbols::java_lang_VerifyError(), "Cannot inherit from final class", nullHandle);
3213       }
3214     }
3215 
3216     // Compute the transitive list of all unique interfaces implemented by this class


3622     this_klass->set_has_nonstatic_fields(has_nonstatic_fields);
3623     this_klass->set_static_oop_field_count(fac.count[STATIC_OOP]);
3624     cp->set_pool_holder(this_klass());
3625     error_handler.set_in_error(false);   // turn off error handler for cp
3626     this_klass->set_constants(cp());
3627     this_klass->set_local_interfaces(local_interfaces);
3628     this_klass->set_fields(fields, java_fields_count);
3629     this_klass->set_methods(methods);
3630     if (has_final_method) {
3631       this_klass->set_has_final_method();
3632     }
3633     this_klass->set_method_ordering(method_ordering);
3634     // The InstanceKlass::_methods_jmethod_ids cache and the
3635     // InstanceKlass::_methods_cached_itable_indices cache are
3636     // both managed on the assumption that the initial cache
3637     // size is equal to the number of methods in the class. If
3638     // that changes, then InstanceKlass::idnum_can_increment()
3639     // has to be changed accordingly.
3640     this_klass->set_initial_method_idnum(methods->length());
3641     this_klass->set_name(cp->klass_name_at(this_class_index));
3642     if (is_anonymous())  // I am well known to myself
3643       cp->klass_at_put(this_class_index, this_klass()); // eagerly resolve
3644 
3645     if (fields_annotations != NULL ||
3646         methods_annotations != NULL ||
3647         methods_parameter_annotations != NULL ||
3648         methods_default_annotations != NULL) {
3649       // Allocate an annotation type if needed.
3650       Annotations* anno = Annotations::allocate(loader_data,
3651                             fields_annotations, methods_annotations,
3652                             methods_parameter_annotations,
3653                             methods_default_annotations, CHECK_(nullHandle));
3654       this_klass->set_annotations(anno);
3655     } else {
3656       this_klass->set_annotations(NULL);
3657     }
3658 
3659 
3660     this_klass->set_minor_version(minor_version);
3661     this_klass->set_major_version(major_version);
3662 


src/share/vm/classfile/classFileParser.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File