changeset 14043:64db0365ed01

Fix: inner classes should not get M3 mangling if no type parameter is present anywhere Enhancement: add -Xverify:all to PrespecializerTest
author mcimadamore
date Thu, 21 Apr 2016 17:57:46 +0100
parents 10e2de50a300
children c82dff06b0d6
files src/java.base/share/classes/valhalla/model3/Model3Converter.java test/valhalla/PrespecializerTest.java
diffstat 2 files changed, 20 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/valhalla/model3/Model3Converter.java	Thu Apr 21 10:47:50 2016 +0200
+++ b/src/java.base/share/classes/valhalla/model3/Model3Converter.java	Thu Apr 21 17:57:46 2016 +0100
@@ -131,8 +131,26 @@
                     && Stream.of(params).allMatch(s -> s.equals("_"));
         }
 
+        boolean allErased() {
+            return java.util.Arrays.stream(params).map(ParameterizedType::normalize).allMatch(s -> s.equals("_"));
+        }
+
+        boolean allErasedRecursive() {
+            ParameterizedType curr = this;
+            while (curr != null) {
+                if (!curr.allErased()) {
+                    return false;
+                }
+                curr = curr.enclosing;
+            }
+            return true;
+        }
+
         public String encode() {
             String canonicalName;
+            if (allErasedRecursive()) {
+                return className.replace('.', '/');
+            }
             if (enclosing != null) {
                 if (className.contains(".")) {
                     canonicalName = className.substring(className.lastIndexOf('.') + 1);
@@ -142,7 +160,7 @@
             } else {
                 canonicalName = className.replace('.', '/');
             }
-            String local = (java.util.Arrays.stream(params).map(ParameterizedType::normalize).allMatch(s -> s.equals("_")))
+            String local = allErased()
                            ? canonicalName
                            : Stream.of(params).map(ParameterizedType::normalize).collect(joining("", canonicalName + "$${", "}"));
             return (enclosing != null) ? enclosing.encode() + "$$$" + local : local;
--- a/test/valhalla/PrespecializerTest.java	Thu Apr 21 10:47:50 2016 +0200
+++ b/test/valhalla/PrespecializerTest.java	Thu Apr 21 17:57:46 2016 +0100
@@ -44,7 +44,7 @@
 /*
  * @test
  * @summary Eager specialization of all types in java.anyutil
- * @run main PrespecializerTest
+ * @run main/othervm -Xverify:all PrespecializerTest
  */
 public class PrespecializerTest {
     private static String[] targets = { "_", "Z", "I" };