Community
Participate
Working Groups
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)
The plugin can be activated in any thread and the plugin activation can result in initialization of the preference store. Therefore preference initialization may not access the Display.
*** Bug 15171 has been marked as a duplicate of this bug. ***
The illegal thread access can happen whenever getPreferenceStore is called from a non-UI thread (see also 15171). It calls JavaEditorPreferencePage.initDefaults that needs access to the Display to get the system colors. Fix discussed with Kai is to get the system colors with a syncExec call. This fix needs to go into the M5 stream.
Build 20020508 + M5'.