8198889: Clarify the throwing of exceptions from ConstantBootstraps.invoke
authorpsandoz
Wed, 14 Mar 2018 12:39:57 -0700
changeset 49242 d2a2a80774e8
parent 49241 de4b3a04feae
child 49243 176b3da8ce61
8198889: Clarify the throwing of exceptions from ConstantBootstraps.invoke Reviewed-by: mchung
src/java.base/share/classes/java/lang/invoke/ConstantBootstraps.java
--- a/src/java.base/share/classes/java/lang/invoke/ConstantBootstraps.java	Wed Mar 14 19:12:30 2018 +0100
+++ b/src/java.base/share/classes/java/lang/invoke/ConstantBootstraps.java	Wed Mar 14 12:39:57 2018 -0700
@@ -104,10 +104,10 @@
      *
      * @param lookup the lookup context describing the class performing the
      * operation (normally stacked by the JVM)
+     * @param name the name of the constant to return, which must exactly match
+     * an enum constant in the specified type.
      * @param type the {@code Class} object describing the enum type for which
      * a constant is to be returned
-     * @param name the name of the constant to return, which must exactly match
-     * an enum constant in the specified type.
      * @param <E> The enum type for which a constant value is to be returned
      * @return the enum constant of the specified enum type with the
      * specified name
@@ -208,20 +208,25 @@
     /**
      * Returns the result of invoking a method handle with the provided
      * arguments.
+     * <p>
+     * This method behaves as if the method handle to be invoked is the result
+     * of adapting the given method handle, via {@link MethodHandle#asType}, to
+     * adjust the return type to the desired type.
      *
      * @param lookup unused
      * @param name unused
-     * @param type the type of the value to be returned, which must be
+     * @param type the desired type of the value to be returned, which must be
      * compatible with the return type of the method handle
      * @param handle the method handle to be invoked
      * @param args the arguments to pass to the method handle, as if with
      * {@link MethodHandle#invokeWithArguments}.  Each argument may be
      * {@code null}.
      * @return the result of invoking the method handle
-     * @throws WrongMethodTypeException if the handle's return type cannot be
-     * adjusted to the desired type
-     * @throws ClassCastException if an argument cannot be converted by
-     * reference casting
+     * @throws WrongMethodTypeException if the handle's method type cannot be
+     * adjusted to take the given number of arguments, or if the handle's return
+     * type cannot be adjusted to the desired type
+     * @throws ClassCastException if an argument or the result produced by
+     * invoking the handle cannot be converted by reference casting
      * @throws Throwable anything thrown by the method handle invocation
      */
     public static Object invoke(MethodHandles.Lookup lookup, String name, Class<?> type,