Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 280819

Summary: [quick fix] Wrong quick fixes when accessing protected field in subclass in different package
Product: [Eclipse Project] JDT Reporter: Bassam Jabbour <bassam.jabbour>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: RESOLVED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert, Olivier_Thomann
Version: 3.5   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Bassam Jabbour CLA 2009-06-18 15:07:09 EDT
When trying to access protected fields of base class objects in subclasses in another package, the compiler rightfully signals an error, but the proposed Quickfix, in this case changing the field visibility to protected, doesn't help; maybe it should suggest changing visibility to public?
Comment 1 Olivier Thomann CLA 2009-06-18 15:46:49 EDT
Moving to JDT/UI.
Could you please provide an example that fails?
Comment 2 Bassam Jabbour CLA 2009-06-19 06:50:57 EDT
[file 1]
package a;

public class Base {
    protected int myField;
}

[file 2]
package b;
import a.Base;

public class Child extends Base {
    public void aMethod(Base parent) {
        System.out.println (parent.myField);
    }
}

This example rightfully fails to compile, but the proposed Quickfix is "change visibility of myField to protected", which is already the case.
Comment 3 Dani Megert CLA 2009-06-22 04:53:15 EDT

*** This bug has been marked as a duplicate of bug 65876 ***