- Legacy 4.x:
- Javadoc 4.x:
- Current 5.x:
- Javadoc 5.x:
- Site: Maven Site
Improved version of Java-DBus library provided by freedesktop.org with support for Java 21+.
Updating dbus-java to a newer major version may always introduce incompatibilities due to breaking changes in classes, methods or API.
If you plan to update to a newer version, please check the update guides below.
| dbus-java version | Required JDK/JRE | Remarks |
|---|---|---|
| 2.7.x | JDK 8 | First forked version with some minor fixes |
| 3.x.x | JDK 8 | General overhaul version |
| 4.x.x | JDK 11 | First version using newer JDK and features (java modules), introduced new artifact names and split between core library and transports |
| 5.x.x | JDK 17 | Lots of cleanups, helper methods and better testing, usage of new JDK features (sealed classes) |
| 6.x.x | JDK 21 | Current version |
In DBus-Java version below < 4.3.1 file descriptor usage was not supported out of the box and required a third party libary (see below). Starting with version 4.3.1 file descriptors are supported when using junixsocket-transport.
When trying to use file descriptors in dbus-java 3.x and not providing a implementation for this feature, you may see weird NullPointerExceptions thrown in Message class. In dbus-java < 4.3.1 you should see error messages indicating that file descriptors are not supported.
To use file descriptors with dbus-java version 4.x before 4.3.1 you have to do the following:
- Add dbus-java-transport-jnr-unixsocket dependency to your project
- Remove dbus-java-transport-native-unixsocket if you have used it before
- Add dependency com.rm5248:dbus-java-nativefd to your classpath
When using dbus-java-nativefd, you have to use version 2.x when using dbus-java 4.x/5.x and 1.x if you use dbus-java 3.x. DBus-java will automatically detect dbus-java-nativefd and will then provide access to file descriptors.
If you are using version 4.3.1 or higher, you may simple switch to dbus-java-transport-junixsocket (instead of dbus-java-transport-jnr-unixsocket or dbus-java-transport-native-unixsocket).
You do this by adding dbus-java-transport-junixsocket to your classpath.
Remember to remove the other unixsocket implementations because you are not allowed to have multiple implementations of the same protocol at once.
When adding dbus-java-transport-junixsocket to your classpath, you will also pull-in some artifacts of junixsocket project.
It is also possible that junixsocket will not work on your platform (depends on which platform and architecture you are using).
They provide a lot of ready-to-use artifacts for different platforms and architectures, but certainly not for all possible combinations out there.
In case your platform is not supported, you may try dbus-java-transport-jnr-unixsocket with com.rm5248:dbus-java-nativefd, compile
junixsocket yourself or open a ticket at junixsocket asking for help.
See the list in our Wiki
This project receives code contributions and donations from LogonBox.
However LogonBox is not responsible for this project and does not take influence in the development.
The library will remain open source and MIT licensed and can still be used, forked or modified for free.
- Minimum Java version: 21
- Removed all methods, members and classes marked as deprecated
- Update JUnit to Version 6
- Remove
throws IOExceptionfromAbstractConnectionBase.close()(Issue #287) - Support usage of
Structs as return value (as alternative toTuplewith generics) (based on discussion in #285) - Updated dependencies and plugins
- Added support to use
Structdatatypes as return values instead ofTuple#- Before this change, only
Tuplebased classes could be returned when multiple values were need as result of a method call - this leads to very long definitions of classes in diamond operators (e.g.,
GetCurrentStateTuple<UInt32, List<GetCurrentStateMonitorsStruct>, List<GetCurrentStateLogicalMonitorsStruct>, Map<String, Variant<?>>>) - with this change, you can also create Structs and use them as return value having something like
GetCurrentStateStructinstead of using the long Tuple-name - Further details on this in #285
- Before this change, only
- Added new commandline option
--disable-tuplestoInterfaceCodeGeneratorto createStructclasses instead ofTuples for multi value return (Caution the generated code will only work with dbus-java 6.0.0+)
- removed properties from dbus-java.version which causes issues with reproducable builds (PR#279)
- Re-Implemented
DBusMatchRule- The new implementation can be found in
org.freedesktop.dbus.matchrules.DBusMatchRule, the oldDBusMatchRuleclass still exists and is now a subclass of the new implementation but is deprecated. - use
DBusMatchRuleBuilderto create instances of the newDBusMatchRule - the
AbstractConnection.addSigHandler(DBusMatchRule, SigHandler)is nowpublicand can be used to register arbitrary rules - the new implementation supports additional MatchRules as defined by DBus Specification (except eavesdrop)
- Extended
EmbeddedDBusDaemonto properly support MatchRules
- The new implementation can be found in
- Improved
InterfaceCodeGeneratorto properly create Tuple classes and create empty signal classes as well - Dependency updates
- Plugin updates
- Increased minimum required Maven version from 3.6.3 to 3.9.3
- Update site descriptors
- Addressed a few PMD findings
- Fixed issue when using
DBusPath("/")ingetRemoteObjectmethod (#290)
- Added new Helper class
VariantBuilderto allow creating Variants which contain Maps or Collections without messing with the required DBus type arguments - Fixed wrong/missing increment when resolving nested structs or deeply nested objects in
Marshalling.getDBusType(#265) - Fixed wrong import when generating Tuple containing Struct (#264)
- Added support for argument prefix for methods and constructors in
InterfaceCodeGenerator(to e. g. allow generating code using similar code style like dbus-java with prefixing every argument with_) - Fixed printed version information in
InterfaceCodeGeneratorwas alwaysnull - Smaller code cleanup in
InterfaceCodeGeneratorto prevent creating multiple empty lines - Dependency updates
- Added support for
EmitsChangedSignal(PR#267), thanks to GeVa2072 - Tighten PMD rules to disallow usage of
varkeyword - Updated Maven plugins
- Improved documentation
- Fixed issue with arrays, primitive arrays and
Collectionwhen used in signal constructors (#268) - Improvements when using library in Kotlin projects (PR#270), thanks to vicr123
- Fixed exporting of methods which used a
Tuplereturn type causedClassCastException(#271) - Deprecated
ObjectPath, useDBusPathinstead - Added
of(String...)factory method toDBusPath - Smaller refactorings to reduce duplicated code
- Added additional
getRemoteObjectmethods which usesDBusPathas argument - Smaller improvements in empty array creation and other minor Improvements (PR#276), thanks to joerg1985
- Use Junit BOM thanks to spannm (PR#248)
- More Java 17 syntactic sugar, thanks to spannm (PR#249)
- Added support for custom ClassLoader/ModuleLayer when configuring Transport (allows usage of third party transports when e.g. using JPMS) (#251)
- Improved handling of
@DBusBoundPropertyannotation (#253), (PR#252) - Improved InterfaceCodeGenerator to handle generated struct class names properly (#254)
- Improved InterfaceCodeGenerator to add parameter/argument name to created struct class name (e.g. MyMethod(something) => MyMethodSomethingStruct)
- Added dbus-java-transport-junixsocket to BOM (#255)
- Fixed issues in InterfaceCodeGenerator regarding missing imports or wrong annotation content (#257)
- Fixed issues with
GetAllon Properites using Annotations (#258) - Changed behavior of de-serialization on Variants containing Collections (Lists). Collections which contained a object which also has a primitive representation the collection was always converted to an array of primitives (e.g. Variant<List> got Variant<int[]> on de-serialization). This is usually not expected. When defining a Variant<List> it is expected to return that same type when de-serialized. The wrong behavior also caused issues when using
GetAllmethod inPropertiesinterface. More information - Deprecated
DBusMap- all methods previously used or returnedDBusMapwill now return aLinkedHashMap - Fixed
hashCode()andequals()method inDBusPath(hashCode()was completely wrong and violating thehashCode()contract when e.g. used as key in maps) - Added possibility to use
WeakHashMapfor imported objects (configurable byDBusConnectionBuilder), default behavior of using aConcurrentHashMapis not changed (yet) (#261)
- Updated minimum required Java version to 17
- Removed all classes and methods marked as deprecated in 4.x
- Updated dependencies and maven plugins
- Improved handling of listening connections to allow proper bootstrapping the connection before actually starting accepting new connections (thanks to brett-smith (#213))
- Updated export-object documentation (#236)
- Fixed issues with autoConnect option, added method to register to bus by 'Hello' message manually, thanks to brett-smith (#238)
- Added feature which allows to annotate setter or getter methods in exported objects to use the DBus Properties interface behind the scenes, thanks to brett-smith (PR#235)
ExportedObject.isExcluded(Method)now returns true for bridge, default and synthetic methods, reported by brett-smith (#240)- DBusViewer: Remove DOCTYPE definition in introspection data using a regex which handles line breaks properly
- Applied changes found by Sonarcloud static code analysis
- Fixed issue with shared connections did not work when underlying transport was disconnected due to end-point (daemon) was stopped/restarted (#244)
- Fixed class cast exception in LoggingHelper (#247), reported by AsamK
