The vararg at the end of the method is just syntactic sugar for an
array, so the "add" method actually takes 4 args, the last being a
Resource array. The java compiler just replaces "missing" varargs
with an empty array.
My guess is that the reflection mechanisms in the compiler just look
at type/arity. The Method object has a isVarArg() boolean, so that
could be used to allow omitting varargs altogether. That would need
to be an enhancement to the clojure compiler, so I opened a ticket:
https://www.assembla.com/spaces/clojure/tickets/440-java-method-calls-cannot-omit-varargs
On Sep 27, 1:16 pm, JonathanBelolo <
jonat...@scorpiomusic.fr> wrote:
> While toying with the Sesame2.3 library, I've come across the
> following behavior for the first time.
>
> This is taken from the api doc for
> org.openrdf.repository.base.RepositoryConnectionBase:
>
> add(Resource subject, URI predicate, Value object, Resource...
> contexts)
> Adds a statement with the specified subject, predicate and
> object to this repository, optionally to one or more named contexts.
>
> But apparently, Clojure seems to think the optional args are
> mandatory...
>
> (.add con alice RDF/TYPE person)
>
> No matching method found: add for class
> org.openrdf.repository.sail.SailRepositoryConnection
> [Thrown class java.lang.IllegalArgumentException]
>
> So I run
>
> (grep #".add" (.getMethods (.getClass con)))
>
> #<Method public void
> org.openrdf.repository.base.RepositoryConnectionBase.add(org.openrdf.model. Resource,org.openrdf.model.URI,org.openrdf.model.Value,
org.openrdf.model.Re source[])