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

Compiler fails to produce error message with ODD number of import static

    Details

    • Subcomponent:
    • Introduced In Version:
      5.0
    • Resolved In Build:
      b75
    • CPU:
      x86
    • OS:
      windows_2000, windows_xp
    • Verification:
      Verified

      Description

      FULL PRODUCT VERSION :
      java version "1.5.0_01"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08)
      Java HotSpot(TM) Client VM (build 1.5.0_01-b08, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP Professional version 2002 Service Pack 2

      A DESCRIPTION OF THE PROBLEM :
      When importing (static) constants with the SAME name from three classes, the complier DOES NOT procuce an error message.
      If one imports from TWO classes, the error is produced.

      In fact, importing (static) from an EVEN number of classes produces an error message, as expected, but importing (static) from an ODD number of classes DOES not produce error message.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile and execute the following class:

      import static javax.swing.JLabel.*;
      import static java.awt.FlowLayout.*;
      import static javax.swing.JLabel.*;

      public class Estatico4 {
        
        public static void main(String[] s) {
          System.out.println(CENTER);
        }

      }

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I would expect a compilation error message. However, it compiles an the execution produces 0, wich is the value of the constante CENTER from the JLabel class (past class imported).
      ACTUAL -
      The program compiles and executes writing 0 on teh console.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      This class writes 0 (no compiler error message):

      import static javax.swing.JLabel.*;
      import static java.awt.FlowLayout.*;
      import static javax.swing.JLabel.*;

      public class Estatico4 {
        
        public static void main(String[] s) {
          System.out.println(CENTER);
        }

      }

      This class writes 1 (no compiler error message):

      import static java.awt.FlowLayout.*;
      import static javax.swing.JLabel.*;
      import static java.awt.FlowLayout.*;

      public class Estatico3 {
        
        public static void main(String[] s) {
          System.out.println(CENTER);
        }

      }


      ---------- END SOURCE ----------
      ###@###.### 2005-1-07 00:09:44 GMT

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                ahe Peter Ahe
                Reporter:
                rmandalasunw Ranjith Mandala (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: