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

Introduce Thread::as_Java_thread() convenience function

    XMLWordPrintable

    Details

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

      Description

      It is very common to see code like this:

      void foo(Thread* thread) {
        assert(thread->is_Java_thread(), "must be");
        JavaThread* jthread = (JavaThread*) thread;

      This can be simplified by adding as_Java_thread:

      JavaThread* Thread::as_JavaThread() {
        assert(is_Java_thread(), "must be");
        return static_cast<JavaThread*>(this);
      }

      so we can then simply have:

      void foo(Thread* thread) {
        JavaThread* jthread = thread->as_Java_thread();

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              dholmes David Holmes
              Reporter:
              dholmes David Holmes
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: