FULL PRODUCT VERSION :
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b18)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
javac fails to compile subclasses that attempt to call an unqualified private static method from their superclass. This only occurs if there is also a non-private method with the same name as the private static method declared in the superclass.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Attempt to compile the provided source using javac.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The code should compile.
ACTUAL -
The code fails to compile.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
src\xxx\StaticFail.java:10: error: method shadow in class StaticFail cannot be applied to given types;
shadow(false);
^
required: no arguments
found: boolean
reason: actual and formal argument lists differ in length
1 error
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class StaticFail {
private static void shadow(boolean misterBool) {}
public void shadow() {}
public static class FailImpl extends StaticFail {
public void abby() {
shadow(false);
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Declare static method as protected or change its name.
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b18)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
javac fails to compile subclasses that attempt to call an unqualified private static method from their superclass. This only occurs if there is also a non-private method with the same name as the private static method declared in the superclass.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Attempt to compile the provided source using javac.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The code should compile.
ACTUAL -
The code fails to compile.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
src\xxx\StaticFail.java:10: error: method shadow in class StaticFail cannot be applied to given types;
shadow(false);
^
required: no arguments
found: boolean
reason: actual and formal argument lists differ in length
1 error
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class StaticFail {
private static void shadow(boolean misterBool) {}
public void shadow() {}
public static class FailImpl extends StaticFail {
public void abby() {
shadow(false);
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Declare static method as protected or change its name.
- duplicates
-
JDK-6998594 anonymous class gets garbled view of private methods within scope
- Closed