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

Compilation depends on order of source files with class BHandler

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 9
    • tools
    • x86_64
    • linux

      FULL PRODUCT VERSION :
      java version "1.9.0-ea"
      Java(TM) SE Runtime Environment (build 1.9.0-ea-b76)
      Java HotSpot(TM) 64-Bit Server VM (build 1.9.0-ea-b76, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Linux x86_64

      A DESCRIPTION OF THE PROBLEM :
      The fix for JDK-7101822 (Compiling depends on order of imports) [1][2] introduced a bug that makes compilation depend on the order of source files passed to javac.

      I already reported a similar issue as JI-9023253. I discovered another instance with a different repro, so I'm including the second test case here.

      [1] http://hg.openjdk.java.net/jdk9/dev/langtools/rev/9d2192f36e53
      [2] https://bugs.openjdk.java.net/browse/JDK-7101822

      REGRESSION. Last worked in version 8u51

      ADDITIONAL REGRESSION INFORMATION:
      java version "1.8.0_51"
      Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
      Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode)

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compiling the included test program succeeds or fails depending on the order of sources passed to javac.

      $ javac pkg/A.java pkg/B.java pkg/C.java
      # compiles successfully

      $ javac pkg/C.java pkg/B.java pkg/A.java
      # fails to compile


      pkg/B.java:4: error: cannot find symbol
        public interface BHandler extends Handler {}
                                          ^
        symbol: class Handler
        location: class B
      1 error


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I expected compilation to not depend on the order of sources.
      ACTUAL -
      Compilation depended on the order of sources.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      pkg/B.java:4: error: cannot find symbol
        public interface BHandler extends Handler {}
                                          ^
        symbol: class Handler
        location: class B
      1 error


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      === pkg/A.java ===
      package pkg;

      public class A {
        public interface Handler {}
      }
      === pkg/B.java ===
      package pkg;

      public class B extends A {
        public interface BHandler extends Handler {}
      }
      === pkg/C.java ===
      package pkg;

      import pkg.B.BHandler;

      public class C implements BHandler {}
      ===
      ---------- END SOURCE ----------

        1. A.java
          0.1 kB
        2. B.java
          0.1 kB
        3. C.java
          0.1 kB

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: