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

Jetty-util contains wrong Import-Package #5830

Closed
akurtakov opened this issue Dec 21, 2020 · 7 comments · Fixed by #5838
Closed

Jetty-util contains wrong Import-Package #5830

akurtakov opened this issue Dec 21, 2020 · 7 comments · Fixed by #5838
Assignees

Comments

@akurtakov
Copy link
Contributor

Jetty version
10.0.0

Java version
openjdk version "11.0.9.1" 2020-11-04
OpenJDK Runtime Environment 18.9 (build 11.0.9.1+1)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.9.1+1, mixed mode, sharing)

OS type/version
Fedora 33

Description
Trying to use jetty-util in osgi context fails to resolve with:
[ERROR] Missing requirement: org.eclipse.jetty.util 10.0.0 requires 'java.package; com.sun.nio.file 0.0.0' but it could not be found
[ERROR] Cannot satisfy dependency: org.eclipse.help.feature.group 2.3.500.qualifier depends on: org.eclipse.equinox.p2.iu; org.eclipse.jetty.util 0.0.0

Import-Package: com.sun.nio.file,javax.imageio,javax.naming.ldap,javax.n
et.ssl,javax.security.auth.x500,javax.xml.parsers,org.eclipse.jetty.uti
l,org.eclipse.jetty.util.annotation,org.eclipse.jetty.util.component,or
g.eclipse.jetty.util.resource,org.eclipse.jetty.util.security,org.eclip
se.jetty.util.statistic,org.eclipse.jetty.util.thread,org.slf4j;version
="[2.0.0,3)"
the com.sun.nio.file import-package looks needless in fully modularized system.

@janbartel janbartel self-assigned this Dec 21, 2020
@janbartel
Copy link
Contributor

@akurtakov thanks for the report. That is very odd, I cannot see why the maven-bundle-plugin is producing an Import-Package statement for "com.sun.nio.file", I'll look into it. I do note though that our osgi tests don't fail when we deploy jetty-util, so there must be something different about our environments, any clue what it could be?

@akurtakov
Copy link
Contributor Author

My guess would be that the target platform you run your osgi tests against contains a.jre.javase IU for older Java version and thus contains the com.sun.nio.file package.

@janbartel
Copy link
Contributor

@akurtakov I've narrowed this down to this line in org.eclipse.jetty.util.PathWatcher:

Class<?> c = Class.forName("com.sun.nio.file.SensitivityWatchEventModifier");

That seems to cause the maven-bundle-plugin to generate the Import-Package statement for com.sun.io.file. Interestingly, there's a Class.forName a couple of lines above that does not generate an Import-Package:

Class<?> pollingWatchServiceClass = Class.forName("sun.nio.fs.PollingWatchService", false, cl);

I'm assuming that maven-bundle-plugin is looking for the single arg version of Class.forName only. I'm checking if we really need to call the single-arg version, or whether we can call the 3 arg method instead.

janbartel added a commit that referenced this issue Dec 22, 2020
This is acheived by using the 3-arg Class.forName() method call.
The bnd tool which generates the osgi manifests doesn't seem to
include Import-Package statements for the 3-arg method call, but
does for the 1-arg method call. The speculative loading of the
com.sun.nio.file.SensitivityWatchEventModifier will probably be
removed in jetty-10 onwards.

Signed-off-by: Jan Bartel <janb@webtide.com>
@janbartel janbartel linked a pull request Dec 22, 2020 that will close this issue
@janbartel
Copy link
Contributor

Raised PR #5838

janbartel added a commit that referenced this issue Dec 24, 2020
Signed-off-by: Jan Bartel <janb@webtide.com>
@akurtakov
Copy link
Contributor Author

Will this land in Jetty 10 branch too?

@sbordet
Copy link
Contributor

sbordet commented Jan 8, 2021

@akurtakov yes we merge from branch jetty-9.4.x forward to Jetty 10 and 11.

janbartel added a commit that referenced this issue Jan 12, 2021
* Issue #5830 Remove native classes from PathWatcher.

Removed use of com.sun.nio.file.SensitivityWatchEventModifier, no longer needed.
This has the desirable side-effect of getting rid of com.sun.nio.file package imports.

Signed-off-by: Jan Bartel <janb@webtide.com>
@janbartel
Copy link
Contributor

Fixed by #5838.

This was referenced Mar 10, 2021
This was referenced Mar 10, 2021
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 a pull request may close this issue.

3 participants