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

Bug 21908

Summary: Pulling up a method results in misplaced & inappropriate access modifier keyword [refactoring]
Product: [Eclipse Project] JDT Reporter: Antonio D'souza <eclipse>
Component: UIAssignee: Adam Kiezun <akiezun>
Status: RESOLVED FIXED QA Contact:
Severity: minor    
Priority: P3 CC: ian
Version: 2.0   
Target Milestone: 2.1 M5   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Antonio D'souza CLA 2002-07-25 11:35:25 EDT
Steps to reproduce:
Create a skeleton class and a subclass with a single protected field & an
associated accessor method that has package-level access (the default with no
keyword). These 2 classes should be in different packages. 
Now use the refactoring wizard to pull up the field & its accessor method. Go
with the defaults supplied by the wizard. 

Expected results:
Both the field & its accessor should be moved from the subclass to the
superclass and the access-level of the method should be changed to public. While
one's 1st inclination might be to change it to protected, this will cause a loss
of functionality if classes withing the subclasses package were previously
calling this method. 

Actual results:
In addition to using protected as the access modifier for the method after it is
moved, the keyword is placed before the Javadoc, which looks decidedly strange,
despite not causing a compile error.
Comment 1 Adam Kiezun CLA 2002-08-28 11:24:32 EDT
i guess you mean that:

1. you have:
package p;
public class A{
}

package p1;

import p.A;
public class A1 extends A{
	/** field javadoc*/
	protected int f;

	/** method javadoc*/	
	int getF() {
		return f;
	}
}

2. you pull up field and method and get:
package p;

public class A{
	/** field javadoc*/
	protected int f;

	protected /** method javadoc*/	
	int getF() {
		return f;
	}
}
package p1;

import p.A;

public class A1 extends A{
}

and not the expected:
package p;

public class A{
	/** field javadoc*/
	protected int f;

	/** method javadoc*/	
	public int getF() {
		return f;
	}
}
package p1;

import p.A;

public class A1 extends A{
}
Comment 2 Antonio D'souza CLA 2002-08-28 11:41:41 EDT
Indeed, that is precisely what I mean. 
Comment 3 Adam Kiezun CLA 2002-08-28 11:43:40 EDT
*** Bug 21229 has been marked as a duplicate of this bug. ***
Comment 4 Adam Kiezun CLA 2002-12-20 11:51:32 EST
'protected' before the comment does look bogus
let's fix it for m5
Comment 5 Adam Kiezun CLA 2003-01-07 10:27:18 EST
'protected' is now placed correctly
will not change the visibility to 'public' for now - unless people protest
(some explanation is in bug 25528)