Description
When compiling the following code:
----------------------------------------
import java.lang.reflect.Method;
public class BridgeMethod {
interface K<T> {void m(T t);}
interface M {void m(String s);}
interface KM extends K<String>, M{} //generic substitution
private static void assertTrue(boolean cond) {
if (!cond)
throw new AssertionError();
}
static void bar(String s) {
System.out.println("BridgeMethod.bar(String) " + s);
}
public static void main(String[] args) {
KM km = BridgeMethod#bar(String); //<<<<<<<<<<<<<<<<<error occurs here
...
----------------------------------------
The following compiler error was encountered:
----------System.err:(13/756)----------
java.lang.IllegalArgumentException: not a single-method interface: BridgeMethod$KM
at java.lang.invoke.MethodHandleProxies.asInterfaceInstance(MethodHandleProxies.java:140)
at BridgeMethod.main(BridgeMethod.java:70)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.sun.javatest.regtest.MainAction$SameVMRunnable.run(MainAction.java:680)
at java.lang.Thread.run(Thread.java:722)
Where KM IS a SAM interface.
----------------------------------------
import java.lang.reflect.Method;
public class BridgeMethod {
interface K<T> {void m(T t);}
interface M {void m(String s);}
interface KM extends K<String>, M{} //generic substitution
private static void assertTrue(boolean cond) {
if (!cond)
throw new AssertionError();
}
static void bar(String s) {
System.out.println("BridgeMethod.bar(String) " + s);
}
public static void main(String[] args) {
KM km = BridgeMethod#bar(String); //<<<<<<<<<<<<<<<<<error occurs here
...
----------------------------------------
The following compiler error was encountered:
----------System.err:(13/756)----------
java.lang.IllegalArgumentException: not a single-method interface: BridgeMethod$KM
at java.lang.invoke.MethodHandleProxies.asInterfaceInstance(MethodHandleProxies.java:140)
at BridgeMethod.main(BridgeMethod.java:70)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.sun.javatest.regtest.MainAction$SameVMRunnable.run(MainAction.java:680)
at java.lang.Thread.run(Thread.java:722)
Where KM IS a SAM interface.
Attachments
Issue Links
- duplicates
-
JDK-7054590 (JSR-292) MethodHandleProxies.asInterfaceInstance() accepts private/protected nested interfaces
- Closed