1

Java code:

public void foo(Object[] args) {}

disassembled signature from class file:

  public void foo(java.lang.Object[]);
    Code:
       0: return

Java code:

public void foo(Object... args) {}

disassembled signature from class file:

  public void foo(java.lang.Object...);
    Code:
       0: return

So the class file keeps the difference.

Maybe the original parameter type string (i.e. Object[]/Object...) is stored in the class file and javap just show them.

Or maybe the binary signature in the class file is differenct which means that varargs is not just syntactic sugar.

Which is true?

jw_
  • 1,663
  • 18
  • 32
  • There is a flag in the bytecode that says it was varargs. https://stackoverflow.com/a/21746736/1527544 – Antoniossss Sep 21 '19 at 13:39
  • Also there is slight difference in case of empty array. myVarargFunc() will be valid with varargs but not with array argument. – Antoniossss Sep 21 '19 at 13:42

0 Answers0