Fork me on GitHub
#clojure-dev
<
2019-07-23
>
dominicm09:07:36

the way I heard the story is that clojure's protocols were invented later, so anything from before that was not included as a protocol. Clojurescript, coming later, bootstrapped to protocols as quickly as possible so that everything else could be built upon them. Could just be an urban legend though 😄

bronsa09:07:15

that's pretty accurate, but even if protocols were invented before the clojure impl existed, the JVM is significantly different than the js runtime, meaning that a protocol-at-the-bottom impl in clojure-jvm would be significantly complex to bootstrapp and potentially much less performant

dominicm15:07:37

ah, that's an interesting detail :thinking_face: I will add it to future tellings to strangers in conference halls

andy.fingerhut18:07:42

I am seeing a situation with Oracle JDK 1.8 on a Mac (haven't tested others yet, but can if you think it matters) where I try to make a Java interop call from Clojure to a public constructor of a Java class on the classpath. It can find the class just fine, but I get the error message "No matching ctor found ...". The code printing that error message in the compiler is calling c.getConstructors() on the class c, and finding an empty list of constructors, which I also see in the REPL. Using clojure.reflect/type-reflect, the constructor is present.

andy.fingerhut18:07:05

Clojure 1.10.1 here

andy.fingerhut18:07:27

Any leads on finding out what is going on here, or trigger any memories of similar situations?

alexmiller18:07:11

can you share example, stack trace, error msg, etc?

alexmiller18:07:20

could be module accessibility

alexmiller18:07:30

although usually that's a different message

ghadi18:07:45

dumb q @andy.fingerhut but are you sure the class contains the constructor you expect?

alexmiller18:07:09

type matching on the args is probably the most likely reason not to find it

ghadi18:07:31

Andy said that class.getConstructors is returning []

ghadi18:07:38

so no reflector involved

andy.fingerhut18:07:22

I have debug print added to Java code just before error of my copy of Clojure 1.10.1, and it definitely shows 0 constructors returned by c.getConstructors() method call, before doing any filtering by parameter types. REPL session also shows 0 constructors from this call: (seq (.getConstructors org.openjdk.jol.info.GraphPathRecord))

andy.fingerhut18:07:47

The weird thing is that this call does show the constructor showing up: (filter #(instance? clojure.reflect.Constructor %) (:members (clojure.reflect/type-reflect org.openjdk.jol.info.GraphPathRecord)))

alexmiller18:07:22

shows that as a non-public constructor

andy.fingerhut18:07:15

ugh. Need more coffee, obviously. Thx

ghadi18:07:54

(fwiw I don't find it helpful to show non-public stuff in reflect/datafy)

andy.fingerhut18:07:58

Sorry for the noise. Just realizing now that clojure.reflect/type-reflect uses a different Java API call that also returns non-public constructors.