Using default implementation, I can compile Illegal Extending Class which is mistaking access modifiers or return-types.
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Wed Feb 8 07:10:16 PST 2012
Right - the check for compatible implementation is currently excluding
default methods - the reason is a flag mismatch - default methods are
not marked with ACC_ABSTRACT anymore - as a result those compiler checks
need to be updated to check for ACC_DEFENDER instead.
I will push a fix soon.
Maurizio
On 08/02/12 14:21, bitter_fox wrote:
> Hi,
> Using default implementation, I can compile Illegal Extending Class which
> is mistaking access modifiers or return-types.
>
> Compiler is the newest binary snapshot.
>
> For instance:
> interface I
> {
> void method() default {} // method is pubilc
> }
>
> class C1
> {
> void method() {} // method is package private
> }
>
> class C2 extends C1 implements I
> {
> // this would be illegal, but I can compile this.
> }
>
> I i = new C2();
> i.method(); // this calling causes IllegalAccessError
>
> The other pattern:
> interface I
> {
> String method() default
> {
> return "str";
> }
> }
>
> class C1
> {
> public Integer method()
> {
> return 0;
> }
> }
>
> class C2 extends C1 implements I
> {
> // this extending would be illegal
> }
>
> C2 c2 = new C2();
> C1 c1 = c2;
> I i = c2;
>
> System.out.println(c2.method()); // 0
> System.out.println(c1.method()); // 0
> System.out.println(i.method()); // str
>
> Was this already known?
>
> Regards,
> bitter_fox
>
More information about the lambda-dev
mailing list