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
public JavaElementImageProvider() {
		fRegistry= JavaPlugin.getImageDescriptorRegistry();
	}	
		
	/**
	 * Returns the icon for a given element. The icon depends on the element type
	 * and element properties. If configured, overlay icons are constructed for
	 * <code>ISourceReference</code>s.
	 * @param flags Flags as defined by the JavaImageLabelProvider
	 */
	public Image getImageLabel(Object element, int flags) {
		return getImageLabel(computeDescriptor(element, flags));
	}
	
	private Image getImageLabel(ImageDescriptor descriptor){
		if (descriptor == null) 
			return null;	
		return fRegistry.get(descriptor);
	}
	private ImageDescriptor computeDescriptor(Object element, int flags){
		if (element instanceof IJavaElement) {
			return getJavaImageDescriptor((IJavaElement) element, flags);
		} else if (element instanceof IFile) {
			IFile file= (IFile) element;
			if ("java".equals(file.getFileExtension())) {
				return getCUResourceImageDescriptor(file, flags); 
			}
			return getWorkbenchImageDescriptor(file, flags);
		} else if (element instanceof IAdaptable) {