Uploaded image for project: 'Commons Math'
  1. Commons Math
  2. MATH-284

Avoid ArrayStoreException

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.0
    • 3.0
    • None
    • None

    Description

      Add a new method
      org.apache.commons.math,Field#getRuntimeClass():
      ...
      /**

      • Returns the runtime class of the FieldElement.
      • @return The {@code Class}

        object that represents the runtime

      • class of this object.
        */
        Class<? extends FieldElement> getRuntimeClass();
        ...

      and replace all occurrences of
      Array.newInstance(field.getZero().getClass(),....)
      with
      Array.newInstance(field.getRuntimeClass(),....)

      to avoid the throwing of ArrayStoreException in the case you have a type hierachy of Fields with a common interface
      and the array should have the interface type at runtime.

      Attachments

        1. math-284.patch
          11 kB
          Luc Maisonobe

        Activity

          People

            Unassigned Unassigned
            khartlage Klaus
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: