Bug 9528 CCE while coping a project to the clipboard
Test pass for M3 Got the following CCE while copying text to the clipboard. java.lang.ClassCastException: org.eclipse.jdt.internal.core.JavaProject at org.eclipse.jdt.internal.ui.reorg.SourceReferenceAction.getWorkingCopyElements (SourceReferenceAction.java:139) at org.eclipse.jdt.internal.ui.reorg.SourceReferenceAction.getSelectedElements (SourceReferenceAction.java:85) at org.eclipse.jdt.internal.ui.reorg.SourceReferenceAction.getElementsToProcess (SourceReferenceAction.java:59) at org.eclipse.jdt.internal.ui.reorg.CopySourceReferencesToClipboardAction.perform (CopySourceReferencesToClipboardAction.java:21) at org.eclipse.jdt.internal.ui.reorg.SourceReferenceAction$1.run (SourceReferenceAction.java:50) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:56) at org.eclipse.jdt.internal.ui.reorg.SourceReferenceAction.run (SourceReferenceAction.java:47) at org.eclipse.jface.action.Action.runWithEvent(Action.java:452) at org.eclipse.ui.internal.RetargetAction.runWithEvent (RetargetAction.java:137) 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:74) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:637) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1413) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1205) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:788) at org.eclipse.ui.internal.Workbench.run(Workbench.java:771) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:777) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:319) at java.lang.reflect.Method.invoke(Native Method) at org.eclipse.core.launcher.Main.basicRun(Main.java:151) at org.eclipse.core.launcher.Main.run(Main.java:502) at org.eclipse.core.launcher.Main.main(Main.java:362)
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/reorg/SourceReferenceAction.java
ICompilationUnit cu= SourceReferenceUtil.getCompilationUnit(elem);
		ICompilationUnit wc= WorkingCopyUtil.getWorkingCopyIfExists(cu);
		if (wc.equals(cu))
			return false;
		IJavaElement element= (IJavaElement)elem;
		IJavaElement wcElement= JavaModelUtil.findInCompilationUnit(wc, element);
		return wcElement == null || ! wcElement.exists();
	}
			
	private static ISourceReference[] getWorkingCopyElements(List l) {
		List wcList= new ArrayList(l.size());
		for (Iterator iter= l.iterator(); iter.hasNext();) {
			ISourceReference element= (ISourceReference) iter.next();
			if (! (element instanceof IJavaElement)) 
				wcList.add(element); 
			ICompilationUnit cu= SourceReferenceUtil.getCompilationUnit(element);
			ICompilationUnit wc= WorkingCopyUtil.getWorkingCopyIfExists(cu);
			try {
				IJavaElement wcElement= JavaModelUtil.findInCompilationUnit(wc, (IJavaElement)element);
				if (wcElement != null && wcElement.exists())
					wcList.add(wcElement);
			} catch(JavaModelException e) {
				JavaPlugin.log(e); 
				
			}
		}
		return (ISourceReference[]) wcList.toArray(new ISourceReference[wcList.size()]);
	}	
}