Skip to content

fix: remove sun.misc for OSGi imports on Java 11 or newer#4223

Open
rombert wants to merge 1 commit intoreactor:mainfrom
rombert:issue/osgi-sun-misc
Open

fix: remove sun.misc for OSGi imports on Java 11 or newer#4223
rombert wants to merge 1 commit intoreactor:mainfrom
rombert:issue/osgi-sun-misc

Conversation

@rombert
Copy link
Copy Markdown

@rombert rombert commented Mar 17, 2026

No longer require sun.misc in OSGi environments running Java 11 or newer.

The sun.misc requirement is only mandatory for Java 8 but this was not reflected in the OSGi requirements,
leading to additional friction when deploying the bundle.

This change post-processes all multi-version manifests to no longer require sun.misc.

Fixes #3338

@rombert rombert requested a review from a team as a code owner March 17, 2026 16:09
Fixes reactor#3338

Signed-off-by: Robert Munteanu <robert@lmn.ro>
@rombert rombert force-pushed the issue/osgi-sun-misc branch from 7d9227b to bfc537f Compare March 17, 2026 16:09
@rombert
Copy link
Copy Markdown
Author

rombert commented Mar 17, 2026

I've tested this on a vanilla distribution of Apache Felix and installed the prerequisites

    9|Active     |    1|JSpecify annotations (1.0.0)|1.0.0
   10|Active     |    1|reactive-streams-jvm (1.0.4)|1.0.4

I've installed a SNAPSHOT build of the bundle, and when running Felix with Java 8 the bundle does not resolve

ERROR: Bundle io.projectreactor.reactor-core [12] Error starting file:/home/robert/sources/oss/reactor-core/reactor-core/build/libs/reactor-core-3.8.5-SNAPSHOT.jar (org.osgi.framework.BundleException: Unable to resolve io.projectreactor.reactor-core [12](R 12.0): missing requirement [io.projectreactor.reactor-core [12](R 12.0)] osgi.wiring.package; (osgi.wiring.package=sun.misc) Unresolved requirements: [[io.projectreactor.reactor-core [12](R 12.0)] osgi.wiring.package; (osgi.wiring.package=sun.misc)])
org.osgi.framework.BundleException: Unable to resolve io.projectreactor.reactor-core [12](R 12.0): missing requirement [io.projectreactor.reactor-core [12](R 12.0)] osgi.wiring.package; (osgi.wiring.package=sun.misc) Unresolved requirements: [[io.projectreactor.reactor-core [12](R 12.0)] osgi.wiring.package; (osgi.wiring.package=sun.misc)]
	at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4398)
	at org.apache.felix.framework.Felix.startBundle(Felix.java:2308)
	at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1566)
	at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:297)
	at java.lang.Thread.run(Thread.java:750)

Running headers 12 | grep misc shows that the Import-Package for sun.misc is there .

When running on Java 21 the bundle is active and requirement for the sun.misc import is missing.

Also, I tried making the change more gradle-idiomatic but I did not really find a way to do so; it seems that the bnd multi-release jar functionality does not allow tweaking the manifest. Happy to take feedback if anyone sees a different way of removing the jars.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can dependencies to sun.misc be optional?

1 participant