Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8281301

Map.of() calls with null argument should throw more contextual information.

XMLWordPrintable

      A DESCRIPTION OF THE PROBLEM :
      Apologies if this discussion has already occurred. I think Map1() and particularly MapN() in ImmutableCollections.java should return more contextual information if a value is null. Changing the lines to something like
      K k = Objects.requireNonNull((K)input[i], () -> "Key for map entry " + i + " was null");
      and
      V v = Objects.requireNonNull((V)input[i+1], () -> "Value for map entry " + i + " was null");
      could prevent some heartache, and these are already more or less off the happy path, so the performance impact should be minimal.


            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: