diff --git a/README.md b/README.md index 29d7c776..3b519f87 100644 --- a/README.md +++ b/README.md @@ -114,6 +114,7 @@ The library will remain open source and MIT licensed and can still be used, fork - Use Junit BOM thanks to [spannm](https://github.com/spannm) ([PR#248](https://github.com/hypfvieh/dbus-java/issues/248)) - More Java 17 syntactic sugar, thanks to [spannm](https://github.com/spannm) ([PR#249](https://github.com/hypfvieh/dbus-java/issues/249)) - Added support for custom ClassLoader/ModuleLayer when configuring Transport (allows usage of third party transports when e.g. using JPMS) ([#251](https://github.com/hypfvieh/dbus-java/issues/251)) + - Improved handling of `@DBusBoundProperty` annotation ([#253](https://github.com/hypfvieh/dbus-java/issues/253)), ([PR#252](https://github.com/hypfvieh/dbus-java/issues/252)) ##### Changes in 5.0.0 (2024-01-25): - **Updated minimum required Java version to 17** diff --git a/dbus-java-core/src/main/java/org/freedesktop/dbus/propertyref/PropRefRemoteHandler.java b/dbus-java-core/src/main/java/org/freedesktop/dbus/propertyref/PropRefRemoteHandler.java index 44a91c97..a7b2698b 100644 --- a/dbus-java-core/src/main/java/org/freedesktop/dbus/propertyref/PropRefRemoteHandler.java +++ b/dbus-java-core/src/main/java/org/freedesktop/dbus/propertyref/PropRefRemoteHandler.java @@ -65,13 +65,24 @@ public static Object handleDBusBoundProperty(AbstractConnection _conn, RemoteObj String[] variantType = type != null ? new String[] {Marshalling.getDBusType(type)} : null; + RemoteObject propertiesRemoteObj = new RemoteObject(_remote.getBusName(), _remote.getObjectPath(), Properties.class, _remote.isAutostart()); + + Object result = null; + if (access == Access.READ) { - return RemoteInvocationHandler.executeRemoteMethod(_remote, PROP_GET_METHOD, + result = RemoteInvocationHandler.executeRemoteMethod(propertiesRemoteObj, PROP_GET_METHOD, new Type[] {_method.getGenericReturnType()}, _conn, RemoteInvocationHandler.CALL_TYPE_SYNC, null, DBusNamingUtil.getInterfaceName(_method.getDeclaringClass()), name); } else { - return RemoteInvocationHandler.executeRemoteMethod(_remote, PROP_SET_METHOD, variantType, + result = RemoteInvocationHandler.executeRemoteMethod(propertiesRemoteObj, PROP_SET_METHOD, variantType, new Type[] {_method.getGenericReturnType()}, _conn, RemoteInvocationHandler.CALL_TYPE_SYNC, null, DBusNamingUtil.getInterfaceName(_method.getDeclaringClass()), name, _args[0]); } + + // requested return type is not Variant but the result is -> unwrap Variant + if (_method.getReturnType() != Variant.class && typeClass != Variant.class && result instanceof Variant v) { + return v.getValue(); + } + + return result; } private static Method getPropertiesMethod(String _method, Class... _signature) {