< prev index next >

src/hotspot/share/classfile/classFileParser.cpp

Print this page




3698           cfs->skip_u1(nest_members_attribute_length, CHECK);
3699         } else if (tag == vmSymbols::tag_nest_host()) {
3700           if (parsed_nest_host_attribute) {
3701             classfile_parse_error("Multiple NestHost attributes in class file %s", CHECK);
3702           } else {
3703             parsed_nest_host_attribute = true;
3704           }
3705           if (parsed_nest_members_attribute) {
3706             classfile_parse_error("Conflicting NestMembers and NestHost attributes in class file %s", CHECK);
3707           }
3708           if (_need_verify) {
3709             guarantee_property(attribute_length == 2, "Wrong NestHost attribute length in class file %s", CHECK);
3710           }
3711           cfs->guarantee_more(2, CHECK);
3712           u2 class_info_index = cfs->get_u2_fast();
3713           check_property(
3714                          valid_klass_reference_at(class_info_index),
3715                          "Nest-host class_info_index %u has bad constant type in class file %s",
3716                          class_info_index, CHECK);
3717           _nest_host = class_info_index;
3718         } else if (tag == vmSymbols::tag_record()) {

3719           // Skip over Record attribute if not supported or if super class is
3720           // not java.lang.Record.
3721           if (supports_records() &&
3722               cp->klass_name_at(_super_class_index) == vmSymbols::java_lang_Record()) {
3723             if (parsed_record_attribute) {
3724               classfile_parse_error("Multiple Record attributes in class file %s", CHECK);
3725             }
3726             // Check that class is final and not abstract.
3727             if (!_access_flags.is_final() || _access_flags.is_abstract()) {
3728               classfile_parse_error("Record attribute in non-final or abstract class file %s", CHECK);
3729             }
3730             parsed_record_attribute = true;
3731             record_attribute_start = cfs->current();
3732             record_attribute_length = attribute_length;
3733           }
3734           cfs->skip_u1(attribute_length, CHECK);




3735         } else {
3736           // Unknown attribute
3737           cfs->skip_u1(attribute_length, CHECK);
3738         }
3739       } else {
3740         // Unknown attribute
3741         cfs->skip_u1(attribute_length, CHECK);
3742       }
3743     } else {
3744       // Unknown attribute
3745       cfs->skip_u1(attribute_length, CHECK);
3746     }
3747   }
3748   _class_annotations = assemble_annotations(runtime_visible_annotations,
3749                                             runtime_visible_annotations_length,
3750                                             runtime_invisible_annotations,
3751                                             runtime_invisible_annotations_length,
3752                                             CHECK);
3753   _class_type_annotations = assemble_annotations(runtime_visible_type_annotations,
3754                                                  runtime_visible_type_annotations_length,




3698           cfs->skip_u1(nest_members_attribute_length, CHECK);
3699         } else if (tag == vmSymbols::tag_nest_host()) {
3700           if (parsed_nest_host_attribute) {
3701             classfile_parse_error("Multiple NestHost attributes in class file %s", CHECK);
3702           } else {
3703             parsed_nest_host_attribute = true;
3704           }
3705           if (parsed_nest_members_attribute) {
3706             classfile_parse_error("Conflicting NestMembers and NestHost attributes in class file %s", CHECK);
3707           }
3708           if (_need_verify) {
3709             guarantee_property(attribute_length == 2, "Wrong NestHost attribute length in class file %s", CHECK);
3710           }
3711           cfs->guarantee_more(2, CHECK);
3712           u2 class_info_index = cfs->get_u2_fast();
3713           check_property(
3714                          valid_klass_reference_at(class_info_index),
3715                          "Nest-host class_info_index %u has bad constant type in class file %s",
3716                          class_info_index, CHECK);
3717           _nest_host = class_info_index;
3718         } else if (_major_version >= JAVA_14_VERSION) {
3719           if (tag == vmSymbols::tag_record()) {
3720             // Skip over Record attribute if not supported or if super class is
3721             // not java.lang.Record.
3722             if (supports_records() &&
3723                 cp->klass_name_at(_super_class_index) == vmSymbols::java_lang_Record()) {
3724               if (parsed_record_attribute) {
3725                 classfile_parse_error("Multiple Record attributes in class file %s", CHECK);
3726               }
3727               // Check that class is final and not abstract.
3728               if (!_access_flags.is_final() || _access_flags.is_abstract()) {
3729                 classfile_parse_error("Record attribute in non-final or abstract class file %s", CHECK);
3730               }
3731               parsed_record_attribute = true;
3732               record_attribute_start = cfs->current();
3733               record_attribute_length = attribute_length;
3734             }
3735             cfs->skip_u1(attribute_length, CHECK);
3736           } else {
3737             // Unknown attribute
3738             cfs->skip_u1(attribute_length, CHECK);
3739           }
3740         } else {
3741           // Unknown attribute
3742           cfs->skip_u1(attribute_length, CHECK);
3743         }
3744       } else {
3745         // Unknown attribute
3746         cfs->skip_u1(attribute_length, CHECK);
3747       }
3748     } else {
3749       // Unknown attribute
3750       cfs->skip_u1(attribute_length, CHECK);
3751     }
3752   }
3753   _class_annotations = assemble_annotations(runtime_visible_annotations,
3754                                             runtime_visible_annotations_length,
3755                                             runtime_invisible_annotations,
3756                                             runtime_invisible_annotations_length,
3757                                             CHECK);
3758   _class_type_annotations = assemble_annotations(runtime_visible_type_annotations,
3759                                                  runtime_visible_type_annotations_length,


< prev index next >