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

Use THREAD instead of CHECK_NULL in return statements

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P2
    • Resolution: Fixed
    • Affects Version/s: 9
    • Fix Version/s: 9
    • Component/s: hotspot
    • Labels:
    • Subcomponent:
      gc
    • Resolved In Build:
      b42

      Backports

        Description

        Take the following method as an example:
         Klass* ConstantPool::klass_ref_at(int which, TRAPS) {
          return klass_at(klass_ref_index_at(which), CHECK_NULL);
         }

        This will expand into:
         Klass* ConstantPool::klass_ref_at(int which, TRAPS) {
          return klass_at(klass_ref_index_at(which), THREAD);
          if (HAS_PENDING_EXCEPTIONS) {
            return NULL;
          }
          (void)(0);
         }

        The if-statement will never be reached.

        We have seen cases where the compiler warns about this, and the recent change to enable -Wreturn-type will make this more likely to happen.

        The suggested solution is to change the example above into:
         Klass* ConstantPool::klass_ref_at(int which, TRAPS) {
          return klass_at(klass_ref_index_at(which), THREAD);
         }

          Attachments

            Issue Links

              Activity

                People

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

                  Dates

                  Created:
                  Updated:
                  Resolved: