Bug 304473 - [extract superclass] extracting superclass with static inner class generates incorrect import
Summary: [extract superclass] extracting superclass with static inner class generates ...
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.6   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2010-03-03 03:59 EST by Jules H CLA
Modified: 2022-08-10 17:12 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.