Top


定義場所(file name)

hotspot/src/share/vm/prims/jvm.cpp

名前(function name)

JVM_ENTRY(jclass, JVM_FindClassFromClassLoader(JNIEnv* env, const char* name,
                                               jboolean init, jobject loader,
                                               jboolean throwError))

本体部(body)

  {- -------------------------------------------
  (1) (トレース出力) (See: JVMWrapper3)
      ---------------------------------------- -}

      JVMWrapper3("JVM_FindClassFromClassLoader %s throw %s", name,
                   throwError ? "error" : "exception");

  {- -------------------------------------------
  (1) クラス名を表す引数(name)が NULL の場合や
      クラス名が長すぎる場合 (Symbol::max_length() を超えている場合) は, 
      NoClassDefFoundError または ClassNotFoundException.
      (throwError 引数が true なら NoClassDefFoundError, false なら ClassNotFoundException)
      ---------------------------------------- -}

      // Java libraries should ensure that name is never null...
      if (name == NULL || (int)strlen(name) > Symbol::max_length()) {
        // It's impossible to create this class;  the name cannot fit
        // into the constant pool.
        if (throwError) {
          THROW_MSG_0(vmSymbols::java_lang_NoClassDefFoundError(), name);
        } else {
          THROW_MSG_0(vmSymbols::java_lang_ClassNotFoundException(), name);
        }
      }

  {- -------------------------------------------
  (1) find_class_from_class_loader() を呼んで, 引数で指定されたクラスオブジェクトを取得する.
      ---------------------------------------- -}

      TempNewSymbol h_name = SymbolTable::new_symbol(name, CHECK_NULL);
      Handle h_loader(THREAD, JNIHandles::resolve(loader));
      jclass result = find_class_from_class_loader(env, h_name, init, h_loader,
                                                   Handle(), throwError, THREAD);

  {- -------------------------------------------
  (1) (トレース出力)
      ---------------------------------------- -}

      if (TraceClassResolution && result != NULL) {
        trace_class_resolution(java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(result)));
      }

  {- -------------------------------------------
  (1) 結果をリターン
      ---------------------------------------- -}

      return result;
    JVM_END

This document is available under the GNU GENERAL PUBLIC LICENSE Version 2.