...
Variable arity signatures using Object
and imprecise generic types are acceptable when the body of the method lacks both casts and autoboxing auto-boxing, and also compiles without error. Consider the following example, which operates correctly for all object types and type-checks successfully:
...
In some circumstances, it is necessary to use a variable arity parameter of type Object
. A good example of this is the method java.util.Formatter.format(String format, Object... args)
which can format objects of any type.
Automated detection appears to be is straightforward.
Bibliography
...