src/share/vm/prims/jvm.cpp

changeset 823
f008d3631bd1
parent 791
1ee8caae33af
child 866
a45484ea312d
     1.1 --- a/src/share/vm/prims/jvm.cpp	Mon Oct 06 11:39:34 2008 -0700
     1.2 +++ b/src/share/vm/prims/jvm.cpp	Wed Oct 08 08:10:51 2008 -0700
     1.3 @@ -628,6 +628,32 @@
     1.4    if (PrintJVMWarnings) warning("JVM_ResolveClass not implemented");
     1.5  JVM_END
     1.6  
     1.7 +// Common implementation for JVM_FindClassFromBootLoader and
     1.8 +// JVM_FindClassFromLoader
     1.9 +static jclass jvm_find_class_from_class_loader(JNIEnv* env, const char* name,
    1.10 +                                  jboolean init, jobject loader,
    1.11 +                                  jboolean throwError, TRAPS) {
    1.12 +  // Java libraries should ensure that name is never null...
    1.13 +  if (name == NULL || (int)strlen(name) > symbolOopDesc::max_length()) {
    1.14 +    // It's impossible to create this class;  the name cannot fit
    1.15 +    // into the constant pool.
    1.16 +    if (throwError) {
    1.17 +      THROW_MSG_0(vmSymbols::java_lang_NoClassDefFoundError(), name);
    1.18 +    } else {
    1.19 +      THROW_MSG_0(vmSymbols::java_lang_ClassNotFoundException(), name);
    1.20 +    }
    1.21 +  }
    1.22 +  symbolHandle h_name = oopFactory::new_symbol_handle(name, CHECK_NULL);
    1.23 +  Handle h_loader(THREAD, JNIHandles::resolve(loader));
    1.24 +  jclass result = find_class_from_class_loader(env, h_name, init, h_loader,
    1.25 +                                               Handle(), throwError, THREAD);
    1.26 +
    1.27 +  if (TraceClassResolution && result != NULL) {
    1.28 +    trace_class_resolution(java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(result)));
    1.29 +  }
    1.30 +  return result;
    1.31 +}
    1.32 +
    1.33  // Rationale behind JVM_FindClassFromBootLoader
    1.34  // a> JVM_FindClassFromClassLoader was never exported in the export tables.
    1.35  // b> because of (a) java.dll has a direct dependecy on the  unexported
    1.36 @@ -649,8 +675,8 @@
    1.37                                                jboolean throwError))
    1.38    JVMWrapper3("JVM_FindClassFromBootLoader %s throw %s", name,
    1.39                throwError ? "error" : "exception");
    1.40 -  return JVM_FindClassFromClassLoader(env, name, JNI_FALSE,
    1.41 -                                      (jobject)NULL, throwError);
    1.42 +  return jvm_find_class_from_class_loader(env, name, JNI_FALSE,
    1.43 +                                          (jobject)NULL, throwError, THREAD);
    1.44  JVM_END
    1.45  
    1.46  JVM_ENTRY(jclass, JVM_FindClassFromClassLoader(JNIEnv* env, const char* name,
    1.47 @@ -658,26 +684,8 @@
    1.48                                                 jboolean throwError))
    1.49    JVMWrapper3("JVM_FindClassFromClassLoader %s throw %s", name,
    1.50                 throwError ? "error" : "exception");
    1.51 -  // Java libraries should ensure that name is never null...
    1.52 -  if (name == NULL || (int)strlen(name) > symbolOopDesc::max_length()) {
    1.53 -    // It's impossible to create this class;  the name cannot fit
    1.54 -    // into the constant pool.
    1.55 -    if (throwError) {
    1.56 -      THROW_MSG_0(vmSymbols::java_lang_NoClassDefFoundError(), name);
    1.57 -    } else {
    1.58 -      THROW_MSG_0(vmSymbols::java_lang_ClassNotFoundException(), name);
    1.59 -    }
    1.60 -  }
    1.61 -  symbolHandle h_name = oopFactory::new_symbol_handle(name, CHECK_NULL);
    1.62 -  Handle h_loader(THREAD, JNIHandles::resolve(loader));
    1.63 -  jclass result = find_class_from_class_loader(env, h_name, init, h_loader,
    1.64 -                                               Handle(), throwError, thread);
    1.65 -
    1.66 -  if (TraceClassResolution && result != NULL) {
    1.67 -    trace_class_resolution(java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(result)));
    1.68 -  }
    1.69 -
    1.70 -  return result;
    1.71 +  return jvm_find_class_from_class_loader(env, name, init, loader,
    1.72 +                                          throwError, THREAD);
    1.73  JVM_END
    1.74  
    1.75  

mercurial