Closed JulianSchuette closed 5 years ago
Also happens for Java 9:
Error:java: the unnamed module reads package jnr.enxio.channels from both jnr.unixsocket and jnr.enxio
Looking forward to see this fixed.
This definitely needs to be fixed. I don't think there's any reason it needs to use the enxio package.
Ok, part of the problem is that it used this package to gain access to the package-private Native
class from jnr-enxio. For simpliciy, I'm just going to make a release of enxio with that class public, since all it really does is bind some libc IO functions. Obviously the right fix (hopefully someone can assist) would be to make jnr-unixsocket just use jnr-enxio or jnr-posix to handle the actual FFI bindings.
In its MANIFST.MF,
jnr-unixsocket
exports packagejnr.enxio.channels
. However, the same package is exported by its dependency bundlejnr-enxio.
This results in ClassNotFoundExceptions in OSGi environments because the class loader will bind exclusively to one bundle and thus fail to load classes from the other bundle. See section 3.6.6 in the OSGi spec [1], for instance.A clean fix would be splitting the classes in
jnr-unixsocket -> jnr.enxio.channels
andjnr-enxio -> jnr.enxio.channels
into two different packages, e.g.jnr.enxio.channels.api
andjnr.enxio.channels.impl
.A workaround without modifying package names could be to use
Require-Bundle: jnr-enxio
in MANIFEST.MF ofjnr-unixsocket
.[1] https://osgi.org/specification/osgi.core/7.0.0/framework.module.html