-
Bug
-
Resolution: Fixed
-
P4
-
8
When compiling a class against another class implementing an interface which is defined in some classfile, such classfile must be available in the classpath used by javac during compilation. This is a new requirement as of JDK 8 - a failure to do so will result in a compilation error.
Example:
//Client.java
import p1.A;
class Client {
void test() {
new A.m();
}
}
//p1/A.java
package p1;
public class A implements I {
public void m() { }
}
//p1/I.java
package p1;
public interface I {
void m();
}
If neither p1/I.java nor p1/I.class are available when compiling Client.java, the following error will be displayed:
Client.java: error: cannot access I
new A().m();
^
class file for p1.I not found
Example:
//Client.java
import p1.A;
class Client {
void test() {
new A.m();
}
}
//p1/A.java
package p1;
public class A implements I {
public void m() { }
}
//p1/I.java
package p1;
public interface I {
void m();
}
If neither p1/I.java nor p1/I.class are available when compiling Client.java, the following error will be displayed:
Client.java: error: cannot access I
new A().m();
^
class file for p1.I not found