Use unmodifiable collectors for constants.

Description

Several places, not just in the base libraries, but across the libraries use collectors such as toList(), toSet(), and toMap() to populate constant variables. There was an assumption that these collectors produced read-only objects, but apparently they do not.

Java 8 needs to use the following form to create an unmodifiable map for example:

Java 11 can simply use the new Collectors.toUnmodifiableMap() and analogous methods.

Environment

None

Assignee

Garret Wilson

Reporter

Garret Wilson

Labels

None

Components

Affects versions

Priority

Critical
Configure