Mercurial > hg > graal-compiler
comparison src/share/vm/prims/jvm.cpp @ 20527:8cb56c8cb30d
Merge
author | jiangli |
---|---|
date | Mon, 15 Sep 2014 16:39:00 -0400 |
parents | 6e0cb14ce59b 1e657b902392 |
children | 4cb90023bf2b |
comparison
equal
deleted
inserted
replaced
20411:fe1f65b0a2d8 | 20527:8cb56c8cb30d |
---|---|
806 trace_class_resolution(k); | 806 trace_class_resolution(k); |
807 } | 807 } |
808 return (jclass) JNIHandles::make_local(env, k->java_mirror()); | 808 return (jclass) JNIHandles::make_local(env, k->java_mirror()); |
809 JVM_END | 809 JVM_END |
810 | 810 |
811 // Not used; JVM_FindClassFromCaller replaces this. | |
811 JVM_ENTRY(jclass, JVM_FindClassFromClassLoader(JNIEnv* env, const char* name, | 812 JVM_ENTRY(jclass, JVM_FindClassFromClassLoader(JNIEnv* env, const char* name, |
812 jboolean init, jobject loader, | 813 jboolean init, jobject loader, |
813 jboolean throwError)) | 814 jboolean throwError)) |
814 JVMWrapper3("JVM_FindClassFromClassLoader %s throw %s", name, | 815 JVMWrapper3("JVM_FindClassFromClassLoader %s throw %s", name, |
815 throwError ? "error" : "exception"); | 816 throwError ? "error" : "exception"); |
832 trace_class_resolution(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(result))); | 833 trace_class_resolution(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(result))); |
833 } | 834 } |
834 return result; | 835 return result; |
835 JVM_END | 836 JVM_END |
836 | 837 |
838 // Find a class with this name in this loader, using the caller's protection domain. | |
839 JVM_ENTRY(jclass, JVM_FindClassFromCaller(JNIEnv* env, const char* name, | |
840 jboolean init, jobject loader, | |
841 jclass caller)) | |
842 JVMWrapper2("JVM_FindClassFromCaller %s throws ClassNotFoundException", name); | |
843 // Java libraries should ensure that name is never null... | |
844 if (name == NULL || (int)strlen(name) > Symbol::max_length()) { | |
845 // It's impossible to create this class; the name cannot fit | |
846 // into the constant pool. | |
847 THROW_MSG_0(vmSymbols::java_lang_ClassNotFoundException(), name); | |
848 } | |
849 | |
850 TempNewSymbol h_name = SymbolTable::new_symbol(name, CHECK_NULL); | |
851 | |
852 oop loader_oop = JNIHandles::resolve(loader); | |
853 oop from_class = JNIHandles::resolve(caller); | |
854 oop protection_domain = NULL; | |
855 // If loader is null, shouldn't call ClassLoader.checkPackageAccess; otherwise get | |
856 // NPE. Put it in another way, the bootstrap class loader has all permission and | |
857 // thus no checkPackageAccess equivalence in the VM class loader. | |
858 // The caller is also passed as NULL by the java code if there is no security | |
859 // manager to avoid the performance cost of getting the calling class. | |
860 if (from_class != NULL && loader_oop != NULL) { | |
861 protection_domain = java_lang_Class::as_Klass(from_class)->protection_domain(); | |
862 } | |
863 | |
864 Handle h_loader(THREAD, loader_oop); | |
865 Handle h_prot(THREAD, protection_domain); | |
866 jclass result = find_class_from_class_loader(env, h_name, init, h_loader, | |
867 h_prot, false, THREAD); | |
868 | |
869 if (TraceClassResolution && result != NULL) { | |
870 trace_class_resolution(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(result))); | |
871 } | |
872 return result; | |
873 JVM_END | |
837 | 874 |
838 JVM_ENTRY(jclass, JVM_FindClassFromClass(JNIEnv *env, const char *name, | 875 JVM_ENTRY(jclass, JVM_FindClassFromClass(JNIEnv *env, const char *name, |
839 jboolean init, jclass from)) | 876 jboolean init, jclass from)) |
840 JVMWrapper2("JVM_FindClassFromClass %s", name); | 877 JVMWrapper2("JVM_FindClassFromClass %s", name); |
841 if (name == NULL || (int)strlen(name) > Symbol::max_length()) { | 878 if (name == NULL || (int)strlen(name) > Symbol::max_length()) { |
3995 | 4032 |
3996 | 4033 |
3997 | 4034 |
3998 // Shared JNI/JVM entry points ////////////////////////////////////////////////////////////// | 4035 // Shared JNI/JVM entry points ////////////////////////////////////////////////////////////// |
3999 | 4036 |
4000 jclass find_class_from_class_loader(JNIEnv* env, Symbol* name, jboolean init, Handle loader, Handle protection_domain, jboolean throwError, TRAPS) { | 4037 jclass find_class_from_class_loader(JNIEnv* env, Symbol* name, jboolean init, |
4038 Handle loader, Handle protection_domain, | |
4039 jboolean throwError, TRAPS) { | |
4001 // Security Note: | 4040 // Security Note: |
4002 // The Java level wrapper will perform the necessary security check allowing | 4041 // The Java level wrapper will perform the necessary security check allowing |
4003 // us to pass the NULL as the initiating class loader. | 4042 // us to pass the NULL as the initiating class loader. The VM is responsible for |
4043 // the checkPackageAccess relative to the initiating class loader via the | |
4044 // protection_domain. The protection_domain is passed as NULL by the java code | |
4045 // if there is no security manager in 3-arg Class.forName(). | |
4004 Klass* klass = SystemDictionary::resolve_or_fail(name, loader, protection_domain, throwError != 0, CHECK_NULL); | 4046 Klass* klass = SystemDictionary::resolve_or_fail(name, loader, protection_domain, throwError != 0, CHECK_NULL); |
4005 | 4047 |
4006 KlassHandle klass_handle(THREAD, klass); | 4048 KlassHandle klass_handle(THREAD, klass); |
4007 // Check if we should initialize the class | 4049 // Check if we should initialize the class |
4008 if (init && klass_handle->oop_is_instance()) { | 4050 if (init && klass_handle->oop_is_instance()) { |