Bug 17271 Not present exception renaming class in java browsing perspective
Build 20020521 (running with java delta tracing) 1. Create the following CU: public class HelloWorld { } 2. Open Java Browsing perspective 3. Open HelloWorld 4. In java editor, rename HelloWorld to Hellorld2 5. Save Observe the following in the console: UPDATING Model with Delta: [Thread[main,5,main]:HelloWorld.java[*]: {CHILDREN | FINE GRAINED} HelloWorld2[+]: {} HelloWorld[-]: {}]: FIRING PRE_AUTO_BUILD Delta [Thread[main,5,main]]: HelloWorld.java[*]: {CHILDREN | FINE GRAINED} HelloWorld2[+]: {} HelloWorld[-]: {} MERGING 2 DELTAS [Thread[main,5,main]] HelloWorld.java[*]: {CHILDREN | FINE GRAINED} HelloWorld2[+]: {} HelloWorld[-]: {} Java Model[*]: {CHILDREN} Test[*]: {CHILDREN} [project root][*]: {CHILDREN} [default][*]: {CHILDREN} HelloWorld.java[*]: {CONTENT} FIRING POST_CHANGE Delta [Thread[main,5,main]]: Java Model[*]: {CHILDREN} Test[*]: {CHILDREN} [project root][*]: {CHILDREN} [default][*]: {CHILDREN} HelloWorld.java[*]: {CHILDREN | FINE GRAINED} HelloWorld2[+]: {} HelloWorld[-]: {} !ENTRY org.eclipse.jdt.ui 4 1 May 23, 2002 16:01:58.72 !MESSAGE Internal Error !STACK 1 Java Model Exception: Java Model Status [HelloWorld does not exist.] at org.eclipse.jdt.internal.core.JavaElement.newNotPresentException (JavaElement.java:501) at org.eclipse.jdt.internal.core.JavaElement.openHierarchy (JavaElement.java:530) at org.eclipse.jdt.internal.core.JavaElement.getElementInfo (JavaElement.java:309) at org.eclipse.jdt.internal.core.JavaElement.getChildren (JavaElement.java:266) at org.eclipse.jdt.internal.core.JavaElement.getChildrenOfType (JavaElement.java:275) at org.eclipse.jdt.internal.core.SourceType.getFields (SourceType.java:178) at org.eclipse.jdt.ui.actions.AddGetterSetterAction.canEnableOn (AddGetterSetterAction.java:168) at org.eclipse.jdt.ui.actions.AddGetterSetterAction.canEnable (AddGetterSetterAction.java:157) at org.eclipse.jdt.ui.actions.AddGetterSetterAction.selectionChanged (AddGetterSetterAction.java:123) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchSelectionChanged (SelectionDispatchAction.java:168) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.selectionChanged (SelectionDispatchAction.java:163) at org.eclipse.jface.viewers.Viewer.fireSelectionChanged (Viewer.java:147) at org.eclipse.jface.viewers.StructuredViewer.updateSelection (StructuredViewer.java:1154) at org.eclipse.jface.viewers.StructuredViewer.handleSelect (StructuredViewer.java:544) at org.eclipse.jface.viewers.StructuredViewer$1.widgetSelected (StructuredViewer.java:568) at org.eclipse.jface.util.OpenStrategy.fireSelectionEvent (OpenStrategy.java:171) at org.eclipse.jface.util.OpenStrategy.access$3(OpenStrategy.java:168) at org.eclipse.jface.util.OpenStrategy$1.handleEvent (OpenStrategy.java:297) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:75) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:825) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1527) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1289) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1085) at org.eclipse.ui.internal.Workbench.run(Workbench.java:1068) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:739) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:432) at EclipseRuntimeLauncher.main(EclipseRuntimeLauncher.java:24) !ENTRY org.eclipse.jdt.core 4 969 May 23, 2002 16:01:58.72 !MESSAGE HelloWorld does not exist. !ENTRY org.eclipse.jdt.ui 4 1 May 23, 2002 16:01:58.102 !MESSAGE An error occurred while accessing a Java element !STACK 1 Java Model Exception: Java Model Status [HelloWorld does not exist.] at org.eclipse.jdt.internal.core.JavaElement.newNotPresentException (JavaElement.java:501) at org.eclipse.jdt.internal.core.JavaElement.openHierarchy (JavaElement.java:530) at org.eclipse.jdt.internal.core.JavaElement.getElementInfo (JavaElement.java:309) at org.eclipse.jdt.internal.core.SourceType.isInterface (SourceType.java:320) at org.eclipse.jdt.ui.actions.FindImplementorsAction.canOperateOn (FindImplementorsAction.java:69) at org.eclipse.jdt.ui.actions.FindAction.canOperateOn (FindAction.java:91) at org.eclipse.jdt.ui.actions.FindAction.selectionChanged (FindAction.java:257) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchSelectionChanged (SelectionDispatchAction.java:168) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.selectionChanged (SelectionDispatchAction.java:163) at org.eclipse.jface.viewers.Viewer.fireSelectionChanged (Viewer.java:147) at org.eclipse.jface.viewers.StructuredViewer.updateSelection (StructuredViewer.java:1154) at org.eclipse.jface.viewers.StructuredViewer.handleSelect (StructuredViewer.java:544) at org.eclipse.jface.viewers.StructuredViewer$1.widgetSelected (StructuredViewer.java:568) at org.eclipse.jface.util.OpenStrategy.fireSelectionEvent (OpenStrategy.java:171) at org.eclipse.jface.util.OpenStrategy.access$3(OpenStrategy.java:168) at org.eclipse.jface.util.OpenStrategy$1.handleEvent (OpenStrategy.java:297) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:75) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:825) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1527) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1289) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1085) at org.eclipse.ui.internal.Workbench.run(Workbench.java:1068) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:739) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:432) at EclipseRuntimeLauncher.main(EclipseRuntimeLauncher.java:24) !ENTRY org.eclipse.jdt.core 4 969 May 23, 2002 16:01:58.102 !MESSAGE HelloWorld does not exist. !ENTRY org.eclipse.jdt.ui 4 1 May 23, 2002 16:01:58.112 !MESSAGE An error occurred while accessing a Java element !STACK 1 Java Model Exception: Java Model Status [HelloWorld does not exist.] at org.eclipse.jdt.internal.core.JavaElement.newNotPresentException (JavaElement.java:501) at org.eclipse.jdt.internal.core.JavaElement.openHierarchy (JavaElement.java:530) at org.eclipse.jdt.internal.core.JavaElement.getElementInfo (JavaElement.java:309) at org.eclipse.jdt.internal.core.SourceType.isInterface (SourceType.java:320) at org.eclipse.jdt.ui.actions.FindImplementorsAction.canOperateOn (FindImplementorsAction.java:69) at org.eclipse.jdt.ui.actions.FindAction.canOperateOn (FindAction.java:91) at org.eclipse.jdt.ui.actions.FindAction.selectionChanged (FindAction.java:257) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchSelectionChanged (SelectionDispatchAction.java:168) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.selectionChanged (SelectionDispatchAction.java:163) at org.eclipse.jface.viewers.Viewer.fireSelectionChanged (Viewer.java:147) at org.eclipse.jface.viewers.StructuredViewer.updateSelection (StructuredViewer.java:1154) at org.eclipse.jface.viewers.StructuredViewer.handleSelect (StructuredViewer.java:544) at org.eclipse.jface.viewers.StructuredViewer$1.widgetSelected (StructuredViewer.java:568) at org.eclipse.jface.util.OpenStrategy.fireSelectionEvent (OpenStrategy.java:171) at org.eclipse.jface.util.OpenStrategy.access$3(OpenStrategy.java:168) at org.eclipse.jface.util.OpenStrategy$1.handleEvent (OpenStrategy.java:297) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:75) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:825) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1527) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1289) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1085) at org.eclipse.ui.internal.Workbench.run(Workbench.java:1068) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:739) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:432) at EclipseRuntimeLauncher.main(EclipseRuntimeLauncher.java:24) !ENTRY org.eclipse.jdt.core 4 969 May 23, 2002 16:01:58.112 !MESSAGE HelloWorld does not exist.
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/browsing/JavaBrowsingContentProvider.java
if (getProvideWorkingCopy()) {
				for (int i= 0; i < sourceRefs.length; i++) {
					IWorkingCopy wc= EditorUtility.getWorkingCopy((ICompilationUnit)sourceRefs[i]);
					if (wc != null)
						sourceRefs[i]= (ICompilationUnit)wc;
				}
			}
		}
		else {
			IClassFile[] classFiles= fragment.getClassFiles();
			List topLevelClassFile= new ArrayList();
			for (int i= 0; i < classFiles.length; i++) {
				IType type= classFiles[i].getType();
				if (type != null && type.getDeclaringType() == null)
					topLevelClassFile.add(classFiles[i]);
			}
			sourceRefs= (ISourceReference[])topLevelClassFile.toArray(new ISourceReference[topLevelClassFile.size()]);
		}
		Object[] result= new Object[0];
		for (int i= 0; i < sourceRefs.length; i++)
			result= concatenate(result, removeImportAndPackageDeclarations(getChildren(sourceRefs[i])));
		return concatenate(result, fragment.getNonJavaResources());
	}
	private Object[] removeImportAndPackageDeclarations(Object[] members) {
		ArrayList tempResult= new ArrayList(members.length);
		for (int i= 0; i < members.length; i++)
			if (!(members[i] instanceof IImportContainer) && !(members[i] instanceof IPackageDeclaration))
				tempResult.add(members[i]);
		return tempResult.toArray();
	}