changeset 53175:9f53142ee638 lworld

Minor fix to Q-type and L-type mirror
author mchung
date Tue, 11 Dec 2018 13:05:29 -0800
parents 26f4a81bd030
children 8dfebd4f5126
files src/java.base/share/classes/java/lang/Class.java src/java.base/share/classes/java/lang/invoke/ValueBootstrapMethods.java test/jdk/valhalla/valuetypes/ObjectMethods.java test/jdk/valhalla/valuetypes/ValueBootstrapMethods.java test/langtools/tools/javac/valhalla/lworld-values/ValueBootstrapMethodsTest.java
diffstat 5 files changed, 11 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/java/lang/Class.java	Tue Dec 11 15:00:35 2018 +0100
+++ b/src/java.base/share/classes/java/lang/Class.java	Tue Dec 11 13:05:29 2018 -0800
@@ -192,7 +192,7 @@
     public String toString() {
         return (isValue() ? "value " : "")
                + (isInterface() ? "interface " : (isPrimitive() ? "" : "class "))
-               + getName();
+               + getName() + (isValue() && isBoxType() ? "/box" : "");
     }
 
     /**
@@ -534,7 +534,7 @@
      * @return the box type of this class if this class is a value class;
      *         otherwise, this class.
      */
-    public Class<?> asBoxType() {
+    public Class<T> asBoxType() {
         return isValue() ? boxType : this;
     }
 
@@ -551,7 +551,7 @@
      * @return the unbox value type of this class if this class is a value class;
      *         otherwise, {@code null}.
      */
-    public Class<?> asValueType() {
+    public Class<T> asValueType() {
         return isValue() ? valueType : null;
     }
 
@@ -563,8 +563,8 @@
     }
 
     // set by VM if this class is a value type
-    private transient Class<?> boxType;
-    private transient Class<?> valueType;
+    private transient Class<T> boxType;
+    private transient Class<T> valueType;
 
     /**
      * Creates a new instance of the class represented by this {@code Class}
--- a/src/java.base/share/classes/java/lang/invoke/ValueBootstrapMethods.java	Tue Dec 11 15:00:35 2018 +0100
+++ b/src/java.base/share/classes/java/lang/invoke/ValueBootstrapMethods.java	Tue Dec 11 13:05:29 2018 -0800
@@ -161,7 +161,7 @@
          */
         static MethodHandle build(MethodHandles.Lookup lookup) {
             // build a MethodHandle[] { Class, getter1, getter2, ...} for the lookup class
-            Class<?> c = lookup.lookupClass();
+            Class<?> c = lookup.lookupClass().asValueType();
             MethodHandle valueClass =
                 MethodHandles.dropArguments(MethodHandles.constant(Class.class, c), 0, Object.class);
             MethodHandle[] getters = Stream.concat(Stream.of(valueClass), fields(lookup))
--- a/test/jdk/valhalla/valuetypes/ObjectMethods.java	Tue Dec 11 15:00:35 2018 +0100
+++ b/test/jdk/valhalla/valuetypes/ObjectMethods.java	Tue Dec 11 13:05:29 2018 -0800
@@ -39,7 +39,7 @@
     @DataProvider(name="hashcodeTests")
     Object[][] hashcodeTests() {
         return new Object[][] {
-            { Point.makePoint(100, 200), hash(Point.class, 100, 200) },
+            { Point.makePoint(100, 200), hash(Point.class.asValueType(), 100, 200) },
  //           { Line.makeLine(1, 2, 3, 4), hash(Line.class, 1, 2, 3, 4)}
         };
     }
--- a/test/jdk/valhalla/valuetypes/ValueBootstrapMethods.java	Tue Dec 11 15:00:35 2018 +0100
+++ b/test/jdk/valhalla/valuetypes/ValueBootstrapMethods.java	Tue Dec 11 13:05:29 2018 -0800
@@ -100,7 +100,7 @@
         }
 
         List<Object> values() {
-            return List.of(Value.class, i, d, s, l);
+            return List.of(Value.class.asValueType(), i, d, s, l);
         }
 
         public int hashCode() {
@@ -117,7 +117,7 @@
 
         public String toString() {
             System.out.println(l);
-            return String.format("[%s, %s, %s, %s, %s]", Value.class,
+            return String.format("[%s, %s, %s, %s, %s]", Value.class.asValueType(),
                                  i, String.valueOf(d), s, l.toString());
         }
     }
--- a/test/langtools/tools/javac/valhalla/lworld-values/ValueBootstrapMethodsTest.java	Tue Dec 11 15:00:35 2018 +0100
+++ b/test/langtools/tools/javac/valhalla/lworld-values/ValueBootstrapMethodsTest.java	Tue Dec 11 13:05:29 2018 -0800
@@ -55,7 +55,7 @@
         }
 
         private List<Object> values() {
-            return List.of(Value.class, i, d, s, l);
+            return List.of(Value.class.asValueType(), i, d, s, l);
         }
 
         public int localHashCode() {
@@ -72,7 +72,7 @@
 
         public String localToString() {
             System.out.println(l);
-            return String.format("[%s, %s, %s, %s, %s]", Value.class,
+            return String.format("[%s, %s, %s, %s, %s]", Value.class.asValueType(),
                                  i, String.valueOf(d), s, l.toString());
         }
     }