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
case IJavaElement.METHOD:
					IMember member= (IMember) element;
					return getMethodImageDescriptor(member.getDeclaringType().isInterface(), member.getFlags());				
				
				case IJavaElement.FIELD:
					IField field= (IField) element;
					return getFieldImageDescriptor(field.getDeclaringType().isInterface(), field.getFlags());				
					
				case IJavaElement.PACKAGE_DECLARATION:
					return JavaPluginImages.DESC_OBJS_PACKDECL;
				
				case IJavaElement.IMPORT_DECLARATION:
					return JavaPluginImages.DESC_OBJS_IMPDECL;
					
				case IJavaElement.IMPORT_CONTAINER:
					return JavaPluginImages.DESC_OBJS_IMPCONT;
				
				case IJavaElement.TYPE: {
					IType type= (IType) element;
					boolean isInterface= type.isInterface();
					
					if (useLightIcons(renderFlags)) {
						return isInterface ? JavaPluginImages.DESC_OBJS_INTERFACEALT : JavaPluginImages.DESC_OBJS_CLASSALT;
					}
					boolean isInner= type.getDeclaringType() != null;
					return getTypeImageDescriptor(isInterface, isInner, type.getFlags());
				}
				case IJavaElement.PACKAGE_FRAGMENT_ROOT: {
					IPackageFragmentRoot root= (IPackageFragmentRoot) element;
					if (root.isArchive()) {