Mercurial > hg > truffle
comparison src/share/vm/prims/jvm.cpp @ 18104:eaf39a954227
Merge with jdk8u25-b17
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Thu, 16 Oct 2014 11:57:39 +0200 |
parents | 52b4284cb496 1e657b902392 |
children | 2a69cbe850a8 |
comparison
equal
deleted
inserted
replaced
18044:42de29c9ffbc | 18104:eaf39a954227 |
---|---|
803 trace_class_resolution(k); | 803 trace_class_resolution(k); |
804 } | 804 } |
805 return (jclass) JNIHandles::make_local(env, k->java_mirror()); | 805 return (jclass) JNIHandles::make_local(env, k->java_mirror()); |
806 JVM_END | 806 JVM_END |
807 | 807 |
808 // Not used; JVM_FindClassFromCaller replaces this. | |
808 JVM_ENTRY(jclass, JVM_FindClassFromClassLoader(JNIEnv* env, const char* name, | 809 JVM_ENTRY(jclass, JVM_FindClassFromClassLoader(JNIEnv* env, const char* name, |
809 jboolean init, jobject loader, | 810 jboolean init, jobject loader, |
810 jboolean throwError)) | 811 jboolean throwError)) |
811 JVMWrapper3("JVM_FindClassFromClassLoader %s throw %s", name, | 812 JVMWrapper3("JVM_FindClassFromClassLoader %s throw %s", name, |
812 throwError ? "error" : "exception"); | 813 throwError ? "error" : "exception"); |
829 trace_class_resolution(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(result))); | 830 trace_class_resolution(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(result))); |
830 } | 831 } |
831 return result; | 832 return result; |
832 JVM_END | 833 JVM_END |
833 | 834 |
835 // Find a class with this name in this loader, using the caller's protection domain. | |
836 JVM_ENTRY(jclass, JVM_FindClassFromCaller(JNIEnv* env, const char* name, | |
837 jboolean init, jobject loader, | |
838 jclass caller)) | |
839 JVMWrapper2("JVM_FindClassFromCaller %s throws ClassNotFoundException", name); | |
840 // Java libraries should ensure that name is never null... | |
841 if (name == NULL || (int)strlen(name) > Symbol::max_length()) { | |
842 // It's impossible to create this class; the name cannot fit | |
843 // into the constant pool. | |
844 THROW_MSG_0(vmSymbols::java_lang_ClassNotFoundException(), name); | |
845 } | |
846 | |
847 TempNewSymbol h_name = SymbolTable::new_symbol(name, CHECK_NULL); | |
848 | |
849 oop loader_oop = JNIHandles::resolve(loader); | |
850 oop from_class = JNIHandles::resolve(caller); | |
851 oop protection_domain = NULL; | |
852 // If loader is null, shouldn't call ClassLoader.checkPackageAccess; otherwise get | |
853 // NPE. Put it in another way, the bootstrap class loader has all permission and | |
854 // thus no checkPackageAccess equivalence in the VM class loader. | |
855 // The caller is also passed as NULL by the java code if there is no security | |
856 // manager to avoid the performance cost of getting the calling class. | |
857 if (from_class != NULL && loader_oop != NULL) { | |
858 protection_domain = java_lang_Class::as_Klass(from_class)->protection_domain(); | |
859 } | |
860 | |
861 Handle h_loader(THREAD, loader_oop); | |
862 Handle h_prot(THREAD, protection_domain); | |
863 jclass result = find_class_from_class_loader(env, h_name, init, h_loader, | |
864 h_prot, false, THREAD); | |
865 | |
866 if (TraceClassResolution && result != NULL) { | |
867 trace_class_resolution(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(result))); | |
868 } | |
869 return result; | |
870 JVM_END | |
834 | 871 |
835 JVM_ENTRY(jclass, JVM_FindClassFromClass(JNIEnv *env, const char *name, | 872 JVM_ENTRY(jclass, JVM_FindClassFromClass(JNIEnv *env, const char *name, |
836 jboolean init, jclass from)) | 873 jboolean init, jclass from)) |
837 JVMWrapper2("JVM_FindClassFromClass %s", name); | 874 JVMWrapper2("JVM_FindClassFromClass %s", name); |
838 if (name == NULL || (int)strlen(name) > Symbol::max_length()) { | 875 if (name == NULL || (int)strlen(name) > Symbol::max_length()) { |
3983 | 4020 |
3984 | 4021 |
3985 | 4022 |
3986 // Shared JNI/JVM entry points ////////////////////////////////////////////////////////////// | 4023 // Shared JNI/JVM entry points ////////////////////////////////////////////////////////////// |
3987 | 4024 |
3988 jclass find_class_from_class_loader(JNIEnv* env, Symbol* name, jboolean init, Handle loader, Handle protection_domain, jboolean throwError, TRAPS) { | 4025 jclass find_class_from_class_loader(JNIEnv* env, Symbol* name, jboolean init, |
4026 Handle loader, Handle protection_domain, | |
4027 jboolean throwError, TRAPS) { | |
3989 // Security Note: | 4028 // Security Note: |
3990 // The Java level wrapper will perform the necessary security check allowing | 4029 // The Java level wrapper will perform the necessary security check allowing |
3991 // us to pass the NULL as the initiating class loader. | 4030 // us to pass the NULL as the initiating class loader. The VM is responsible for |
4031 // the checkPackageAccess relative to the initiating class loader via the | |
4032 // protection_domain. The protection_domain is passed as NULL by the java code | |
4033 // if there is no security manager in 3-arg Class.forName(). | |
3992 Klass* klass = SystemDictionary::resolve_or_fail(name, loader, protection_domain, throwError != 0, CHECK_NULL); | 4034 Klass* klass = SystemDictionary::resolve_or_fail(name, loader, protection_domain, throwError != 0, CHECK_NULL); |
3993 | 4035 |
3994 KlassHandle klass_handle(THREAD, klass); | 4036 KlassHandle klass_handle(THREAD, klass); |
3995 // Check if we should initialize the class | 4037 // Check if we should initialize the class |
3996 if (init && klass_handle->oop_is_instance()) { | 4038 if (init && klass_handle->oop_is_instance()) { |