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

Replace some enums with static const members in hotspot/compiler

XMLWordPrintable

    • b23

      In JDK-8211073, we tried to enable -Wextra for gcc on hotspot. This triggers the "enumeral and non-enumeral type in conditional expression" warning for eight methods in hotspot. The code typically looks like this:

      types[index] = (tag.is_unresolved_klass()) ? JVM_CONSTANT_Class : tag.value();

      but tag.value() returns an unsigned char, and JVM_CONSTANT_Class is an enum.

      Kim Barrett suggested to rewrite those enums to be static const members instead. This would allow us to enable -Wextra, without having to add casts to the enums in the ?: clauses.

      The enums in question that triggers this warning are:

      * CompLevel_highest_tier
      * Op_RegFlags
      * NO_HASH
      * JVM_CONSTANT_Class

      I'm also getting the compiler warning for Klass::_lh_array_tag_obj_value, but from my cursory reading of the source code it is not clear to me that any of them is an enum..? But apparently the compiler believes this, so it's probably correct.

            rraghavan Rahul Raghavan
            ihse Magnus Ihse Bursie
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: