Bug 12683 Invalid Thread Access self hosting using Java Search
The Java Search causes an Invalid Thread Access when you are self hosting. This will also occur if you use search in a JUnit test or if I run Eclipse using the following options: eclipse -ws win32 -debug -dev bin The problem is a call to Display.getCurrent() in the initialization code for the JavaEditorPreferencePage which is called the first time you do a search. STEPS 1) Self host Eclipse 2) Select Java Search 3) Enter the name of a class 4) Hit Search - Invalid Thread Access Log: Wed Apr 03 08:57:31 EST 2002 4 org.eclipse.jdt.ui 1 Internal Error java.lang.reflect.InvocationTargetException: org.eclipse.swt.SWTException: Invalid thread access at org.eclipse.swt.SWT.error(SWT.java:1887) at org.eclipse.swt.SWT.error(SWT.java:1819) at org.eclipse.swt.widgets.Display.checkDevice(Display.java(Compiled Code)) at org.eclipse.swt.widgets.Display.checkDevice(Display.java(Compiled Code)) at org.eclipse.swt.widgets.Display.getSystemColor(Display.java:965) at org.eclipse.jdt.internal.ui.preferences.JavaEditorPreferencePage.initDefaults (JavaEditorPreferencePage.java:209) at org.eclipse.jdt.internal.ui.JavaPlugin.initializeDefaultPreferences (JavaPlugin.java:320) at org.eclipse.ui.plugin.AbstractUIPlugin.getPreferenceStore (AbstractUIPlugin.java(Compiled Code)) at org.eclipse.jdt.internal.ui.preferences.AppearancePreferencePage.showMethodRetur nType(AppearancePreferencePage.java:40) at org.eclipse.jdt.internal.ui.viewsupport.StandardJavaUILabelProvider.initMasks (StandardJavaUILabelProvider.java:43) at org.eclipse.jdt.internal.ui.viewsupport.StandardJavaUILabelProvider.<init> (StandardJavaUILabelProvider.java:29) at org.eclipse.jdt.internal.ui.search.JavaSearchResultLabelProvider.<init> (JavaSearchResultLabelProvider.java:39) at org.eclipse.jdt.internal.ui.search.JavaSearchResultCollector.aboutToStart (JavaSearchResultCollector.java:104) at org.eclipse.jdt.core.search.SearchEngine.search (SearchEngine.java:376) at org.eclipse.jdt.internal.ui.search.JavaSearchOperation.execute (JavaSearchOperation.java:84) at org.eclipse.ui.actions.WorkspaceModifyOperation$1.run (WorkspaceModifyOperation.java:64) at org.eclipse.core.internal.resources.Workspace.run (Workspace.java:1343) at org.eclipse.ui.actions.WorkspaceModifyOperation.run (WorkspaceModifyOperation.java:78) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run (ModalContext.java:98)
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavaEditorPreferencePage.java
fPreviewViewer.invalidateTextPresentation();
			}
		});
		
		return fPreviewViewer.getControl();
	}
	
	private Color fBackgroundColor;
	
	/**
	 * Initializes the given viewer's colors.
	 * 
	 * @param viewer the viewer to be initialized
	 */
	private void initializeViewerColors(ISourceViewer viewer) {
		
		IPreferenceStore store= fOverlayStore;
		if (store != null) {
			
			StyledText styledText= viewer.getTextWidget();
						
			
			Color color= store.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT)
				? null
				: createColor(store, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND, styledText.getDisplay());
			styledText.setBackground(color);
				
			if (fBackgroundColor != null)
				fBackgroundColor.dispose();