changeset 55118:baa7d191cc28 lworld

8223350: [lworld] Use inline classes instead of value classes Reviewed-by: hseigel
author rriggs
date Mon, 06 May 2019 16:40:29 +0800
parents aabb0a86787a
children 39702d8b184c
files src/java.base/share/classes/java/lang/Class.java src/java.base/share/classes/java/lang/reflect/Constructor.java src/java.base/share/classes/java/lang/reflect/Field.java test/jdk/java/lang/invoke/VarHandles/Value.java test/jdk/valhalla/valuetypes/ArrayElementVarHandleTest.java test/jdk/valhalla/valuetypes/Line.java test/jdk/valhalla/valuetypes/MethodHandleTest.java test/jdk/valhalla/valuetypes/MixedValues.java test/jdk/valhalla/valuetypes/NonFlattenValue.java test/jdk/valhalla/valuetypes/ObjectMethods.java test/jdk/valhalla/valuetypes/Point.java test/jdk/valhalla/valuetypes/QTypeDescriptorTest.java test/jdk/valhalla/valuetypes/Reflection.java test/jdk/valhalla/valuetypes/SubstitutabilityTest.java test/jdk/valhalla/valuetypes/Value.java test/jdk/valhalla/valuetypes/ValueArray.java test/jdk/valhalla/valuetypes/ValueBootstrapMethods.java
diffstat 17 files changed, 41 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/java/lang/Class.java	Fri May 10 10:25:57 2019 +0200
+++ b/src/java.base/share/classes/java/lang/Class.java	Mon May 06 16:40:29 2019 +0800
@@ -197,9 +197,9 @@
      * @return a string representation of this class object.
      */
     public String toString() {
-        return (isValue() ? "value " : "")
+        return (isValue() ? "inline " : "")
                + (isInterface() ? "interface " : (isPrimitive() ? "" : "class "))
-               + getName() + (isValue() && isBoxType() ? "/box" : "");
+               + getName() + (isValue() && isBoxType() ? "?" : "");
     }
 
     /**
@@ -520,10 +520,10 @@
         int mods = this.getModifiers();
         if ((mods & VALUE_TYPE) != 0) {
             if ((mods & (Modifier.INTERFACE | Modifier.ABSTRACT)) != 0) {
-                throw new InternalError("value class can't have ACC_INTERFACE or ACC_ABSTRACT set");
+                throw new InternalError("inline class can't have ACC_INTERFACE or ACC_ABSTRACT set");
             }
             if (getSuperclass() != Object.class) {
-                throw new InternalError("Super class of a value class must be java.lang.Object");
+                throw new InternalError("Super class of an inline class must be java.lang.Object");
             }
             return true;
         }
@@ -637,7 +637,7 @@
     {
         if (this.isValue()) {
             throw new IllegalAccessException(
-                "cannot create new instance of value class " + this.getName());
+                "cannot create new instance of an inline class " + this.getName());
         }
 
         SecurityManager sm = System.getSecurityManager();
--- a/src/java.base/share/classes/java/lang/reflect/Constructor.java	Fri May 10 10:25:57 2019 +0200
+++ b/src/java.base/share/classes/java/lang/reflect/Constructor.java	Mon May 06 16:40:29 2019 +0800
@@ -182,7 +182,7 @@
         if (flag) {
             if (clazz.isValue()) {
                 throw new InaccessibleObjectException(
-                    "Unable to make a value class constructor \"" + this + "\" accessible");
+                    "Unable to make an inline class constructor \"" + this + "\" accessible");
             }
             checkCanSetAccessible(Reflection.getCallerClass());
         }
@@ -485,7 +485,7 @@
     {
         if (clazz.isValue()) {
             throw new IllegalAccessException(
-                "cannot create new instance of value class " + clazz.getName());
+                "cannot create new instance of an inline class " + clazz.getName());
         }
         Class<?> caller = override ? null : Reflection.getCallerClass();
         return newInstanceWithCaller(initargs, !override, caller);
--- a/src/java.base/share/classes/java/lang/reflect/Field.java	Fri May 10 10:25:57 2019 +0200
+++ b/src/java.base/share/classes/java/lang/reflect/Field.java	Mon May 06 16:40:29 2019 +0800
@@ -168,12 +168,11 @@
     public void setAccessible(boolean flag) {
         AccessibleObject.checkPermission();
 
+        if (clazz.isValue()) {
+            throw new InaccessibleObjectException("cannot make a field accessible of inline class "
+                    + clazz.getName());
+        }
         if (flag) {
-            if (clazz.isValue()) {
-                throw new InaccessibleObjectException(
-                    "Unable to make a value class field \"" + this + "\" accessible");
-            }
-
             checkCanSetAccessible(Reflection.getCallerClass());
         }
         setAccessible0(flag);
@@ -1105,11 +1104,11 @@
     }
 
     /*
-     * Ensure the declaring class is not a value class.
+     * Ensure the declaring class is not an inline class.
      */
     private void ensureNotValueClass() throws IllegalAccessException {
         if (clazz.isValue()) {
-            throw new IllegalAccessException("cannot set this field of a value class "
+            throw new IllegalAccessException("cannot set field \"" + this + "\" of inline class "
                 + clazz.getName());
         }
     }
--- a/test/jdk/java/lang/invoke/VarHandles/Value.java	Fri May 10 10:25:57 2019 +0200
+++ b/test/jdk/java/lang/invoke/VarHandles/Value.java	Mon May 06 16:40:29 2019 +0800
@@ -21,7 +21,7 @@
  * questions.
  */
 
-final value class Value {
+final inline class Value {
     final char char_v;
     final byte byte_v;
     final boolean boolean_v;
--- a/test/jdk/valhalla/valuetypes/ArrayElementVarHandleTest.java	Fri May 10 10:25:57 2019 +0200
+++ b/test/jdk/valhalla/valuetypes/ArrayElementVarHandleTest.java	Mon May 06 16:40:29 2019 +0800
@@ -24,7 +24,7 @@
 
 /*
  * @test
- * @summary test VarHandle on value array
+ * @summary test VarHandle on inline class array
  * @compile -XDallowWithFieldOperator Point.java
  * @compile -XDallowWithFieldOperator Line.java
  * @compile -XDallowWithFieldOperator MutablePath.java
--- a/test/jdk/valhalla/valuetypes/Line.java	Fri May 10 10:25:57 2019 +0200
+++ b/test/jdk/valhalla/valuetypes/Line.java	Mon May 06 16:40:29 2019 +0800
@@ -21,7 +21,7 @@
  * questions.
  */
 
-public final value class Line {
+public final inline class Line {
     public Point p1;
     public Point p2;
     Line () {
--- a/test/jdk/valhalla/valuetypes/MethodHandleTest.java	Fri May 10 10:25:57 2019 +0200
+++ b/test/jdk/valhalla/valuetypes/MethodHandleTest.java	Mon May 06 16:40:29 2019 +0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,7 +24,7 @@
 
 /*
  * @test
- * @summary test MethodHandle/VarHandle on value types
+ * @summary test MethodHandle/VarHandle on inline types
  * @compile -XDallowWithFieldOperator Point.java Line.java MutablePath.java MixedValues.java
  * @run testng/othervm -XX:+EnableValhalla MethodHandleTest
  */
@@ -71,7 +71,7 @@
     @Test
     public static void testValueFields() throws Throwable {
         MutablePath path = MutablePath.makePath(1, 2, 3, 4);
-        // p1 and p2 are a non-final field of value type in a reference
+        // p1 and p2 are a non-final field of inline type in a reference
         MethodHandleTest test1 = new MethodHandleTest("Point", path.p1, "x", "y");
         test1.run();
 
@@ -122,11 +122,11 @@
         // set an array element to null
         Class<?> elementType = c.getComponentType();
         try {
-            // value array element is flattenable
+            // inline array element is flattenable
             Object v = (Object)setter.invoke(array, 0, null);
-            assertFalse(elementType.isValue(), "should fail to set a value array element to null");
+            assertFalse(elementType.isValue(), "should fail to set an inline class array element to null");
         } catch (NullPointerException e) {
-            assertTrue(elementType.isValue(), "should only fail to set a value array element to null");
+            assertTrue(elementType.isValue(), "should only fail to set an inline class array element to null");
         }
     }
 
@@ -172,7 +172,7 @@
     }
 
     /*
-     * Test setting value field to a new value.
+     * Test setting a field of an inline type to a new value.
      * The field must be flattenable but may or may not be flattened.
      */
     void setValueField(String name, Object obj, Object value) throws Throwable {
--- a/test/jdk/valhalla/valuetypes/MixedValues.java	Fri May 10 10:25:57 2019 +0200
+++ b/test/jdk/valhalla/valuetypes/MixedValues.java	Mon May 06 16:40:29 2019 +0800
@@ -25,7 +25,7 @@
 
 public class MixedValues {
     static Point staticPoint = Point.makePoint(10, 10);
-    static Line? staticLine;   // null static value box field
+    static Line? staticLine;   // null static field of non-flattened type
     Point p;
     Line l;
     MutablePath mutablePath;
--- a/test/jdk/valhalla/valuetypes/NonFlattenValue.java	Fri May 10 10:25:57 2019 +0200
+++ b/test/jdk/valhalla/valuetypes/NonFlattenValue.java	Mon May 06 16:40:29 2019 +0800
@@ -21,7 +21,7 @@
  * questions.
  */
 
-public value class NonFlattenValue {
+public inline class NonFlattenValue {
     Point? nfp;
 
     NonFlattenValue() {
--- a/test/jdk/valhalla/valuetypes/ObjectMethods.java	Fri May 10 10:25:57 2019 +0200
+++ b/test/jdk/valhalla/valuetypes/ObjectMethods.java	Mon May 06 16:40:29 2019 +0800
@@ -24,7 +24,7 @@
 
 /*
  * @test
- * @summary test Object methods on value types
+ * @summary test Object methods on inline types
  * @compile -XDallowWithFieldOperator ObjectMethods.java
  * @run testng/othervm -XX:+EnableValhalla -Dvalue.bsm.salt=1 ObjectMethods
  * @run testng/othervm -XX:+EnableValhalla -Dvalue.bsm.salt=1 -XX:ValueFieldMaxFlatSize=0 ObjectMethods
@@ -78,7 +78,7 @@
                               .setNumber(Value.Number.intValue(10)).build(), true},
             { new Value.Builder().setNumber(new Value.IntNumber(10)).build(),
               new Value.Builder().setNumber(new Value.IntNumber(10)).build(), false},
-            // reference classes containing value fields
+            // reference classes containing fields of inline type
             { MUTABLE_PATH, MutablePath.makePath(10, 20, 30, 40), false},
             { MIXED_VALUES, MIXED_VALUES, true},
             { MIXED_VALUES, new MixedValues(P1, LINE1, MUTABLE_PATH, "value"), false},
@@ -179,7 +179,7 @@
         return hc;
     }
 
-    static value class MyValue1 {
+    static inline class MyValue1 {
         Point p = Point.default;
         Point? box = Point.default;
 
--- a/test/jdk/valhalla/valuetypes/Point.java	Fri May 10 10:25:57 2019 +0200
+++ b/test/jdk/valhalla/valuetypes/Point.java	Mon May 06 16:40:29 2019 +0800
@@ -21,7 +21,7 @@
  * questions.
  */
 
-public value class Point {
+public inline class Point {
     static final Object STATIC_FIELD = new Object();
     public int x;
     public int y;
--- a/test/jdk/valhalla/valuetypes/QTypeDescriptorTest.java	Fri May 10 10:25:57 2019 +0200
+++ b/test/jdk/valhalla/valuetypes/QTypeDescriptorTest.java	Mon May 06 16:40:29 2019 +0800
@@ -80,7 +80,7 @@
 
     @Test
     public static void testStaticMethod() throws Throwable {
-        // static method in a value type with no parameter and void return type
+        // static method in an inline type with no parameter and void return type
         Runnable r = () -> ValueTest.run();
         r.run();
 
@@ -207,7 +207,7 @@
         Line toLine(Point p, NonFlattenValue nfv);
     }
 
-    static value class ValueTest {
+    static inline class ValueTest {
         private final int value;
         public ValueTest() { this.value = 0; }
 
--- a/test/jdk/valhalla/valuetypes/Reflection.java	Fri May 10 10:25:57 2019 +0200
+++ b/test/jdk/valhalla/valuetypes/Reflection.java	Mon May 06 16:40:29 2019 +0800
@@ -24,7 +24,7 @@
 
 /*
  * @test
- * @summary test reflection on value types
+ * @summary test reflection on inline types
  * @compile -XDallowWithFieldOperator Point.java Line.java NonFlattenValue.java
  * @run main/othervm -XX:+EnableValhalla Reflection
  */
@@ -75,7 +75,7 @@
     Reflection(Class<?> type, String cn, Object o) throws Exception {
         this.c = Class.forName(cn);
         if (!c.isValue() || c != type) {
-            throw new RuntimeException(cn + " is not a value class");
+            throw new RuntimeException(cn + " is not an inline class");
         }
 
         // the box type is the primary mirror
@@ -133,7 +133,7 @@
     void newInstance() throws Exception {
         try {
             Object o = c.newInstance();
-            throw new RuntimeException("newInstance expected to be unsupported on value class");
+            throw new RuntimeException("newInstance expected to be unsupported on inline class");
         } catch (IllegalAccessException e) {}
     }
 
--- a/test/jdk/valhalla/valuetypes/SubstitutabilityTest.java	Fri May 10 10:25:57 2019 +0200
+++ b/test/jdk/valhalla/valuetypes/SubstitutabilityTest.java	Mon May 06 16:40:29 2019 +0800
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @summary test MethodHandle/VarHandle on value types
+ * @summary test MethodHandle/VarHandle on inline types
  * @compile -XDallowWithFieldOperator Point.java Line.java Value.java MutablePath.java MixedValues.java
  * @run testng/othervm -XX:+EnableValhalla SubstitutabilityTest
  */
--- a/test/jdk/valhalla/valuetypes/Value.java	Fri May 10 10:25:57 2019 +0200
+++ b/test/jdk/valhalla/valuetypes/Value.java	Mon May 06 16:40:29 2019 +0800
@@ -21,7 +21,7 @@
  * questions.
  */
 
-public value class Value {
+public inline class Value {
     char char_v;
     byte byte_v;
     boolean boolean_v;
@@ -147,7 +147,7 @@
         }
     }
 
-    static value class IntValue implements Number {
+    static inline class IntValue implements Number {
         int i;
         IntValue() {
             i = 0;
@@ -157,7 +157,7 @@
         }
     }
 
-    static value class ShortValue implements Number {
+    static inline class ShortValue implements Number {
         short s;
         ShortValue() {
             s = 0;
--- a/test/jdk/valhalla/valuetypes/ValueArray.java	Fri May 10 10:25:57 2019 +0200
+++ b/test/jdk/valhalla/valuetypes/ValueArray.java	Mon May 06 16:40:29 2019 +0800
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @summary Basic test for Array::get, Array::set, Arrays::setAll on value array
+ * @summary Basic test for Array::get, Array::set, Arrays::setAll on inline class array
  * @compile -XDallowWithFieldOperator Point.java NonFlattenValue.java
  * @compile -XDallowWithFieldOperator ValueArray.java
  * @run testng/othervm -XX:+EnableValhalla -XX:ValueArrayElemMaxFlatSize=-1 ValueArray
@@ -135,7 +135,7 @@
         }
     }
 
-    static value class PointArray {
+    static inline class PointArray {
         public Point?[] points;
         PointArray() {
             points = new Point?[0];
--- a/test/jdk/valhalla/valuetypes/ValueBootstrapMethods.java	Fri May 10 10:25:57 2019 +0200
+++ b/test/jdk/valhalla/valuetypes/ValueBootstrapMethods.java	Mon May 06 16:40:29 2019 +0800
@@ -76,7 +76,7 @@
         }
     }
 
-    public static final value class Value {
+    public static final inline class Value {
         private final int i;
         private final double d;
         private final String s;