-
Bug
-
Resolution: Fixed
-
P2
-
7, 7u4
-
b10
-
generic, x86
-
generic, linux, os_x
-
Not verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2212408 | 8 | John Rose | P3 | Resolved | Fixed | b01 |
The javadoc specification for the MethodHandleProxies.asInterfaceInstance method states:
"The interface must be public. No additional access checks are performed."
However, this method still accepts private/default-access/protected *nested* interfaces.
Minimized test:
===============
--- Test.java ---
import java.lang.invoke.*;
import static java.lang.invoke.MethodType.*;
import static java.lang.invoke.MethodHandles.*;
import static java.lang.invoke.MethodHandleProxies.*;
public class Test {
/*protected*/ /*private*/ interface PrivateIntf {
void m();
}
public static class C {
public static void m() {}
}
public static void main(String argv[]) throws Throwable {
MethodHandle mh = lookup().findStatic(
C.class, "m", methodType(void.class));
PrivateIntf intf = asInterfaceInstance(PrivateIntf.class, mh);
}
}
--- Test.java ---
Minimized test output:
======================
$ java -showversion -verify Test
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b145)
Java HotSpot(TM) Server VM (build 21.0-b15, mixed mode)
"The interface must be public. No additional access checks are performed."
However, this method still accepts private/default-access/protected *nested* interfaces.
Minimized test:
===============
--- Test.java ---
import java.lang.invoke.*;
import static java.lang.invoke.MethodType.*;
import static java.lang.invoke.MethodHandles.*;
import static java.lang.invoke.MethodHandleProxies.*;
public class Test {
/*protected*/ /*private*/ interface PrivateIntf {
void m();
}
public static class C {
public static void m() {}
}
public static void main(String argv[]) throws Throwable {
MethodHandle mh = lookup().findStatic(
C.class, "m", methodType(void.class));
PrivateIntf intf = asInterfaceInstance(PrivateIntf.class, mh);
}
}
--- Test.java ---
Minimized test output:
======================
$ java -showversion -verify Test
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b145)
Java HotSpot(TM) Server VM (build 21.0-b15, mixed mode)
- backported by
-
JDK-2212408 (JSR-292) MethodHandleProxies.asInterfaceInstance() accepts private/protected nested interfaces
- Resolved
- duplicates
-
JDK-7065524 Compiler error - java.lang.IllegalArgumentException when compiling some method references code
- Closed
-
JDK-7142431 (invoke) Test use private interface for testing MethodHandleProxies.asInterfaceInstance
- Closed
-
JDK-7148356 MethodHandleProxies does not correctly identify single-method interfaces
- Closed
- relates to
-
JDK-7058630 JSR 292 method handle proxy violates contract for Object methods
- Closed