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

Clean up OSGi metadata #60

Merged
merged 5 commits into from
Oct 13, 2016
Merged

Conversation

ctron
Copy link
Contributor

@ctron ctron commented Oct 11, 2016

This change does remove "sun.misc" and "sun.nio.ch" from the list of
imported packages.

Signed-off-by: Jens Reimann jreimann@redhat.com

This change does remove "sun.misc" and "sun.nio.ch" from the list of
imported packages.

Signed-off-by: Jens Reimann <jreimann@redhat.com>
@kevinherron
Copy link
Contributor

Should we fix the duplicate package export as well? This commit just cleans up the imports.

@ctron
Copy link
Contributor Author

ctron commented Oct 12, 2016

I will. I just thought I will start with the easier one 😉

Signed-off-by: Jens Reimann <jreimann@redhat.com>
Copy link
Contributor

@kevinherron kevinherron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing the packaging type to 'bundle' and relying on the bundle plugin makes me uncomfortable. The docs for the plugin say by doing this you're (potentially) changing what gets packed in the jar files as well.

I've been trying to model OSGi support off of what the netty project does, which seems both minimal and non-intrusive.

@ctron
Copy link
Contributor Author

ctron commented Oct 13, 2016

Well I have made good experience with the bundle plugin ... no issues up until now. But I'll understand .. I will try to switch back and still keep it simple.

I did find another issue though .. there is a reference to "com.sun.managment". That may cause troubles since this package could be missing. And I am not sure what will happen with Java 9 regarding that.

@kevinherron
Copy link
Contributor

com.sun.management.UnixOperatingSystemMXBean is used in VendorNamespace to get the open and max FD count on *nix systems... if the Java 9 module system takes this ability away it won't be a big deal, it's not essential functionality.

@ctron
Copy link
Contributor Author

ctron commented Oct 13, 2016

Could I wrap this into some sort of "test if possible, don't fail otherwise" section?

@ctron
Copy link
Contributor Author

ctron commented Oct 13, 2016

Then I could make the import optional ... and nothing would fail.

@kevinherron
Copy link
Contributor

You could. I don't see any way to make sure it doesn't appear in the imports other than using reflection to check if the class is available and also to invoke the getOpenFileDescriptorCount and getMaxFileDescriptorCount methods.

This change does use the maven-bundle-plugin in order to create OSGi
metadata. It falls back to the default configuration, only overriding
this when really necessary.

Signed-off-by: Jens Reimann <jreimann@redhat.com>
@ctron
Copy link
Contributor Author

ctron commented Oct 13, 2016

No, I wouldn't use reflection for that. Since it doesn't appear in the class definition it should be fine just catching ClassNotFoundException

@ctron
Copy link
Contributor Author

ctron commented Oct 13, 2016

I updated the PR ... better that way? 😉

@ctron
Copy link
Contributor Author

ctron commented Oct 13, 2016

Damn ... I need to do some more testing with Karaf for that.

@kevinherron
Copy link
Contributor

I meant for Java 9 compatibility - even trying to import a com.sun package should result in a compilation error if we're not allowed access to that module, no?

@ctron
Copy link
Contributor Author

ctron commented Oct 13, 2016

Hm .. that is a good point... I have no clue how Java 9 would behave when I comes to compiling that.

I guess you just gave me a reason to finally install Java 9 😁

@ctron
Copy link
Contributor Author

ctron commented Oct 13, 2016

I just pushed a new update. That let's Karaf validate the OSGi metadata successfully. But I will try an actually install the bundle. So give me a bit more time.

@ctron
Copy link
Contributor Author

ctron commented Oct 13, 2016

Ok .. it is getting close. But now I run into a "uses" issue:

  Bundle was not resolved because of a uses contraint violation.
  org.osgi.service.resolver.ResolutionException: Uses constraint violation. Unable to resolve resource org.eclipse.milo.stack-client [osgi.identity; osgi.identity="org.eclipse.milo.stack-client"; type="osgi.bundle"; version:Version="0.1.0.SNAPSHOT"] because it is exposed to package 'javax.annotation' from resources org.jsr-305 [osgi.identity; osgi.identity="org.jsr-305"; type="osgi.bundle"; version:Version="3.0.1"] and org.eclipse.osgi [osgi.identity; osgi.identity="org.eclipse.osgi"; type="osgi.bundle"; version:Version="3.10.2.v20150203-1939"; singleton:="true"] via two dependency chains.

Chain 1:
  org.eclipse.milo.stack-client [osgi.identity; osgi.identity="org.eclipse.milo.stack-client"; type="osgi.bundle"; version:Version="0.1.0.SNAPSHOT"]
    import: (&(osgi.wiring.package=javax.annotation)(&(version>=3.0.0)(!(version>=4.0.0))))
     |
    export: osgi.wiring.package: javax.annotation
  org.jsr-305 [osgi.identity; osgi.identity="org.jsr-305"; type="osgi.bundle"; version:Version="3.0.1"]

Chain 2:
  org.eclipse.milo.stack-client [osgi.identity; osgi.identity="org.eclipse.milo.stack-client"; type="osgi.bundle"; version:Version="0.1.0.SNAPSHOT"]
    import: (&(osgi.wiring.package=org.eclipse.milo.opcua.stack.core.serialization.binary)(&(version>=0.1.0)(!(version>=1.0.0))))
     |
    export: osgi.wiring.package=org.eclipse.milo.opcua.stack.core.serialization.binary; uses:=org.eclipse.milo.opcua.stack.core
  org.eclipse.milo.stack-core [osgi.identity; osgi.identity="org.eclipse.milo.stack-core"; type="osgi.bundle"; version:Version="0.1.0.SNAPSHOT"]
    import: (osgi.wiring.package=org.eclipse.milo.opcua.stack.core)
     |
    export: osgi.wiring.package=org.eclipse.milo.opcua.stack.core; uses:=com.google.common.collect
  org.eclipse.milo.stack-core [osgi.identity; osgi.identity="org.eclipse.milo.stack-core"; type="osgi.bundle"; version:Version="0.1.0.SNAPSHOT"]
    import: (&(osgi.wiring.package=com.google.common.collect)(&(version>=19.0.0)(!(version>=20.0.0))))
     |
    export: osgi.wiring.package=com.google.common.collect; uses:=javax.annotation
  com.google.guava [osgi.identity; osgi.identity="com.google.guava"; type="osgi.bundle"; version:Version="19.0.0"]
    import: (osgi.wiring.package=javax.annotation)
     |
    export: osgi.wiring.package: javax.annotation
  org.eclipse.osgi [osgi.identity; osgi.identity="org.eclipse.osgi"; type="osgi.bundle"; version:Version="3.10.2.v20150203-1939"; singleton:="true"]
    at org.eclipse.osgi.container.Module.start(Module.java:434)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
    at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:393)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
    at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:412)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
    at org.apache.karaf.features.internal.service.FeaturesServiceImpl.startBundle(FeaturesServiceImpl.java:1262)[9:org.apache.karaf.features.core:4.0.5]
    at org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:840)[9:org.apache.karaf.features.core:4.0.5]
    ... 6 more


@ctron
Copy link
Contributor Author

ctron commented Oct 13, 2016

This one seems to be the issue:

karaf@root()> package:exports -p javax.anno
Package Name                | Version | ID  | Bundle Name
--------------------------------------------------------------
javax.annotation.concurrent | 3.0.1   | 145 | org.jsr-305
javax.annotation.meta       | 3.0.1   | 145 | org.jsr-305
javax.annotation.processing | 1.0.0   | 0   | org.eclipse.osgi
javax.annotation            | 1.0.0   | 0   | org.eclipse.osgi
javax.annotation            | 3.0.1   | 145 | org.jsr-305

This change does prevent the maven-bundle-plugin from importing
'javax.annotation' in order to prevent a "uses violation".

Signed-off-by: Jens Reimann <jreimann@redhat.com>
@kevinherron
Copy link
Contributor

kevinherron commented Oct 13, 2016

Yeah, you're on your own with the weird OSGi errors ;) I really have no experience with OSGi, and while I find it to be interesting and somewhat compelling in theory, the reality/implementation seems overly complicated and messy.

@ctron
Copy link
Contributor Author

ctron commented Oct 13, 2016

I know .. and I am just talking to myself in order to remember 😉

This was tricky. And although I seem to have a solution, I don't like the situation.

The JSR 305 annotation live in the same package javax.annotation as the JRE brings along. This is due to the history of JSR 305, which intended to extend Java of course. However this causes a massive problem for OSGi.

As is seems right now JSR 305 will never make into Java. At least not as it is now. But I do see the value of "findbugs". Maybe there is a different way.

@ctron
Copy link
Contributor Author

ctron commented Oct 13, 2016

I am doing one final test now on an actual target. Docker already is fine.

@ctron
Copy link
Contributor Author

ctron commented Oct 13, 2016

Ok ... looks good! Ready to merge, if you like.

@kevinherron kevinherron merged commit 02c0342 into eclipse:master Oct 13, 2016
@kevinherron
Copy link
Contributor

Thanks!

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.

None yet

2 participants