638 switch (tag) {
639 case JVM_CONSTANT_UnresolvedClass: {
640 const Symbol* const class_name = cp->klass_name_at(index);
641 // check the name, even if _cp_patches will overwrite it
642 verify_legal_class_name(class_name, CHECK);
643 break;
644 }
645 case JVM_CONSTANT_NameAndType: {
646 if (_need_verify) {
647 const int sig_index = cp->signature_ref_index_at(index);
648 const int name_index = cp->name_ref_index_at(index);
649 const Symbol* const name = cp->symbol_at(name_index);
650 const Symbol* const sig = cp->symbol_at(sig_index);
651 guarantee_property(sig->utf8_length() != 0,
652 "Illegal zero length constant pool entry at %d in class %s",
653 sig_index, CHECK);
654 guarantee_property(name->utf8_length() != 0,
655 "Illegal zero length constant pool entry at %d in class %s",
656 name_index, CHECK);
657
658 if (sig->byte_at(0) == JVM_SIGNATURE_FUNC) {
659 // Format check method name and signature
660 verify_legal_method_name(name, CHECK);
661 verify_legal_method_signature(name, sig, CHECK);
662 } else {
663 // Format check field name and signature
664 verify_legal_field_name(name, CHECK);
665 verify_legal_field_signature(name, sig, CHECK);
666 }
667 }
668 break;
669 }
670 case JVM_CONSTANT_Dynamic: {
671 const int name_and_type_ref_index =
672 cp->name_and_type_ref_index_at(index);
673 // already verified to be utf8
674 const int name_ref_index =
675 cp->name_ref_index_at(name_and_type_ref_index);
676 // already verified to be utf8
677 const int signature_ref_index =
678 cp->signature_ref_index_at(name_and_type_ref_index);
679 const Symbol* const name = cp->symbol_at(name_ref_index);
680 const Symbol* const signature = cp->symbol_at(signature_ref_index);
681 if (_need_verify) {
682 // CONSTANT_Dynamic's name and signature are verified above, when iterating NameAndType_info.
683 // Need only to be sure signature is non-zero length and the right type.
684 if (signature->utf8_length() == 0 ||
685 signature->byte_at(0) == JVM_SIGNATURE_FUNC) {
686 throwIllegalSignature("CONSTANT_Dynamic", name, signature, CHECK);
687 }
688 }
689 break;
690 }
691 case JVM_CONSTANT_InvokeDynamic:
692 case JVM_CONSTANT_Fieldref:
693 case JVM_CONSTANT_Methodref:
694 case JVM_CONSTANT_InterfaceMethodref: {
695 const int name_and_type_ref_index =
696 cp->name_and_type_ref_index_at(index);
697 // already verified to be utf8
698 const int name_ref_index =
699 cp->name_ref_index_at(name_and_type_ref_index);
700 // already verified to be utf8
701 const int signature_ref_index =
702 cp->signature_ref_index_at(name_and_type_ref_index);
703 const Symbol* const name = cp->symbol_at(name_ref_index);
704 const Symbol* const signature = cp->symbol_at(signature_ref_index);
705 if (tag == JVM_CONSTANT_Fieldref) {
706 if (_need_verify) {
707 // Field name and signature are verified above, when iterating NameAndType_info.
708 // Need only to be sure signature is non-zero length and the right type.
709 if (signature->utf8_length() == 0 ||
710 signature->byte_at(0) == JVM_SIGNATURE_FUNC) {
711 throwIllegalSignature("Field", name, signature, CHECK);
712 }
713 }
714 } else {
715 if (_need_verify) {
716 // Method name and signature are verified above, when iterating NameAndType_info.
717 // Need only to be sure signature is non-zero length and the right type.
718 if (signature->utf8_length() == 0 ||
719 signature->byte_at(0) != JVM_SIGNATURE_FUNC) {
720 throwIllegalSignature("Method", name, signature, CHECK);
721 }
722 }
723 // 4509014: If a class method name begins with '<', it must be "<init>"
724 const unsigned int name_len = name->utf8_length();
725 if (tag == JVM_CONSTANT_Methodref &&
726 name_len != 0 &&
727 name->byte_at(0) == '<' &&
728 name != vmSymbols::object_initializer_name()) {
729 classfile_parse_error(
730 "Bad method name at constant pool index %u in class file %s",
731 name_ref_index, CHECK);
732 }
733 }
734 break;
735 }
736 case JVM_CONSTANT_MethodHandle: {
737 const int ref_index = cp->method_handle_index_at(index);
738 const int ref_kind = cp->method_handle_ref_kind_at(index);
739 switch (ref_kind) {
740 case JVM_REF_invokeVirtual:
741 case JVM_REF_invokeStatic:
742 case JVM_REF_invokeSpecial:
743 case JVM_REF_newInvokeSpecial: {
744 const int name_and_type_ref_index =
745 cp->name_and_type_ref_index_at(ref_index);
746 const int name_ref_index =
747 cp->name_ref_index_at(name_and_type_ref_index);
925 _local_interfaces = Universe::the_empty_instance_klass_array();
926 } else {
927 assert(itfs_len > 0, "only called for len>0");
928 _local_interfaces = MetadataFactory::new_array<InstanceKlass*>(_loader_data, itfs_len, NULL, CHECK);
929
930 int index;
931 for (index = 0; index < itfs_len; index++) {
932 const u2 interface_index = stream->get_u2(CHECK);
933 Klass* interf;
934 check_property(
935 valid_klass_reference_at(interface_index),
936 "Interface name has bad constant pool index %u in class file %s",
937 interface_index, CHECK);
938 if (cp->tag_at(interface_index).is_klass()) {
939 interf = cp->resolved_klass_at(interface_index);
940 } else {
941 Symbol* const unresolved_klass = cp->klass_name_at(interface_index);
942
943 // Don't need to check legal name because it's checked when parsing constant pool.
944 // But need to make sure it's not an array type.
945 guarantee_property(unresolved_klass->byte_at(0) != JVM_SIGNATURE_ARRAY,
946 "Bad interface name in class file %s", CHECK);
947
948 // Call resolve_super so classcircularity is checked
949 interf = SystemDictionary::resolve_super_or_fail(
950 _class_name,
951 unresolved_klass,
952 Handle(THREAD, _loader_data->class_loader()),
953 _protection_domain,
954 false,
955 CHECK);
956 }
957
958 if (!interf->is_interface()) {
959 THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(),
960 err_msg("class %s can not implement %s, because it is not an interface (%s)",
961 _class_name->as_klass_external_name(),
962 interf->external_name(),
963 interf->class_in_module_of_loader()));
964 }
965
3735 const InstanceKlass* super_klass = NULL;
3736
3737 if (super_class_index == 0) {
3738 check_property(_class_name == vmSymbols::java_lang_Object(),
3739 "Invalid superclass index %u in class file %s",
3740 super_class_index,
3741 CHECK_NULL);
3742 } else {
3743 check_property(valid_klass_reference_at(super_class_index),
3744 "Invalid superclass index %u in class file %s",
3745 super_class_index,
3746 CHECK_NULL);
3747 // The class name should be legal because it is checked when parsing constant pool.
3748 // However, make sure it is not an array type.
3749 bool is_array = false;
3750 if (cp->tag_at(super_class_index).is_klass()) {
3751 super_klass = InstanceKlass::cast(cp->resolved_klass_at(super_class_index));
3752 if (need_verify)
3753 is_array = super_klass->is_array_klass();
3754 } else if (need_verify) {
3755 is_array = (cp->klass_name_at(super_class_index)->byte_at(0) == JVM_SIGNATURE_ARRAY);
3756 }
3757 if (need_verify) {
3758 guarantee_property(!is_array,
3759 "Bad superclass name in class file %s", CHECK_NULL);
3760 }
3761 }
3762 return super_klass;
3763 }
3764
3765 static unsigned int compute_oop_map_count(const InstanceKlass* super,
3766 unsigned int nonstatic_oop_map_count,
3767 int first_nonstatic_oop_offset) {
3768
3769 unsigned int map_count =
3770 NULL == super ? 0 : super->nonstatic_oop_map_count();
3771 if (nonstatic_oop_map_count > 0) {
3772 // We have oops to add to map
3773 if (map_count == 0) {
3774 map_count = nonstatic_oop_map_count;
3775 }
5362 unsigned int length = signature->utf8_length();
5363 const char* nextp;
5364
5365 // The first character must be a '('
5366 if ((length > 0) && (*p++ == JVM_SIGNATURE_FUNC)) {
5367 length--;
5368 // Skip over legal field signatures
5369 nextp = skip_over_field_signature(p, false, length, CHECK_0);
5370 while ((length > 0) && (nextp != NULL)) {
5371 args_size++;
5372 if (p[0] == 'J' || p[0] == 'D') {
5373 args_size++;
5374 }
5375 length -= nextp - p;
5376 p = nextp;
5377 nextp = skip_over_field_signature(p, false, length, CHECK_0);
5378 }
5379 // The first non-signature thing better be a ')'
5380 if ((length > 0) && (*p++ == JVM_SIGNATURE_ENDFUNC)) {
5381 length--;
5382 if (name->utf8_length() > 0 && name->byte_at(0) == '<') {
5383 // All internal methods must return void
5384 if ((length == 1) && (p[0] == JVM_SIGNATURE_VOID)) {
5385 return args_size;
5386 }
5387 } else {
5388 // Now we better just have a return value
5389 nextp = skip_over_field_signature(p, true, length, CHECK_0);
5390 if (nextp && ((int)length == (nextp - p))) {
5391 return args_size;
5392 }
5393 }
5394 }
5395 }
5396 // Report error
5397 throwIllegalSignature("Method", name, signature, CHECK_0);
5398 return 0;
5399 }
5400
5401 int ClassFileParser::static_field_size() const {
5402 assert(_field_info != NULL, "invariant");
5779 strncpy(new_anon_name, host_pkg_name, host_pkg_len);
5780 new_anon_name[host_pkg_len] = '/';
5781 // Append unsafe anonymous class name. The unsafe anonymous class name can contain odd
5782 // characters. So, do a strncpy instead of using sprintf("%s...").
5783 strncpy(new_anon_name + host_pkg_len + 1, (char *)_class_name->base(), class_name_len);
5784
5785 // Create a symbol and update the anonymous class name.
5786 _class_name = SymbolTable::new_symbol(new_anon_name,
5787 (int)host_pkg_len + 1 + class_name_len,
5788 CHECK);
5789 }
5790 }
5791
5792 // If the host class and the anonymous class are in the same package then do
5793 // nothing. If the anonymous class is in the unnamed package then move it to its
5794 // host's package. If the classes are in different packages then throw an IAE
5795 // exception.
5796 void ClassFileParser::fix_unsafe_anonymous_class_name(TRAPS) {
5797 assert(_unsafe_anonymous_host != NULL, "Expected an unsafe anonymous class");
5798
5799 const jbyte* anon_last_slash = UTF8::strrchr(_class_name->base(),
5800 _class_name->utf8_length(), '/');
5801 if (anon_last_slash == NULL) { // Unnamed package
5802 prepend_host_package_name(_unsafe_anonymous_host, CHECK);
5803 } else {
5804 if (!_unsafe_anonymous_host->is_same_class_package(_unsafe_anonymous_host->class_loader(), _class_name)) {
5805 ResourceMark rm(THREAD);
5806 THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
5807 err_msg("Host class %s and anonymous class %s are in different packages",
5808 _unsafe_anonymous_host->name()->as_C_string(), _class_name->as_C_string()));
5809 }
5810 }
5811 }
5812
5813 static bool relax_format_check_for(ClassLoaderData* loader_data) {
5814 bool trusted = (loader_data->is_the_null_class_loader_data() ||
5815 SystemDictionary::is_platform_class_loader(loader_data->class_loader()));
5816 bool need_verify =
5817 // verifyAll
5818 (BytecodeVerificationLocal && BytecodeVerificationRemote) ||
5819 // verifyRemote
6102
6103 // This class and superclass
6104 _this_class_index = stream->get_u2_fast();
6105 check_property(
6106 valid_cp_range(_this_class_index, cp_size) &&
6107 cp->tag_at(_this_class_index).is_unresolved_klass(),
6108 "Invalid this class index %u in constant pool in class file %s",
6109 _this_class_index, CHECK);
6110
6111 Symbol* const class_name_in_cp = cp->klass_name_at(_this_class_index);
6112 assert(class_name_in_cp != NULL, "class_name can't be null");
6113
6114 // Update _class_name which could be null previously
6115 // to reflect the name in the constant pool
6116 _class_name = class_name_in_cp;
6117
6118 // Don't need to check whether this class name is legal or not.
6119 // It has been checked when constant pool is parsed.
6120 // However, make sure it is not an array type.
6121 if (_need_verify) {
6122 guarantee_property(_class_name->byte_at(0) != JVM_SIGNATURE_ARRAY,
6123 "Bad class name in class file %s",
6124 CHECK);
6125 }
6126
6127 // Checks if name in class file matches requested name
6128 if (_requested_name != NULL && _requested_name != _class_name) {
6129 ResourceMark rm(THREAD);
6130 Exceptions::fthrow(
6131 THREAD_AND_LOCATION,
6132 vmSymbols::java_lang_NoClassDefFoundError(),
6133 "%s (wrong name: %s)",
6134 _class_name->as_C_string(),
6135 _requested_name != NULL ? _requested_name->as_C_string() : "NoName"
6136 );
6137 return;
6138 }
6139
6140 // if this is an anonymous class fix up its name if it's in the unnamed
6141 // package. Otherwise, throw IAE if it is in a different package than
6142 // its host class.
|
638 switch (tag) {
639 case JVM_CONSTANT_UnresolvedClass: {
640 const Symbol* const class_name = cp->klass_name_at(index);
641 // check the name, even if _cp_patches will overwrite it
642 verify_legal_class_name(class_name, CHECK);
643 break;
644 }
645 case JVM_CONSTANT_NameAndType: {
646 if (_need_verify) {
647 const int sig_index = cp->signature_ref_index_at(index);
648 const int name_index = cp->name_ref_index_at(index);
649 const Symbol* const name = cp->symbol_at(name_index);
650 const Symbol* const sig = cp->symbol_at(sig_index);
651 guarantee_property(sig->utf8_length() != 0,
652 "Illegal zero length constant pool entry at %d in class %s",
653 sig_index, CHECK);
654 guarantee_property(name->utf8_length() != 0,
655 "Illegal zero length constant pool entry at %d in class %s",
656 name_index, CHECK);
657
658 if (sig->char_at(0) == JVM_SIGNATURE_FUNC) {
659 // Format check method name and signature
660 verify_legal_method_name(name, CHECK);
661 verify_legal_method_signature(name, sig, CHECK);
662 } else {
663 // Format check field name and signature
664 verify_legal_field_name(name, CHECK);
665 verify_legal_field_signature(name, sig, CHECK);
666 }
667 }
668 break;
669 }
670 case JVM_CONSTANT_Dynamic: {
671 const int name_and_type_ref_index =
672 cp->name_and_type_ref_index_at(index);
673 // already verified to be utf8
674 const int name_ref_index =
675 cp->name_ref_index_at(name_and_type_ref_index);
676 // already verified to be utf8
677 const int signature_ref_index =
678 cp->signature_ref_index_at(name_and_type_ref_index);
679 const Symbol* const name = cp->symbol_at(name_ref_index);
680 const Symbol* const signature = cp->symbol_at(signature_ref_index);
681 if (_need_verify) {
682 // CONSTANT_Dynamic's name and signature are verified above, when iterating NameAndType_info.
683 // Need only to be sure signature is non-zero length and the right type.
684 if (signature->utf8_length() == 0 ||
685 signature->char_at(0) == JVM_SIGNATURE_FUNC) {
686 throwIllegalSignature("CONSTANT_Dynamic", name, signature, CHECK);
687 }
688 }
689 break;
690 }
691 case JVM_CONSTANT_InvokeDynamic:
692 case JVM_CONSTANT_Fieldref:
693 case JVM_CONSTANT_Methodref:
694 case JVM_CONSTANT_InterfaceMethodref: {
695 const int name_and_type_ref_index =
696 cp->name_and_type_ref_index_at(index);
697 // already verified to be utf8
698 const int name_ref_index =
699 cp->name_ref_index_at(name_and_type_ref_index);
700 // already verified to be utf8
701 const int signature_ref_index =
702 cp->signature_ref_index_at(name_and_type_ref_index);
703 const Symbol* const name = cp->symbol_at(name_ref_index);
704 const Symbol* const signature = cp->symbol_at(signature_ref_index);
705 if (tag == JVM_CONSTANT_Fieldref) {
706 if (_need_verify) {
707 // Field name and signature are verified above, when iterating NameAndType_info.
708 // Need only to be sure signature is non-zero length and the right type.
709 if (signature->utf8_length() == 0 ||
710 signature->char_at(0) == JVM_SIGNATURE_FUNC) {
711 throwIllegalSignature("Field", name, signature, CHECK);
712 }
713 }
714 } else {
715 if (_need_verify) {
716 // Method name and signature are verified above, when iterating NameAndType_info.
717 // Need only to be sure signature is non-zero length and the right type.
718 if (signature->utf8_length() == 0 ||
719 signature->char_at(0) != JVM_SIGNATURE_FUNC) {
720 throwIllegalSignature("Method", name, signature, CHECK);
721 }
722 }
723 // 4509014: If a class method name begins with '<', it must be "<init>"
724 const unsigned int name_len = name->utf8_length();
725 if (tag == JVM_CONSTANT_Methodref &&
726 name_len != 0 &&
727 name->char_at(0) == '<' &&
728 name != vmSymbols::object_initializer_name()) {
729 classfile_parse_error(
730 "Bad method name at constant pool index %u in class file %s",
731 name_ref_index, CHECK);
732 }
733 }
734 break;
735 }
736 case JVM_CONSTANT_MethodHandle: {
737 const int ref_index = cp->method_handle_index_at(index);
738 const int ref_kind = cp->method_handle_ref_kind_at(index);
739 switch (ref_kind) {
740 case JVM_REF_invokeVirtual:
741 case JVM_REF_invokeStatic:
742 case JVM_REF_invokeSpecial:
743 case JVM_REF_newInvokeSpecial: {
744 const int name_and_type_ref_index =
745 cp->name_and_type_ref_index_at(ref_index);
746 const int name_ref_index =
747 cp->name_ref_index_at(name_and_type_ref_index);
925 _local_interfaces = Universe::the_empty_instance_klass_array();
926 } else {
927 assert(itfs_len > 0, "only called for len>0");
928 _local_interfaces = MetadataFactory::new_array<InstanceKlass*>(_loader_data, itfs_len, NULL, CHECK);
929
930 int index;
931 for (index = 0; index < itfs_len; index++) {
932 const u2 interface_index = stream->get_u2(CHECK);
933 Klass* interf;
934 check_property(
935 valid_klass_reference_at(interface_index),
936 "Interface name has bad constant pool index %u in class file %s",
937 interface_index, CHECK);
938 if (cp->tag_at(interface_index).is_klass()) {
939 interf = cp->resolved_klass_at(interface_index);
940 } else {
941 Symbol* const unresolved_klass = cp->klass_name_at(interface_index);
942
943 // Don't need to check legal name because it's checked when parsing constant pool.
944 // But need to make sure it's not an array type.
945 guarantee_property(unresolved_klass->char_at(0) != JVM_SIGNATURE_ARRAY,
946 "Bad interface name in class file %s", CHECK);
947
948 // Call resolve_super so classcircularity is checked
949 interf = SystemDictionary::resolve_super_or_fail(
950 _class_name,
951 unresolved_klass,
952 Handle(THREAD, _loader_data->class_loader()),
953 _protection_domain,
954 false,
955 CHECK);
956 }
957
958 if (!interf->is_interface()) {
959 THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(),
960 err_msg("class %s can not implement %s, because it is not an interface (%s)",
961 _class_name->as_klass_external_name(),
962 interf->external_name(),
963 interf->class_in_module_of_loader()));
964 }
965
3735 const InstanceKlass* super_klass = NULL;
3736
3737 if (super_class_index == 0) {
3738 check_property(_class_name == vmSymbols::java_lang_Object(),
3739 "Invalid superclass index %u in class file %s",
3740 super_class_index,
3741 CHECK_NULL);
3742 } else {
3743 check_property(valid_klass_reference_at(super_class_index),
3744 "Invalid superclass index %u in class file %s",
3745 super_class_index,
3746 CHECK_NULL);
3747 // The class name should be legal because it is checked when parsing constant pool.
3748 // However, make sure it is not an array type.
3749 bool is_array = false;
3750 if (cp->tag_at(super_class_index).is_klass()) {
3751 super_klass = InstanceKlass::cast(cp->resolved_klass_at(super_class_index));
3752 if (need_verify)
3753 is_array = super_klass->is_array_klass();
3754 } else if (need_verify) {
3755 is_array = (cp->klass_name_at(super_class_index)->char_at(0) == JVM_SIGNATURE_ARRAY);
3756 }
3757 if (need_verify) {
3758 guarantee_property(!is_array,
3759 "Bad superclass name in class file %s", CHECK_NULL);
3760 }
3761 }
3762 return super_klass;
3763 }
3764
3765 static unsigned int compute_oop_map_count(const InstanceKlass* super,
3766 unsigned int nonstatic_oop_map_count,
3767 int first_nonstatic_oop_offset) {
3768
3769 unsigned int map_count =
3770 NULL == super ? 0 : super->nonstatic_oop_map_count();
3771 if (nonstatic_oop_map_count > 0) {
3772 // We have oops to add to map
3773 if (map_count == 0) {
3774 map_count = nonstatic_oop_map_count;
3775 }
5362 unsigned int length = signature->utf8_length();
5363 const char* nextp;
5364
5365 // The first character must be a '('
5366 if ((length > 0) && (*p++ == JVM_SIGNATURE_FUNC)) {
5367 length--;
5368 // Skip over legal field signatures
5369 nextp = skip_over_field_signature(p, false, length, CHECK_0);
5370 while ((length > 0) && (nextp != NULL)) {
5371 args_size++;
5372 if (p[0] == 'J' || p[0] == 'D') {
5373 args_size++;
5374 }
5375 length -= nextp - p;
5376 p = nextp;
5377 nextp = skip_over_field_signature(p, false, length, CHECK_0);
5378 }
5379 // The first non-signature thing better be a ')'
5380 if ((length > 0) && (*p++ == JVM_SIGNATURE_ENDFUNC)) {
5381 length--;
5382 if (name->utf8_length() > 0 && name->char_at(0) == '<') {
5383 // All internal methods must return void
5384 if ((length == 1) && (p[0] == JVM_SIGNATURE_VOID)) {
5385 return args_size;
5386 }
5387 } else {
5388 // Now we better just have a return value
5389 nextp = skip_over_field_signature(p, true, length, CHECK_0);
5390 if (nextp && ((int)length == (nextp - p))) {
5391 return args_size;
5392 }
5393 }
5394 }
5395 }
5396 // Report error
5397 throwIllegalSignature("Method", name, signature, CHECK_0);
5398 return 0;
5399 }
5400
5401 int ClassFileParser::static_field_size() const {
5402 assert(_field_info != NULL, "invariant");
5779 strncpy(new_anon_name, host_pkg_name, host_pkg_len);
5780 new_anon_name[host_pkg_len] = '/';
5781 // Append unsafe anonymous class name. The unsafe anonymous class name can contain odd
5782 // characters. So, do a strncpy instead of using sprintf("%s...").
5783 strncpy(new_anon_name + host_pkg_len + 1, (char *)_class_name->base(), class_name_len);
5784
5785 // Create a symbol and update the anonymous class name.
5786 _class_name = SymbolTable::new_symbol(new_anon_name,
5787 (int)host_pkg_len + 1 + class_name_len,
5788 CHECK);
5789 }
5790 }
5791
5792 // If the host class and the anonymous class are in the same package then do
5793 // nothing. If the anonymous class is in the unnamed package then move it to its
5794 // host's package. If the classes are in different packages then throw an IAE
5795 // exception.
5796 void ClassFileParser::fix_unsafe_anonymous_class_name(TRAPS) {
5797 assert(_unsafe_anonymous_host != NULL, "Expected an unsafe anonymous class");
5798
5799 const jbyte* anon_last_slash = UTF8::strrchr((const jbyte*)_class_name->base(),
5800 _class_name->utf8_length(), '/');
5801 if (anon_last_slash == NULL) { // Unnamed package
5802 prepend_host_package_name(_unsafe_anonymous_host, CHECK);
5803 } else {
5804 if (!_unsafe_anonymous_host->is_same_class_package(_unsafe_anonymous_host->class_loader(), _class_name)) {
5805 ResourceMark rm(THREAD);
5806 THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
5807 err_msg("Host class %s and anonymous class %s are in different packages",
5808 _unsafe_anonymous_host->name()->as_C_string(), _class_name->as_C_string()));
5809 }
5810 }
5811 }
5812
5813 static bool relax_format_check_for(ClassLoaderData* loader_data) {
5814 bool trusted = (loader_data->is_the_null_class_loader_data() ||
5815 SystemDictionary::is_platform_class_loader(loader_data->class_loader()));
5816 bool need_verify =
5817 // verifyAll
5818 (BytecodeVerificationLocal && BytecodeVerificationRemote) ||
5819 // verifyRemote
6102
6103 // This class and superclass
6104 _this_class_index = stream->get_u2_fast();
6105 check_property(
6106 valid_cp_range(_this_class_index, cp_size) &&
6107 cp->tag_at(_this_class_index).is_unresolved_klass(),
6108 "Invalid this class index %u in constant pool in class file %s",
6109 _this_class_index, CHECK);
6110
6111 Symbol* const class_name_in_cp = cp->klass_name_at(_this_class_index);
6112 assert(class_name_in_cp != NULL, "class_name can't be null");
6113
6114 // Update _class_name which could be null previously
6115 // to reflect the name in the constant pool
6116 _class_name = class_name_in_cp;
6117
6118 // Don't need to check whether this class name is legal or not.
6119 // It has been checked when constant pool is parsed.
6120 // However, make sure it is not an array type.
6121 if (_need_verify) {
6122 guarantee_property(_class_name->char_at(0) != JVM_SIGNATURE_ARRAY,
6123 "Bad class name in class file %s",
6124 CHECK);
6125 }
6126
6127 // Checks if name in class file matches requested name
6128 if (_requested_name != NULL && _requested_name != _class_name) {
6129 ResourceMark rm(THREAD);
6130 Exceptions::fthrow(
6131 THREAD_AND_LOCATION,
6132 vmSymbols::java_lang_NoClassDefFoundError(),
6133 "%s (wrong name: %s)",
6134 _class_name->as_C_string(),
6135 _requested_name != NULL ? _requested_name->as_C_string() : "NoName"
6136 );
6137 return;
6138 }
6139
6140 // if this is an anonymous class fix up its name if it's in the unnamed
6141 // package. Otherwise, throw IAE if it is in a different package than
6142 // its host class.
|