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

Introduce Thread::as_Java_thread() convenience function

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 16
    • 16
    • hotspot
    • b16

      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();

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

              Created:
              Updated:
              Resolved: