mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8024423: JVMTI: GetLoadedClasses doesn't enumerate anonymous classes
Rewrite of the getLoadedClasses() method implementation to include anonymous classes. Reviewed-by: coleenp, sspitsyn
This commit is contained in:
parent
e731a6d078
commit
508272e5f5
4 changed files with 97 additions and 60 deletions
|
@ -2393,15 +2393,38 @@ address InstanceKlass::static_field_addr(int offset) {
|
|||
|
||||
|
||||
const char* InstanceKlass::signature_name() const {
|
||||
int hash_len = 0;
|
||||
char hash_buf[40];
|
||||
|
||||
// If this is an anonymous class, append a hash to make the name unique
|
||||
if (is_anonymous()) {
|
||||
assert(EnableInvokeDynamic, "EnableInvokeDynamic was not set.");
|
||||
intptr_t hash = (java_mirror() != NULL) ? java_mirror()->identity_hash() : 0;
|
||||
sprintf(hash_buf, "/" UINTX_FORMAT, (uintx)hash);
|
||||
hash_len = (int)strlen(hash_buf);
|
||||
}
|
||||
|
||||
// Get the internal name as a c string
|
||||
const char* src = (const char*) (name()->as_C_string());
|
||||
const int src_length = (int)strlen(src);
|
||||
char* dest = NEW_RESOURCE_ARRAY(char, src_length + 3);
|
||||
int src_index = 0;
|
||||
|
||||
char* dest = NEW_RESOURCE_ARRAY(char, src_length + hash_len + 3);
|
||||
|
||||
// Add L as type indicator
|
||||
int dest_index = 0;
|
||||
dest[dest_index++] = 'L';
|
||||
while (src_index < src_length) {
|
||||
|
||||
// Add the actual class name
|
||||
for (int src_index = 0; src_index < src_length; ) {
|
||||
dest[dest_index++] = src[src_index++];
|
||||
}
|
||||
|
||||
// If we have a hash, append it
|
||||
for (int hash_index = 0; hash_index < hash_len; ) {
|
||||
dest[dest_index++] = hash_buf[hash_index++];
|
||||
}
|
||||
|
||||
// Add the semicolon and the NULL
|
||||
dest[dest_index++] = ';';
|
||||
dest[dest_index] = '\0';
|
||||
return dest;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue