JDK-7065524 : Compiler error - java.lang.IllegalArgumentException when compiling some method references code
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 8
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2011-07-11
  • Updated: 2011-07-12
  • Resolved: 2011-07-12
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8
8Resolved
Related Reports
Duplicate :  
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.