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

APIs that require JavaThread should take JavaThread arguments

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 17
    • 16
    • hotspot
    • b23

      For a variety of historical reasons we tend to use "Thread*" as a parameter type widely throughout the VM (in particular this is likely due to the use of TRAPS/CHECK* and the fanout therefrom). In many cases though the first thing a method does is cast the Thread* to JavaThread* as it "must be a JavaThread". We should look at changing those APIs so that they take a JavaThread* parameter to begin with.

      This will also impact the definition of JVM_ENTRY/JNI_ENTRY etc which typically declare:

      JavaThread * thread = JavaThreadCurrent();
      Thread* THREAD = thread; // Needed for CHECK macro

      and the TRAPS macro (as exceptions should only be relevant to JavaThreads in the first place).

      This may also lead into related refactoring of the Thread hierarchy as there are things in Thread that really only pertain to JavaThread (or at least Java-executing threads, which not be exactly the same thing - TBD).

      It isn't clear how far we can unravel this and clean up the APIs, but it is worth investigating.

      This will also lead into cleanups in the ObjectMonitor code to rationalise the use of Self/THREAD/jt.

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

              Created:
              Updated:
              Resolved: