Call to defender method with missing return keyword hangs the JVM

Robert Field Robert.Field at oracle.com
Wed Dec 14 18:54:40 PST 2011


On 12/14/11 3: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.

I don't believe this is the current plan.  I think this is a straight-up 
compiler bug.

Thanks for reporting this (no it isn't known)

-Robert

>
> 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