FULL PRODUCT VERSION :
java version "1.6.0_25"
Java(TM) SE Runtime Environment (build 1.6.0_25-b06)
Java HotSpot(TM) Client VM (build 20.0-b11, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
Assuming we have the following 3 classes:
1. EnumInterface .java:
public interface EnumInterface {
public void doSomething();
}
2. EnumImplements .java
public enum EnumImplements implements EnumInterface {
A1 {
@Override
public void doSomething() {
}
};
}
3. Main.java
public class Main {
public static void main(String[] args) {
EnumImplements ei = EnumImplements.A1;
ei.doSomething();
}
}
Now, if we compile Main.java, we get::
Main.java:6: cannot find symbol
symbol : method doSomething()
location: class EnumImplements
ei.doSomething();
^
1 error
But if we compile EnumImplements.java first, and than Main.java (I.e. 2 javac commands), the compilation succeeds.
The workaround we found was to declare the interface method as abstract in EnumImplements.java:
public enum EnumImplements implements EnumInterface {
A1 {
@Override
public void doSomething() {
}
};
public abstract void doSomething();
}
REPRODUCIBILITY :
This bug can be reproduced always.
java version "1.6.0_25"
Java(TM) SE Runtime Environment (build 1.6.0_25-b06)
Java HotSpot(TM) Client VM (build 20.0-b11, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
Assuming we have the following 3 classes:
1. EnumInterface .java:
public interface EnumInterface {
public void doSomething();
}
2. EnumImplements .java
public enum EnumImplements implements EnumInterface {
A1 {
@Override
public void doSomething() {
}
};
}
3. Main.java
public class Main {
public static void main(String[] args) {
EnumImplements ei = EnumImplements.A1;
ei.doSomething();
}
}
Now, if we compile Main.java, we get::
Main.java:6: cannot find symbol
symbol : method doSomething()
location: class EnumImplements
ei.doSomething();
^
1 error
But if we compile EnumImplements.java first, and than Main.java (I.e. 2 javac commands), the compilation succeeds.
The workaround we found was to declare the interface method as abstract in EnumImplements.java:
public enum EnumImplements implements EnumInterface {
A1 {
@Override
public void doSomething() {
}
};
public abstract void doSomething();
}
REPRODUCIBILITY :
This bug can be reproduced always.
- duplicates
-
JDK-6724345 incorrect method resolution for enum classes entered as source files
-
- Closed
-