java

2020-11-20T13:46:17.118500Z

@emccue Hey thanks again for all the effort and answers, I appreciate. I learned a lot in a few days about Java interop even if it was not the easiest path. For the moment, I left aside this test project because I had a lot of work but I did not completely give up. I intend to recover and compile the dbus-java library locally in order to be able to put debug points in the function which poses a problem. That is to say this one recursiveGetDBusType here: https://github.com/hypfvieh/dbus-java/blob/f51c6668c7a92cd1cdbc4cac1156cd3797a8474a/dbus-java/src/main/java/org/freedesktop/dbus/Marshalling.java#L297 This will allow me to see how Java sees the object that Clojure sends it.

2020-11-20T14:06:00.122100Z

Hey! I think I just find out what is wrong! 🙂 I'm a Java newbies, but if I understand correctly this following for loop, the condition block tests some types, right?

boolean found = false;

                for (Entry<Class<?>, Byte> entry : CLASS_TO_ARGUMENTTYPE.entrySet()) {
                    if (entry.getKey().isAssignableFrom(dataTypeClazz)) {
                        _out[_level].append((char) entry.getValue().byteValue());
                        found = true;
                        break;
                    }
                }
                if (!found) {
                    throw new DBusException("Exporting non-exportable type: " + _dataType);
                }
Source: https://github.com/hypfvieh/dbus-java/blob/f51c6668c7a92cd1cdbc4cac1156cd3797a8474a/dbus-java/src/main/java/org/freedesktop/dbus/Marshalling.java#L297

2020-11-20T14:07:20.122400Z

It's the lack of typing on my object created in my Clojure code that doesn't meet the condition, right?

2020-11-20T14:11:08.123600Z

We can see that CLASS_TO_ARGUMENTTYPE is a LinkedHashMap which contains a list of excpected type: https://github.com/hypfvieh/dbus-java/blob/f51c6668c7a92cd1cdbc4cac1156cd3797a8474a/dbus-java/src/main/java/org/freedesktop/dbus/Marshalling.java#L56

2020-11-20T21:47:08.125300Z

Does someone master in Java confirm my diagnosis? 😉

alexmiller 2020-11-20T21:49:53.125500Z

what you said seems correct

alexmiller 2020-11-20T21:51:21.126400Z

by default, most of the class generating things in Clojure create methods that only take and return Object. But if you are implementing an interface and its methods, it will use those types instead

👍 1
alexmiller 2020-11-20T21:51:32.126700Z

so @emccue's advice above is probably right

emccue 2020-11-20T21:52:37.127600Z

the gen-class is going to have the right type hints, but instead of making state a public final field, it also adds a method to access it

👍 1
emccue 2020-11-20T21:52:47.127900Z

that method will always have object as its return

alexmiller 2020-11-20T21:53:29.128900Z

type hints won't be used when gen'ing the class iirc

emccue 2020-11-20T21:53:35.129Z

that is my current guess as to the problem - deftype wont have that issue

2020-11-20T22:41:41.131100Z

You guys, are awesome. Clojure community are awesome. Thanks you!