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

Make Monitor inherit from Mutex

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 14
    • Fix Version/s: 14
    • Component/s: hotspot
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b12

      Description

      And not the other way around.

      Currently Monitor is the base class, and Mutex inherits from it in order to hide the notify and wait functions. This is easily defeated by having a Mutex downcast to Monitor implicitly, and then it can call notify or wait. So the Mutex class doesn't strongly serve the purpose of encapsulation.

      It seems worth keeping the distinction between Monitor and Mutex since most code mostly deals with Mutex in locking code (eg MutexLocker) and commentary.

      Lastly, PlatformMonitor inherits from PlatformMutex, so it made sense for the higher level runtime classes to do the same. Note that I didn't change Mutex underlying lock. That could be a further enhancement.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                coleenp Coleen Phillimore
                Reporter:
                coleenp Coleen Phillimore
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: