JDK-8065303 : Complex method reference conversion fails unbox case
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 8u40
  • Priority: P4
  • Status: Resolved
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2014-11-18
  • Updated: 2015-01-20
  • 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
9Resolved
Related Reports
Duplicate :  
Description
Modifying this test to make the method private fails --

import org.testng.annotations.Test;

import static org.testng.Assert.assertEquals;

/**
 * @author Robert Field
 */

@Test
public class MethodReferenceTestTypeConversion {

    class MethodReferenceTestTypeConversion_E<T> {
        private T xI(T t) { return t; }
    }

    interface ISi { int m(Short a); }

    interface ICc { char m(Character a); }

    public void testUnboxObjectToNumberWiden() {
        ISi q = (new MethodReferenceTestTypeConversion_E<Short>())::xI;
        assertEquals(q.m((short)77), (short)77);
    }

    public void testUnboxObjectToChar() {
        ICc q = (new MethodReferenceTestTypeConversion_E<Character>())::xI;
        assertEquals(q.m('@'), '@');
    }

}

Comments
I have verified the patch under consideration for https://bugs.openjdk.java.net/browse/JDK-8046977 fixes this problem, I'll also include the test from here in that patch for regression test purposes.
20-01-2015

The reason public -> private triggers the failure is because making xI private results in com.sun.tools.javac.comp.LambdaToMethod.LambdaAnalyzerPreprocessor.ReferenceTranslationContext#needsConversionToLambda answering true and thereby hitting the landmine.
20-01-2015

I believe this is the same as https://bugs.openjdk.java.net/browse/JDK-8046977. I have a patch there that is under review that handles this snippet properly.
30-12-2014