changeset 17141:c5b0465f06d0

8180075: Javadoc of MethodHandles.Lookup::bind should note the difference from MethodHandle::bindTo Reviewed-by: psandoz Contributed-by: ron.pressler@oracle.com
author psandoz
date Fri, 12 May 2017 13:43:06 -0700
parents 9fc68c99204d
children 661765f8b131
files src/java.base/share/classes/java/lang/invoke/MethodHandles.java
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/java/lang/invoke/MethodHandles.java	Fri May 12 13:29:38 2017 -0700
+++ b/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