Call to defender method with missing return keyword hangs the JVM

Per Rovegård per at rovegard.se
Wed Dec 14 23:23:36 PST 2011


That's indeed what happened with the binary snapshot in my first
attempt, so I proceeded to build from source to see if defender
support was implemented recently. But to do that I had to build
defender-prototype first, and in the end defender methods worked
transparently without manual weaving (is that the correct term?)
needed.

Per

On Thu, Dec 15, 2011 at 3:23 AM, Brian Goetz <brian.goetz at oracle.com> wrote:
> 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