339 InstanceKlass* InstanceKlass::allocate_instance_klass(const ClassFileParser& parser, TRAPS) { |
339 InstanceKlass* InstanceKlass::allocate_instance_klass(const ClassFileParser& parser, TRAPS) { |
340 const int size = InstanceKlass::size(parser.vtable_size(), |
340 const int size = InstanceKlass::size(parser.vtable_size(), |
341 parser.itable_size(), |
341 parser.itable_size(), |
342 nonstatic_oop_map_size(parser.total_oop_map_count()), |
342 nonstatic_oop_map_size(parser.total_oop_map_count()), |
343 parser.is_interface(), |
343 parser.is_interface(), |
344 parser.is_anonymous(), |
344 parser.is_unsafe_anonymous(), |
345 should_store_fingerprint(parser.is_anonymous())); |
345 should_store_fingerprint(parser.is_unsafe_anonymous())); |
346 |
346 |
347 const Symbol* const class_name = parser.class_name(); |
347 const Symbol* const class_name = parser.class_name(); |
348 assert(class_name != NULL, "invariant"); |
348 assert(class_name != NULL, "invariant"); |
349 ClassLoaderData* loader_data = parser.loader_data(); |
349 ClassLoaderData* loader_data = parser.loader_data(); |
350 assert(loader_data != NULL, "invariant"); |
350 assert(loader_data != NULL, "invariant"); |
410 _itable_len(parser.itable_size()), |
410 _itable_len(parser.itable_size()), |
411 _reference_type(parser.reference_type()) { |
411 _reference_type(parser.reference_type()) { |
412 set_vtable_length(parser.vtable_size()); |
412 set_vtable_length(parser.vtable_size()); |
413 set_kind(kind); |
413 set_kind(kind); |
414 set_access_flags(parser.access_flags()); |
414 set_access_flags(parser.access_flags()); |
415 set_is_anonymous(parser.is_anonymous()); |
415 set_is_unsafe_anonymous(parser.is_unsafe_anonymous()); |
416 set_layout_helper(Klass::instance_layout_helper(parser.layout_size(), |
416 set_layout_helper(Klass::instance_layout_helper(parser.layout_size(), |
417 false)); |
417 false)); |
418 |
418 |
419 assert(NULL == _methods, "underlying memory not zeroed?"); |
419 assert(NULL == _methods, "underlying memory not zeroed?"); |
420 assert(is_instance_klass(), "is layout incorrect?"); |
420 assert(is_instance_klass(), "is layout incorrect?"); |
2191 } |
2191 } |
2192 |
2192 |
2193 return true; |
2193 return true; |
2194 } |
2194 } |
2195 |
2195 |
2196 bool InstanceKlass::should_store_fingerprint(bool is_anonymous) { |
2196 bool InstanceKlass::should_store_fingerprint(bool is_unsafe_anonymous) { |
2197 #if INCLUDE_AOT |
2197 #if INCLUDE_AOT |
2198 // We store the fingerprint into the InstanceKlass only in the following 2 cases: |
2198 // We store the fingerprint into the InstanceKlass only in the following 2 cases: |
2199 if (CalculateClassFingerprint) { |
2199 if (CalculateClassFingerprint) { |
2200 // (1) We are running AOT to generate a shared library. |
2200 // (1) We are running AOT to generate a shared library. |
2201 return true; |
2201 return true; |
2202 } |
2202 } |
2203 if (DumpSharedSpaces) { |
2203 if (DumpSharedSpaces) { |
2204 // (2) We are running -Xshare:dump to create a shared archive |
2204 // (2) We are running -Xshare:dump to create a shared archive |
2205 return true; |
2205 return true; |
2206 } |
2206 } |
2207 if (UseAOT && is_anonymous) { |
2207 if (UseAOT && is_unsafe_anonymous) { |
2208 // (3) We are using AOT code from a shared library and see an anonymous class |
2208 // (3) We are using AOT code from a shared library and see an unsafe anonymous class |
2209 return true; |
2209 return true; |
2210 } |
2210 } |
2211 #endif |
2211 #endif |
2212 |
2212 |
2213 // In all other cases we might set the _misc_has_passed_fingerprint_check bit, |
2213 // In all other cases we might set the _misc_has_passed_fingerprint_check bit, |
2505 |
2505 |
2506 const char* InstanceKlass::signature_name() const { |
2506 const char* InstanceKlass::signature_name() const { |
2507 int hash_len = 0; |
2507 int hash_len = 0; |
2508 char hash_buf[40]; |
2508 char hash_buf[40]; |
2509 |
2509 |
2510 // If this is an anonymous class, append a hash to make the name unique |
2510 // If this is an unsafe anonymous class, append a hash to make the name unique |
2511 if (is_anonymous()) { |
2511 if (is_unsafe_anonymous()) { |
2512 intptr_t hash = (java_mirror() != NULL) ? java_mirror()->identity_hash() : 0; |
2512 intptr_t hash = (java_mirror() != NULL) ? java_mirror()->identity_hash() : 0; |
2513 jio_snprintf(hash_buf, sizeof(hash_buf), "/" UINTX_FORMAT, (uintx)hash); |
2513 jio_snprintf(hash_buf, sizeof(hash_buf), "/" UINTX_FORMAT, (uintx)hash); |
2514 hash_len = (int)strlen(hash_buf); |
2514 hash_len = (int)strlen(hash_buf); |
2515 } |
2515 } |
2516 |
2516 |
2557 return pkg_name; |
2557 return pkg_name; |
2558 } |
2558 } |
2559 } |
2559 } |
2560 |
2560 |
2561 ModuleEntry* InstanceKlass::module() const { |
2561 ModuleEntry* InstanceKlass::module() const { |
|
2562 // For an unsafe anonymous class return the host class' module |
|
2563 if (is_unsafe_anonymous()) { |
|
2564 assert(unsafe_anonymous_host() != NULL, "unsafe anonymous class must have a host class"); |
|
2565 return unsafe_anonymous_host()->module(); |
|
2566 } |
|
2567 |
|
2568 // Class is in a named package |
2562 if (!in_unnamed_package()) { |
2569 if (!in_unnamed_package()) { |
2563 return _package_entry->module(); |
2570 return _package_entry->module(); |
2564 } |
2571 } |
2565 const Klass* host = host_klass(); |
2572 |
2566 if (host == NULL) { |
2573 // Class is in an unnamed package, return its loader's unnamed module |
2567 return class_loader_data()->unnamed_module(); |
2574 return class_loader_data()->unnamed_module(); |
2568 } |
|
2569 return host->class_loader_data()->unnamed_module(); |
|
2570 } |
2575 } |
2571 |
2576 |
2572 void InstanceKlass::set_package(ClassLoaderData* loader_data, TRAPS) { |
2577 void InstanceKlass::set_package(ClassLoaderData* loader_data, TRAPS) { |
2573 |
2578 |
2574 // ensure java/ packages only loaded by boot or platform builtin loaders |
2579 // ensure java/ packages only loaded by boot or platform builtin loaders |
2811 Klass* ok = i_cp->klass_at(ooff, CHECK_NULL); |
2816 Klass* ok = i_cp->klass_at(ooff, CHECK_NULL); |
2812 outer_klass = InstanceKlass::cast(ok); |
2817 outer_klass = InstanceKlass::cast(ok); |
2813 *inner_is_member = true; |
2818 *inner_is_member = true; |
2814 } |
2819 } |
2815 if (NULL == outer_klass) { |
2820 if (NULL == outer_klass) { |
2816 // It may be anonymous; try for that. |
2821 // It may be unsafe anonymous; try for that. |
2817 int encl_method_class_idx = enclosing_method_class_index(); |
2822 int encl_method_class_idx = enclosing_method_class_index(); |
2818 if (encl_method_class_idx != 0) { |
2823 if (encl_method_class_idx != 0) { |
2819 Klass* ok = i_cp->klass_at(encl_method_class_idx, CHECK_NULL); |
2824 Klass* ok = i_cp->klass_at(encl_method_class_idx, CHECK_NULL); |
2820 outer_klass = InstanceKlass::cast(ok); |
2825 outer_klass = InstanceKlass::cast(ok); |
2821 *inner_is_member = false; |
2826 *inner_is_member = false; |
3159 if (class_loader_data() != NULL) { |
3164 if (class_loader_data() != NULL) { |
3160 st->print(BULLET"class loader data: "); |
3165 st->print(BULLET"class loader data: "); |
3161 class_loader_data()->print_value_on(st); |
3166 class_loader_data()->print_value_on(st); |
3162 st->cr(); |
3167 st->cr(); |
3163 } |
3168 } |
3164 st->print(BULLET"host class: "); Metadata::print_value_on_maybe_null(st, host_klass()); st->cr(); |
3169 st->print(BULLET"unsafe anonymous host class: "); Metadata::print_value_on_maybe_null(st, unsafe_anonymous_host()); st->cr(); |
3165 if (source_file_name() != NULL) { |
3170 if (source_file_name() != NULL) { |
3166 st->print(BULLET"source file: "); |
3171 st->print(BULLET"source file: "); |
3167 source_file_name()->print_value_on(st); |
3172 source_file_name()->print_value_on(st); |
3168 st->cr(); |
3173 st->cr(); |
3169 } |
3174 } |
3610 guarantee(array_klasses()->is_klass(), "should be klass"); |
3615 guarantee(array_klasses()->is_klass(), "should be klass"); |
3611 } |
3616 } |
3612 if (constants() != NULL) { |
3617 if (constants() != NULL) { |
3613 guarantee(constants()->is_constantPool(), "should be constant pool"); |
3618 guarantee(constants()->is_constantPool(), "should be constant pool"); |
3614 } |
3619 } |
3615 const Klass* host = host_klass(); |
3620 const Klass* anonymous_host = unsafe_anonymous_host(); |
3616 if (host != NULL) { |
3621 if (anonymous_host != NULL) { |
3617 guarantee(host->is_klass(), "should be klass"); |
3622 guarantee(anonymous_host->is_klass(), "should be klass"); |
3618 } |
3623 } |
3619 } |
3624 } |
3620 |
3625 |
3621 void InstanceKlass::oop_verify_on(oop obj, outputStream* st) { |
3626 void InstanceKlass::oop_verify_on(oop obj, outputStream* st) { |
3622 Klass::oop_verify_on(obj, st); |
3627 Klass::oop_verify_on(obj, st); |