Bug 22260 Internal Error during creation of class using New Class Wizard [code manipulation]
When trying to create the class "URLs" by means of New Class Wizard I get the error "Invalid Contents specified.". Source file is created with only package statement. So far I've figured out that it happens if second letter of the class is uppercased. After that Error Log contains the Internal Error: Java Model Exception: Java Model Status [Invalid contents specified.] at org.eclipse.jdt.internal.core.JavaModelOperation.execute (JavaModelOperation.java:307) at org.eclipse.jdt.internal.core.JavaModelOperation.run (JavaModelOperation.java:513) at org.eclipse.core.internal.resources.Workspace.run (Workspace.java:1361) at org.eclipse.jdt.internal.core.JavaModelManager.runOperation (JavaModelManager.java:1212) at org.eclipse.jdt.internal.core.JavaElement.runOperation (JavaElement.java:574) at org.eclipse.jdt.internal.core.CompilationUnit.createType (CompilationUnit.java:203) at org.eclipse.jdt.ui.wizards.NewTypeWizardPage.createType (NewTypeWizardPage.java:1335) at org.eclipse.jdt.ui.wizards.NewTypeWizardPage$1.run (NewTypeWizardPage.java:1637) at org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation.execute (WorkspaceModifyDelegatingOperation.java:39) at org.eclipse.ui.actions.WorkspaceModifyOperation$1.run (WorkspaceModifyOperation.java:64) at org.eclipse.core.internal.resources.Workspace.run (Workspace.java:1361) at org.eclipse.ui.actions.WorkspaceModifyOperation.run (WorkspaceModifyOperation.java:78) at org.eclipse.jface.operation.ModalContext.runInCurrentThread (ModalContext.java:299) at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:249) at org.eclipse.jface.wizard.WizardDialog.run(WizardDialog.java:720) at org.eclipse.jdt.internal.ui.wizards.NewElementWizard.finishPage (NewElementWizard.java:66) at org.eclipse.jdt.internal.ui.wizards.NewClassCreationWizard.performFinish (NewClassCreationWizard.java:42) at org.eclipse.jface.wizard.WizardDialog.finishPressed (WizardDialog.java:577) at org.eclipse.jface.wizard.WizardDialog.buttonPressed (WizardDialog.java:312) at org.eclipse.jface.dialogs.Dialog$1.widgetSelected(Dialog.java:398) at org.eclipse.swt.widgets.TypedListener.handleEvent (TypedListener.java:87) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:77) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:827) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1529) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1291) at org.eclipse.jface.window.Window.runEventLoop(Window.java:557) at org.eclipse.jface.window.Window.open(Window.java:537) at org.eclipse.ui.internal.NewWizardShortcutAction.run (NewWizardShortcutAction.java:88) at org.eclipse.jface.action.Action.runWithEvent(Action.java:749) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:407) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java:361) at org.eclipse.jface.action.ActionContributionItem.access$0 (ActionContributionItem.java:352) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java:47) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:77) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:827) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1529) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1291) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1177) at org.eclipse.ui.internal.Workbench.run(Workbench.java:1160) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:775) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:462) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:248) at org.eclipse.core.launcher.Main.run(Main.java:698) at org.eclipse.core.launcher.Main.main(Main.java:534)
org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/wizards/NewTypeWizardPage.java
/**
	 * Class used in stub creation routines to add needed imports to a 
	 * compilation unit.
	 */
	public static class ImportsManager {
		private IImportsStructure fImportsStructure;
		 ImportsManager(IImportsStructure structure) {
			fImportsStructure= structure;
		}
		 IImportsStructure getImportsStructure() {
			return fImportsStructure;
		}
				
		/**
		 * Adds a new import declaration that is sorted in the existing imports.
		 * If an import already exists or the import would conflict with another import
		 * of an other type with the same simple name  the import is not added.
		 * 
		 * @param qualifiedTypeName The fully qualified name of the type to import
		 * (dot separated)
		 * @return Returns the simple type name that can be used in the code or the
		 * fully qualified type name if an import conflict prevented the import
		 */				
		public String addImport(String qualifiedTypeName) {
			return fImportsStructure.addImport(qualifiedTypeName);
		}
	}