Possible bug with defender method that calls itself
Per Rovegård
per at rovegard.se
Fri Dec 16 03:56:52 PST 2011
On Fri, Dec 16, 2011 at 12:15 PM, Maurizio Cimadamore
<maurizio.cimadamore at oracle.com> wrote:
> The program should give a StackTraceException - however as pointed out by
> Robert and Brian, VM support for extension methods is not in place yet -
> there are cases (like the one you posted yesterday) in which things seem to
> 'just' work, but that's mostly by accident. In the most general case you
> will get AbstractMethodErrror if you don't run the extensin method static
> weaver on your classes.
You're right - when I run the weaver on the classes I get a
StackOverflowError as expected!
How is it that some cases work "by accident" as you say? When I tried
to build the lambda source *without* defender-prototype in place the
build script stopped with an error. That's why I assumed that
defender-prototype weaving had been incorporated in some way.
-- Per
> On 16/12/11 08:24, Per Rovegård wrote:
>>
>> Hi,
>>
>> While testing defender methods, I wrote the following small program:
>>
>> public class TestDefender2 {
>> public static interface A {
>> String sayHi() default { return sayHi(); };
>> }
>>
>> public static class AImpl implements A { }
>>
>> public static void main(String[] args) throws Exception {
>> System.out.println(new AImpl().sayHi());
>> }
>> }
>>
>> How should the program behave? I would expect to get one of the following:
>> a) A compilation error, saying that I try to call an abstract method, or
>> b) A StackOverflowError at runtime resulting from infinite recursion.
>>
>> But it compiles successfully and when run it gives:
>>
>> $ ../lambda/build/linux-amd64/j2sdk-image/bin/java TestDefender2
>> Exception in thread "main" java.lang.AbstractMethodError:
>> TestDefender2$AImpl.sayHi()Ljava/lang/String;
>> at TestDefender2$A.sayHi(TestDefender2.java:3)
>> at TestDefender2.main(TestDefender2.java:9)
>>
>> Is this a bug?
>>
>> Br,
>> Per
>>
>
More information about the lambda-dev
mailing list