Bug 12683 - Invalid Thread Access self hosting using Java Search
Summary: Invalid Thread Access self hosting using Java Search
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P1 normal (vote)
Target Milestone: 2.0 M6   Edit
Assignee: Kai-Uwe Maetzel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 15171 (view as bug list)
Depends on:
Blocks:
 
Reported: 2002-04-03 09:10 EST by Tod Creasey CLA
Modified: 2002-05-09 06:41 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tod Creasey CLA 2002-04-03 09:10:25 EST
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)
Comment 1 Erich Gamma CLA 2002-04-09 12:01:02 EDT
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.
Comment 2 Erich Gamma CLA 2002-05-03 07:39:26 EDT
*** Bug 15171 has been marked as a duplicate of this bug. ***
Comment 3 Erich Gamma CLA 2002-05-03 07:49:57 EDT
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.
Comment 4 Kai-Uwe Maetzel CLA 2002-05-09 06:41:41 EDT
Build 20020508 + M5'.