Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8046977

ClassCastException: typing information needed for method reference bridging not preserved

XMLWordPrintable

    • b48
    • generic
    • generic
    • Verified

        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.

              sadayapalam Srikanth Adayapalam (Inactive)
              rfield Robert Field (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: