-
Bug
-
Resolution: Fixed
-
P2
-
1.3.0, 1.4.0
-
beta2
-
generic
-
generic, solaris_7
The following program when compiled with -target 1.2 should print
Initializing A.
but it prints
Initializing A.
Initializing B.
As this is a gratuitous incompatibility with the previous (correct) runtime behavior when the program is compiled with -target 1.1, this bug must be fixed in order to change the default to -target 1.2 for Merlin javac.
Note that according to the JVM specification the invokestatic instruction is only supposed to initialize the class which declared the resolved method, which in this case is A. There is nothing in the execution of this program that should cause B to be initialized.
1
2 class A {
3 static void foo() {}
4 static { System.out.println("Initializing A."); }
5 }
6
7 class B extends A {
8 static { System.out.println("Initializing B."); }
9 }
10
11 class Test {
12 public static void main(String[] args) {
13 B.foo();
14 }
15 }
16
Initializing A.
but it prints
Initializing A.
Initializing B.
As this is a gratuitous incompatibility with the previous (correct) runtime behavior when the program is compiled with -target 1.1, this bug must be fixed in order to change the default to -target 1.2 for Merlin javac.
Note that according to the JVM specification the invokestatic instruction is only supposed to initialize the class which declared the resolved method, which in this case is A. There is nothing in the execution of this program that should cause B to be initialized.
1
2 class A {
3 static void foo() {}
4 static { System.out.println("Initializing A."); }
5 }
6
7 class B extends A {
8 static { System.out.println("Initializing B."); }
9 }
10
11 class Test {
12 public static void main(String[] args) {
13 B.foo();
14 }
15 }
16
- duplicates
-
JDK-4424152 Virtual Machine initializes too many classes
- Closed
- relates to
-
JDK-4393930 Default for -target should be 1.2 in Merlin
- Closed