Call to defender method with missing return keyword hangs the JVM

Robert Field robert.field at oracle.com
Thu Dec 15 11:12:31 PST 2011


Maurizio has fixed this bug in the most recent push.  It now gives:

% ~/work/lambda/build/solaris-i586/j2sdk-image/bin/javac TestDefender.java
TestDefender.java:7: error: missing return statement
                 String sayHi() default { sayHi(this); }
                                                       ^
1 error

And it works fine with the return (where "j2sdk-image" is actually 
"<lambda_dir>/build/<platform>/j2sdk-image" ; and "defender-prototype" 
is wherever that repo is):

% j2sdk-image/bin/javac TestDefender.java
% j2sdk-image/bin/java -cp 
defender-prototype/distrib/jsr335-agent.jar:defender-prototype/lib/asm-4.0.jar 
jsr335.agent.Main -d td --jdk j2sdk-image TestDefender*.class
% cd td
% j2sdk-image/bin/java TestDefender
Hello from TestDefender$AImpl at 1d9c3e7



-Robert



On 12/14/11 18:54, Robert Field wrote:
> 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