Uploaded image for project: 'HPPC'
  1. HPPC
  2. HPPC-46

toArray() on object types must return actual T[], not Object[]

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 0.4.0
    • Component/s: Core
    • Labels:
      None

      Description

      There is actually a comment in the code about this (ObjectArrayList):

      • The actual value in this field is always <code>Object[]</code>, regardless of the
      • generic type used. The JDK is inconsistent here too – {@link ArrayList}

        declares

      • internal <code>Object[]</code> buffer, but {@link ArrayDeque}

        declares an array of

      • generic type objects like we do. The tradeoff is probably minimal, but you should
      • be aware of additional casts generated by <code>javac</code>
      • when <code>buffer</code> is directly accessed - these casts may result in exceptions
      • at runtime. A workaround is to cast directly to <code>Object[]</code> before
      • accessing the buffer's elements.

      but this can't stay this way indeed, it's weird. I'll look for a workaround.

        Attachments

          Activity

            People

            • Assignee:
              dweiss Dawid Weiss
              Reporter:
              dweiss Dawid Weiss
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: