< prev index next >

src/hotspot/share/prims/jvm.cpp

Print this page

3164   }
3165 JVM_END
3166 
3167 JVM_ENTRY(void, JVM_SetNativeThreadName(JNIEnv* env, jobject jthread, jstring name))
3168   // We don't use a ThreadsListHandle here because the current thread
3169   // must be alive.
3170   oop java_thread = JNIHandles::resolve_non_null(jthread);
3171   JavaThread* thr = java_lang_Thread::thread(java_thread);
3172   if (thread == thr && !thr->has_attached_via_jni()) {
3173     // Thread naming is only supported for the current thread and
3174     // we don't set the name of an attached thread to avoid stepping
3175     // on other programs.
3176     ResourceMark rm(thread);
3177     const char *thread_name = java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(name));
3178     os::set_native_thread_name(thread_name);
3179   }
3180 JVM_END
3181 
3182 JVM_ENTRY(jobject, JVM_ExtentLocalCache(JNIEnv* env, jclass threadClass))
3183   oop theCache = thread->extentLocalCache();
3184   if (theCache) {
3185     arrayOop objs = arrayOop(theCache);
3186     assert(objs->length() == ExtentLocalCacheSize * 2, "wrong length");
3187   }
3188   return JNIHandles::make_local(THREAD, theCache);
3189 JVM_END
3190 
3191 JVM_ENTRY(void, JVM_SetExtentLocalCache(JNIEnv* env, jclass threadClass,
3192                                        jobject theCache))
3193   arrayOop objs = arrayOop(JNIHandles::resolve(theCache));
3194   if (objs != NULL) {
3195     assert(objs->length() == ExtentLocalCacheSize * 2, "wrong length");
3196   }
3197   thread->set_extentLocalCache(objs);
3198 JVM_END
3199 
3200 // java.lang.SecurityManager ///////////////////////////////////////////////////////////////////////
3201 
3202 JVM_ENTRY(jobjectArray, JVM_GetClassContext(JNIEnv *env))
3203   ResourceMark rm(THREAD);
3204   JvmtiVMObjectAllocEventCollector oam;
3205   vframeStream vfst(thread);
3206 
3207   if (vmClasses::reflect_CallerSensitive_klass() != NULL) {
3208     // This must only be called from SecurityManager.getClassContext
3209     Method* m = vfst.method();
3210     if (!(m->method_holder() == vmClasses::SecurityManager_klass() &&
3211           m->name()          == vmSymbols::getClassContext_name() &&
3212           m->signature()     == vmSymbols::void_class_array_signature())) {
3213       THROW_MSG_NULL(vmSymbols::java_lang_InternalError(), "JVM_GetClassContext must only be called from SecurityManager.getClassContext");
3214     }
3215   }
3216 

3164   }
3165 JVM_END
3166 
3167 JVM_ENTRY(void, JVM_SetNativeThreadName(JNIEnv* env, jobject jthread, jstring name))
3168   // We don't use a ThreadsListHandle here because the current thread
3169   // must be alive.
3170   oop java_thread = JNIHandles::resolve_non_null(jthread);
3171   JavaThread* thr = java_lang_Thread::thread(java_thread);
3172   if (thread == thr && !thr->has_attached_via_jni()) {
3173     // Thread naming is only supported for the current thread and
3174     // we don't set the name of an attached thread to avoid stepping
3175     // on other programs.
3176     ResourceMark rm(thread);
3177     const char *thread_name = java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(name));
3178     os::set_native_thread_name(thread_name);
3179   }
3180 JVM_END
3181 
3182 JVM_ENTRY(jobject, JVM_ExtentLocalCache(JNIEnv* env, jclass threadClass))
3183   oop theCache = thread->extentLocalCache();




3184   return JNIHandles::make_local(THREAD, theCache);
3185 JVM_END
3186 
3187 JVM_ENTRY(void, JVM_SetExtentLocalCache(JNIEnv* env, jclass threadClass,
3188                                        jobject theCache))
3189   arrayOop objs = arrayOop(JNIHandles::resolve(theCache));



3190   thread->set_extentLocalCache(objs);
3191 JVM_END
3192 
3193 // java.lang.SecurityManager ///////////////////////////////////////////////////////////////////////
3194 
3195 JVM_ENTRY(jobjectArray, JVM_GetClassContext(JNIEnv *env))
3196   ResourceMark rm(THREAD);
3197   JvmtiVMObjectAllocEventCollector oam;
3198   vframeStream vfst(thread);
3199 
3200   if (vmClasses::reflect_CallerSensitive_klass() != NULL) {
3201     // This must only be called from SecurityManager.getClassContext
3202     Method* m = vfst.method();
3203     if (!(m->method_holder() == vmClasses::SecurityManager_klass() &&
3204           m->name()          == vmSymbols::getClassContext_name() &&
3205           m->signature()     == vmSymbols::void_class_array_signature())) {
3206       THROW_MSG_NULL(vmSymbols::java_lang_InternalError(), "JVM_GetClassContext must only be called from SecurityManager.getClassContext");
3207     }
3208   }
3209 
< prev index next >