< prev index next >

src/jdk.jdi/share/classes/com/sun/jdi/ThreadReference.java

Print this page

  1 /*
  2  * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
  3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4  *
  5  * This code is free software; you can redistribute it and/or modify it
  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.  Oracle designates this
  8  * particular file as subject to the "Classpath" exception as provided
  9  * by Oracle in the LICENSE file that accompanied this code.
 10  *
 11  * This code is distributed in the hope that it will be useful, but WITHOUT
 12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 14  * version 2 for more details (a copy is included in the LICENSE file that
 15  * accompanied this code).
 16  *
 17  * You should have received a copy of the GNU General Public License version
 18  * 2 along with this work; if not, write to the Free Software Foundation,
 19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 20  *
 21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 22  * or visit www.oracle.com if you need additional information or have any
 23  * questions.
 24  */
 25 
 26 package com.sun.jdi;
 27 
 28 import java.util.List;
 29 
 30 import com.sun.jdi.event.EventSet;

 31 
 32 /**
 33  * A thread object from the target VM.
 34  * A ThreadReference is an {@link ObjectReference} with additional
 35  * access to thread-specific information from the target VM.
 36  *
 37  * @author Robert Field
 38  * @author Gordon Hirsch
 39  * @author James McIlree
 40  * @since  1.3
 41  */
 42 public interface ThreadReference extends ObjectReference {
 43 
 44     /** Thread status is unknown */
 45     public final int THREAD_STATUS_UNKNOWN  =-1;
 46     /** Thread has completed execution */
 47     public final int THREAD_STATUS_ZOMBIE = 0;
 48     /** Thread is runnable */
 49     public final int THREAD_STATUS_RUNNING = 1;
 50     /** Thread is sleeping - Thread.sleep() or JVM_Sleep() was called */
 51     public final int THREAD_STATUS_SLEEPING = 2;
 52     /** Thread is waiting on a java monitor */
 53     public final int THREAD_STATUS_MONITOR = 3;
 54     /** Thread is waiting - Object.wait() or JVM_MonitorWait() was called */



 55     public final int THREAD_STATUS_WAIT = 4;
 56     /** Thread has not yet been started */
 57     public final int THREAD_STATUS_NOT_STARTED = 5;
 58 
 59     /**
 60      * Returns the name of this thread.
 61      *
 62      * @return the string containing the thread name.
 63      */
 64     String name();
 65 
 66     /**
 67      * Suspends this thread. The thread can be resumed through
 68      * {@link #resume} or resumed with other threads through
 69      * {@link VirtualMachine#resume}.
 70      * <p>
 71      * Unlike {@link java.lang.Thread#suspend},
 72      * suspends of both the virtual machine and individual threads are
 73      * counted. Before a thread will run again, it must be resumed
 74      * (through {@link #resume} or {@link ThreadReference#resume})

456      *
457      * @throws NativeMethodException if the frame to be returned from
458      * is that of a native method.
459      *
460      * @throws InvalidStackFrameException if there are no frames.
461      *
462      * @throws InvalidTypeException if the value's type does not match
463      * the method's return type.
464      *
465      * @throws ClassNotLoadedException if the method's return type has not yet
466      * been loaded through the appropriate class loader.
467      *
468      * @throws VMCannotBeModifiedException if the VirtualMachine is read-only - see {@link VirtualMachine#canBeModified()}.
469      *
470      * @since 1.6
471      */
472     void forceEarlyReturn(Value value) throws InvalidTypeException,
473                                               ClassNotLoadedException,
474                                               IncompatibleThreadStateException;
475 















476 }

  1 /*
  2  * Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved.
  3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4  *
  5  * This code is free software; you can redistribute it and/or modify it
  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.  Oracle designates this
  8  * particular file as subject to the "Classpath" exception as provided
  9  * by Oracle in the LICENSE file that accompanied this code.
 10  *
 11  * This code is distributed in the hope that it will be useful, but WITHOUT
 12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 14  * version 2 for more details (a copy is included in the LICENSE file that
 15  * accompanied this code).
 16  *
 17  * You should have received a copy of the GNU General Public License version
 18  * 2 along with this work; if not, write to the Free Software Foundation,
 19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 20  *
 21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 22  * or visit www.oracle.com if you need additional information or have any
 23  * questions.
 24  */
 25 
 26 package com.sun.jdi;
 27 
 28 import java.util.List;

 29 import com.sun.jdi.event.EventSet;
 30 import jdk.internal.javac.PreviewFeature;
 31 
 32 /**
 33  * A thread object from the target VM.
 34  * A ThreadReference is an {@link ObjectReference} with additional
 35  * access to thread-specific information from the target VM.
 36  *
 37  * @author Robert Field
 38  * @author Gordon Hirsch
 39  * @author James McIlree
 40  * @since  1.3
 41  */
 42 public interface ThreadReference extends ObjectReference {
 43 
 44     /** Thread status is unknown */
 45     public final int THREAD_STATUS_UNKNOWN  =-1;
 46     /** Thread has completed execution */
 47     public final int THREAD_STATUS_ZOMBIE = 0;
 48     /** Thread is runnable */
 49     public final int THREAD_STATUS_RUNNING = 1;
 50     /** Thread is sleeping - {@link Thread#sleep(long)}. */
 51     public final int THREAD_STATUS_SLEEPING = 2;
 52     /** Thread is waiting on a java monitor */
 53     public final int THREAD_STATUS_MONITOR = 3;
 54     /** Thread is waiting - {@link Object#wait()} or
 55      * {@link java.util.concurrent.locks.LockSupport#park()}.
 56      * A virtual thread that is sleeping in {@link Thread#sleep(long)} may
 57      * have this thread status instead of {@link #THREAD_STATUS_SLEEPING}. */
 58     public final int THREAD_STATUS_WAIT = 4;
 59     /** Thread has not yet been started */
 60     public final int THREAD_STATUS_NOT_STARTED = 5;
 61 
 62     /**
 63      * Returns the name of this thread.
 64      *
 65      * @return the string containing the thread name.
 66      */
 67     String name();
 68 
 69     /**
 70      * Suspends this thread. The thread can be resumed through
 71      * {@link #resume} or resumed with other threads through
 72      * {@link VirtualMachine#resume}.
 73      * <p>
 74      * Unlike {@link java.lang.Thread#suspend},
 75      * suspends of both the virtual machine and individual threads are
 76      * counted. Before a thread will run again, it must be resumed
 77      * (through {@link #resume} or {@link ThreadReference#resume})

459      *
460      * @throws NativeMethodException if the frame to be returned from
461      * is that of a native method.
462      *
463      * @throws InvalidStackFrameException if there are no frames.
464      *
465      * @throws InvalidTypeException if the value's type does not match
466      * the method's return type.
467      *
468      * @throws ClassNotLoadedException if the method's return type has not yet
469      * been loaded through the appropriate class loader.
470      *
471      * @throws VMCannotBeModifiedException if the VirtualMachine is read-only - see {@link VirtualMachine#canBeModified()}.
472      *
473      * @since 1.6
474      */
475     void forceEarlyReturn(Value value) throws InvalidTypeException,
476                                               ClassNotLoadedException,
477                                               IncompatibleThreadStateException;
478 
479     /**
480      * Returns {@code true} if the thread is a
481      * <a href="{@docRoot}/java.base/java/lang/Thread.html#virtual-threads">virtual thread</a>.
482      *
483      * @return true if the thread is a virtual thread
484      *
485      * @implSpec
486      * The default implementation throws {@code UnsupportedOperationException}.
487      *
488      * @since 99
489      */
490     @PreviewFeature(feature = PreviewFeature.Feature.VIRTUAL_THREADS)
491     default boolean isVirtual() {
492         throw new UnsupportedOperationException("Method not implemented");
493     }
494 }
< prev index next >