Taughtological if check in Reflection::array_set

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Unresolved
    • Priority: P4
    • 27
    • Affects Version/s: None
    • Component/s: hotspot

      While reviewing code in the Valhalla repository I saw that Reflection::array_set has this funny-looking code:
      ```
        if (a->is_objArray()) {
          if (value_type == T_OBJECT) {
          ...
          } // what happens in the else case? here
        } else {
          assert(a->is_typeArray(), "just checking");
        }
      ```
      And wondered what would happen if the `value_type == T_OBJECT` check failed, and how is this handled with flattened arrays, given that we have T_FLAT_ELEMENT there.

      It turns out that the calling code passes down T_OBJECT even for flat arrays so they do take the `value_type == T_OBJECT` path, so that's fine.

      So, I propose that we just replace one of the ifs with an assert.

            Assignee:
            Stefan Karlsson
            Reporter:
            Stefan Karlsson
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: