changeset 51206:952990c8f3c2 condy-folding

manual merge with jep-334
author vromero
date Wed, 27 Jun 2018 12:59:47 -0700
parents 46783b684636 315c40fafba2
children 72c3a4b94fd3
files src/java.base/share/classes/java/lang/Class.java src/java.base/share/classes/java/lang/constant/ClassDesc.java src/java.base/share/classes/java/lang/constant/MethodTypeDesc.java src/java.base/share/classes/java/lang/invoke/FieldTypeDescriptor.java src/java.base/share/classes/java/lang/invoke/MethodType.java src/java.base/share/classes/java/lang/invoke/MethodTypeDescriptor.java src/java.base/share/classes/java/lang/invoke/TypeDescriptor.java
diffstat 8 files changed, 147 insertions(+), 147 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/java/lang/Class.java	Tue Jun 26 19:17:29 2018 -0700
+++ b/src/java.base/share/classes/java/lang/Class.java	Wed Jun 27 12:59:47 2018 -0700
@@ -27,7 +27,7 @@
 
 import java.lang.annotation.Annotation;
 import java.lang.constant.ClassDesc;
-import java.lang.invoke.FieldTypeDescriptor;
+import java.lang.invoke.TypeDescriptor;
 import java.lang.module.ModuleReader;
 import java.lang.ref.SoftReference;
 import java.io.IOException;
@@ -134,7 +134,7 @@
                               GenericDeclaration,
                               Type,
                               AnnotatedElement,
-                              FieldTypeDescriptor<Class<?>>,
+                                       TypeDescriptor.OfField<Class<?>>,
                               Constable<Class<?>> {
     private static final int ANNOTATION= 0x00002000;
     private static final int ENUM      = 0x00004000;
--- a/src/java.base/share/classes/java/lang/constant/ClassDesc.java	Tue Jun 26 19:17:29 2018 -0700
+++ b/src/java.base/share/classes/java/lang/constant/ClassDesc.java	Wed Jun 27 12:59:47 2018 -0700
@@ -25,8 +25,8 @@
 package java.lang.constant;
 
 import jdk.internal.lang.annotation.Foldable;
-import java.lang.invoke.FieldTypeDescriptor;
 import java.lang.invoke.MethodHandles;
+import java.lang.invoke.TypeDescriptor;
 import java.util.stream.Stream;
 
 import sun.invoke.util.Wrapper;
@@ -60,7 +60,7 @@
 public interface ClassDesc
         extends ConstantDesc<Class<?>>,
                 Constable<ConstantDesc<Class<?>>>,
-                FieldTypeDescriptor<ClassDesc> {
+                TypeDescriptor.OfField<ClassDesc> {
 
     /**
      * Create a {@linkplain ClassDesc} given the name of a class or interface
--- a/src/java.base/share/classes/java/lang/constant/MethodTypeDesc.java	Tue Jun 26 19:17:29 2018 -0700
+++ b/src/java.base/share/classes/java/lang/constant/MethodTypeDesc.java	Wed Jun 27 12:59:47 2018 -0700
@@ -28,7 +28,7 @@
 
 import java.lang.invoke.MethodHandles;
 import java.lang.invoke.MethodType;
-import java.lang.invoke.MethodTypeDescriptor;
+import java.lang.invoke.TypeDescriptor;
 import java.util.List;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
@@ -47,7 +47,7 @@
 public interface MethodTypeDesc
         extends ConstantDesc<MethodType>,
                 Constable<ConstantDesc<MethodType>>,
-                MethodTypeDescriptor<ClassDesc, MethodTypeDesc> {
+                TypeDescriptor.OfMethod<ClassDesc, MethodTypeDesc> {
     /**
      * Create a {@linkplain MethodTypeDesc} given a method descriptor string
      *
--- a/src/java.base/share/classes/java/lang/invoke/FieldTypeDescriptor.java	Tue Jun 26 19:17:29 2018 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-package java.lang.invoke;
-
-/**
- * Represents a field type descriptor, as per JVMS 4.3.2.
- *
- * @param <F> the class implementing {@linkplain FieldTypeDescriptor}
- * @jvms 4.3.2 Field Descriptors
- */
-public interface FieldTypeDescriptor<F extends FieldTypeDescriptor<F>> extends TypeDescriptor {
-    /**
-     * Does this field descriptor describe an array type?
-     * @return whether this field descriptor describes an array type
-     */
-    boolean isArray();
-
-    /**
-     * Does this field descriptor describe a primitive type?
-     * @return whether this field descriptor describes a primitive type
-     */
-    boolean isPrimitive();
-
-    /**
-     * If this field descriptor describes an array type, return
-     * a descriptor for its component type, otherwise return {@code null}.
-     * @return the component type, or {@code null} if this field descriptor does
-     * not describe an array type
-     */
-    F componentType();
-
-    /**
-     * Return a descriptor for the array type whose component type is described by this
-     * descriptor
-     * @return the descriptor for the array type
-     */
-    F arrayType();
-}
--- a/src/java.base/share/classes/java/lang/invoke/MethodType.java	Tue Jun 26 19:17:29 2018 -0700
+++ b/src/java.base/share/classes/java/lang/invoke/MethodType.java	Wed Jun 27 12:59:47 2018 -0700
@@ -102,7 +102,7 @@
 public final
 class MethodType
         implements Constable<MethodType>,
-                   MethodTypeDescriptor<Class<?>, MethodType>,
+                   TypeDescriptor.OfMethod<Class<?>, MethodType>,
                    java.io.Serializable {
     private static final long serialVersionUID = 292L;  // {rtype, {ptype...}}
 
--- a/src/java.base/share/classes/java/lang/invoke/MethodTypeDescriptor.java	Tue Jun 26 19:17:29 2018 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,102 +0,0 @@
-package java.lang.invoke;
-
-import java.util.List;
-
-/**
- * Represents a method type descriptor, as per JVMS 4.3.3
- *
- * @param <F> the type representing field type descriptors
- * @param <M> the class implementing {@linkplain MethodTypeDescriptor}
- * @jvms 4.3.3 Method Descriptors
- */
-public interface MethodTypeDescriptor<F extends FieldTypeDescriptor<F>, M extends MethodTypeDescriptor<F, M>>
-        extends TypeDescriptor {
-
-    /**
-     * Return the number of parameters in the method type
-     * @return the number of parameters
-     */
-    int parameterCount();
-
-    /**
-     * Return a field descriptor describing the requested parameter of the method type
-     * described by this descriptor
-     * @param i the index of the parameter
-     * @return a field descriptor for the requested parameter type
-     * @throws IndexOutOfBoundsException if the index is outside the half-open
-     * range {[0, parameterCount)}
-     */
-    F parameterType(int i);
-
-    /**
-     * Return a field descriptor describing the return type of the method type described
-     * by this descriptor
-     * @return a field descriptor for the return type
-     */
-    F returnType();
-
-    /**
-     * Return an array of field descriptors for the parameter types of the method type
-     * described by this descriptor
-     * @return field descriptors for the parameter types
-     */
-    F[] parameterArray();
-
-    /**
-     * Return a list of field descriptors for the parameter types of the method type
-     * described by this descriptor
-     * @return field descriptors for the parameter types
-     */
-    List<F> parameterList();
-
-    /**
-     * Return a method descriptor that is identical to this one, except that the return
-     * type has been changed to the specified type
-     *
-     * @param newReturn a field descriptor for the new return type
-     * @throws NullPointerException if any argument is {@code null}
-     * @return the new method descriptor
-     */
-    M changeReturnType(F newReturn);
-
-    /**
-     * Return a method descriptor that is identical to this one,
-     * except that a single parameter type has been changed to the specified type.
-     *
-     * @param index the index of the parameter to change
-     * @param paramType a field descriptor describing the new parameter type
-     * @return the new method descriptor
-     * @throws NullPointerException if any argument is {@code null}
-     * @throws IndexOutOfBoundsException if the index is outside the half-open
-     * range {[0, parameterCount)}
-     */
-    M changeParameterType(int index, F paramType);
-
-    /**
-     * Return a method descriptor that is identical to this one,
-     * except that a range of parameter types have been removed.
-     *
-     * @param start the index of the first parameter to remove
-     * @param end the index after the last parameter to remove
-     * @return the new method descriptor
-     * @throws IndexOutOfBoundsException if {@code start} is outside the half-open
-     * range {[0, parameterCount)}, or {@code end} is outside the closed range
-     * {@code [0, parameterCount]}
-     */
-    M dropParameterTypes(int start, int end);
-
-    /**
-     * Return a method descriptor that is identical to this one,
-     * except that a range of additional parameter types have been inserted.
-     *
-     * @param pos the index at which to insert the first inserted parameter
-     * @param paramTypes field descriptors describing the new parameter types
-     *                   to insert
-     * @return the new method descriptor
-     * @throws NullPointerException if any argument is {@code null}
-     * @throws IndexOutOfBoundsException if {@code pos} is outside the closed
-     * range {[0, parameterCount]}
-     */
-    @SuppressWarnings("unchecked")
-    M insertParameterTypes(int pos, F... paramTypes);
-}
--- a/src/java.base/share/classes/java/lang/invoke/TypeDescriptor.java	Tue Jun 26 19:17:29 2018 -0700
+++ b/src/java.base/share/classes/java/lang/invoke/TypeDescriptor.java	Wed Jun 27 12:59:47 2018 -0700
@@ -1,5 +1,7 @@
 package java.lang.invoke;
 
+import java.util.List;
+
 /**
  * An entity that has a field or method type descriptor, as per JVMS 4.3.2 or 4.3.3.
  * @jvms 4.3.2 Field Descriptors
@@ -11,4 +13,140 @@
      * @return the type descriptor
      */
     String descriptorString();
+
+
+    /**
+     * Represents a field type descriptor, as per JVMS 4.3.2.
+     *
+     * @param <F> the class implementing {@linkplain TypeDescriptor.OfField}
+     * @jvms 4.3.2 Field Descriptors
+     */
+    interface OfField<F extends TypeDescriptor.OfField<F>> extends TypeDescriptor {
+        /**
+         * Does this field descriptor describe an array type?
+         * @return whether this field descriptor describes an array type
+         */
+        boolean isArray();
+
+        /**
+         * Does this field descriptor describe a primitive type?
+         * @return whether this field descriptor describes a primitive type
+         */
+        boolean isPrimitive();
+
+        /**
+         * If this field descriptor describes an array type, return
+         * a descriptor for its component type, otherwise return {@code null}.
+         * @return the component type, or {@code null} if this field descriptor does
+         * not describe an array type
+         */
+        F componentType();
+
+        /**
+         * Return a descriptor for the array type whose component type is described by this
+         * descriptor
+         * @return the descriptor for the array type
+         */
+        F arrayType();
+    }
+
+
+    /**
+     * Represents a method type descriptor, as per JVMS 4.3.3
+     *
+     * @param <F> the type representing field type descriptors
+     * @param <M> the class implementing {@linkplain TypeDescriptor.OfMethod}
+     * @jvms 4.3.3 Method Descriptors
+     */
+    interface OfMethod<F extends TypeDescriptor.OfField<F>, M extends TypeDescriptor.OfMethod<F, M>>
+            extends TypeDescriptor {
+
+        /**
+         * Return the number of parameters in the method type
+         * @return the number of parameters
+         */
+        int parameterCount();
+
+        /**
+         * Return a field descriptor describing the requested parameter of the method type
+         * described by this descriptor
+         * @param i the index of the parameter
+         * @return a field descriptor for the requested parameter type
+         * @throws IndexOutOfBoundsException if the index is outside the half-open
+         * range {[0, parameterCount)}
+         */
+        F parameterType(int i);
+
+        /**
+         * Return a field descriptor describing the return type of the method type described
+         * by this descriptor
+         * @return a field descriptor for the return type
+         */
+        F returnType();
+
+        /**
+         * Return an array of field descriptors for the parameter types of the method type
+         * described by this descriptor
+         * @return field descriptors for the parameter types
+         */
+        F[] parameterArray();
+
+        /**
+         * Return a list of field descriptors for the parameter types of the method type
+         * described by this descriptor
+         * @return field descriptors for the parameter types
+         */
+        List<F> parameterList();
+
+        /**
+         * Return a method descriptor that is identical to this one, except that the return
+         * type has been changed to the specified type
+         *
+         * @param newReturn a field descriptor for the new return type
+         * @throws NullPointerException if any argument is {@code null}
+         * @return the new method descriptor
+         */
+        M changeReturnType(F newReturn);
+
+        /**
+         * Return a method descriptor that is identical to this one,
+         * except that a single parameter type has been changed to the specified type.
+         *
+         * @param index the index of the parameter to change
+         * @param paramType a field descriptor describing the new parameter type
+         * @return the new method descriptor
+         * @throws NullPointerException if any argument is {@code null}
+         * @throws IndexOutOfBoundsException if the index is outside the half-open
+         * range {[0, parameterCount)}
+         */
+        M changeParameterType(int index, F paramType);
+
+        /**
+         * Return a method descriptor that is identical to this one,
+         * except that a range of parameter types have been removed.
+         *
+         * @param start the index of the first parameter to remove
+         * @param end the index after the last parameter to remove
+         * @return the new method descriptor
+         * @throws IndexOutOfBoundsException if {@code start} is outside the half-open
+         * range {[0, parameterCount)}, or {@code end} is outside the closed range
+         * {@code [0, parameterCount]}
+         */
+        M dropParameterTypes(int start, int end);
+
+        /**
+         * Return a method descriptor that is identical to this one,
+         * except that a range of additional parameter types have been inserted.
+         *
+         * @param pos the index at which to insert the first inserted parameter
+         * @param paramTypes field descriptors describing the new parameter types
+         *                   to insert
+         * @return the new method descriptor
+         * @throws NullPointerException if any argument is {@code null}
+         * @throws IndexOutOfBoundsException if {@code pos} is outside the closed
+         * range {[0, parameterCount]}
+         */
+        @SuppressWarnings("unchecked")
+        M insertParameterTypes(int pos, F... paramTypes);
+    }
 }
--- a/test/jdk/java/lang/constant/TypeDescriptorTest.java	Tue Jun 26 19:17:29 2018 -0700
+++ b/test/jdk/java/lang/constant/TypeDescriptorTest.java	Wed Jun 27 12:59:47 2018 -0700
@@ -23,7 +23,7 @@
  * questions.
  */
 
-import java.lang.invoke.FieldTypeDescriptor;
+import java.lang.invoke.TypeDescriptor;
 import java.lang.constant.ClassDesc;
 
 import org.testng.annotations.Test;
@@ -42,7 +42,7 @@
  */
 @Test
 public class TypeDescriptorTest {
-    private<F extends FieldTypeDescriptor<F>> void testArray(F f, boolean isArray, F component, F array) {
+    private<F extends TypeDescriptor.OfField<F>> void testArray(F f, boolean isArray, F component, F array) {
         if (isArray) {
             assertTrue(f.isArray());
             assertEquals(f.arrayType(), array);