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

Bug 531942

Summary: [refactoring] Pull Up Field changes the accessibility of the field
Product: [Eclipse Project] JDT Reporter: Jonhnanthan Oliveira <jonhnanthan>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3    
Version: 4.5.2   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard: stalebug

Description Jonhnanthan Oliveira CLA 2018-03-02 12:35:20 EST
Applying pull up field refactoring to move B.field to class A, increases the accessibility of the field from "no modifier" to protected. The same input was tested in NetBeans IDE and it does not increase the accessibility of the field. According to Fowler's book [1], we should preserve the field accessibility.

--- Before Refactoring:
public class A {}

public class B extends A {
    int field = 11;
    public long m() {
        return field;
    }
}


--- Resulting Program:

public class A {
    protected int field = 11;
}

public class B extends A {
    public long m() {
        return field;
    }
}

[1] Martin Fowler. Refactoring: improving the design of existing code. Addison-Wesley Longman Publishing Company, Inc., Boston, MA, USA, 1999.
Comment 1 Eclipse Genie CLA 2020-02-28 02:53:50 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.