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
IPath attach= root.getSourceAttachmentPath();
						if (root.isExternal()) {
							if (attach == null) {
								return JavaPluginImages.DESC_OBJS_EXTJAR;
							} else {
								return JavaPluginImages.DESC_OBJS_EXTJAR_WSRC;
							}
						} else {
							if (attach == null) {
								return JavaPluginImages.DESC_OBJS_JAR;
							} else {
								return JavaPluginImages.DESC_OBJS_JAR_WSRC;
							}
						}							
					} else {
						return JavaPluginImages.DESC_OBJS_PACKFRAG_ROOT;
					}
				}
				
				case IJavaElement.PACKAGE_FRAGMENT:
					return getPackageFragmentIcon(element, renderFlags);
					
				case IJavaElement.COMPILATION_UNIT:
					return JavaPluginImages.DESC_OBJS_CUNIT;
					
				case IJavaElement.CLASS_FILE:
					/* this is too expensive for large packages
					try {
						IClassFile cfile= (IClassFile)element;
						if (cfile.isClass())