What part of the Java language specification describes the behavior of omitted varargs?

I am looking for the appropriate part of the Java Language Specification (JLS), which describes the behavior when calling the method of the variable arity (vararg).

Consider the method:

public static void printVarArgs(String... args) {
    System.out.println(Arrays.toString(args));
}

If I call the method as follows:

printVarArgs();

The result will look like this: []because the omission argson the call site has been converted to an empty array in the method printVarArgs.

I am looking for a JLS point that defines this behavior. The closest I found 15.12.4.2 Evaluation of arguments , but this does not give this example, and I'm not sure that this case is actually covered by a formal / mathematical description.

What part of JLS describes the automatic creation of an empty array when vararg is omitted?

+5
2

JLS :

arity (Β§8.4.1) m, n > 0. m T[] T, m k >= 0.

m kn , m k != n, kth T[], (e1, ... , en-1, en, ...ek) , (e1, ..., en-1, new T[]{en, ..., ek}).

, , k == n - 1, en, ..., ek - , , , (e1, ..., en-1, new T[]{}).

, , .

+4

JLS 15.12.4.2:

m T [] T, m k >= 0.

. , , , .

+5

All Articles