compilation fails with 'no enclosing instance' error
Alex Buckley
alex.buckley at oracle.com
Wed Feb 12 18:20:21 PST 2014
Regression. MyImpl inherits the instance method foo(Object) from Impl,
and foo(o) should invoke the inherited method. At least javac is
recognizing that the type Impl is an important source of truth.
The foo(Object) method in base.BaseImpl is irrelevant because, having
package access, it's not inherited by Impl.
Alex
On 2/12/2014 5:49 PM, Liam Miller-Cushon wrote:
> Hi,
>
> I discovered a JDK8-b128 compilation error that does not occur with JDK7:
>
> === base/BaseImpl.java ===
> package base;
>
> public class BaseImpl {
> static void foo(Object o) {}
> }
> ===
>
> === Test.java ===
> class Impl extends base.BaseImpl {
> public void foo(Object o) {}
> }
>
> class MyImpl extends Impl {
> public void m(Object o) {
> foo(o);
> }
> }
> ===
>
> $ javac base/BaseImpl.java Test.java
> Test.java:7: error: no enclosing instance of type Impl is in scope
> foo(o);
> ^
>
> Is this a deliberate change, or a regression? If it's deliberate, the
> error message is not very clear.
More information about the compiler-dev
mailing list