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

Import order can cause compilation errors

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 6u16
    • Fix Version/s: None
    • Component/s: tools
    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_xp

      Description

      FULL PRODUCT VERSION :
      java version "1.6.0_16"
      Java(TM) SE Runtime Environment (build 1.6.0_16-b01)
      Java HotSpot(TM) Client VM (build 14.2-b01, mixed mode, sharing)


      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      The javac compiler reports an error while trying to compile the attached code (which seems to be correct). The code is compiled just fine by the Java compiler used by Eclipse IDE and can be fixed by simply changing the order of the import.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Attempt to compile the attached code will cause compilations errors (the import java.util.Date can be replaced by any other class, assuming it is not in the same package):



      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The code should compile without any errors. (it is compiled by the compiler used by Eclipse IDE)
      ACTUAL -
      The code does not compile.




      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      \src\a\A.java:8: cannot find symbol
      symbol : class Date
      location: class a.A
      public static class InnerB extends Date {

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package a;

      import a.A.InnerB.InterfaceB;
      import java.util.Date;

      public class A {

        public static class InnerB extends Date {

      public interface InterfaceB {
      }
      }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Any of the following will fix the problem:
      *changing the order of the imports
      *changing "extends Date" to "extends java.util.Date"

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Imported:
              Indexed: