|
Quick Lists
|
|
Bug ID:
|
6724345
|
|
Votes
|
0
|
|
Synopsis
|
incorrect method resolution for enum classes entered as source files
|
|
Category
|
java:compiler
|
|
Reported Against
|
|
|
Release Fixed
|
7(b39)
|
|
State
|
10-Fix Delivered,
bug
|
|
Priority:
|
4-Low
|
|
Related Bugs
|
|
|
Submit Date
|
10-JUL-2008
|
|
Description
|
FULL PRODUCT VERSION :
java version "1.6.0_10-rc"
Java(TM) SE Runtime Environment (build 1.6.0_10-rc-b27)
Java HotSpot(TM) Client VM (build 11.0-b14, mixed mode)
A DESCRIPTION OF THE PROBLEM :
Compilation of the enclosed program is very sensitive to the order in which the source files are presented.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Unpack the sources and try
javac U.java
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Compiles successfully
ACTUAL -
Fails to compile
ERROR MESSAGES/STACK TRACES THAT OCCUR :
U.java:5: cannot find customer
customer : method i()
location: class E
E.V.i();
^
1 error
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
==> I.java <==
interface I {
void i();
}
==> E.java <==
enum E implements I {
V { public void i() { } };
// public abstract void i();
}
==> U.java <==
class U {
{
I i = E.V;
i.i();
E.V.i();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
running 'javac E.java && javac U.java' succeeds.
Uncommenting line 3 of E.java also works around the problem.
Posted Date : 2008-07-10 00:37:57.0
|
|
Work Around
|
N/A
|
|
Evaluation
|
This is a resolution bug due to the fact that javac doesn't check for superinterfaces method when resolving a method invoked on a receiver whose type is an enum type. In the submitted example we have that i() is invoked on the enum type E. Since abstract method checking is disabled, no such method is found in E. On the other hand, if we compile the enum first (or if we simply alter the order in which classes get compiled) the enum gets translated by javac into an abstract class, thus enabling abstract method checking as a side-effect. This explains why the program compiles only when a given compilation order is specified.
Posted Date : 2008-07-22 14:34:04.0
|
|
Comments
|
PLEASE NOTE: JDK6 is formerly known as Project Mustang
|
|
|
 |