JDK-8238663 : [nestmates] array type of hidden class returns incorrect name
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: repo-valhalla
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2020-02-07
  • Updated: 2020-02-22
  • Resolved: 2020-02-07
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
repo-valhallaFixed
Related Reports
Relates :  
Description
To reproduce, uncomment the assert on the array class name, it returns an incorrect name:

java.lang.AssertionError: unexpected name: [LHiddenClass+0x0000000139190040; expected [true] but found [false]


diff --git a/test/jdk/java/lang/invoke/defineHiddenClass/BasicTest.java b/test/jdk/java/lang/invoke/defineHiddenClass/BasicTest.java
--- a/test/jdk/java/lang/invoke/defineHiddenClass/BasicTest.java
+++ b/test/jdk/java/lang/invoke/defineHiddenClass/BasicTest.java
@@ -129,7 +129,7 @@
         assertTrue(arrayType.isArray());
         assertTrue(Array.getLength(array) == 2);
         assertFalse(arrayType.isHiddenClass());
-        // assertTrue(arrayType.getName().startsWith("[LHiddenClass/"), "unexpected name: " + arrayType.getName());
+        assertTrue(arrayType.getName().startsWith("[LHiddenClass/"), "unexpected name: " + arrayType.getName());
 
         assertTrue(arrayType.getComponentType().isHiddenClass());
         assertTrue(arrayType.getComponentType() == type);
Comments
Fixed with this check-in: Changeset: 78e0a67de946 Author: hseigel Date: 2020-02-07 21:11 +0000 URL: https://hg.openjdk.java.net/valhalla/valhalla/rev/78e0a67de946 8238663: [nestmates] array type of hidden class returns incorrect name Summary: If the array type bottom class is hidden then change the last '+' in its name to '/' Reviewed-by: hseigel Contributed-by: serguei.spitsyn@oracle.com ! src/hotspot/share/oops/klass.cpp ! src/hotspot/share/oops/klass.hpp ! test/hotspot/jtreg/serviceability/jvmti/HiddenClass/MyPackage/HiddenClassSigTest.java ! test/hotspot/jtreg/serviceability/jvmti/HiddenClass/libHiddenClassSigTest.cpp ! test/jdk/java/lang/invoke/defineHiddenClass/BasicTest.java
07-02-2020

I'm suggesting a fix like this: http://cr.openjdk.java.net/~sspitsyn/webrevs/2020/valhalla-hidden.1/ The patch is below: --- old/src/hotspot/share/oops/klass.cpp 2020-02-07 05:51:22.126119365 +0000 +++ new/src/hotspot/share/oops/klass.cpp 2020-02-07 05:51:21.567107567 +0000 @@ -669,6 +669,20 @@ } } +// Replace the last '+' char with '/'. +char* Klass::convert_hidden_name_to_java(Symbol* name) { + size_t name_len = name->utf8_length(); + char* result = NEW_RESOURCE_ARRAY(char, name_len + 1); + name->as_klass_external_name(result, (int)name_len + 1); + for (int index = (int)name_len; index > 0; index--) { + if (result[index] == '+') { + result[index] = '/'; + break; + } + } + return result; +} + // In product mode, this function doesn't have virtual function calls so // there might be some performance advantage to handling InstanceKlass here. const char* Klass::external_name() const { @@ -687,18 +701,12 @@ return result; } else if (ik->is_hidden()) { - // Replace the last '+' char with '/'. - size_t name_len = name()->utf8_length(); - char* result = NEW_RESOURCE_ARRAY(char, name_len + 1); - name()->as_klass_external_name(result, (int)name_len + 1); - for (int index = (int)name_len; index > 0; index--) { - if (result[index] == '+') { - result[index] = '/'; - break; - } - } + char* result = convert_hidden_name_to_java(name()); return result; } + } else if (is_objArray_klass() && ObjArrayKlass::cast(this)->element_klass()->is_hidden()) { + char* result = convert_hidden_name_to_java(name()); + return result; } if (name() == NULL) return "<unknown>"; return name()->as_klass_external_name(); @@ -706,6 +714,10 @@ const char* Klass::signature_name() const { if (name() == NULL) return "<unknown>"; + if (is_objArray_klass() && ObjArrayKlass::cast(this)->element_klass()->is_hidden()) { + char* result = convert_hidden_name_to_java(name()); + return result; + } return name()->as_C_string(); } --- old/src/hotspot/share/oops/klass.hpp 2020-02-07 05:51:23.243142939 +0000 +++ new/src/hotspot/share/oops/klass.hpp 2020-02-07 05:51:22.687131205 +0000 @@ -685,6 +685,7 @@ virtual void oop_print_on (oop obj, outputStream* st); virtual const char* internal_name() const = 0; + static char* convert_hidden_name_to_java(Symbol* name); // Verification virtual void verify_on(outputStream* st);
07-02-2020