Bug 304473

Summary: [extract superclass] extracting superclass with static inner class generates incorrect import
Product: [Eclipse Project] JDT Reporter: Jules H <jeclipse>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: ASSIGNED --- QA Contact:
Severity: normal    
Priority: P3 CC: markus.kell.r, Olivier_Thomann
Version: 3.6   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard: stalebug

Description Jules H CLA 2010-03-03 03:59:23 EST
Build Identifier: 20090621-0832

When extracting a superclass and moving a static inner class to the new superclass along with a method that uses that class, the generated code includes an import which refers to it in its old location.

Reproducible: Always

Steps to Reproduce:
1.  Create the following class:

public class A
{
	public static class InnerClass
	{
	}
	
	public void aMethod ()
	{
		new InnerClass ();
	}
}

2.  Activate the extract superclass refactoring, enter a name, and select to move both members.  Click Finish.

3.  A "problem" is described that "inaccurate matches" have been found in the newly generated class.  Click Finish again.

The resulting new class looks like this:

import A.InnerClass;

public class NewSuperclass
{

	public static class InnerClass
    {
    }

	public NewSuperclass ()
	{
		super ();
	}

	public void aMethod ()
    {
    	new InnerClass ();
    }

}

The import on the first line is erroneous; it should not have been generated.  The same problem occurs whether the class is in the default package or a named package.
Comment 1 Olivier Thomann CLA 2010-03-03 13:49:35 EST
Moving to JDT/UI
Comment 2 Eclipse Genie CLA 2020-07-16 14:41:09 EDT
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.

If you have further information on the current state of the bug, please add it. 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.
Comment 3 Eclipse Genie CLA 2022-08-10 17:12:47 EDT
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.

If you have further information on the current state of the bug, please add it. 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.