eclipse-xtext / eclipse-xtext/xtext
Can't access Activator/BundleContext during shared service initialization
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 831
- Forks
- 330
- Avg merge
- 3d 7h
- Merged PRs (30d)
- 12
Description
Steps to reproduce:
- create a service (Java class) that accesses something like
Activator.getDefault().getBundle().getBundleContext().getServiceReference(SomeService.class)in the constructor. - bind the service in a custom shared state module that has been registered via Xtext's extension point.
- Starting
org.eclipse.xtext.ui.sharedwill now fail.
Analysis: the code from (1) throws an NPE because it's called during org.eclipse.xtext.ui.shared.internal.Activator.start(BundleContext)
Since the bundle can't be activated users see tons of subsequent ClassNotFoundExceptions because classes from that bundle can't be accessed.
While I don't think the code from (1) needs to be supported in any case... I can say that this used to work because the Shared Injector used to be initialized lazily and thus after bundle startup finished.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with org.eclipse.xtext.ui.shared.internal.Activator.start(BundleContext) and trace how the custom shared state module is initialized through Xtext's extension point. Reproduce the constructor access to Activator.getDefault().getBundle().getBundleContext() and determine the initialization ordering that causes the NPE. Done means org.eclipse.xtext.ui.shared starts successfully without the subsequent ClassNotFoundExceptions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100