5344 assert(NULL == _inner_classes, "invariant"); 5345 assert(NULL == _local_interfaces, "invariant"); 5346 assert(NULL == _transitive_interfaces, "invariant"); 5347 assert(NULL == _combined_annotations, "invariant"); 5348 5349 if (_has_final_method) { 5350 ik->set_has_final_method(); 5351 } 5352 5353 ik->copy_method_ordering(_method_ordering, CHECK); 5354 // The InstanceKlass::_methods_jmethod_ids cache 5355 // is managed on the assumption that the initial cache 5356 // size is equal to the number of methods in the class. If 5357 // that changes, then InstanceKlass::idnum_can_increment() 5358 // has to be changed accordingly. 5359 ik->set_initial_method_idnum(ik->methods()->length()); 5360 5361 ik->set_name(_class_name); 5362 5363 if (is_anonymous()) { 5364 // I am well known to myself 5365 patch_class(ik->constants(), _this_class_index, ik, ik->name()); // eagerly resolve 5366 } 5367 5368 ik->set_minor_version(_minor_version); 5369 ik->set_major_version(_major_version); 5370 ik->set_has_nonstatic_concrete_methods(_has_nonstatic_concrete_methods); 5371 ik->set_declares_nonstatic_concrete_methods(_declares_nonstatic_concrete_methods); 5372 5373 if (_host_klass != NULL) { 5374 assert (ik->is_anonymous(), "should be the same"); 5375 ik->set_host_klass(_host_klass); 5376 } 5377 5378 // Set PackageEntry for this_klass 5379 oop cl = ik->class_loader(); 5380 Handle clh = Handle(THREAD, java_lang_ClassLoader::non_reflection_class_loader(cl)); 5381 ClassLoaderData* cld = ClassLoaderData::class_loader_data_or_null(clh()); 5382 ik->set_package(cld, CHECK); 5383 5384 const Array<Method*>* const methods = ik->methods(); 5385 assert(methods != NULL, "invariant"); 5655 assert(THREAD->is_Java_thread(), "invariant"); 5656 assert(_loader_data != NULL, "invariant"); 5657 assert(stream != NULL, "invariant"); 5658 assert(_stream != NULL, "invariant"); 5659 assert(_stream->buffer() == _stream->current(), "invariant"); 5660 assert(_class_name != NULL, "invariant"); 5661 assert(0 == _access_flags.as_int(), "invariant"); 5662 5663 // Figure out whether we can skip format checking (matching classic VM behavior) 5664 if (DumpSharedSpaces) { 5665 // verify == true means it's a 'remote' class (i.e., non-boot class) 5666 // Verification decision is based on BytecodeVerificationRemote flag 5667 // for those classes. 5668 _need_verify = (stream->need_verify()) ? BytecodeVerificationRemote : 5669 BytecodeVerificationLocal; 5670 } 5671 else { 5672 _need_verify = Verifier::should_verify_for(_loader_data->class_loader(), 5673 stream->need_verify()); 5674 } 5675 // reserve space for names of the patches classes 5676 if (is_anonymous()) { 5677 _max_num_patched_klasses ++; // for patching the <this> class index 5678 } 5679 if (_cp_patches != NULL) { 5680 int len = _cp_patches->length(); 5681 for (int i=0; i<len; i++) { 5682 if (has_cp_patch_at(i)) { 5683 Handle patch = cp_patch_at(i); 5684 if (java_lang_String::is_instance(patch()) || java_lang_Class::is_instance(patch())) { 5685 // We need to append the names of the patched classes to the end of the constant pool, 5686 // because a patched class may have a Utf8 name that's not already included in the 5687 // original constant pool. 5688 // 5689 // Note that a String in cp_patch_at(i) may be used to patch a Utf8, a String, or a Class. 5690 // At this point, we don't know the tag for index i yet, because we haven't parsed the 5691 // constant pool. So we can only assume the worst -- every String is used to patch a Class. 5692 _max_num_patched_klasses ++; 5693 } 5694 } 5695 } 5696 } 5697 5698 // synch back verification state to stream 5699 stream->set_verify(_need_verify); 5700 5701 // Check if verification needs to be relaxed for this class file 5702 // Do not restrict it to jdk1.0 or jdk1.1 to maintain backward compatibility (4982376) 5703 _relax_verify = relax_format_check_for(_loader_data); 5704 5705 parse_stream(stream, CHECK); 5706 5707 post_process_parsed_stream(stream, _cp, CHECK); 5708 } 5709 5710 void ClassFileParser::clear_class_metadata() { 5711 // metadata created before the instance klass is created. Must be 5712 // deallocated if classfile parsing returns an error. | 5344 assert(NULL == _inner_classes, "invariant"); 5345 assert(NULL == _local_interfaces, "invariant"); 5346 assert(NULL == _transitive_interfaces, "invariant"); 5347 assert(NULL == _combined_annotations, "invariant"); 5348 5349 if (_has_final_method) { 5350 ik->set_has_final_method(); 5351 } 5352 5353 ik->copy_method_ordering(_method_ordering, CHECK); 5354 // The InstanceKlass::_methods_jmethod_ids cache 5355 // is managed on the assumption that the initial cache 5356 // size is equal to the number of methods in the class. If 5357 // that changes, then InstanceKlass::idnum_can_increment() 5358 // has to be changed accordingly. 5359 ik->set_initial_method_idnum(ik->methods()->length()); 5360 5361 ik->set_name(_class_name); 5362 5363 if (is_anonymous()) { 5364 // _this_class_index is a CONSTANT_Class entry that refers to this 5365 // anonymous class itself. If this class needs to refer to its own methods or 5366 // fields, it would use a CONSTANT_MethodRef, etc, which would reference 5367 // _this_class_index. However, because this class is anonymous (it's 5368 // not stored in SystemDictionary), _this_class_index cannot be resolved 5369 // with ConstantPool::klass_at_impl, which does a SystemDictionary lookup. 5370 // Therefore, we must eagerly resolve _this_class_index now. 5371 ik->constants()->klass_at_put(_this_class_index, ik); 5372 } 5373 5374 ik->set_minor_version(_minor_version); 5375 ik->set_major_version(_major_version); 5376 ik->set_has_nonstatic_concrete_methods(_has_nonstatic_concrete_methods); 5377 ik->set_declares_nonstatic_concrete_methods(_declares_nonstatic_concrete_methods); 5378 5379 if (_host_klass != NULL) { 5380 assert (ik->is_anonymous(), "should be the same"); 5381 ik->set_host_klass(_host_klass); 5382 } 5383 5384 // Set PackageEntry for this_klass 5385 oop cl = ik->class_loader(); 5386 Handle clh = Handle(THREAD, java_lang_ClassLoader::non_reflection_class_loader(cl)); 5387 ClassLoaderData* cld = ClassLoaderData::class_loader_data_or_null(clh()); 5388 ik->set_package(cld, CHECK); 5389 5390 const Array<Method*>* const methods = ik->methods(); 5391 assert(methods != NULL, "invariant"); 5661 assert(THREAD->is_Java_thread(), "invariant"); 5662 assert(_loader_data != NULL, "invariant"); 5663 assert(stream != NULL, "invariant"); 5664 assert(_stream != NULL, "invariant"); 5665 assert(_stream->buffer() == _stream->current(), "invariant"); 5666 assert(_class_name != NULL, "invariant"); 5667 assert(0 == _access_flags.as_int(), "invariant"); 5668 5669 // Figure out whether we can skip format checking (matching classic VM behavior) 5670 if (DumpSharedSpaces) { 5671 // verify == true means it's a 'remote' class (i.e., non-boot class) 5672 // Verification decision is based on BytecodeVerificationRemote flag 5673 // for those classes. 5674 _need_verify = (stream->need_verify()) ? BytecodeVerificationRemote : 5675 BytecodeVerificationLocal; 5676 } 5677 else { 5678 _need_verify = Verifier::should_verify_for(_loader_data->class_loader(), 5679 stream->need_verify()); 5680 } 5681 if (_cp_patches != NULL) { 5682 int len = _cp_patches->length(); 5683 for (int i=0; i<len; i++) { 5684 if (has_cp_patch_at(i)) { 5685 Handle patch = cp_patch_at(i); 5686 if (java_lang_String::is_instance(patch()) || java_lang_Class::is_instance(patch())) { 5687 // We need to append the names of the patched classes to the end of the constant pool, 5688 // because a patched class may have a Utf8 name that's not already included in the 5689 // original constant pool. These class names are used when patch_constant_pool() 5690 // calls patch_class(). 5691 // 5692 // Note that a String in cp_patch_at(i) may be used to patch a Utf8, a String, or a Class. 5693 // At this point, we don't know the tag for index i yet, because we haven't parsed the 5694 // constant pool. So we can only assume the worst -- every String is used to patch a Class. 5695 _max_num_patched_klasses++; 5696 } 5697 } 5698 } 5699 } 5700 5701 // synch back verification state to stream 5702 stream->set_verify(_need_verify); 5703 5704 // Check if verification needs to be relaxed for this class file 5705 // Do not restrict it to jdk1.0 or jdk1.1 to maintain backward compatibility (4982376) 5706 _relax_verify = relax_format_check_for(_loader_data); 5707 5708 parse_stream(stream, CHECK); 5709 5710 post_process_parsed_stream(stream, _cp, CHECK); 5711 } 5712 5713 void ClassFileParser::clear_class_metadata() { 5714 // metadata created before the instance klass is created. Must be 5715 // deallocated if classfile parsing returns an error. |