FULL PRODUCT VERSION :
java version "1.6.0_10"
Java(TM) SE Runtime Environment (build 1.6.0_10-b33)
Java HotSpot(TM) Client VM (build 11.0-b15, mixed mode, sharing)
java version "1.5.0_16"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_16-b02)
Java HotSpot(TM) Client VM (build 1.5.0_16-b02, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Versione 5.1.2600]
(Italian)
A DESCRIPTION OF THE PROBLEM :
I found a wrong compile error "abstract method cannot be accessed directly" when calling on a superclass a method with a row parameter that overrides an abstract method with a generic parameter and default or public accessibility.
If the overridden method is declared protected, instead of public or default, no problem arises.
This particular situation can happen when trying to generify a class, leaving unchanged all existing subclasses.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Try to compile the supplied source code (each class in its own compilation unit).
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
All should compile fine.
Specifically, call to super.methodA(AVO) in CMgr.methodC() should be resolved as BMgr.methodA(AVO).
ACTUAL -
Compiler error in CMgr.methodC():
- abstract method methodA(AVO<?>) in AMgr cannot be accessed directly
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class AVO<Type> {
}
public abstract class AMgr {
public abstract void methodA(AVO<?> vo);
}
public abstract class BMgr extends AMgr {
@Override
public void methodA(AVO vo) {
}
}
public class CMgr extends BMgr {
public void methodC() {
super.methodA(new AVO()); //compile error
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Change AMgr.methodA(AVO<?>) to protected accessibility.
But that's not always possible, e.g. if some existing code call it from outside.