11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "classfile/classLoader.hpp"
27 #include "classfile/javaAssertions.hpp"
28 #include "classfile/javaClasses.hpp"
29 #include "classfile/stringTable.hpp"
30 #include "classfile/systemDictionary.hpp"
31 #include "classfile/vmSymbols.hpp"
32 #include "gc_interface/collectedHeap.inline.hpp"
33 #include "interpreter/bytecode.hpp"
34 #include "memory/oopFactory.hpp"
35 #include "memory/universe.inline.hpp"
36 #include "oops/fieldStreams.hpp"
37 #include "oops/instanceKlass.hpp"
38 #include "oops/objArrayKlass.hpp"
39 #include "oops/method.hpp"
40 #include "prims/jvm.h"
41 #include "prims/jvm_misc.hpp"
42 #include "prims/jvmtiExport.hpp"
43 #include "prims/jvmtiThreadState.hpp"
44 #include "prims/nativeLookup.hpp"
45 #include "prims/privilegedStack.hpp"
46 #include "runtime/arguments.hpp"
47 #include "runtime/atomic.inline.hpp"
48 #include "runtime/dtraceJSDT.hpp"
49 #include "runtime/handles.inline.hpp"
50 #include "runtime/init.hpp"
976 // It's impossible to create this class; the name cannot fit
977 // into the constant pool.
978 return NULL;
979 }
980 TempNewSymbol klass_name = SymbolTable::new_symbol(str, str_len, CHECK_NULL);
981
982 // Security Note:
983 // The Java level wrapper will perform the necessary security check allowing
984 // us to pass the NULL as the initiating class loader.
985 Handle h_loader(THREAD, JNIHandles::resolve(loader));
986 if (UsePerfData) {
987 is_lock_held_by_thread(h_loader,
988 ClassLoader::sync_JVMFindLoadedClassLockFreeCounter(),
989 THREAD);
990 }
991
992 Klass* k = SystemDictionary::find_instance_or_array_klass(klass_name,
993 h_loader,
994 Handle(),
995 CHECK_NULL);
996
997 return (k == NULL) ? NULL :
998 (jclass) JNIHandles::make_local(env, k->java_mirror());
999 JVM_END
1000
1001
1002 // Reflection support //////////////////////////////////////////////////////////////////////////////
1003
1004 JVM_ENTRY(jstring, JVM_GetClassName(JNIEnv *env, jclass cls))
1005 assert (cls != NULL, "illegal class");
1006 JVMWrapper("JVM_GetClassName");
1007 JvmtiVMObjectAllocEventCollector oam;
1008 ResourceMark rm(THREAD);
1009 const char* name;
1010 if (java_lang_Class::is_primitive(JNIHandles::resolve(cls))) {
1011 name = type2name(java_lang_Class::primitive_type(JNIHandles::resolve(cls)));
1012 } else {
1013 // Consider caching interned string in Klass
1014 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve(cls));
1015 assert(k->is_klass(), "just checking");
1016 name = k->external_name();
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "classfile/classLoader.hpp"
27 #include "classfile/javaAssertions.hpp"
28 #include "classfile/javaClasses.hpp"
29 #include "classfile/stringTable.hpp"
30 #include "classfile/systemDictionary.hpp"
31 #if INCLUDE_CDS
32 #include "classfile/sharedClassUtil.hpp"
33 #include "classfile/systemDictionaryShared.hpp"
34 #endif
35 #include "classfile/vmSymbols.hpp"
36 #include "gc_interface/collectedHeap.inline.hpp"
37 #include "interpreter/bytecode.hpp"
38 #include "memory/oopFactory.hpp"
39 #include "memory/universe.inline.hpp"
40 #include "oops/fieldStreams.hpp"
41 #include "oops/instanceKlass.hpp"
42 #include "oops/objArrayKlass.hpp"
43 #include "oops/method.hpp"
44 #include "prims/jvm.h"
45 #include "prims/jvm_misc.hpp"
46 #include "prims/jvmtiExport.hpp"
47 #include "prims/jvmtiThreadState.hpp"
48 #include "prims/nativeLookup.hpp"
49 #include "prims/privilegedStack.hpp"
50 #include "runtime/arguments.hpp"
51 #include "runtime/atomic.inline.hpp"
52 #include "runtime/dtraceJSDT.hpp"
53 #include "runtime/handles.inline.hpp"
54 #include "runtime/init.hpp"
980 // It's impossible to create this class; the name cannot fit
981 // into the constant pool.
982 return NULL;
983 }
984 TempNewSymbol klass_name = SymbolTable::new_symbol(str, str_len, CHECK_NULL);
985
986 // Security Note:
987 // The Java level wrapper will perform the necessary security check allowing
988 // us to pass the NULL as the initiating class loader.
989 Handle h_loader(THREAD, JNIHandles::resolve(loader));
990 if (UsePerfData) {
991 is_lock_held_by_thread(h_loader,
992 ClassLoader::sync_JVMFindLoadedClassLockFreeCounter(),
993 THREAD);
994 }
995
996 Klass* k = SystemDictionary::find_instance_or_array_klass(klass_name,
997 h_loader,
998 Handle(),
999 CHECK_NULL);
1000 #if INCLUDE_CDS
1001 if (k == NULL) {
1002 // If the class is not already loaded, try to see if it's in the shared
1003 // archive for the current classloader (h_loader).
1004 instanceKlassHandle ik = SystemDictionaryShared::find_or_load_shared_class(
1005 klass_name, h_loader, CHECK_NULL);
1006 k = ik();
1007 }
1008 #endif
1009 return (k == NULL) ? NULL :
1010 (jclass) JNIHandles::make_local(env, k->java_mirror());
1011 JVM_END
1012
1013
1014 // Reflection support //////////////////////////////////////////////////////////////////////////////
1015
1016 JVM_ENTRY(jstring, JVM_GetClassName(JNIEnv *env, jclass cls))
1017 assert (cls != NULL, "illegal class");
1018 JVMWrapper("JVM_GetClassName");
1019 JvmtiVMObjectAllocEventCollector oam;
1020 ResourceMark rm(THREAD);
1021 const char* name;
1022 if (java_lang_Class::is_primitive(JNIHandles::resolve(cls))) {
1023 name = type2name(java_lang_Class::primitive_type(JNIHandles::resolve(cls)));
1024 } else {
1025 // Consider caching interned string in Klass
1026 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve(cls));
1027 assert(k->is_klass(), "just checking");
1028 name = k->external_name();
|