Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8061598

Missing release note: Interfaces need to be present when compiling against their implementations

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 8u40
    • 8
    • docs

    Description

      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


      Attachments

        Activity

          People

            dgollapudi Devika Gollapudi (Inactive)
            mcimadamore Maurizio Cimadamore
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: