Open issues

Add tap-> that returns the value
CLJ-2538
Unpredictable behaviour with combination of type inference and autoboxing
CLJ-2522
ClassFormatError when nesting try->loop->try
CLJ-2521
calls to static interface methods are broken for primitive args
CLJ-2517
remote-prepl blocks main-thread upon in-reader's eos
CLJ-2509
clojure.reflect protocol meta regression
CLJ-2494
Integration with java.util.function interfaces
CLJ-2365
clojure.repl/doc repeats doc string in output for special forms in Clojure 1.9.0
CLJ-2295
case fails for vectors with negative numbers
CLJ-2275
#clojure/var tag for transmitting var identity
CLJ-2165
locals closed over by a ^:once fn aren't cleared if the fn is in a branch
CLJ-2145
Lighter-weight aliasing for keywords
CLJ-2123
[spec] Nesting cat inside ? causes unform to return nested result
CLJ-2003
[spec] clojure.spec/def should support an optional doc-string
CLJ-1965
empty? is broken for transient collections
CLJ-1872
Clojure-generated class names length exceed file-system limit
CLJ-1852
Avoid compile-time static initialization of classes when using inheritance
CLJ-1743
clojure.java.io/pushback-reader
CLJ-1611
Enhance multimethods metadata
CLJ-1522
Unrolled small vectors
CLJ-1517
The locking macro fails bytecode verification on Graal native-image and ART runtime
CLJ-1472
aset-* and aget perform poorly on multi-dimensional arrays even with type hints.
CLJ-1289
java method calls cannot omit varargs
CLJ-440
Unnecessary array clones when creating an empty transient vector
CLJ-2541
prepl does not run with a DynamicClassLoader
CLJ-2540
Differing results for meta with fns
CLJ-2539
sorted-map-by fails for namespaced keywords
CLJ-2537
Compiler.load() reports wrong exception phase
CLJ-2529
Exceptions thrown in tests outside assertions don't report *testing-contexts*
CLJ-2525
CompilerException java.lang.ClassFormatError: Duplicate field name&signature
CLJ-2518
[spec] spec creation should allow checking validity of specs
CLJ-2515
Supporting `add-method` on multi fns to install a function instead of a function tail
CLJ-2514
Macroexpanded case statement throws `java.lang.NegativeArraySizeException`
CLJ-2511
Cannot use clojure.stracktrace/print-stack-trace with GraalVM
CLJ-2502
Provide guidance on configuring error printer for handling errors
CLJ-2501
[spec] explain-data :via loses aliased keys
CLJ-2496
prepl docstring doesn't correctly doc exception :ret maps
CLJ-2495
clojure.java.shell/sh hangs calling xdg-open
CLJ-2493
Uses of deprecated Class.newInstance() method
CLJ-2492
[spec] generator in keys* spec not overridable
CLJ-2483
Document that a promise can be invoked to deliver
CLJ-2480
[core.specs] Destructuring spec is overly restrictive in namespaced :keys
CLJ-2473
transient vectors should support the stack interface (peek/pop)
CLJ-2464
Clojure-aware error stacktrace rendering
CLJ-2456
Doc that rseq works on colls satisfying reversible?
CLJ-2455
Add convenience parse-int, parse-float, parse-short, etc. functions
CLJ-2451
[spec] defining new multimethod for a speced multi method fails under instrumentation
CLJ-2450
[spec] Spec'ed fn doesn't throw when called lazily
CLJ-2443
Invalid calls to clojure.set functions return an incorrect answer rather than error
CLJ-2433
Separate compiler exceptions into :compilation and :compile-syntax-check
CLJ-2428
issue 23 of 729

java method calls cannot omit varargs

Description

Problem

Clojure calls to Java vararg methods require creating an object array for the final arg. This is a frequent source of confusion when doing interop.

E.g., trying to call java.util.Collections.addAll(Collection c, T... elements):

The Method class provides an isVarArg() method, which could be used to inform the compiler to process things differently.

From http://groups.google.com/group/clojure/browse_thread/thread/7d0d6cb32656a621

Latest patch: Removed because incomplete and goal not clear

Varargs in Java

As currently stated, the scope of this ticket is only to omit varargs, but this is only one case where Clojures handling of varargs differs from Java. For completeness, here is a brief survey of how Java handles vararg methods, which could hopefully inform a discussion for how Clojure could do things differently, and what the goal of this ticket should be.

Given the following setup:

VarArgs.java

Java

Possible clojure equivalent?

Comments

VarArgs.SingleVarargMethod.m("a");

(SingleVarargMethod/m "a")

VarArgs.SingleVarargMethod.m("a", "b");

(SingleVarargMethod/m "a" "b")

VarArgs.SingleVarargMethod.m("a", "b", "c");

(SingleVarargMethod/m "a" "b" "c")

VarArgs.SingleVarargMethod.m("a", new String[]{"b", "c"});

(SingleVarargMethod/m "a" (object-array ["b" "c"]))

VarArgs.MultipleVarargMethods.m();

(MultipleVarargMethods/m)

VarArgs.MultipleVarargMethods.m((String) null);

(MultipleVarargMethods/m nil)

Use type hints to disambiguate?

VarArgs.MultipleVarargMethods.m((String[]) null);

(MultipleVarargMethods/m nil)

Use type hints to disambiguate?

VarArgs.MultipleVarargMethods.m("a", null);

(MultipleVarargMethods/m "a" nil)

VarArgs.MultipleVarargMethods.m("a", new String[]{});

(MultipleVarargMethods/m "a" (object-array 0))

VarArgs.MultipleVarargMethods.m(new String[]{"a"});

(MultipleVarargMethods/m (object-array ["a"]))

VarArgs.MultipleVarargMethods.m("a", new String[]{"b", "c"});

(MultipleVarargMethods/m "a" (object-array ["b" "c"]))

Environment

None

Status

Assignee

Ragnar Dahlén

Reporter

Alexander Taggart

Labels

Approval

Triaged

Patch

None

Priority

Critical
Configure