Bug 22164 Referencing JavaPlugin class in earlyStartup causes invalid thread access [misc]
It is possible that this is not a bug, either because it's known & not supported to because it's internal API, but it was rather unexpected, bizzare behavor. I have a plugin which depends on JDT-UI. This plugin also happens to implement IStartup. If at anypoint, I load the org.eclipse.jdt.internal.ui.JavaPlugin class from earlyStartup(), the Plugin loader attempts to load JDT-UI, which then promptly bombs out with invalid thread access and fails to load. This only happens if no JDT UI perspectives are loaded (in other words, on a fresh workspace). I will attach a simple plugin that demonstrates the problem. Just run it on a fresh workspace. The line it fails on seems to be "manager.registerAdapters(new JavaElementAdapterFactory(), IJavaElement.class);" in the startup() method. Thanks, Andrew
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/viewsupport/JavaElementImageProvider.java
/**
	 * Flags for the JavaImageLabelProvider:
	 * Generate images with overlays.
	 */
	public final static int OVERLAY_ICONS= 0x1;
	/**
	 * Generate small sized images.
	 */
	public final static int SMALL_ICONS= 0x2;
	
	/**
	 * Use the 'light' style for rendering types.
	 */	
	public final static int LIGHT_TYPE_ICONS= 0x4;	
	public static final Point SMALL_SIZE= new Point(16, 16);
	public static final Point BIG_SIZE= new Point(22, 16);
	private static ImageDescriptor DESC_OBJ_PROJECT_CLOSED;	
	private static ImageDescriptor DESC_OBJ_PROJECT;	
	private static ImageDescriptor DESC_OBJ_FOLDER;
	{
		ISharedImages images= JavaPlugin.getDefault().getWorkbench().getSharedImages(); 
		DESC_OBJ_PROJECT_CLOSED= images.getImageDescriptor(ISharedImages.IMG_OBJ_PROJECT_CLOSED);
		DESC_OBJ_PROJECT= 		 images.getImageDescriptor(ISharedImages.IMG_OBJ_PROJECT);
		DESC_OBJ_FOLDER= 		 images.getImageDescriptor(ISharedImages.IMG_OBJ_FOLDER);
	}
	
	private ImageDescriptorRegistry fRegistry;