Compiler creates broken classfiles although errors are shown in output

Jan Lahoda jan.lahoda at oracle.com
Mon Feb 15 19:03:01 UTC 2016


Hi Sven,

I tried the example with:
$ javac -fullversion
javac full version "1.8.0_40-b25"

And it produced:
$ javac  Client.java
Client.java:7: error: cannot access I
        new A().m();
               ^
   class file for p1.I not found
1 error

No classfile was written.

With:
$ javac -fullversion
javac full version "1.7.0_45-b35"

$ javac  Client.java

produced no errors, and written a (correct as far as I can tell) 
classfile (equivalent to a classfile written when I.class is available).

Do you have a testcase where javac produces an error, but writes an 
(incorrect) classfile?

Thanks,
     Jan

On 15.2.2016 17:02, Sven Reimers wrote:
> 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 intohttps://bugs.openjdk.java.net/browse/JDK-8145208
>     <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
>      >
>


More information about the compiler-dev mailing list