8180075: Javadoc of MethodHandles.Lookup::bind should note the difference from MethodHandle::bindTo
authorpsandoz
Fri, 12 May 2017 13:43:06 -0700
changeset 45140 2901d2f1a6aa
parent 45139 7be55dfa1742
child 45141 99a3dd59f831
8180075: Javadoc of MethodHandles.Lookup::bind should note the difference from MethodHandle::bindTo Reviewed-by: psandoz Contributed-by: ron.pressler@oracle.com
jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java	Fri May 12 13:29:38 2017 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java	Fri May 12 13:43:06 2017 -0700
@@ -1660,7 +1660,7 @@
          * (If the trailing array argument is the only argument,
          * the given receiver value will be bound to it.)
          * <p>
-         * This is equivalent to the following code:
+         * This is almost equivalent to the following code, with some differences noted below:
          * <blockquote><pre>{@code
 import static java.lang.invoke.MethodHandles.*;
 import static java.lang.invoke.MethodType.*;
@@ -1673,7 +1673,10 @@
          * where {@code defc} is either {@code receiver.getClass()} or a super
          * type of that class, in which the requested method is accessible
          * to the lookup class.
-         * (Note that {@code bindTo} does not preserve variable arity.)
+         * (Unlike {@code bind}, {@code bindTo} does not preserve variable arity.
+         * Also, {@code bindTo} may throw a {@code ClassCastException} in instances where {@code bind} would
+         * throw an {@code IllegalAccessException}, as in the case where the member is {@code protected} and
+         * the receiver is restricted by {@code findVirtual} to the lookup class.)
          * @param receiver the object from which the method is accessed
          * @param name the name of the method
          * @param type the type of the method, with the receiver argument omitted