Kotlin vararg arguments method invoke jave vararg arguments method boxed two times


#1

When kotlin class has an method like
fun kotlin(vararg args:Any) {
JavaTest.foo(args)
}
JavaTest.java has an method
public static void foo(Object… objects){
System.out.println(Arrays.deepToString(objects));
}

invoke kotlin(“test”,1,“foo”,3.4) then get the result
[[test, 1, foo, 3.4]]

But invoke from a java vararg arguments method boxed only time


#2

Use spread operator.