Call to defender method with missing return keyword hangs the JVM

Brian Goetz brian.goetz at oracle.com
Wed Dec 14 18:23:55 PST 2011


There is currently no support for defenders in the VM, so I would expect this program to throw AbstractMethodError.

On Dec 14, 2011, at 6:52 PM, Per Rovegård wrote:

> Hi,
> 
> 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?
> 
> Br,
> Per Rovegård
> 



More information about the lambda-dev mailing list