Bug 273656 - Generated launch configuration has no name if anonymous class is instantiated in main
Summary: Generated launch configuration has no name if anonymous class is instantiated...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 3.5   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.5 RC1   Edit
Assignee: Michael Rennie CLA
QA Contact:
URL:
Whiteboard:
Keywords: polish
Depends on:
Blocks:
 
Reported: 2009-04-24 17:53 EDT by Remy Suen CLA
Modified: 2009-05-04 14:36 EDT (History)
2 users (show)

See Also:
curtis.windatt.public: review+


Attachments
fix (1.75 KB, patch)
2009-05-01 13:01 EDT, Michael Rennie CLA
no flags Details | Diff
better fix (3.12 KB, patch)
2009-05-01 13:09 EDT, Michael Rennie CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Remy Suen CLA 2009-04-24 17:53:22 EDT
Build id: I20090421-0930

1. Create a 'Main' class with the content below.
2. Bring up the context menu on the editor.
3. Run As > Java Application
4. A dialog appears with two choices.
 - Main
Main - (default package)
5. Select the first one.
6. The application runs.
7. Run > Run Configurations...
8. See that the generated launch configuration has no name.
9. Try to do something with it, the dialog now tells you "A name is required for the configuration".

It seems the launching code is buggy as it is generating bad launch configurations. I believe this bug to be the cause behind bug 273498.

public class Main {
	
	public static void main(String[] args) {
		new Main() {};
		System.out.println("Hello world!"); //$NON-NLS-1$
	}

}
Comment 1 Michael Rennie CLA 2009-05-01 13:01:40 EDT
Created attachment 134085 [details]
fix

The problem is that anonymous types do not have names, they are only referenced via a number - in this example 'Main$1'. Our code was setting the name of the new configuration to be IType.getElementName() which is nothing, since anonymous types don't have names. 

Changed the code to use IType.getTypeQualifiedName() which using the given example will name the config 'Main.1'
Comment 2 Michael Rennie CLA 2009-05-01 13:09:52 EDT
Created attachment 134087 [details]
better fix

this fix also updates the main type selection dialog to better show anonymous types. Using the example one of the choices would be ' - Main' and the other 'Main'. With the patch we get 'Main$1 - Main' and 'Main'.
Comment 3 Michael Rennie CLA 2009-05-04 10:36:05 EDT
applied patch to HEAD

please verify Curtis
Comment 4 Curtis Windatt CLA 2009-05-04 14:36:10 EDT
+1 Verified.