clojure-dev

Issues: https://clojure.atlassian.net/browse/CLJ | Guide: https://insideclojure.org/2015/05/01/contributing-clojure/
dominicm 2019-07-23T09:13:36.005600Z

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 😄

bronsa 2019-07-23T09:14:03.005900Z

it's not

bronsa 2019-07-23T09:15:15.007300Z

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

dominicm 2019-07-23T15:20:37.007900Z

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

2019-07-23T18:43:42.012400Z

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.

2019-07-23T18:44:05.012600Z

Clojure 1.10.1 here

2019-07-23T18:44:27.013Z

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

alexmiller 2019-07-23T18:45:11.013500Z

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

alexmiller 2019-07-23T18:45:20.013900Z

could be module accessibility

alexmiller 2019-07-23T18:45:30.014300Z

although usually that's a different message

ghadi 2019-07-23T18:45:45.014700Z

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

alexmiller 2019-07-23T18:47:09.015800Z

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

ghadi 2019-07-23T18:47:31.016500Z

Andy said that class.getConstructors is returning []

ghadi 2019-07-23T18:47:38.016900Z

so no reflector involved

2019-07-23T18:48:22.017600Z

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))

2019-07-23T18:49:47.018100Z

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)))

alexmiller 2019-07-23T18:50:22.018900Z

shows that as a non-public constructor

2019-07-23T18:51:15.019300Z

ugh. Need more coffee, obviously. Thx

ghadi 2019-07-23T18:51:54.019800Z

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

2019-07-23T18:52:58.020400Z

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