hypfvieh / dbus-java

Improved version of java DBus library provided by freedesktop.org (https://dbus.freedesktop.org/doc/dbus-java/)
https://hypfvieh.github.io/dbus-java/
MIT License
185 stars 73 forks source link

sun.misc entry in dbus-java-osgi pom.xml preventing compilation #117

Closed NatAmundsen closed 3 years ago

NatAmundsen commented 4 years ago

I don't see jnr-unixsocket depending on sun.misc anymore in the latest release, and it doesn't provide that package, so now the use of sun.misc impedes compilation.

Originally posted by @NatAmundsen in https://github.com/hypfvieh/dbus-java/issues/78#issuecomment-680969003

NatAmundsen commented 4 years ago

Actually, it looks like it does need it, but I can't find it in the current release of jnr-unixsocket. Here's the output from trying to call DBusConnection.getConnection():

Caused by: java.lang.NoClassDefFoundError: sun/misc/SignalHandler
    at jnr.posix.POSIXFactory.getJavaPOSIX(POSIXFactory.java:54)
    at jnr.posix.POSIXFactory.getJavaPOSIX(POSIXFactory.java:64)
    at org.freedesktop.dbus.connections.SASL.auth(SASL.java:410)

At that line in SASL.java:

        long uid = POSIXFactory.getJavaPOSIX().getuid();

POSIXFactory is part of jnr-posix, not jnr-unixsocket.

jnr-posix is a dependency of jnr-unixsocket, but it is not explicitly labeled as a dependency in dbus-java despite using it in SASL.java. Adding jnr-posix as a dependency may help.

NatAmundsen commented 4 years ago

I solved this by adding com.diffplug.osgi/com.diffplug.osgi.extension.sun.misc/0.0.0 to my runtime dependencies. I haven't tested it, but I expect adding that to the pom.xml would help solve the issue too.

hypfvieh commented 4 years ago

I have to admit I don't test or use the OSGI bundled version of dbus-java, it was contributed by someone and will be packaged when creating new versions.

Nice finding anyways. I added the required package to the OSGI bundle pom, I hope that the guys at jnr-posix will get rid of using sun.misc in the future...