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

Rectify Thread::is_ConcurrentGC_thread()

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 18
    • Fix Version/s: 18
    • Component/s: hotspot
    • Labels:
      None
    • Subcomponent:
      gc
    • Resolved In Build:
      b15

      Description

      Thread::is_ConcurrentGC_thread() behaves differently to all other Thread::is_xxx_thread() functions, in the sense that it doesn't directly map to a distinct Thread sub-class. Instead, is_ConcurrentGC_thread() can today return true for both ConcurrentGCThread and GangWorker. These two classes have no super/sub-class relation. This is confusing and and potentially dangerous.

      It would be reasonable to think that code like this would be correct:

        if (thread->is_ConcurrentGC_thread()) {
          conc_thread = static_cast<ConcurrentGCThread*>(thread);
          ...
        }

      but it's not, since we might try to cast a GangWorker to a ConcurrentGCThread. And again, these two classes have no super/sub-class relation.

      I propose that we clean this up, so that is_ConcurrentGCThread() only returns true for threads inheriting from ConcurrentGCThread. The main side-effect is that a handful of asserts need to be adjusted. In return, the code example above would become legal, and we can also remove some cruft from WorkGang/GangWorker.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              pliden Per Liden
              Reporter:
              pliden Per Liden
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: