-
Bug
-
Resolution: Fixed
-
P1
-
5.0, 6
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
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
- duplicates
-
JDK-6307721 static import bug with more than 2 imports of the same name
-
- Closed
-
- relates to
-
JDK-6225935 "import static" accessibility rules for symbols different for no reason
-
- Closed
-