JDK-6775192 : Abstract method accessed directly on super overrided method w. generic params
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 6u10
  • Priority: P4
  • Status: Closed
  • Resolution: Cannot Reproduce
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2008-11-22
  • Updated: 2010-07-29
  • Resolved: 2010-07-29
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7Resolved
Related Reports
Relates :  
Relates :  
Description
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.

Comments
EVALUATION Fixed as a side-effect of 6400189
29-07-2010

EVALUATION Essentially a duplicate of 6400189. Javac chooses AMgr.methodA(AVO<?>) as the most specific between AMgr.methodAB(AVO<?>) and CMgr.methodAB(AVO) (which is wrong, javac shouldn't even apply overload resolution to overriding methods) - basically the overriding method is not considered. This situation is determined as a result of a bug in the Resolve.isAccessible routine; overridden method shouldn't be considered accessible from the overriding class.
24-11-2008