This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 237997

Summary: [Move Inner To Outer Level] Problem with extended class
Product: java Reporter: ssazonov
Component: RefactoringAssignee: Ralph Ruijs <ralphbenjamin>
Status: RESOLVED WONTFIX    
Severity: normal    
Priority: P3    
Version: 8.0   
Hardware: PC   
OS: Windows 7   
Issue Type: DEFECT Exception Reporter:
Attachments: error

Description ssazonov 2013-11-05 13:29:48 UTC
Created attachment 141868 [details]
error

1. Create new java project and add simple java class ClassC:

package inner_to_outer;

public class ClassC {
	public class ClassD {
	}

	public class ClassE extends ClassD {

		private final ClassD classd;

		public ClassE(final ClassD outer){
			this.classd = outer;
		}
	}
}

2. Put caret into "public class Cla|ssE extends ClassD {" and from main menu select Refactor > Move Inner To Outer Level...

3. Leave default options (so, Class Name: "ClassE", Declare Field for the Current Outer Class: checked, Field Name: "outer") and press Refactor

>> Without any warning it generates incompilable code with error saying "an enclosing instance that contains ClassC.ClassD is required" (see attached img)

Product Version: NetBeans IDE Dev (Build 201310290001)
Java: 1.7.0_45; Java HotSpot(TM) 64-Bit Server VM 24.45-b08
Runtime: Java(TM) SE Runtime Environment 1.7.0_45-b18
System: Windows 7 version 6.1 running on amd64; Cp1252; en_US (nb)
Comment 1 Martin Balin 2016-07-07 07:18:37 UTC
This old bug may not be relevant anymore. If you can still reproduce it in 8.2 development builds please reopen this issue.

Thanks for your cooperation,
NetBeans IDE 8.2 Release Boss