2665 intptr_t hash = (java_mirror() != NULL) ? java_mirror()->identity_hash() : 0;
2666 jio_snprintf(hash_buf, sizeof(hash_buf), "/" UINTX_FORMAT, (uintx)hash);
2667 hash_len = (int)strlen(hash_buf);
2668 }
2669
2670 // Get the internal name as a c string
2671 const char* src = (const char*) (name()->as_C_string());
2672 const int src_length = (int)strlen(src);
2673
2674 char* dest = NEW_RESOURCE_ARRAY(char, src_length + hash_len + 3);
2675
2676 // Add L as type indicator
2677 int dest_index = 0;
2678 dest[dest_index++] = JVM_SIGNATURE_CLASS;
2679
2680 // Add the actual class name
2681 for (int src_index = 0; src_index < src_length; ) {
2682 dest[dest_index++] = src[src_index++];
2683 }
2684
2685 if (is_hidden()) { // Replace the last '+' with a '.'.
2686 for (int index = (int)src_length; index > 0; index--) {
2687 if (dest[index] == '+') {
2688 dest[index] = JVM_SIGNATURE_DOT;
2689 break;
2690 }
2691 }
2692 }
2693
2694 // If we have a hash, append it
2695 for (int hash_index = 0; hash_index < hash_len; ) {
2696 dest[dest_index++] = hash_buf[hash_index++];
2697 }
2698
2699 // Add the semicolon and the NULL
2700 dest[dest_index++] = JVM_SIGNATURE_ENDCLASS;
2701 dest[dest_index] = '\0';
2702 return dest;
2703 }
2704
2705 ModuleEntry* InstanceKlass::module() const {
2706 // For an unsafe anonymous class return the host class' module
2707 if (is_unsafe_anonymous()) {
2708 assert(unsafe_anonymous_host() != NULL, "unsafe anonymous class must have a host class");
2709 return unsafe_anonymous_host()->module();
2710 }
2711
2712 if (is_hidden() &&
2713 in_unnamed_package() &&
2714 class_loader_data()->has_class_mirror_holder()) {
2715 // For a non-strong hidden class defined to an unnamed package,
2716 // its (class held) CLD will not have an unnamed module created for it.
2717 // Two choices to find the correct ModuleEntry:
2718 // 1. If hidden class is within a nest, use nest host's module
2719 // 2. Find the unnamed module off from the class loader
2720 // For now option #2 is used since a nest host is not set until
|
2665 intptr_t hash = (java_mirror() != NULL) ? java_mirror()->identity_hash() : 0;
2666 jio_snprintf(hash_buf, sizeof(hash_buf), "/" UINTX_FORMAT, (uintx)hash);
2667 hash_len = (int)strlen(hash_buf);
2668 }
2669
2670 // Get the internal name as a c string
2671 const char* src = (const char*) (name()->as_C_string());
2672 const int src_length = (int)strlen(src);
2673
2674 char* dest = NEW_RESOURCE_ARRAY(char, src_length + hash_len + 3);
2675
2676 // Add L as type indicator
2677 int dest_index = 0;
2678 dest[dest_index++] = JVM_SIGNATURE_CLASS;
2679
2680 // Add the actual class name
2681 for (int src_index = 0; src_index < src_length; ) {
2682 dest[dest_index++] = src[src_index++];
2683 }
2684
2685 if (is_hidden()) {
2686 int end_class = -1;
2687 for (int index = (int)dest_index-1; index > 0; index--) { // dest[0] is "L"
2688 dest[index+1] = dest[index];
2689 if (dest[index] == '+') {
2690 // Replace the last '+' with a ';' followed with '/'.
2691 dest[index] = JVM_SIGNATURE_ENDCLASS;
2692 dest[index+1] = JVM_SIGNATURE_SLASH;
2693 end_class = index;
2694 break;
2695 }
2696 }
2697 assert(end_class > 0, "unexpected hidden class name");
2698 dest_index++;
2699 }
2700
2701 // If we have a hash, append it
2702 for (int hash_index = 0; hash_index < hash_len; ) {
2703 dest[dest_index++] = hash_buf[hash_index++];
2704 }
2705
2706 // Add the semicolon and the NULL
2707 if (!is_hidden()) {
2708 dest[dest_index++] = JVM_SIGNATURE_ENDCLASS;
2709 }
2710 dest[dest_index] = '\0';
2711 return dest;
2712 }
2713
2714 ModuleEntry* InstanceKlass::module() const {
2715 // For an unsafe anonymous class return the host class' module
2716 if (is_unsafe_anonymous()) {
2717 assert(unsafe_anonymous_host() != NULL, "unsafe anonymous class must have a host class");
2718 return unsafe_anonymous_host()->module();
2719 }
2720
2721 if (is_hidden() &&
2722 in_unnamed_package() &&
2723 class_loader_data()->has_class_mirror_holder()) {
2724 // For a non-strong hidden class defined to an unnamed package,
2725 // its (class held) CLD will not have an unnamed module created for it.
2726 // Two choices to find the correct ModuleEntry:
2727 // 1. If hidden class is within a nest, use nest host's module
2728 // 2. Find the unnamed module off from the class loader
2729 // For now option #2 is used since a nest host is not set until
|