Welcome! Please see the About page for a little more info on how this works.

0 votes
in Clojure by
closed by

Just when I think i'm getting the hang of clojure/java interop, i get
stumped!

I want to make use of some java code,jkahypar.

It is nicely registered in Maven, and I have a slug in my projects.clj:

[fr.cril/jkahypar "0.2.0"]

I can import the particular tool I am starting with:

(import fr.univartois.cril.jkahypar.tools.HypergraphParser)
=> fr.univartois.cril.jkahypar.tools.HypergraphParser

(type HypergraphParser)
=> java.lang.Class

what i can NOT do is call either of the class's constructor methods,
using either a String or InputStream for the data file path:

(def tf ".../graphs/add20.metis")

(def fs (clojure.java.io/input-stream tf))
(type fs)
=> java.io.BufferedInputStream
	

(def hgp (HypergraphParser/HypergraphParser tf))

Syntax error (IllegalArgumentException) compiling . at (/private/var/folders/dz/8plg36qs1r50kjb6wvn4dwh00000gn/T/form-init7854241673144140259.clj:1:10).
No matching method HypergraphParser found taking 1 args for class fr.univartois.cril.jkahypar.tools.HypergraphParser

(def hgp (HypergraphParser/HypergraphParser fs))

Syntax error (IllegalArgumentException) compiling . at (/private/var/folders/dz/8plg36qs1r50kjb6wvn4dwh00000gn/T/form-init7854241673144140259.clj:1:10).
No matching method HypergraphParser found taking 1 args for class fr.univartois.cril.jkahypar.tools.HypergraphParser

i've tried a bunch of other variants on this, but nothing seems to
work.

is there a way to get ("reflect"?) the methods available on this class that might let me know what is amiss? i'm used to having my Cursive IDE pop up prompts (eg, telling me it knew of HypergraphParser), but i don't get any when I type the slash / after this class?

any ideas what am i doing wrong, please?

closed with the note: resolved

1 Answer

+1 vote
by
selected by
 
Best answer

Constructor call: (HypergraphParser. tf)

You're trying (ClassName/ClassName arg) so Clojure is looking for a (static) method ClassName inside the class ClassName.

by
that's it, thanks very much Sean!  NOW I find the doc telling me about the trailing dot and the (new) special form for constructors; once blind now I see.
...