683 JVM_END
684
685
686 JVM_ENTRY(jclass, JVM_FindPrimitiveClass(JNIEnv* env, const char* utf))
687 JVMWrapper("JVM_FindPrimitiveClass");
688 oop mirror = NULL;
689 BasicType t = name2type(utf);
690 if (t != T_ILLEGAL && t != T_OBJECT && t != T_ARRAY) {
691 mirror = Universe::java_mirror(t);
692 }
693 if (mirror == NULL) {
694 THROW_MSG_0(vmSymbols::java_lang_ClassNotFoundException(), (char*) utf);
695 } else {
696 return (jclass) JNIHandles::make_local(env, mirror);
697 }
698 JVM_END
699
700
701 // Returns a class loaded by the bootstrap class loader; or null
702 // if not found. ClassNotFoundException is not thrown.
703 //
704 // Rationale behind JVM_FindClassFromBootLoader
705 // a> JVM_FindClassFromClassLoader was never exported in the export tables.
706 // b> because of (a) java.dll has a direct dependecy on the unexported
707 // private symbol "_JVM_FindClassFromClassLoader@20".
708 // c> the launcher cannot use the private symbol as it dynamically opens
709 // the entry point, so if something changes, the launcher will fail
710 // unexpectedly at runtime, it is safest for the launcher to dlopen a
711 // stable exported interface.
712 // d> re-exporting JVM_FindClassFromClassLoader as public, will cause its
713 // signature to change from _JVM_FindClassFromClassLoader@20 to
714 // JVM_FindClassFromClassLoader and will not be backward compatible
715 // with older JDKs.
716 // Thus a public/stable exported entry point is the right solution,
717 // public here means public in linker semantics, and is exported only
718 // to the JDK, and is not intended to be a public API.
719
720 JVM_ENTRY(jclass, JVM_FindClassFromBootLoader(JNIEnv* env,
721 const char* name))
722 JVMWrapper2("JVM_FindClassFromBootLoader %s", name);
723
724 // Java libraries should ensure that name is never null...
725 if (name == NULL || (int)strlen(name) > Symbol::max_length()) {
726 // It's impossible to create this class; the name cannot fit
727 // into the constant pool.
728 return NULL;
729 }
730
731 TempNewSymbol h_name = SymbolTable::new_symbol(name, CHECK_NULL);
732 Klass* k = SystemDictionary::resolve_or_null(h_name, CHECK_NULL);
733 if (k == NULL) {
734 return NULL;
735 }
736
737 if (TraceClassResolution) {
738 trace_class_resolution(k);
739 }
740 return (jclass) JNIHandles::make_local(env, k->java_mirror());
741 JVM_END
742
743 // Not used; JVM_FindClassFromCaller replaces this.
744 JVM_ENTRY(jclass, JVM_FindClassFromClassLoader(JNIEnv* env, const char* name,
745 jboolean init, jobject loader,
746 jboolean throwError))
747 JVMWrapper3("JVM_FindClassFromClassLoader %s throw %s", name,
748 throwError ? "error" : "exception");
749 // Java libraries should ensure that name is never null...
750 if (name == NULL || (int)strlen(name) > Symbol::max_length()) {
751 // It's impossible to create this class; the name cannot fit
752 // into the constant pool.
753 if (throwError) {
754 THROW_MSG_0(vmSymbols::java_lang_NoClassDefFoundError(), name);
755 } else {
756 THROW_MSG_0(vmSymbols::java_lang_ClassNotFoundException(), name);
757 }
758 }
759 TempNewSymbol h_name = SymbolTable::new_symbol(name, CHECK_NULL);
760 Handle h_loader(THREAD, JNIHandles::resolve(loader));
761 jclass result = find_class_from_class_loader(env, h_name, init, h_loader,
762 Handle(), throwError, THREAD);
763
764 if (TraceClassResolution && result != NULL) {
765 trace_class_resolution(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(result)));
766 }
767 return result;
768 JVM_END
769
770 // Find a class with this name in this loader, using the caller's protection domain.
771 JVM_ENTRY(jclass, JVM_FindClassFromCaller(JNIEnv* env, const char* name,
772 jboolean init, jobject loader,
773 jclass caller))
774 JVMWrapper2("JVM_FindClassFromCaller %s throws ClassNotFoundException", name);
775 // Java libraries should ensure that name is never null...
776 if (name == NULL || (int)strlen(name) > Symbol::max_length()) {
777 // It's impossible to create this class; the name cannot fit
778 // into the constant pool.
779 THROW_MSG_0(vmSymbols::java_lang_ClassNotFoundException(), name);
780 }
781
782 TempNewSymbol h_name = SymbolTable::new_symbol(name, CHECK_NULL);
783
784 oop loader_oop = JNIHandles::resolve(loader);
785 oop from_class = JNIHandles::resolve(caller);
786 oop protection_domain = NULL;
787 // If loader is null, shouldn't call ClassLoader.checkPackageAccess; otherwise get
|
683 JVM_END
684
685
686 JVM_ENTRY(jclass, JVM_FindPrimitiveClass(JNIEnv* env, const char* utf))
687 JVMWrapper("JVM_FindPrimitiveClass");
688 oop mirror = NULL;
689 BasicType t = name2type(utf);
690 if (t != T_ILLEGAL && t != T_OBJECT && t != T_ARRAY) {
691 mirror = Universe::java_mirror(t);
692 }
693 if (mirror == NULL) {
694 THROW_MSG_0(vmSymbols::java_lang_ClassNotFoundException(), (char*) utf);
695 } else {
696 return (jclass) JNIHandles::make_local(env, mirror);
697 }
698 JVM_END
699
700
701 // Returns a class loaded by the bootstrap class loader; or null
702 // if not found. ClassNotFoundException is not thrown.
703 // FindClassFromBootLoader is exported to the launcher for windows.
704 JVM_ENTRY(jclass, JVM_FindClassFromBootLoader(JNIEnv* env,
705 const char* name))
706 JVMWrapper2("JVM_FindClassFromBootLoader %s", name);
707
708 // Java libraries should ensure that name is never null...
709 if (name == NULL || (int)strlen(name) > Symbol::max_length()) {
710 // It's impossible to create this class; the name cannot fit
711 // into the constant pool.
712 return NULL;
713 }
714
715 TempNewSymbol h_name = SymbolTable::new_symbol(name, CHECK_NULL);
716 Klass* k = SystemDictionary::resolve_or_null(h_name, CHECK_NULL);
717 if (k == NULL) {
718 return NULL;
719 }
720
721 if (TraceClassResolution) {
722 trace_class_resolution(k);
723 }
724 return (jclass) JNIHandles::make_local(env, k->java_mirror());
725 JVM_END
726
727 // Find a class with this name in this loader, using the caller's protection domain.
728 JVM_ENTRY(jclass, JVM_FindClassFromCaller(JNIEnv* env, const char* name,
729 jboolean init, jobject loader,
730 jclass caller))
731 JVMWrapper2("JVM_FindClassFromCaller %s throws ClassNotFoundException", name);
732 // Java libraries should ensure that name is never null...
733 if (name == NULL || (int)strlen(name) > Symbol::max_length()) {
734 // It's impossible to create this class; the name cannot fit
735 // into the constant pool.
736 THROW_MSG_0(vmSymbols::java_lang_ClassNotFoundException(), name);
737 }
738
739 TempNewSymbol h_name = SymbolTable::new_symbol(name, CHECK_NULL);
740
741 oop loader_oop = JNIHandles::resolve(loader);
742 oop from_class = JNIHandles::resolve(caller);
743 oop protection_domain = NULL;
744 // If loader is null, shouldn't call ClassLoader.checkPackageAccess; otherwise get
|