clojure 2026-05-02

I have a problem invoking dynamically a constructor of a java class which takes "variadic" String. The first syntax does work, while I want the second to work, as I want to create the class "reflective":

(org.renjin.sexp.StringArrayVector. (into-array String ["1"]))
;;=> #object[org.renjin.sexp.StringArrayVector 0x50f4d755 "1"]

(clojure.lang.Reflector/invokeConstructor
   (Class/forName "org.renjin.sexp.StringArrayVector")
   (into-array String ["1"]))
;;=> Execution error (IllegalArgumentException) at scicloj.metamorph.ml.r-model-matrix/eval54341 (r_model_matrix.clj:102).
;;   No matching ctor found for class org.renjin.sexp.StringArrayVector
;;

found it.... "array of array" was needed for invokeConstructore

(clojure.lang.Reflector/invokeConstructor
   (Class/forName "org.renjin.sexp.StringArrayVector")
   (object-array [(into-array String ["1"])])))

it needs an array of arguments? and you were just passing the arguments rather than a collection of them?

ha. that stuff gets tricky sometimes and you just have to rubber duck it. basically apply

👍 1