jnr / jnr-unixsocket

UNIX domain sockets (AF_UNIX) for Java
Apache License 2.0
278 stars 75 forks source link

Duplicate package export: jnr.enxio.channels #58

Closed JulianSchuette closed 5 years ago

JulianSchuette commented 6 years ago

In its MANIFST.MF, jnr-unixsocket exports package jnr.enxio.channels. However, the same package is exported by its dependency bundle jnr-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 and jnr-enxio -> jnr.enxio.channels into two different packages, e.g. jnr.enxio.channels.api and jnr.enxio.channels.impl.

A workaround without modifying package names could be to use Require-Bundle: jnr-enxio in MANIFEST.MF of jnr-unixsocket.

[1] https://osgi.org/specification/osgi.core/7.0.0/framework.module.html

guenhter commented 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.

headius commented 5 years ago

This definitely needs to be fixed. I don't think there's any reason it needs to use the enxio package.

headius commented 5 years ago

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.