-
Bug
-
Resolution: Fixed
-
P5
-
9
-
b170
-
Not verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8180705 | 10 | Paul Sandoz | P5 | Resolved | Fixed | b09 |
JDK-8180554 | 9.0.4 | Paul Sandoz | P5 | Resolved | Fixed | b01 |
Javadoc of MethodHandles.Lookup::bind describes its relation to the MethodHandle::bindTo. Specifically, it says
(Note that {@code bindTo} does not preserve variable arity.)
JDK-8177146 introduced another difference: in the example below 'bind' throws IllegalAccessException but 'bindTo' throws ClassCastException.
That should be noted in the Javadoc.
Example:
=================================
public class B extends A {
public static void main(String[] args) throws Throwable {
// throws IAE
MethodHandle bound2 = lookup().bind(new A() , "m", MethodType.methodType(void.class));
// throws CCE
lookup().findVirtual(A.class, "m", MethodType.methodType(void.class))
.bindTo(new A());
}
}
package pkg;
public class A {
protected void m() { }
}
=================================
(Note that {@code bindTo} does not preserve variable arity.)
That should be noted in the Javadoc.
Example:
=================================
public class B extends A {
public static void main(String[] args) throws Throwable {
// throws IAE
MethodHandle bound2 = lookup().bind(new A() , "m", MethodType.methodType(void.class));
// throws CCE
lookup().findVirtual(A.class, "m", MethodType.methodType(void.class))
.bindTo(new A());
}
}
package pkg;
public class A {
protected void m() { }
}
=================================
- backported by
-
JDK-8180554 Javadoc of MethodHandles.Lookup::bind should note the difference from MethodHandle::bindTo
-
- Resolved
-
-
JDK-8180705 Javadoc of MethodHandles.Lookup::bind should note the difference from MethodHandle::bindTo
-
- Resolved
-
- relates to
-
JDK-8177146 MethodHandles.Lookup::bind allows illegal protected access
-
- Closed
-