Community
Participate
Working Groups
When using the Groovy plugin, users can get these exceptions: org.eclipse.core.runtime.InvalidRegistryObjectException: Invalid registry object at org.eclipse.core.internal.registry.RegistryObjectManager.basicGetObject(RegistryObjectManager.java:277) at org.eclipse.core.internal.registry.RegistryObjectManager.getObject(RegistryObjectManager.java:267) at org.eclipse.core.internal.registry.ConfigurationElementHandle.getConfigurationElement(ConfigurationElementHandle.java:29) at org.eclipse.core.internal.registry.ConfigurationElementHandle.getChildren(ConfigurationElementHandle.java:53) at org.eclipse.core.internal.adapter.AdapterFactoryProxy.getAdapterNames(AdapterFactoryProxy.java:97) at org.eclipse.core.internal.runtime.AdapterManager.addFactoriesFor(AdapterManager.java:109) at org.eclipse.core.internal.runtime.AdapterManager.getFactories(AdapterManager.java:212) at org.eclipse.core.internal.runtime.AdapterManager.getAdapter(AdapterManager.java:295) at org.eclipse.core.runtime.PlatformObject.getAdapter(PlatformObject.java:72) ... The exception gives no clue which object is wrong or why. Please improve the error message so we're able to see which registry is invalid (it and type) plus chain the exception in org.eclipse.core.internal.runtime.AdapterManager.addFactoriesFor to get the typeName.
This issue has a bit of a long history. I wanted to include references in case anyone wanted to trace it. https://bugs.eclipse.org/bugs/show_bug.cgi?id=528462 https://github.com/spring-projects/spring-ide/issues/148 https://github.com/spring-projects/spring-ide/issues/151 https://github.com/groovy/groovy-eclipse/issues/309 https://github.com/groovy/groovy-eclipse/issues/317 https://github.com/groovy/groovy-eclipse/issues/555 https://github.com/groovy/groovy-eclipse/issues/590 https://github.com/groovy/groovy-eclipse/issues/620 https://github.com/groovy/groovy-eclipse/issues/681 Long story short: Groovy Development Tools include a bundle that starts very early and tries to enable only the user-selected version of the org.codehaus.groovyXY bundles. If any GDT or JDT components have started before this, like say the Package Explorer or Java Editor, they may have already established references to the highest version bundle (default activated) and when this bundle is stopped, it is possible to get Invalid Registry Object errors. Workaround available to user: uninstall versions of "Groovy Compile X.Y" feature that are not used. If highest version available is the one in use, no switching is required. Additional workaround: close all open editors and views that may try to reference Groovy features during IDE startup. Mostly this means the Java and Groovy editors.
Sounds like a valid request. Do you want to contribute a patch?
How about this in org.eclipse.core.internal.adapter.AdapterFactoryProxy? @Override public String[] getAdapterNames() { /* was: IConfigurationElement[] children = element.getChildren(); ArrayList<String> adapters = new ArrayList<>(children.length); for (IConfigurationElement child : children) { //ignore unknown children for forward compatibility if ("adapter".equals(child.getName())) {//$NON-NLS-1$ String type = child.getAttribute("type"); //$NON-NLS-1$ if (type != null) adapters.add(type); } } if (adapters.isEmpty()) logError(); return adapters.toArray(new String[adapters.size()]); */ try { String[] adapters = Arrays.stream(element.getChildren()) // ignore unknown children for forward compatibility .filter(child -> "adapter".equals(child.getName())) //$NON-NLS-1$ .map(child -> child.getAttribute("type")) //$NON-NLS-1$ .filter(Objects::nonNull) .toArray(String[]::new); if (adapters.isEmpty()) { logError(); } return adapters; } catch (InvalidRegistryObjectException e) { String msg = NLS.bind(RegistryMessages.adapters_cantInstansiate, getAdaptableType(), element.getContributor().getName()); RuntimeLog.log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, 0, msg, e)); return new String[0]; } } "element.getContributor().getName()" also indicates that it throws InvalidRegistryObjectException, so you may want to log more carefully.
I missed org.eclipse.core.runtime.IConfigurationElement#isValid(). I think the more general approach is to have any component that accesses an IConfigurationElement to check isValid() first and take appropriate steps if not valid.
@Override public String[] getAdapterNames() { if (element.isValid()) { String[] adapters = Arrays.stream(element.getChildren()) // ignore unknown children for forward compatibility .filter(child -> "adapter".equals(child.getName())) //$NON-NLS-1$ .map(child -> child.getAttribute("type")) //$NON-NLS-1$ .filter(Objects::nonNull) .toArray(String[]::new); if (adapters.isEmpty()) { logError(); } return adapters; } else { String msg = NLS.bind(RegistryMessages.adapters_cantInstansiate, getAdaptableType(), "<unknown>"); RuntimeLog.log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, 0, msg, e)); return new String[0]; } }
Eric, please if you have an idea for the patch, use gerrit and not bugzilla.
New Gerrit change created: https://git.eclipse.org/r/155098
I left a few comments in the gerrit. Most are just minor but can you please include information which element is the problem? Otherwise, we just get a log message "there was a problem" but no clue what it was.
I don't know much about IConfigurationElement. At least include name and namespace. I guess value is off limits when valid is false.
(In reply to Aaron Digulla from comment #8) > I left a few comments in the gerrit. Most are just minor but can you please > include information which element is the problem? > > Otherwise, we just get a log message "there was a problem" but no clue what > it was. Aaron, please *submit* your comments, otherwise others can't see them on Gerrit.
Thanks for the hint. Should be done now. I was very lost how to do that; the keyword was "Reply to make them visible" :-)
Okay, so I submitted a Gerrit change. Any chance it makes it into Eclipse 2020-03 (4.15)?
Behavior looks good in the debugger to me, I merge this so that we can get it into our M1 testing. Eric, thanks and sorry for the long delay in review time. Please test with tomorrows I-build and watch https://download.eclipse.org/eclipse/downloads/ the latest I-Build for new test errors related to this change.
*** Bug 540888 has been marked as a duplicate of this bug. ***
Bug 542086 also looks related.
*** Bug 562561 has been marked as a duplicate of this bug. ***