Skip to content
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

OSGi import of package com.ibm.xml.xlxp.api.stax should be resolution:=optional #152

Closed
wilx opened this issue Jun 20, 2019 · 5 comments
Closed
Assignees
Milestone

Comments

@wilx
Copy link
Contributor

wilx commented Jun 20, 2019

The XStream core package 1.4.11.1 does not resolve in OSGi environment with Oracle Java. This seems to be because its OSGi manifest is requiring import of package com.ibm.xml.xlxp.api.stax. This appears to be IBM Java specific package, judging from this code in com.thoughtworks.xstream.core.JVM#getStaxInputFactory:

    public static Class<? extends XMLInputFactory> getStaxInputFactory() throws ClassNotFoundException {
        if (isIBM()) {
            return (Class<? extends XMLInputFactory>)Class.forName("com.ibm.xml.xlxp.api.stax.XMLInputFactoryImpl");
        } else {
            return (Class<? extends XMLInputFactory>)Class.forName("com.sun.xml.internal.stream.XMLInputFactoryImpl");
        }
    }

The import should be marked with resolution:=optional:

diff --git a/xstream/pom.xml b/xstream/pom.xml
index e1b0986b..353346a4 100644
--- a/xstream/pom.xml
+++ b/xstream/pom.xml
@@ -394,7 +394,7 @@

   <properties>
     <bundle.export.package>!com.thoughtworks.xstream.core.util,com.thoughtworks.xstream.*;-noimport:=true</bundle.export.package>
-    <bundle.import.package>org.xmlpull.mxp1;resolution:=optional,org.xmlpull.v1;resolution:=optional,*</bundle.import.package>
+    <bundle.import.package>org.xmlpull.mxp1;resolution:=optional,org.xmlpull.v1;resolution:=optional,com.ibm.xml.xlxp.api.stax;resolution:=optional,*</bundle.import.package>
   </properties>

 </project>
@wilx
Copy link
Contributor Author

wilx commented Jun 20, 2019

Now that I think of it, the com.sun.xml.internal.stream package should be also imported with resolution:=optional so that the OSGi bundle works on AIX with IBM Java.

@joehni
Copy link
Member

joehni commented Jun 23, 2019

These are packages of the specific Java runtimes. Why should those be imported?

@wilx
Copy link
Contributor Author

wilx commented Jun 23, 2019

@joehni I guess that depends OSGi runtime and its setup. Ideally, AFAIK, everything you use should be imported. In any case, the 1.4.11.1 version downloadable from central repository contains OSGi manifest that contains this (I have highlighted the important parts:

Import-Package: org.xmlpull.mxp1;resolution:=optional,org.xmlpull.v1;r
esolution:=optional,com.bea.xml.stream;resolution:=optional,com.ctc.w
stx.stax;resolution:=optional,com.ibm.xml.xlxp.api.stax,com.sun.xml.i
nternal.stream
,javax.activation,javax.security.auth,javax.swing,javax

As you can see, both internals of IBM Java and Oracle Java are imported without any qualifiers, so they are hard requirements and the OSGi bundle won't resolve in either Java.

@wilx
Copy link
Contributor Author

wilx commented Jun 23, 2019

And now that I look closer, I am not sure if sun.misc import is compatible with IBM Java either.

@joehni
Copy link
Member

joehni commented Jul 1, 2019

sun.misc is available in any Java runtime ... ;-)

However, I've configured the bundle plugin now to import all classes as optional.

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

No branches or pull requests

2 participants