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

DBusConnectionBuilder tried to access private field DBusConnection.CONNECTIONS #171

Closed l0drex closed 2 years ago

l0drex commented 2 years ago

I upgraded to version 4.1.0 and saw that DBusConnection.getConnection(DBusConnection.DBusBusType.SESSION) was deprecated, so I replace it with the Builder as suggested in the docs:

DBusConnectionBuilder.forSessionBus().build()

But now I get the following errors:

class org.freedesktop.dbus.connections.impl.DBusConnectionBuilder tried to access private field org.freedesktop.dbus.connections.impl.DBusConnection.CONNECTIONS (org.freedesktop.dbus.connections.impl.DBusConnectionBuilder and org.freedesktop.dbus.connections.impl.DBusConnection are in unnamed module of loader 'app')
java.lang.IllegalAccessError: class org.freedesktop.dbus.connections.impl.DBusConnectionBuilder tried to access private field org.freedesktop.dbus.connections.impl.DBusConnection.CONNECTIONS (org.freedesktop.dbus.connections.impl.DBusConnectionBuilder and org.freedesktop.dbus.connections.impl.DBusConnection are in unnamed module of loader 'app')
    at org.freedesktop.dbus.connections.impl.DBusConnectionBuilder.build(DBusConnectionBuilder.java:259)

Is this a bug, or do I use the Builder wrong?

hypfvieh commented 2 years ago

Are you sure you only have the new version in classpath not the new and a older version?

The member CONNECTIONS in DBusConnection was private in the older versions and is now package visible (because the builder needs access to it and is in the same package). So if the member would still be private, the library would not compile.

l0drex commented 2 years ago

No, I checked the version and deleted all build and cache directories, the error is still there. I am using this with Kotlin and Gradle, could that be the problem?

hypfvieh commented 2 years ago

This should not be an issue, but I'm not using kotlin or gradle. Can you reproduce this in a sample project and upload so I can have a look?

l0drex commented 2 years ago

So I created the example, but I can't reproduce it there. I guess Gradle indeed did mess up the versions somewhere, I just don't know why.