13

Take the code:

public class A {
    public static void main(String[] args) {
        new Thread((new I() {})::test);
    }

    interface I {
        private void test() {}
    }
}

And try to compile. I receive:

A.java:5: error: invalid method reference
        new Thread(((new I() {}))::test);
                   ^
  compiler message file broken: key=compiler.misc.cant.resolve.args arguments=method, test, , , {4}, {5}, {6}, {7}

Where compiler message file broken seems to be something incomprehensible. Is it a bug or I am missing something?

P.S. Submitted a bug: ID : 9052216

Andremoniy
  • 34,031
  • 20
  • 135
  • 241
  • 5
    this is obviously a bug and should be reported if already isn't. it should simple say something along the lines of `private method can not be accessed...` or `method is not visible/present` whatever – Eugene Jan 11 '18 at 20:29
  • 2
    Linked: https://stackoverflow.com/questions/48215297/interface-with-private-method-as-functional-interface#48215886 – MC Emperor Jan 11 '18 at 21:38

1 Answers1

9

Admitted as a bug by the Java Development Support:

https://bugs.openjdk.java.net/browse/JDK-8194997

Andremoniy
  • 34,031
  • 20
  • 135
  • 241