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

Introduce Thread::as_Java_thread() convenience function

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Fixed
    • P4
    • 16
    • 16
    • hotspot
    • 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

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

              Dates

                Created:
                Updated:
                Resolved: