Skip to content

Bundle with Export-Package javax.annotation prevents Eclipse from starting #727

@guw

Description

@guw

Noticed an interesting exception when trying to run an Eclipse Application self-hosted.

!ENTRY org.eclipse.osgi 4 0 2023-04-22 11:23:57.490
!MESSAGE Application error
!STACK 1
java.lang.NullPointerException: Cannot invoke "org.eclipse.emf.ecore.resource.Resource.getContents()" because "applicationResource" is null
	at org.eclipse.e4.ui.internal.workbench.ResourceHandler.loadMostRecentModel(ResourceHandler.java:182)
	at org.eclipse.e4.ui.internal.workbench.swt.E4Application.loadApplicationModel(E4Application.java:371)
	at org.eclipse.e4.ui.internal.workbench.swt.E4Application.createE4Workbench(E4Application.java:247)
	at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:572)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:550)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:171)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:152)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:136)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:402)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:596)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1467)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1440)

The issue is caused by having JSR 305 available in the target platform (dsl):

	dependency {
		groupId="com.google.code.findbugs"
		artifactId="jsr305"
		version="3.0.2"
	}

The problem is that org.eclipse.e4.ui.workbench (and a lot other bundles) get wired to the JSR 305 provided package because they use Import-Package and the package is exported with a higher version. However, the problem is that JSR 305 does not provide a PostConstruct annotation. Therefore e4 DI does not invoke the init method on ResourceHandler.

image

org.eclipse.e4.core.di is doing Require-Bundle:
image

This is a difficult split-package situation. I think the JSR bundle should export packages with split attribute. Same probably applies to the javax.annotation bundle but I am afraid this will break lots of existing plug-ins.

Note, I don't have a recommendation for a fix yet. But I wanted to report the issue for visibility. It's easy to run into with Maven support in target platforms.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions