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

Mistaken type check in CheckedEntrySet.toArray

    Details

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

      Description

      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.

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved: