2621
2622 void InstanceKlass::set_source_debug_extension(const char* array, int length) {
2623 if (array == NULL) {
2624 _source_debug_extension = NULL;
2625 } else {
2626 // Adding one to the attribute length in order to store a null terminator
2627 // character could cause an overflow because the attribute length is
2628 // already coded with an u4 in the classfile, but in practice, it's
2629 // unlikely to happen.
2630 assert((length+1) > length, "Overflow checking");
2631 char* sde = NEW_C_HEAP_ARRAY(char, (length + 1), mtClass);
2632 for (int i = 0; i < length; i++) {
2633 sde[i] = array[i];
2634 }
2635 sde[length] = '\0';
2636 _source_debug_extension = sde;
2637 }
2638 }
2639
2640 const char* InstanceKlass::signature_name() const {
2641 int hash_len = 0;
2642 char hash_buf[40];
2643
2644 // If this is an unsafe anonymous class, append a hash to make the name unique
2645 if (is_unsafe_anonymous()) {
2646 intptr_t hash = (java_mirror() != NULL) ? java_mirror()->identity_hash() : 0;
2647 jio_snprintf(hash_buf, sizeof(hash_buf), "/" UINTX_FORMAT, (uintx)hash);
2648 hash_len = (int)strlen(hash_buf);
2649 }
2650
2651 // Get the internal name as a c string
2652 const char* src = (const char*) (name()->as_C_string());
2653 const int src_length = (int)strlen(src);
2654
2655 char* dest = NEW_RESOURCE_ARRAY(char, src_length + hash_len + 3);
2656
2657 // Add L or Q as type indicator
2658 int dest_index = 0;
2659 if (is_value()) {
2660 dest[dest_index++] = 'Q';
2661 } else {
2662 dest[dest_index++] = 'L';
2663 }
2664
2665 // Add the actual class name
2666 for (int src_index = 0; src_index < src_length; ) {
2667 dest[dest_index++] = src[src_index++];
2668 }
2669
2670 // If we have a hash, append it
2671 for (int hash_index = 0; hash_index < hash_len; ) {
2672 dest[dest_index++] = hash_buf[hash_index++];
2673 }
2674
2675 // Add the semicolon and the NULL
2676 dest[dest_index++] = ';';
2677 dest[dest_index] = '\0';
2678 return dest;
2679 }
2680
2681 // Used to obtain the package name from a fully qualified class name.
2682 Symbol* InstanceKlass::package_from_name(const Symbol* name, TRAPS) {
2683 if (name == NULL) {
|
2621
2622 void InstanceKlass::set_source_debug_extension(const char* array, int length) {
2623 if (array == NULL) {
2624 _source_debug_extension = NULL;
2625 } else {
2626 // Adding one to the attribute length in order to store a null terminator
2627 // character could cause an overflow because the attribute length is
2628 // already coded with an u4 in the classfile, but in practice, it's
2629 // unlikely to happen.
2630 assert((length+1) > length, "Overflow checking");
2631 char* sde = NEW_C_HEAP_ARRAY(char, (length + 1), mtClass);
2632 for (int i = 0; i < length; i++) {
2633 sde[i] = array[i];
2634 }
2635 sde[length] = '\0';
2636 _source_debug_extension = sde;
2637 }
2638 }
2639
2640 const char* InstanceKlass::signature_name() const {
2641 return signature_name_of(is_value() ? 'Q' : 'L');
2642 }
2643
2644 const char* InstanceKlass::signature_name_of(char c) const {
2645 int hash_len = 0;
2646 char hash_buf[40];
2647
2648 // If this is an unsafe anonymous class, append a hash to make the name unique
2649 if (is_unsafe_anonymous()) {
2650 intptr_t hash = (java_mirror() != NULL) ? java_mirror()->identity_hash() : 0;
2651 jio_snprintf(hash_buf, sizeof(hash_buf), "/" UINTX_FORMAT, (uintx)hash);
2652 hash_len = (int)strlen(hash_buf);
2653 }
2654
2655 // Get the internal name as a c string
2656 const char* src = (const char*) (name()->as_C_string());
2657 const int src_length = (int)strlen(src);
2658
2659 char* dest = NEW_RESOURCE_ARRAY(char, src_length + hash_len + 3);
2660
2661 // Add L or Q as type indicator
2662 int dest_index = 0;
2663 dest[dest_index++] = c;
2664
2665 // Add the actual class name
2666 for (int src_index = 0; src_index < src_length; ) {
2667 dest[dest_index++] = src[src_index++];
2668 }
2669
2670 // If we have a hash, append it
2671 for (int hash_index = 0; hash_index < hash_len; ) {
2672 dest[dest_index++] = hash_buf[hash_index++];
2673 }
2674
2675 // Add the semicolon and the NULL
2676 dest[dest_index++] = ';';
2677 dest[dest_index] = '\0';
2678 return dest;
2679 }
2680
2681 // Used to obtain the package name from a fully qualified class name.
2682 Symbol* InstanceKlass::package_from_name(const Symbol* name, TRAPS) {
2683 if (name == NULL) {
|