Call to defender method with missing return keyword hangs the JVM

Per Rovegård per at
Wed Dec 14 15:52:19 PST 2011


To test defender methods, I wrote the following tiny test program:

public class TestDefender {
        public static String sayHi(A a) {
                return "Hello from " + a;

        public static interface A {
                String sayHi() default { sayHi(this); }

        public static class AImpl implements A { }

        public static void main(String[] args) throws Exception {
                System.out.println(new AImpl().sayHi());

In the defender/default implementation of sayHi, I assumed that the
compiler would infer that a value needs to be returned (like with
closures). And the compiler indeed doesn't complain about the missing
"return" keyword.

But when I run the program, it simply hangs.

Is this a known bug?

Per Rovegård

More information about the lambda-dev mailing list