8316992: Potential null pointer from get_current_thread JVMCI helper function.
Reviewed-by: thartmann
This commit is contained in:
parent
d1c82156ba
commit
fd89b334c4
@ -179,20 +179,11 @@ Handle JavaArgumentUnboxer::next_arg(BasicType expectedType) {
|
||||
CompilerThreadCanCallJava ccj(thread, __is_hotspot); \
|
||||
JVMCIENV_FROM_JNI(JVMCI::compilation_tick(thread), env); \
|
||||
|
||||
static JavaThread* get_current_thread(bool allow_null=true) {
|
||||
Thread* thread = Thread::current_or_null_safe();
|
||||
if (thread == nullptr) {
|
||||
assert(allow_null, "npe");
|
||||
return nullptr;
|
||||
}
|
||||
return JavaThread::cast(thread);
|
||||
}
|
||||
|
||||
// Entry to native method implementation that transitions
|
||||
// current thread to '_thread_in_vm'.
|
||||
#define C2V_VMENTRY(result_type, name, signature) \
|
||||
JNIEXPORT result_type JNICALL c2v_ ## name signature { \
|
||||
JavaThread* thread = get_current_thread(); \
|
||||
JavaThread* thread = JavaThread::current_or_null(); \
|
||||
if (thread == nullptr) { \
|
||||
env->ThrowNew(JNIJVMCI::InternalError::clazz(), \
|
||||
err_msg("Cannot call into HotSpot from JVMCI shared library without attaching current thread")); \
|
||||
@ -203,7 +194,7 @@ static JavaThread* get_current_thread(bool allow_null=true) {
|
||||
|
||||
#define C2V_VMENTRY_(result_type, name, signature, result) \
|
||||
JNIEXPORT result_type JNICALL c2v_ ## name signature { \
|
||||
JavaThread* thread = get_current_thread(); \
|
||||
JavaThread* thread = JavaThread::current_or_null(); \
|
||||
if (thread == nullptr) { \
|
||||
env->ThrowNew(JNIJVMCI::InternalError::clazz(), \
|
||||
err_msg("Cannot call into HotSpot from JVMCI shared library without attaching current thread")); \
|
||||
@ -219,7 +210,7 @@ static JavaThread* get_current_thread(bool allow_null=true) {
|
||||
// current thread to '_thread_in_vm'.
|
||||
#define C2V_VMENTRY_PREFIX(result_type, name, signature) \
|
||||
JNIEXPORT result_type JNICALL c2v_ ## name signature { \
|
||||
JavaThread* thread = get_current_thread();
|
||||
JavaThread* thread = JavaThread::current_or_null();
|
||||
|
||||
#define C2V_END }
|
||||
|
||||
@ -2616,7 +2607,7 @@ static void attachSharedLibraryThread(JNIEnv* env, jbyteArray name, jboolean as_
|
||||
if (res != JNI_OK) {
|
||||
JNI_THROW("attachSharedLibraryThread", InternalError, err_msg("Trying to attach thread returned %d", res));
|
||||
}
|
||||
JavaThread* thread = get_current_thread(false);
|
||||
JavaThread* thread = JavaThread::thread_from_jni_environment(hotspotEnv);
|
||||
const char* attach_error;
|
||||
{
|
||||
// Transition to VM
|
||||
|
Loading…
Reference in New Issue
Block a user