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

Static import error message might be improved

XMLWordPrintable

    • x86
    • windows_nt

      FULL PRODUCT VERSION :
      E:\prep\src>java -version
      java version "1.5.0_05"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_05-b05)
      Java HotSpot(TM) Client VM (build 1.5.0_05-b05, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Windows NT

      A DESCRIPTION OF THE PROBLEM :
      there is a class A where the package stattement is

      package Use.Examples;

      there is a class B which uses static import in the following way.

      import static Use.Examples.*

      When we try to compile B.java the following error message is displayed.

      E:\prep\src>javac -d E:\prep\build B.java
      B.java:2: package Use does not exist
      import static Use.Examples.*;

      But package Use exists.
                        
      Ideally speaking it should display the following 4 lines as error message.
      "Use.Examples" is not a class and import staic is being used in a wrong way.
      Correct way of using import static is
      import static pack1.pckg2.pckg3....classname.*;


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :

      //A.java
      package Use.Examples;

      public class A
      {
      public static int i=10;
      }


      //B.java

      import static Use.Examples.*;
      //import Use.Temp.A.*;

      public class B
      {
      }

      Compile A.java
      Compile B.java
      At the time B.jva is compiled wrong error message is shown;

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      "Use.Examples" is not a class and import staic is being used in a wrong way.
      Correct way of using import static is
      import static pack1.pckg2.pckg3....classname.*;

      ACTUAL -
      E:\prep\src>javac -d E:\prep\build B.java
      B.java:2: package Use does not exist
      import static Use.Examples.*;


      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      E:\prep\src>javac -d E:\prep\build B.java
      B.java:2: package Use does not exist
      import static Use.Examples.*;


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      //A.java
      package Use.Examples;

      public class A
      {
      public static int i=10;
      }


      //B.java

      import static Use.Examples.*;
      //import Use.Temp.A.*;

      public class B
      {
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      No...........

            Unassigned Unassigned
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: