-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
6u26
-
x86
-
windows_xp
FULL PRODUCT VERSION :
javac -version output:
javac 1.7.0-internal
javac 1.6.0_26
ADDITIONAL OS VERSION INFORMATION :
Irrelevant (tested on Mac OS X using openJDK7's javac, Soylatte 1.6 javac, and Apple VM's javac which is the same as Oracle's javac, as well as ecj 3.6)
EXTRA RELEVANT SYSTEM CONFIGURATION :
Irrelevant.
A DESCRIPTION OF THE PROBLEM :
If an enum value defines internal methods, then any code in those methods cannot reference private methods defined at the enum level, if this enum value overloads that method itself. The snippet should make things clear.
javac 6 and javac 7 both choke on this and act as if the targetted method doesn't exist at all. ecj does compile the snippet just fine as the JLS suggests it should.
The fix is for javac to compile the snippet without warning or error.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
run: javac JavacEnumFail.java
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No errors, no warnings, compiled source file.
ACTUAL -
The following error on javac 7:
JavacEnumFail.java:4: error: method bar in enum <anonymous JavacEnumFail> cannot be applied to given types;
bar("");
^
required: no arguments
found: String
reason: actual and formal argument lists differ in length
1 error
Same error minus the 'reason/required/found' lines at the end for javac 6.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
See 'actual result'.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public enum JavacEnumFail {
A {
public void foo() {
bar("");
}
// If you delete the next line, bug does not occur.
void bar() {}
};
// If you make this method package private, bug does not occur.
private static void bar(String x) {}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Make the target method package private.
javac -version output:
javac 1.7.0-internal
javac 1.6.0_26
ADDITIONAL OS VERSION INFORMATION :
Irrelevant (tested on Mac OS X using openJDK7's javac, Soylatte 1.6 javac, and Apple VM's javac which is the same as Oracle's javac, as well as ecj 3.6)
EXTRA RELEVANT SYSTEM CONFIGURATION :
Irrelevant.
A DESCRIPTION OF THE PROBLEM :
If an enum value defines internal methods, then any code in those methods cannot reference private methods defined at the enum level, if this enum value overloads that method itself. The snippet should make things clear.
javac 6 and javac 7 both choke on this and act as if the targetted method doesn't exist at all. ecj does compile the snippet just fine as the JLS suggests it should.
The fix is for javac to compile the snippet without warning or error.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
run: javac JavacEnumFail.java
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No errors, no warnings, compiled source file.
ACTUAL -
The following error on javac 7:
JavacEnumFail.java:4: error: method bar in enum <anonymous JavacEnumFail> cannot be applied to given types;
bar("");
^
required: no arguments
found: String
reason: actual and formal argument lists differ in length
1 error
Same error minus the 'reason/required/found' lines at the end for javac 6.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
See 'actual result'.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public enum JavacEnumFail {
A {
public void foo() {
bar("");
}
// If you delete the next line, bug does not occur.
void bar() {}
};
// If you make this method package private, bug does not occur.
private static void bar(String x) {}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Make the target method package private.