< prev index next >

src/jdk.jdi/share/classes/com/sun/tools/jdi/ThreadReferenceImpl.java

Print this page
*** 74,13 ***
       * both ThreadReferenceImpl and ObjectReferenceImpl register themselves as
       * VMListeners so that they get notified when all threads are suspended and
       * when any thread is resumed.
       */
  
!     // This is cached for the life of the thread
      private ThreadGroupReference threadGroup;
  
      // This is cached only while this one thread is suspended.  Each time
      // the thread is resumed, we abandon the current cache object and
      // create a new initialized one.
      private static class LocalCache {
          JDWP.ThreadReference.Status status = null;
--- 74,17 ---
       * both ThreadReferenceImpl and ObjectReferenceImpl register themselves as
       * VMListeners so that they get notified when all threads are suspended and
       * when any thread is resumed.
       */
  
!     // The ThreadGroup is cached for the life of the thread
      private ThreadGroupReference threadGroup;
  
+     // Whether a thread is a virtual thread or not is cached
+     private volatile boolean isVirtual;
+     private volatile boolean isVirtualCached;
+ 
      // This is cached only while this one thread is suspended.  Each time
      // the thread is resumed, we abandon the current cache object and
      // create a new initialized one.
      private static class LocalCache {
          JDWP.ThreadReference.Status status = null;

*** 595,10 ***
--- 599,27 ---
                  throw exc.toJDIException();
              }
          }
      }
  
+     @Override
+     public boolean isVirtual() {
+         if (isVirtualCached) {
+             return isVirtual;
+         } else {
+             boolean result;
+             try {
+                 result = JDWP.ThreadReference.IsVirtual.process(vm, this).isVirtual;
+             } catch (JDWPException exc) {
+                 throw exc.toJDIException();
+             }
+             isVirtual = result;
+             isVirtualCached = true;
+             return result;
+         }
+     }
+ 
      public String toString() {
          return "instance of " + referenceType().name() +
                 "(name='" + name() + "', " + "id=" + uniqueID() + ")";
      }
  
< prev index next >