< prev index next >
src/hotspot/share/prims/jvm.cpp
Print this page
@@ -715,10 +715,21 @@
// Misc. class handling ///////////////////////////////////////////////////////////
+JVM_ENTRY(void, JVM_LinkClass(JNIEnv* env, jclass classClass, jclass arg))
+ JVMWrapper("JVM_LinkClass");
+
+ oop r = JNIHandles::resolve(arg);
+ Klass* klass = java_lang_Class::as_Klass(r);
+
+ if (!ClassForNameDeferLinking && klass->is_instance_klass()) {
+ InstanceKlass::cast(klass)->link_class(CHECK);
+ }
+JVM_END
+
JVM_ENTRY(jclass, JVM_GetCallerClass(JNIEnv* env))
JVMWrapper("JVM_GetCallerClass");
// Getting the class of the caller frame.
//
@@ -825,13 +836,14 @@
protection_domain = java_lang_Class::as_Klass(from_class)->protection_domain();
}
Handle h_loader(THREAD, loader_oop);
Handle h_prot(THREAD, protection_domain);
- jclass result = find_class_from_class_loader(env, h_name, init, h_loader,
- h_prot, false, THREAD);
+ jboolean link = !ClassForNameDeferLinking;
+ jclass result = find_class_from_class_loader(env, h_name, init, link, h_loader,
+ h_prot, false, THREAD);
if (log_is_enabled(Debug, class, resolve) && result != NULL) {
trace_class_resolution(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(result)));
}
return result;
JVM_END
@@ -864,11 +876,11 @@
class_loader = from_class->class_loader();
protection_domain = from_class->protection_domain();
}
Handle h_loader(THREAD, class_loader);
Handle h_prot (THREAD, protection_domain);
- jclass result = find_class_from_class_loader(env, h_name, init, h_loader,
+ jclass result = find_class_from_class_loader(env, h_name, init, false, h_loader,
h_prot, true, thread);
if (log_is_enabled(Debug, class, resolve) && result != NULL) {
// this function is generally only used for class loading during verification.
ResourceMark rm;
@@ -3422,24 +3434,26 @@
}
// Shared JNI/JVM entry points //////////////////////////////////////////////////////////////
-jclass find_class_from_class_loader(JNIEnv* env, Symbol* name, jboolean init,
+jclass find_class_from_class_loader(JNIEnv* env, Symbol* name, jboolean init, jboolean link,
Handle loader, Handle protection_domain,
jboolean throwError, TRAPS) {
// Security Note:
// The Java level wrapper will perform the necessary security check allowing
// us to pass the NULL as the initiating class loader. The VM is responsible for
// the checkPackageAccess relative to the initiating class loader via the
// protection_domain. The protection_domain is passed as NULL by the java code
// if there is no security manager in 3-arg Class.forName().
Klass* klass = SystemDictionary::resolve_or_fail(name, loader, protection_domain, throwError != 0, CHECK_NULL);
- // Check if we should initialize the class
+ // Check if we should initialize the class (which implies linking), or just link it
if (init && klass->is_instance_klass()) {
klass->initialize(CHECK_NULL);
+ } else if (link && klass->is_instance_klass()) {
+ InstanceKlass::cast(klass)->link_class(CHECK_NULL);
}
return (jclass) JNIHandles::make_local(env, klass->java_mirror());
}
< prev index next >