Mistaken type check in CheckedEntrySet.toArray

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P3
    • 11
    • Affects Version/s: None
    • Component/s: core-libs

      errorprone reports:

      java/java/util/Collections.java:3819: warning: [IsInstanceOfClass] The argument to Class#isInstance(Object) should not be a Class

                  @SuppressWarnings("unchecked")
                  public Object[] toArray() {
                      Object[] source = s.toArray();

                      /*
                       * Ensure that we don't get an ArrayStoreException even if
                       * s.toArray returns an array of something other than Object
                       */
                      Object[] dest = (CheckedEntry.class.isInstance(
                          source.getClass().getComponentType()) ? source :
                                       new Object[source.length]);

      although the only consequence of the mistake is an extra copy.

            Assignee:
            Martin Buchholz
            Reporter:
            Martin Buchholz
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: