Compiler creates broken classfiles although errors are shown in output
Sven Reimers
sven.reimers at gmail.com
Mon Feb 15 16:02:00 UTC 2016
There is an example in here
http://www.oracle.com/technetwork/java/javase/8-compatibility-guide-2156366.html
Area: Tools / javac
Synopsis
Interfaces need to be present when compiling against their implementations
Description
When compiling a class against another class implementing an interface
which is defined in yet another class file, such class file (where
interface is defined) must be available in the class path 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
If this does not reproduce the problem, I will try to reduce our code sample
Thanks
Sven
Hi Sven,
Would you have a testcase on which this can be seen?
Thanks,
Jan
On 15.2.2016 15:34, Sven Reimers wrote:
>
> Hi,
>
> I just ran into https://bugs.openjdk.java.net/browse/JDK-8145208
>
> The main problem is not to fix the error, but our continuous
> integration is not creating breaking builds, so the error can get
> unnoticed into builds and fails at runtime.
>
> Any idea if this can be fixed in an upcoming jdk 8u release?
>
> Any idea how to make the build break in this case?
>
> Thanks for your help
>
> -Sven
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20160215/0e157150/attachment.html>
More information about the compiler-dev
mailing list