-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing Constraint: Import-Package: sun.misc #1981
Comments
Hi Jaroslav! |
Hello Éamonn! |
* #1981: Avoid OSGi bundle's dependency on sun.misc package * Specify optional dependency on sun.misc.Unsafe * Adjusting the test to sun.misc import being optional * Using Collections.list and for loop * Let the fail message include name of package Co-authored-by: Marcono1234 <Marcono1234@users.noreply.github.com> * Closing the input stream * Dedicated assertSubstring method Co-authored-by: Marcono1234 <Marcono1234@users.noreply.github.com>
Gson version
The Apache NetBeans project has just tried to migrate from version
2.8.5
to version2.8.8
in the pull request PR-3200 and the update fails with unsatisfied OSGi missing constraint:Import-Package: sun.misc
.Java / Android version
NetBeans project builds & runs primarily on JDK8.
Used tools
NetBeans is using home-made Ant based build system. I don't think it matters for this bug report.
Description
As PR-3200 states: The start of NetBeans fails with exception coming from an OSGi container (Apache NetBeans project is using OSGi behind the scene):
Expected behavior
Version 2.8.5 starts. It's manifest doesn't have any unavoidable dependency on
sun.misc
package. There isin NetBeans 12.5.
Actual behavior
However the new, 2.8.8 version contains explicit dependency on
sun.misc
:The Apache NetBeans project doesn't allow OSGi bundles to access
sun.misc
package and as such the OSGi container refuses to launch the GSON 2.8.8 bundle.Reproduction steps
To reproduce I would:
ant build
to build NetBeansant tryme
to launch itHowever I assume the problem is clear from the printed error. The
sun.misc
imported package is causing it. Any compliant OSGi container shall fail on similar error.Exception stack trace
Workaround
OSGi specification defines a special property
org.osgi.framework.system.packages.extra
which makes additional boot classpath packages available to the OSGi bundles. Yes, setting it to:works. Yes, we can use it, if necessary. But it puzzles me:
Have you introduced the dependency intentionally? Or is it just an accidental by-product of other changes? I can see that the new version of GSON is built with JDK11 from its JAR manifest. Also the BND tools got upgraded to
Bnd-5.3.0.202102221516
- maybe the added dependency onsun.misc
is just a by-product of one of the build changes? It seems thesun.misc
code is used just conditionally - e.g. the dependency could beoptional:=true
. Maybe specifying the optional dependency explicitly to BND is all that's needed to eliminate it?Thanks for taking a look and helping Apache NetBeans (possibly others) resolve the upgrade issue.
The text was updated successfully, but these errors were encountered: