Fork me on GitHub
#java
<
2020-11-20
>
Michaël Salihi13:11:17

@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.

Michaël Salihi14:11:00

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

Michaël Salihi14:11:20

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

Michaël Salihi21:11:08

Does someone master in Java confirm my diagnosis? 😉

Alex Miller (Clojure team)21:11:53

what you said seems correct

Alex Miller (Clojure team)21:11:21

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

👍 3
Alex Miller (Clojure team)21:11:32

so @emccue's advice above is probably right

emccue21:11:37

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

👍 3
emccue21:11:47

that method will always have object as its return

Alex Miller (Clojure team)21:11:29

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

emccue21:11:35

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

Michaël Salihi22:11:41

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