FULL PRODUCT VERSION :
java version "1.8.0"
Java(TM) SE Runtime Environment (build 1.8.0-b132)
Java HotSpot(TM) 64-Bit Server VM (build 25.0-b70, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
3.4.69-desktop-1.mga2 #1 SMP Sat Nov 16 17:32:02 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
When a class implements an interface containing a default method, and that interface in turn has a superinterface with a static method declared with the same signature as the default method, trying to call the default method from the class generates the error: "no enclosing instance of type [ ] is in scope". If instead adding the "this"-keyword before the method call there is no error.
ADDITIONAL REGRESSION INFORMATION:
The test case compiles with javac 1.8.0-ea.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile the provided test case.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Compilation was expected to pass.
ACTUAL -
Compilation fails.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Test.java:19: error: no enclosing instance of type B is in scope
m();
^
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class Test {
interface A {
static void m() { }
}
interface B extends A {
default void m() { }
default void m2() { m(); }
}
class Inner implements B {
public void method() {
m();
// These two generate no error
// m2();
// this.m();
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Add the keyword "this" before the method access.
java version "1.8.0"
Java(TM) SE Runtime Environment (build 1.8.0-b132)
Java HotSpot(TM) 64-Bit Server VM (build 25.0-b70, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
3.4.69-desktop-1.mga2 #1 SMP Sat Nov 16 17:32:02 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
When a class implements an interface containing a default method, and that interface in turn has a superinterface with a static method declared with the same signature as the default method, trying to call the default method from the class generates the error: "no enclosing instance of type [ ] is in scope". If instead adding the "this"-keyword before the method call there is no error.
ADDITIONAL REGRESSION INFORMATION:
The test case compiles with javac 1.8.0-ea.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile the provided test case.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Compilation was expected to pass.
ACTUAL -
Compilation fails.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Test.java:19: error: no enclosing instance of type B is in scope
m();
^
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class Test {
interface A {
static void m() { }
}
interface B extends A {
default void m() { }
default void m2() { m(); }
}
class Inner implements B {
public void method() {
m();
// These two generate no error
// m2();
// this.m();
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Add the keyword "this" before the method access.