4364 || ik->size_helper() >= FastAllocateSizeLimit) { 4365 // Forbid fast-path allocation. 4366 const jint lh = Klass::instance_layout_helper(ik->size_helper(), true); 4367 ik->set_layout_helper(lh); 4368 } 4369 } 4370 4371 // Attach super classes and interface classes to class loader data 4372 static void record_defined_class_dependencies(const InstanceKlass* defined_klass, 4373 TRAPS) { 4374 assert(defined_klass != NULL, "invariant"); 4375 4376 ClassLoaderData* const defining_loader_data = defined_klass->class_loader_data(); 4377 if (defining_loader_data->is_the_null_class_loader_data()) { 4378 // Dependencies to null class loader data are implicit. 4379 return; 4380 } else { 4381 // add super class dependency 4382 Klass* const super = defined_klass->super(); 4383 if (super != NULL) { 4384 defining_loader_data->record_dependency(super, CHECK); 4385 } 4386 4387 // add super interface dependencies 4388 const Array<Klass*>* const local_interfaces = defined_klass->local_interfaces(); 4389 if (local_interfaces != NULL) { 4390 const int length = local_interfaces->length(); 4391 for (int i = 0; i < length; i++) { 4392 defining_loader_data->record_dependency(local_interfaces->at(i), CHECK); 4393 } 4394 } 4395 } 4396 } 4397 4398 // utility methods for appending an array with check for duplicates 4399 4400 static void append_interfaces(GrowableArray<Klass*>* result, 4401 const Array<Klass*>* const ifs) { 4402 // iterate over new interfaces 4403 for (int i = 0; i < ifs->length(); i++) { 4404 Klass* const e = ifs->at(i); 4405 assert(e->is_klass() && InstanceKlass::cast(e)->is_interface(), "just checking"); 4406 // add new interface 4407 result->append_if_missing(e); 4408 } 4409 } 4410 4411 static Array<Klass*>* compute_transitive_interfaces(const InstanceKlass* super, 4412 Array<Klass*>* local_ifs, 5345 5346 ik->set_has_passed_fingerprint_check(false); 5347 if (UseAOT && ik->supers_have_passed_fingerprint_checks()) { 5348 uint64_t aot_fp = AOTLoader::get_saved_fingerprint(ik); 5349 if (aot_fp != 0 && aot_fp == _stream->compute_fingerprint()) { 5350 // This class matches with a class saved in an AOT library 5351 ik->set_has_passed_fingerprint_check(true); 5352 } else { 5353 ResourceMark rm; 5354 log_info(class, fingerprint)("%s : expected = " PTR64_FORMAT " actual = " PTR64_FORMAT, 5355 ik->external_name(), aot_fp, _stream->compute_fingerprint()); 5356 } 5357 } 5358 5359 return ik; 5360 } 5361 5362 void ClassFileParser::fill_instance_klass(InstanceKlass* ik, bool changed_by_loadhook, TRAPS) { 5363 assert(ik != NULL, "invariant"); 5364 5365 set_klass_to_deallocate(ik); 5366 5367 assert(_field_info != NULL, "invariant"); 5368 assert(ik->static_field_size() == _field_info->static_field_size, "sanity"); 5369 assert(ik->nonstatic_oop_map_count() == _field_info->total_oop_map_count, 5370 "sanity"); 5371 5372 assert(ik->is_instance_klass(), "sanity"); 5373 assert(ik->size_helper() == _field_info->instance_size, "sanity"); 5374 5375 // Fill in information already parsed 5376 ik->set_should_verify_class(_need_verify); 5377 5378 // Not yet: supers are done below to support the new subtype-checking fields 5379 ik->set_class_loader_data(_loader_data); 5380 ik->set_nonstatic_field_size(_field_info->nonstatic_field_size); 5381 ik->set_has_nonstatic_fields(_field_info->has_nonstatic_fields); 5382 assert(_fac != NULL, "invariant"); 5383 ik->set_static_oop_field_count(_fac->count[STATIC_OOP]); 5384 5385 // this transfers ownership of a lot of arrays from 5386 // the parser onto the InstanceKlass* 5387 apply_parsed_class_metadata(ik, _java_fields_count, CHECK); 5388 5389 // note that is not safe to use the fields in the parser from this point on 5390 assert(NULL == _cp, "invariant"); 5391 assert(NULL == _fields, "invariant"); 5392 assert(NULL == _methods, "invariant"); 5393 assert(NULL == _inner_classes, "invariant"); 5394 assert(NULL == _local_interfaces, "invariant"); 5395 assert(NULL == _transitive_interfaces, "invariant"); 5396 assert(NULL == _combined_annotations, "invariant"); 5397 5398 if (_has_final_method) { 5399 ik->set_has_final_method(); 5400 } 5401 5402 ik->copy_method_ordering(_method_ordering, CHECK); 5403 // The InstanceKlass::_methods_jmethod_ids cache 5404 // is managed on the assumption that the initial cache 5405 // size is equal to the number of methods in the class. If 5406 // that changes, then InstanceKlass::idnum_can_increment() 5407 // has to be changed accordingly. 5408 ik->set_initial_method_idnum(ik->methods()->length()); 5409 5410 ik->set_name(_class_name); 5411 5412 if (is_anonymous()) { 5413 // _this_class_index is a CONSTANT_Class entry that refers to this 5414 // anonymous class itself. If this class needs to refer to its own methods or 5415 // fields, it would use a CONSTANT_MethodRef, etc, which would reference 5416 // _this_class_index. However, because this class is anonymous (it's 5417 // not stored in SystemDictionary), _this_class_index cannot be resolved 5418 // with ConstantPool::klass_at_impl, which does a SystemDictionary lookup. 5419 // Therefore, we must eagerly resolve _this_class_index now. 5420 ik->constants()->klass_at_put(_this_class_index, ik); 5421 } 5422 5423 ik->set_minor_version(_minor_version); 5424 ik->set_major_version(_major_version); 5425 ik->set_has_nonstatic_concrete_methods(_has_nonstatic_concrete_methods); 5426 ik->set_declares_nonstatic_concrete_methods(_declares_nonstatic_concrete_methods); 5427 5428 if (_host_klass != NULL) { 5429 assert (ik->is_anonymous(), "should be the same"); 5430 ik->set_host_klass(_host_klass); | 4364 || ik->size_helper() >= FastAllocateSizeLimit) { 4365 // Forbid fast-path allocation. 4366 const jint lh = Klass::instance_layout_helper(ik->size_helper(), true); 4367 ik->set_layout_helper(lh); 4368 } 4369 } 4370 4371 // Attach super classes and interface classes to class loader data 4372 static void record_defined_class_dependencies(const InstanceKlass* defined_klass, 4373 TRAPS) { 4374 assert(defined_klass != NULL, "invariant"); 4375 4376 ClassLoaderData* const defining_loader_data = defined_klass->class_loader_data(); 4377 if (defining_loader_data->is_the_null_class_loader_data()) { 4378 // Dependencies to null class loader data are implicit. 4379 return; 4380 } else { 4381 // add super class dependency 4382 Klass* const super = defined_klass->super(); 4383 if (super != NULL) { 4384 defining_loader_data->record_dependency(super); 4385 } 4386 4387 // add super interface dependencies 4388 const Array<Klass*>* const local_interfaces = defined_klass->local_interfaces(); 4389 if (local_interfaces != NULL) { 4390 const int length = local_interfaces->length(); 4391 for (int i = 0; i < length; i++) { 4392 defining_loader_data->record_dependency(local_interfaces->at(i)); 4393 } 4394 } 4395 } 4396 } 4397 4398 // utility methods for appending an array with check for duplicates 4399 4400 static void append_interfaces(GrowableArray<Klass*>* result, 4401 const Array<Klass*>* const ifs) { 4402 // iterate over new interfaces 4403 for (int i = 0; i < ifs->length(); i++) { 4404 Klass* const e = ifs->at(i); 4405 assert(e->is_klass() && InstanceKlass::cast(e)->is_interface(), "just checking"); 4406 // add new interface 4407 result->append_if_missing(e); 4408 } 4409 } 4410 4411 static Array<Klass*>* compute_transitive_interfaces(const InstanceKlass* super, 4412 Array<Klass*>* local_ifs, 5345 5346 ik->set_has_passed_fingerprint_check(false); 5347 if (UseAOT && ik->supers_have_passed_fingerprint_checks()) { 5348 uint64_t aot_fp = AOTLoader::get_saved_fingerprint(ik); 5349 if (aot_fp != 0 && aot_fp == _stream->compute_fingerprint()) { 5350 // This class matches with a class saved in an AOT library 5351 ik->set_has_passed_fingerprint_check(true); 5352 } else { 5353 ResourceMark rm; 5354 log_info(class, fingerprint)("%s : expected = " PTR64_FORMAT " actual = " PTR64_FORMAT, 5355 ik->external_name(), aot_fp, _stream->compute_fingerprint()); 5356 } 5357 } 5358 5359 return ik; 5360 } 5361 5362 void ClassFileParser::fill_instance_klass(InstanceKlass* ik, bool changed_by_loadhook, TRAPS) { 5363 assert(ik != NULL, "invariant"); 5364 5365 // Set name and CLD before adding to CLD 5366 ik->set_class_loader_data(_loader_data); 5367 ik->set_name(_class_name); 5368 5369 // Add all classes to our internal class loader list here, 5370 // including classes in the bootstrap (NULL) class loader. 5371 const bool publicize = !is_internal(); 5372 5373 _loader_data->add_class(ik, publicize); 5374 5375 set_klass_to_deallocate(ik); 5376 5377 assert(_field_info != NULL, "invariant"); 5378 assert(ik->static_field_size() == _field_info->static_field_size, "sanity"); 5379 assert(ik->nonstatic_oop_map_count() == _field_info->total_oop_map_count, 5380 "sanity"); 5381 5382 assert(ik->is_instance_klass(), "sanity"); 5383 assert(ik->size_helper() == _field_info->instance_size, "sanity"); 5384 5385 // Fill in information already parsed 5386 ik->set_should_verify_class(_need_verify); 5387 5388 // Not yet: supers are done below to support the new subtype-checking fields 5389 ik->set_nonstatic_field_size(_field_info->nonstatic_field_size); 5390 ik->set_has_nonstatic_fields(_field_info->has_nonstatic_fields); 5391 assert(_fac != NULL, "invariant"); 5392 ik->set_static_oop_field_count(_fac->count[STATIC_OOP]); 5393 5394 // this transfers ownership of a lot of arrays from 5395 // the parser onto the InstanceKlass* 5396 apply_parsed_class_metadata(ik, _java_fields_count, CHECK); 5397 5398 // note that is not safe to use the fields in the parser from this point on 5399 assert(NULL == _cp, "invariant"); 5400 assert(NULL == _fields, "invariant"); 5401 assert(NULL == _methods, "invariant"); 5402 assert(NULL == _inner_classes, "invariant"); 5403 assert(NULL == _local_interfaces, "invariant"); 5404 assert(NULL == _transitive_interfaces, "invariant"); 5405 assert(NULL == _combined_annotations, "invariant"); 5406 5407 if (_has_final_method) { 5408 ik->set_has_final_method(); 5409 } 5410 5411 ik->copy_method_ordering(_method_ordering, CHECK); 5412 // The InstanceKlass::_methods_jmethod_ids cache 5413 // is managed on the assumption that the initial cache 5414 // size is equal to the number of methods in the class. If 5415 // that changes, then InstanceKlass::idnum_can_increment() 5416 // has to be changed accordingly. 5417 ik->set_initial_method_idnum(ik->methods()->length()); 5418 5419 if (is_anonymous()) { 5420 // _this_class_index is a CONSTANT_Class entry that refers to this 5421 // anonymous class itself. If this class needs to refer to its own methods or 5422 // fields, it would use a CONSTANT_MethodRef, etc, which would reference 5423 // _this_class_index. However, because this class is anonymous (it's 5424 // not stored in SystemDictionary), _this_class_index cannot be resolved 5425 // with ConstantPool::klass_at_impl, which does a SystemDictionary lookup. 5426 // Therefore, we must eagerly resolve _this_class_index now. 5427 ik->constants()->klass_at_put(_this_class_index, ik); 5428 } 5429 5430 ik->set_minor_version(_minor_version); 5431 ik->set_major_version(_major_version); 5432 ik->set_has_nonstatic_concrete_methods(_has_nonstatic_concrete_methods); 5433 ik->set_declares_nonstatic_concrete_methods(_declares_nonstatic_concrete_methods); 5434 5435 if (_host_klass != NULL) { 5436 assert (ik->is_anonymous(), "should be the same"); 5437 ik->set_host_klass(_host_klass); |