RFR: 8296935: Arrays.asList().set() with wrong types throws undocumented ArrayStoreException

Stuart Marks smarks at openjdk.org
Mon Jan 23 06:32:06 UTC 2023


On Mon, 23 Jan 2023 02:35:19 GMT, Tingjun Yuan <duke at openjdk.org> wrote:

> Modify `java.util.Arrays.ArrayList.{set,replaceAll}` to throw a `ClassCastException` (as documented in `java.util.List`) when attempting to set an element with a wrong type.

We don't want to change long-standing exception-throwing behavior for these cases. See my comments in [JDK-8296935](https://bugs.openjdk.org/browse/JDK-8296935).

-------------

PR: https://git.openjdk.org/jdk/pull/12135


More information about the core-libs-dev mailing list