-
Bug
-
Resolution: Cannot Reproduce
-
P2
-
None
-
5.0u12
-
x86
-
linux
An attempt to compile the following code (to be placed in Main.java):
-----------------------------------------------
public class Main {
public static void main(String[] args) {
E.A.test();
}
}
enum E implements X{
A {
public void test() {}
}
}
interface X {
public void test();
}
-----------------------------------------------
Fails with this error:
Main.java:4: cannot find symbol
symbol : method test()
location: class E
E.A.test();
^
1 error
If the Main class is moved at the end of the file, it can be compiled fine.
The same problem can be reproduced when Main, E and X are in individual files. The problem occurs when the compiler is invoked as:
javac Main.java E.java X.java
but does not appear when the compiler is invoked as:
javac E.java X.java Main.java
Tested on:
>java -version
java version "1.5.0_12"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_12-b04)
Java HotSpot(TM) Server VM (build 1.5.0_12-b04, mixed mode)
>java -version
java version "1.6.0_05-ea"
Java(TM) SE Runtime Environment (build 1.6.0_05-ea-b04)
Java HotSpot(TM) Tiered VM (build 1.6.0_05-ea-b04, mixed mode)
See also the original NetBeans issue:
http://www.netbeans.org/issues/show_bug.cgi?id=121458
-----------------------------------------------
public class Main {
public static void main(String[] args) {
E.A.test();
}
}
enum E implements X{
A {
public void test() {}
}
}
interface X {
public void test();
}
-----------------------------------------------
Fails with this error:
Main.java:4: cannot find symbol
symbol : method test()
location: class E
E.A.test();
^
1 error
If the Main class is moved at the end of the file, it can be compiled fine.
The same problem can be reproduced when Main, E and X are in individual files. The problem occurs when the compiler is invoked as:
javac Main.java E.java X.java
but does not appear when the compiler is invoked as:
javac E.java X.java Main.java
Tested on:
>java -version
java version "1.5.0_12"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_12-b04)
Java HotSpot(TM) Server VM (build 1.5.0_12-b04, mixed mode)
>java -version
java version "1.6.0_05-ea"
Java(TM) SE Runtime Environment (build 1.6.0_05-ea-b04)
Java HotSpot(TM) Tiered VM (build 1.6.0_05-ea-b04, mixed mode)
See also the original NetBeans issue:
http://www.netbeans.org/issues/show_bug.cgi?id=121458
- relates to
-
JDK-6724345 incorrect method resolution for enum classes entered as source files
-
- Closed
-