Comments (9)
I've looked at this case and I agree that something is missing here.
I first investigated what you mentioned about PropRefRemoteHandler
.
When the method handleDBusBoundProperty
is used it is assumed that Properties
is supported by the given remote object.
That is wrong. The remote object the method receives is an arbitrary object which is not necessarily related to Properties
.
In most cases the object behind the remote path is supporting Properties
but not necessarily the object passed to this method.
So your fix to create another remote object using Properties
will work because the calls are delegated to the object behind the path, not to the given object itself.
For me this seems to be a valid fix. Some tests would be great, but how to test a thing which did work before?
The second thing you mentioned is Marshalling
class.
I have to admit I don't see why there is a need to change anything. Also I'm not sure what your change should do. When debugging this the parameter
is not Variant
it is String
so the code will never be executed.
The right fix for this is again in PropRefRemoteHandler
.
When handleDBusBoundProperty
has executed the remote method call, it must take care of the result.
What is happening here?
The remote call will (hopefully) resolve the requested property and as the javadoc on that method already says, all properties on DBus are always Variant
.
Variant
may not be the type of object we want to return here. This depends on how the @DBusBoundProperty
was used (e.g. the return of the method is Variant
).
So we may have to unwrap the Variant
here to get the correct object type:
Object result = null;
if (access == Access.READ) {
result = RemoteInvocationHandler.executeRemoteMethod(propertiesRemoteObj, PROP_GET_METHOD,
new Type[] {_method.getGenericReturnType()}, _conn, RemoteInvocationHandler.CALL_TYPE_SYNC, null, DBusNamingUtil.getInterfaceName(_method.getDeclaringClass()), name);
} else {
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;
I've already updated master branch to include this patch and your patch as well.
from dbus-java.
I did some more work on this stuff.
I found that there are some combinations of implementing Properties
and using @DBusBoundProperty
annotation which will not work or will not produce the expected results.
Especially some instanceof checks with @DBusProperties
annotations were definitely wrong as no object exported on/to the bus can/will ever be a subclass of an annotation.
All changes are already in master
branch so you can try it when the new snapshot is deployed to snapshot repository.
from dbus-java.
Related Issues (20)
- dbus-java's Maven site is difficult to discover
- Emit meaningful error message instead of IndexOutOfBoundsException when demarshalling FileDescriptor without prerequisites satisfied HOT 5
- DBusSignal constructor is package private HOT 1
- Kotlin Interface does not work HOT 3
- NPE in org.freedesktop.dbus.connections.AbstractConnection.internalDisconnect(IOException) prevents JVM shutdown HOT 4
- Documentation example does not work correctly. HOT 1
- In version 5, `withAutoConnect(false)` appears broken. HOT 2
- Cleanup AbstractConnection
- `default` interface methods. Or not. HOT 7
- problem to execute DBusViewer HOT 3
- How to export/publish Property in interface? HOT 2
- Properties Get method endless waiting HOT 1
- Cannot connect to DBUS HOT 11
- Sending signal with byte[] fails with verbose logging HOT 1
- [Feature request] Any plan in adding a module-info ? HOT 2
- Custom ITransportProvider cannot be found by ServiceLoader HOT 4
- Incorrect code generation for systemd StartTransientUnit HOT 3
- Add dbus-java-transport-junixsocket to dbus-java-bom
- Help with DBusConnectionBuilder HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dbus-java.