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 122812 - [60cat] moving inner to outer class produced new class with syntax errors
Summary: [60cat] moving inner to outer class produced new class with syntax errors
Status: RESOLVED WORKSFORME
Alias: None
Product: java
Classification: Unclassified
Component: Source (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Max Sauer
URL:
Keywords:
Depends on:
Blocks: 152192
  Show dependency tree
 
Reported: 2007-11-26 23:25 UTC by wobster
Modified: 2009-03-04 09:49 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description wobster 2007-11-26 23:25:14 UTC
For NetBeans RC2, when I moved the following inner class to an outer class (see text at end), the resulting class was
missing imports and didn't remove the original "this" reference from the line with
"...ControlPanelView.this.getResourceMap();" which resulted in this erroneous line "outer.this.getResourceMap();"

<snippet from="ControlPanelView">

	private class BackupTask extends org.jdesktop.application.Task<Object, Void> {

		BackupTask(org.jdesktop.application.Application app) {
			super(app);
		}

		@Override
		protected Object doInBackground() {

			ResourceMap resourceMap = ControlPanelView.this.getResourceMap();
			String command = resourceMap.getString("restart.Action.command");
			if (command == null) {
				return -1;
			}

			JobRunner.TextListener outputListener = new JobRunner.TextListener() {
				public void receive(String message) {
					setMessage(message);
					System.out.println(message);
				}
			};

			JobRunner.TextListener errorListener = new JobRunner.TextListener() {
				public void receive(String message) {
					setMessage(message);
					System.err.println(message);
				}
			};

			try {
				JobRunner runner = new JobRunner(command);
				runner.addOutputListener(outputListener);
				runner.addErrorListener(errorListener);
				int status = runner.run();
				return status; // return your result
			} catch (IOException ex) {
				Logger.getLogger(ControlPanelView.class.getName()).log(Level.SEVERE, null, ex);
			}
			return -1;
		}

		@Override
		protected void succeeded(Object result) {
		}
	}

</snippet>


package com.ticomgeo.tags.cp;

import java.io.IOException;
import org.jdesktop.application.Application;
import org.jdesktop.application.ResourceMap;
import org.jdesktop.application.Task;

class GenericTask extends Task<Object, Void> {

	@Override
	protected Object doInBackground() {
		ResourceMap resourceMap = outer.this.getResourceMap();
		String command = resourceMap.getString("restart.Action.command");
		if (command == null) {
			return -1;
		}
		JobRunner.TextListener outputListener = new JobRunner.TextListener() {

			public void receive(String message) {
				setMessage(message);
				System.out.println(message);
			}
		};
		JobRunner.TextListener errorListener = new JobRunner.TextListener() {

			public void receive(String message) {
				setMessage(message);
				System.err.println(message);
			}
		};
		try {
			JobRunner runner = new JobRunner(command);
			runner.addOutputListener(outputListener);
			runner.addErrorListener(errorListener);
			int status = runner.run();
			return status;
		} catch (IOException ex) {
			Logger.getLogger(ControlPanelView.class.getName()).log(Level.SEVERE, null, ex);
		}
		return -1;
	}

	@Override
	protected void succeeded(Object result) {
	}
	ControlPanelView outer;

	GenericTask(Application app, ControlPanelView outer) {
		super(app);
		this.outer = outer;
	}
}
Comment 1 Jan Becicka 2007-12-06 13:56:53 UTC
"outer.this" problem was already fixed. Missing import should be added automatically. For me it does not import Logger
and Level.
Comment 2 Jiri Prox 2008-04-11 00:52:55 UTC
moving opened issues from TM <= 6.1 to TM=Dev
Comment 3 Max Sauer 2009-03-04 09:49:13 UTC
Works for me in current trunk. Please reopen with additional details in case it's still reproducible for you, thanks.
---
Product Version: NetBeans IDE Dev (Build 090303)
Java: 1.5.0_16; Java HotSpot(TM) Client VM 1.5.0_16-133
System: Mac OS X version 10.5.6 running on i386; MacRoman; en_US (nb)