java.lang.Thread.
Two parallel sets of definitions are used here, one for internal implementation purposes, the other for the JNI interface. The first uses internal data types (via #ifdef JLTHREAD_LOCAL_DEFINED) where the second does not. Instead, it uses <jni.h> data
types. Those types must match up for JNI to work, yet by keeping them absolutely separate, application JNI code does not have any dependencies on the core code of this JVM implementation.
Even though there is only apparently one set of definitions, the #ifdef statement
controls which set is used.
This file must be included by JNI code along with the java.lang.Class JNI
header file. The following example shows how to call one of the local native methods of this class from the JNI environment. Notice that although this is not necessary due to the local implementation shortcut defined in native.c, it is not only possible, but sometimes quite desirable to do so.
#include <jni.h> #include <solaris/jni_md.h> ... or appropriate platform-specifics #include "java_lang_Thread.h" ... JNI definitions #include "jlThread.h" ... this file JNIEXPORT jboolean JNICALL Java_java_lang_Thread_holdsLock(JNIEnv *env, jclass thisclass, jobject thisobj) { jboolean b; b = jlThread_holdsLock(thisclass, thisobj); ... call native implementation return(b); }
Although jvalue is indeed a part of both this implementation and the standard JNI interface through <jni.h>
, it is not recommended to use it if at all possible. Due to the fact that both definitions involve unions, along with the slightly differing contents between the two versions, it is almost certain that there will be compilation compatibility problems in the memory layouts from one platform to another, and possibly between the layouts between them on any given platform. Since jvalue is not specificaly a Java type, but instead a JNI construction, this may not be a problem, but this advisory is raised anyway in order to encourage reliable implementation of JNI.
Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
Licensed under the Apache License, Version 2.0 ("the License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
Definition in file jlThread.h.
#include "jlObject.h"
Go to the source code of this file.
|
Value: case JLTHREAD_NMO_CURRENTTHREAD: \ case JLTHREAD_NMO_YIELD: \ case JLTHREAD_NMO_INTERRUPT: \ case JLTHREAD_NMO_INTERRUPTED: \ case JLTHREAD_NMO_ISINTERRUPTED: \ case JLTHREAD_NMO_SLEEP: \ case JLTHREAD_NMO_SLEEP_NANOS: \ case JLTHREAD_NMO_JOIN4EVER: \ case JLTHREAD_NMO_JOINTIMED: \ case JLTHREAD_NMO_JOINTIMED_NANOS: \ case JLTHREAD_NMO_ISALIVE: \ case JLTHREAD_NMO_START: \ case JLTHREAD_NMO_COUNTSTACKFRAMES: \ case JLTHREAD_NMO_HOLDSLOCK: \ case JLTHREAD_NMO_SETPRIORITY: \ case JLTHREAD_NMO_GETPRIORITY: \ case JLTHREAD_NMO_DESTROY: \ case JLTHREAD_NMO_CHECKACCESS: \ case JLTHREAD_NMO_SETDAEMON: \ case JLTHREAD_NMO_ISDAEMON: \ case JLTHREAD_NMO_STOP: java.lang.Thread.
Definition at line 366 of file jlThread.h. Referenced by native_verify_ordinal_definition(). |
|
Table of local native methods and their descriptors for
Definition at line 393 of file jlThread.h. |
|
Value: case JLTHREAD_NMO_YIELD: \ case JLTHREAD_NMO_INTERRUPT: \ case JLTHREAD_NMO_SLEEP: \ case JLTHREAD_NMO_SLEEP_NANOS: \ case JLTHREAD_NMO_JOIN4EVER: \ case JLTHREAD_NMO_JOINTIMED: \ case JLTHREAD_NMO_JOINTIMED_NANOS: \ case JLTHREAD_NMO_START: \ case JLTHREAD_NMO_SETPRIORITY: \ case JLTHREAD_NMO_DESTROY: \ case JLTHREAD_NMO_CHECKACCESS: \ case JLTHREAD_NMO_SETDAEMON: \ case JLTHREAD_NMO_STOP: \ case JLTHREAD_NMO_SUSPEND: \ case JLTHREAD_NMO_RESUME: (jvoid ) local native method ordinal table for java.lang.Thread
Definition at line 436 of file jlThread.h. |
|
Definition at line 457 of file jlThread.h. |
|
Value: case JLTHREAD_NMO_INTERRUPTED: \ case JLTHREAD_NMO_ISINTERRUPTED: \ case JLTHREAD_NMO_ISALIVE: \ case JLTHREAD_NMO_COUNTSTACKFRAMES: \ case JLTHREAD_NMO_HOLDSLOCK: \ case JLTHREAD_NMO_GETPRIORITY: \ case JLTHREAD_NMO_ISDAEMON: (jint ) local native method ordinal table for java.lang.Thread
Definition at line 464 of file jlThread.h. |
|
No
Definition at line 473 of file jlThread.h. |
|
No
Definition at line 474 of file jlThread.h. |
|
No
Definition at line 475 of file jlThread.h. |
|
Definition at line 133 of file jlThread.h. |
|
JNI hook to currentThread().
Definition at line 308 of file jlThread.c. References CURRENT_THREAD, jfalse, threadstate_request_badlogic(), and threadstate_request_runnable(). Referenced by Java_java_lang_Thread_currentThread(), and native_run_local_return_jobject(). |
|
JNI hook to yield().
Definition at line 332 of file jlThread.c. References CURRENT_THREAD, jfalse, jtrue, THREAD, and THREAD_STATUS_INTERRUPTED. Referenced by Java_java_lang_Thread_yield(), and native_run_local_return_jvoid(). |
|
JNI hook to interrupt(). The THREAD_STATUS_INTERRUPTED bit is unconditionally set here. The logic for clearing the bit and throwing exceptions is performed when this bit is read by other functions.
< Object is a
< Object is a
< Object is a < This slot contains an object
< Object is a < This slot contains an object
< Object is a
< Object is a < This slot contains an object
< Object is a < This slot contains an object
< Object is a
< Object is a < Access structures of the thread now running in the JVM.
< thread threw a Definition at line 498 of file jlThread.c. References jfalse, jtrue, OBJECT_THREAD_LINKAGE, rtrue, THREAD, THREAD_STATUS_INTERRUPTED, VERIFY_OBJECT_THREAD_LINKAGE, and VERIFY_THREAD_LINKAGE. Referenced by Java_java_lang_Thread_interrupt(), and native_run_local_return_jvoid(). |
|
JNI hook to interrupted().
|
|
JNI hook to isInterrupted(). Status is UNCHANGED by this method after testing it.
< Object is a
< Object is a
< Object is a < This slot contains an object
< Object is a < This slot contains an object
< Object is a
< Object is a < This slot contains an object
< Object is a < This slot contains an object
< Object is a
< Object is a Definition at line 565 of file jlThread.c. Referenced by Java_java_lang_Thread_isInterrupted(), and native_run_local_return_jint(). |
|
JNI hook to sleep(). < Access structures of the thread now running in the JVM. < thread is sleeping Definition at line 117 of file jlThread.c. References CURRENT_THREAD, THREAD, THREAD_STATUS_SLEEP, and threadstate_request_runnable(). Referenced by Java_java_lang_Thread_sleep__J(), jlThread_sleep_nanos(), and native_run_local_return_jint(). |
|
JNI hook to sleep_nanos(). Ignore the sleeptime_nanoseconds parameter in this implementation. Definition at line 143 of file jlThread.c. References jlThread_sleep(). Referenced by Java_java_lang_Thread_sleep__JI(), and native_run_local_return_jint(). |
|
JNI hook to join4ever(). < Access structures of the thread now running in the JVM. < This slot contains an object
< Object is a Definition at line 201 of file jlThread.c. Referenced by Java_java_lang_Thread_join(), and native_run_local_return_jvoid(). |
|
JNI hook to jointimed(). < Access structures of the thread now running in the JVM. < This slot contains an object
< Object is a Definition at line 228 of file jlThread.c. Referenced by Java_java_lang_Thread_join__J(), and native_run_local_return_jvoid(). |
|
JNI hook to jointimed_nanos(). Ignore the sleeptime_nanoseconds parameter in this implementation. Definition at line 259 of file jlThread.c. References CURRENT_THREAD, and THREAD. Referenced by Java_java_lang_Thread_join__JI(), and native_run_local_return_jvoid(). |
|
JNI hook to jointimed().
< Object is a
< Object is a
< Object is a < This slot contains an object
< Object is a < This slot contains an object
< Object is a
< Object is a < This slot contains an object
< Object is a < This slot contains an object
< Object is a
< Object is a Definition at line 627 of file jlThread.c. References CHECK_FINAL_STACK_FRAME_GENERIC, FIRST_STACK_FRAME, JVMCLASS_JAVA_LANG_ILLEGALTHREADSTATEEXCEPTION, NEXT_STACK_FRAME_GENERIC, OBJECT_THREAD_LINKAGE, rfalse, THREAD, THREAD_STATUS_INTERRUPTED, THREAD_STATUS_THREW_EXCEPTION, thread_throw_exception(), VERIFY_OBJECT_THREAD_LINKAGE, and VERIFY_THREAD_LINKAGE. Referenced by Java_java_lang_Thread_isAlive(), and native_run_local_return_jint(). |
|
JNI hook to start(). This will only succeed if thread is in NEW state.
< Object is a
< Object is a
< Object is a < This slot contains an object
< Object is a < This slot contains an object
< Object is a
< Object is a < This slot contains an object
< Object is a < This slot contains an object
< Object is a
< Object is a Definition at line 687 of file jlThread.c. References CURRENT_THREAD, jfalse, jtrue, JVMCLASS_JAVA_LANG_ILLEGALARGUMENTEXCEPTION, JVMCLASS_JAVA_LANG_SECURITYEXCEPTION, OBJECT_THREAD_LINKAGE, rtrue, THREAD, THREAD_PRIORITY_MAX, THREAD_PRIORITY_MIN, THREAD_STATUS_THREW_EXCEPTION, thread_throw_exception(), VERIFY_OBJECT_THREAD_LINKAGE, and VERIFY_THREAD_LINKAGE. Referenced by Java_java_lang_Thread_start(), and native_run_local_return_jint(). |
|
JNI hook to countStackFrames().
< Object is a
< Object is a
< Object is a < This slot contains an object
< Object is a < This slot contains an object
< Object is a
< Object is a < This slot contains an object
< Object is a < This slot contains an object
< Object is a
< Object is a
< thread threw a Definition at line 742 of file jlThread.c. References OBJECT_THREAD_LINKAGE, rtrue, THREAD, THREAD_PRIORITY_BAD, VERIFY_OBJECT_THREAD_LINKAGE, and VERIFY_THREAD_LINKAGE. Referenced by Java_java_lang_Thread_countStackFrames(), and native_run_local_return_jint(). |
|
JNI hook to holdsLock().
< thread threw a < Access structures of the thread now running in the JVM. Definition at line 418 of file jlThread.c. Referenced by Java_java_lang_Thread_holdsLock(), and native_run_local_return_jint(). |
|
JNI hook to setPriority().
< thread threw a < This slot contains an object
< Object is a
< Object is a
< Object is a < This slot contains an object
< Object is a < This slot contains an object
< Object is a
< Object is a < This slot contains an object
< Object is a < This slot contains an object
< Object is a
< Object is a Definition at line 831 of file jlThread.c. References CURRENT_THREAD, jfalse, jtrue, JVMCLASS_JAVA_LANG_SECURITYEXCEPTION, OBJECT_THREAD_LINKAGE, rtrue, THREAD_STATUS_THREW_EXCEPTION, thread_throw_exception(), VERIFY_OBJECT_THREAD_LINKAGE, and VERIFY_THREAD_LINKAGE. Referenced by Java_java_lang_Thread_setPriority(), and native_run_local_return_jint(). |
|
JNI hook to getPriority().
< Object is a
< Object is a
< Object is a < This slot contains an object
< Object is a < This slot contains an object
< Object is a
< Object is a < This slot contains an object
< Object is a < This slot contains an object
< Object is a
< Object is a Definition at line 914 of file jlThread.c. References CURRENT_THREAD, JVMCLASS_JAVA_LANG_SECURITYEXCEPTION, THREAD_STATUS_THREW_EXCEPTION, and thread_throw_exception(). Referenced by Java_java_lang_Thread_getPriority(), and native_run_local_return_jint(). |
|
JNI hook to destroy(). Simply kill the thread without any cleanup. THIS IS A VERY BAD THING! (Perhaps this is why most JDK's do not implement this method any more!)
There is typically no implementation done of
< Object is a
< Object is a
< Object is a < This slot contains an object
< Object is a < This slot contains an object
< Object is a
< Object is a < This slot contains an object
< Object is a < This slot contains an object
< Object is a
< Object is a Definition at line 973 of file jlThread.c. References jfalse, jtrue, OBJECT_THREAD_LINKAGE, THREAD, and THREAD_STATUS_ISDAEMON. Referenced by Java_java_lang_Thread_destroy(), and native_run_local_return_jint(). |
|
JNI hook to checkAccess(). This method will always give permission in this JVM.
< Object is a
< Object is a
< Object is a < This slot contains an object
< Object is a < This slot contains an object
< Object is a
< Object is a < This slot contains an object
< Object is a < This slot contains an object
< Object is a
< thread threw a Definition at line 1037 of file jlThread.c. References OBJECT_THREAD_LINKAGE, rtrue, THREAD, VERIFY_OBJECT_THREAD_LINKAGE, and VERIFY_THREAD_LINKAGE. Referenced by Java_java_lang_Thread_checkAccess(), and native_run_local_return_jint(). |
|
JNI hook to setDaemon().
< Object is a
< Object is a
< Object is a < This slot contains an object
< Object is a < This slot contains an object
< Object is a
< Object is a < This slot contains an object
< Object is a < This slot contains an object
< Object is a
< thread threw a < This slot contains an object
< Object is a < Daemon thread state, vs user thread, per Thread.isdaemon()
< thread threw a Definition at line 1136 of file jlThread.c. References CURRENT_THREAD, JVMCLASS_JAVA_LANG_SECURITYEXCEPTION, OBJECT_THREAD_LINKAGE, rtrue, THREAD, THREAD_STATUS_SUSPEND, THREAD_STATUS_THREW_EXCEPTION, thread_throw_exception(), threadstate_activate_badlogic(), threadstate_request_badlogic(), threadstate_request_blockingevent(), VERIFY_OBJECT_THREAD_LINKAGE, and VERIFY_THREAD_LINKAGE. Referenced by Java_java_lang_Thread_setDaemon(), and native_run_local_return_jvoid(). |
|
JNI hook to isDaemon().
< Object is a
< Object is a
< Object is a < This slot contains an object
< Object is a < This slot contains an object
< Object is a
< Object is a < This slot contains an object
< Object is a < This slot contains an object
< Object is a
< Object is a Definition at line 1230 of file jlThread.c. References CURRENT_THREAD, JVMCLASS_JAVA_LANG_SECURITYEXCEPTION, OBJECT_THREAD_LINKAGE, rtrue, THREAD, THREAD_STATE_BADLOGIC, THREAD_STATE_BLOCKED, THREAD_STATE_BLOCKINGEVENT, THREAD_STATUS_SUSPEND, THREAD_STATUS_THREW_EXCEPTION, thread_throw_exception(), threadstate_activate_blocked(), threadstate_activate_blockingevent(), threadstate_process_blocked(), threadstate_process_blockingevent(), threadstate_request_blocked(), threadstate_request_blockingevent(), threadstate_request_unblocked(), VERIFY_OBJECT_THREAD_LINKAGE, and VERIFY_THREAD_LINKAGE. Referenced by Java_java_lang_Thread_isDaemon(), and native_run_local_return_jint(). |
|
JNI hook to stop().
There is typically no native implementation of
< Object is a
< Object is a
< Object is a < This slot contains an object
< Object is a < This slot contains an object
< Object is a
< Object is a < This slot contains an object
< Object is a < This slot contains an object
< Object is a
< thread threw a < This slot contains an object
< Object is a < Object monitor locked by mlock_thridx < Object monitor locked by mlock_thridx Definition at line 1364 of file jlThread.c. Referenced by Java_java_lang_Thread_stop(), and native_run_local_return_jvoid(). |
|
JNI hook to suspend(). Results are undefined if thread has the SLEEP, WAIT4EVER, WAITTIMED, or INTERRUPTIBLEIO status or if thread has been NOTIFIED or INTERRUPTED. This will work if thread is in any state at all.
< Object is a
< Object is a
< Object is a < This slot contains an object
< Object is a < This slot contains an object
< Object is a
< Object is a < This slot contains an object
< Object is a < This slot contains an object
< Object is a
< Object is a < Access structures of the thread now running in the JVM.
< thread threw a Definition at line 1476 of file jlThread.c. Referenced by Java_java_lang_Thread_suspend(), and native_run_local_return_jvoid(). |
|
JNI hook to resume(). Results are undefined if thread has the SLEEP, WAIT4EVER, WAITTIMED, or INTERRUPTIBLEIO status or if thread has been NOTIFIED or INTERRUPTED. This will work if thread is in any state at all.
< Object is a
< Object is a
< Object is a < This slot contains an object
< Object is a < This slot contains an object
< Object is a
< Object is a < This slot contains an object
< Object is a < This slot contains an object
< Object is a
< Object is a < Access structures of the thread now running in the JVM.
< thread threw a Definition at line 1568 of file jlThread.c. Referenced by Java_java_lang_Thread_resume(), and native_run_local_return_jvoid(). |