On Sat, 21 Nov 2020 10:58:49 GMT, Rémi Forax <[email protected]> wrote:
>> It's an implementation invariant that the internal array be Object[]. Having >> it be something other than Object[] can lead to subtle bugs. See >> [JDK-6260652](https://bugs.openjdk.java.net/browse/JDK-6260652) for example. > > you can still calls the varargs with an already created array > listFromTrustedArray(new String[] { "foo" }); > > I think at least an assert is missing > assert input.getClass() == Object.class; If the parameter were of type `E...`, then a call such as `listFromTrustedArray("foo", "bar")` would result in a `String[]`. The idea is to avoid accidents such as the one that caused JDK-6260652, and not prevent deliberate passing of an array of the wrong type, though this is an internal interface so it's unlikely to occur. Still, a stronger comment and an assert might be worthwhile. ------------- PR: https://git.openjdk.java.net/jdk/pull/1026
