Bug 65237 JavaModelException on Generate Constructor using Fields
3.0RC1 In a Java file from a non-Java project. Invoking "Generate Constructor using Fields" throws the following exception, where "Test123" is the enclosing project: Java Model Exception: Java Model Status [Test123 does not exist.] at org.eclipse.jdt.internal.core.JavaElement.newNotPresentException(Java Element.java:561) at org.eclipse.jdt.internal.core.JavaModelManager.getPerProjectInfoCheck Existence(JavaModelManager.java:927) at org.eclipse.jdt.internal.core.JavaProject.getPerProjectInfo(JavaProje ct.java:1648) at org.eclipse.jdt.internal.core.JavaProject.getResolvedClasspath(JavaPr oject.java:1774) at org.eclipse.jdt.internal.core.JavaProject.buildStructure(JavaProject. java:266) at org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:18 3) at org.eclipse.jdt.internal.core.JavaElement.openWhenClosed(JavaElement. java:572) at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement. java:309) at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement. java:295) at org.eclipse.jdt.internal.core.JavaProject.getJavaProjectElementInfo(J avaProject.java:1392) at org.eclipse.jdt.internal.core.JavaProject.newNameLookup(JavaProject.j ava:2196) at org.eclipse.jdt.internal.core.JavaProject.newNameLookup(JavaProject.j ava:2210) at org.eclipse.jdt.internal.core.SearchableEnvironment.<init>(Searchable Environment.java:64) at org.eclipse.jdt.internal.core.JavaProject.newSearchableNameEnvironmen t(JavaProject.java:2225) at org.eclipse.jdt.internal.core.Openable.codeSelect(Openable.java:129) at org.eclipse.jdt.internal.core.CompilationUnit.codeSelect(CompilationU nit.java:301) at org.eclipse.jdt.internal.core.CompilationUnit.codeSelect(CompilationU nit.java:295) at org.eclipse.jdt.internal.ui.actions.SelectionConverter.codeResolve(Se lectionConverter.java:219) at org.eclipse.jdt.internal.ui.actions.SelectionConverter.codeResolve(Se lectionConverter.java:153) at org.eclipse.jdt.ui.actions.GenerateNewConstructorUsingFieldsAction.ru n(GenerateNewConstructorUsingFieldsAction.java:293) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(Select ionDispatchAction.java:216) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispa tchAction.java:188) at org.eclipse.jface.action.Action.runWithEvent(Action.java:881) at org.eclipse.ui.actions.RetargetAction.runWithEvent(RetargetAction.jav a:212) at org.eclipse.ui.internal.WWinPluginAction.runWithEvent(WWinPluginActio n.java:211) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:915) at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContri butionItem.java:866) at org.eclipse.jface.action.ActionContributionItem$7.handleEvent(ActionC ontributionItem.java:785) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2716) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2382) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1363) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1334) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.jav a:253) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:141) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:96 ) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformAct ivator.java:334) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.ja va:273) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.ja va:128) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces sorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.launcher.Main.basicRun(Main.java:185) at org.eclipse.core.launcher.Main.run(Main.java:638) at org.eclipse.core.launcher.Main.main(Main.java:622) !SUBENTRY 1 org.eclipse.jdt.core 4 969 Jun 02, 2004 11:00:07.527 !MESSAGE Test123 does not exist.
org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/AddUnimplementedConstructorsAction.java
EditorUtility.revealInEditor(editor, res[0]);
				}
			} catch (InvocationTargetException e) {
				ExceptionHandler.handle(e, shell, getDialogTitle(), null); 
			} catch (InterruptedException e) {
				
			} finally {
				if (target != null) {
					target.endCompoundChange();		
				}
			}		
		}
	}
	
	private static ISelectionStatusValidator createValidator(int entries) {
		AddUnimplementedConstructorsValidator validator= new AddUnimplementedConstructorsValidator(entries);
		return validator;
	}
		
	private IType getSelectedType(IStructuredSelection selection) throws JavaModelException {
		Object[] elements= selection.toArray();
		if (elements.length == 1 && (elements[0] instanceof IType)) {
			IType type= (IType) elements[0];
			if (type.getCompilationUnit() != null && type.isClass()) {
				return type;
			}
		}
		else if (elements[0] instanceof ICompilationUnit) {
			ICompilationUnit cu= (ICompilationUnit) elements[0];
			IType type= cu.findPrimaryType();