Top


定義場所(file name)

hotspot/src/share/vm/memory/universe.cpp

名前(function name)

void Universe::run_finalizers_on_exit() {

本体部(body)

  {- -------------------------------------------
  (1) 既に一度実行済みであれば (= has_run_finalizers_on_exit が true ならば), 
      もう何もすることはないので, ここでリターン.

      そうでなければ, 実行済みだと印を付けてから先に進む.
      ---------------------------------------- -}

      if (has_run_finalizers_on_exit) return;
      has_run_finalizers_on_exit = true;

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

      // Called on VM exit. This ought to be run in a separate thread.
      if (TraceReferenceGC) tty->print_cr("Callback to run finalizers on exit");

  {- -------------------------------------------
  (1) JavaCalls::call_static() 経由で
      java.lang.ref.Finalizer.runFinalizersOnExit() を呼び出し, 
      finalizer を実行させる.
      ---------------------------------------- -}

      {
        PRESERVE_EXCEPTION_MARK;
        KlassHandle finalizer_klass(THREAD, SystemDictionary::Finalizer_klass());
        JavaValue result(T_VOID);
        JavaCalls::call_static(
          &result,
          finalizer_klass,
          vmSymbols::run_finalizers_on_exit_name(),
          vmSymbols::void_method_signature(),
          THREAD
        );
        // Ignore any pending exceptions
        CLEAR_PENDING_EXCEPTION;
      }
    }

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