`List.of()` along with `Set.of()` create unmodifiable `List/Set` but with 
smaller footprint comparing to `Arrays.asList()` / `new HashSet()` when called 
with vararg of size 0, 1, 2.

In general replacement of `Arrays.asList()` with `List.of()` is dubious as the 
latter is null-hostile, however in some cases we are sure that arguments are 
non-null. Into this PR I've included the following cases (in addition to those 
where the argument is proved to be non-null at compile-time):
- `MethodHandles.longestParameterList()` never returns null
- parameter types are never null
- interfaces used for proxy construction and returned from 
`Class.getInterfaces()` are never null
- exceptions types of method signature are never null

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

Commit messages:
 - 8282662: Use List/Set.of() factory methods to save memory

Changes: https://git.openjdk.java.net/jdk/pull/7729/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=7729&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8282662
  Stats: 22 lines in 8 files changed: 1 ins; 3 del; 18 mod
  Patch: https://git.openjdk.java.net/jdk/pull/7729.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/7729/head:pull/7729

PR: https://git.openjdk.java.net/jdk/pull/7729

Reply via email to