Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 269478 - Marking a method 'protected' gives error when accessing in subclass
Summary: Marking a method 'protected' gives error when accessing in subclass
Status: RESOLVED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.5   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-03-20 05:33 EDT by Prakash Rangaraj CLA
Modified: 2009-03-20 06:13 EDT (History)
1 user (show)

See Also:


Attachments
Project with the classes. Error is on (1.78 KB, application/octet-stream)
2009-03-20 05:33 EDT, Prakash Rangaraj CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Prakash Rangaraj CLA 2009-03-20 05:33:09 EDT
Created attachment 129429 [details]
Project with the classes. Error is on 

Build ID: I20090313-0100

Steps To Reproduce:

pkg1 ->Base class. Declares a protected abstract method
pkg2 ->Derived extends Base. defines the method and uses that. 

While calling the method from Derived, I get an error saying its not accessible. Further, the quick fix suggests to make the method protected in Base (which is already protected)
Comment 1 Philipe Mulet CLA 2009-03-20 06:13:30 EDT
This is expected behavior. A protected member can only be used for receiver type (or one of its subtype). This is why implicit access is allowed, but not via an AbstractBase.


========
AbstractBase other = null;
getSomething(arg); // no error
other.getSomething(arg); // error here. Also see the quick fix

ConcreteDerived other2 = ...;
other2.getSomething(null); // allowed as well.