JDK-8046977 : ClassCastException: typing information needed for method reference bridging not preserved
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 8,9
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2014-06-16
  • Updated: 2015-06-04
  • Resolved: 2015-01-20
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 9
9 b48Fixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
The following test fails with a CCE:

public class MethodReferenceTestPrivateTypeConversion {

    interface ISi { int m(Short a); }
    
    public static void main(String[] args) {
      (new MethodReferenceTestPrivateTypeConversion()).testUnboxObjectToNumberWiden();
    }

    public void testUnboxObjectToNumberWiden() {
        ISi q = (new E<Short>())::xI;
        q.m((short)77);
    }
    
    class E<T> {
        private T xI(T t) { return t; }
    }
}

The <Short> info is lost and the type of the result (before conversion to the functional interface type) is needed.

Maurizio suggests that something like preserving the type computed by Attr into the JCMemberReference tree should be done.

This problem exists before and after the change from reference bridging to reference to lambda conversion for 8037404 et. al.

Comments
https://bugs.openjdk.java.net/browse/JDK-8065303 is a duplicate of this, The patch here passes that test too.
30-12-2014

Maurizio, can I grab this one ? I have a preliminary fix under test
30-12-2014