例外オブジェクトの生成と送出処理を行うために, Interpreter クラスに以下のようなフィールドが用意されている.
これらのフィールドには, 各種の例外発生コードのアドレスが登録されており, ここにジャンプすれば例外生成&送出が行える.
((cite: hotspot/src/share/vm/interpreter/templateInterpreter.cpp))
Interpreter::_throw_ArrayIndexOutOfBoundsException_entry = generate_ArrayIndexOutOfBounds_handler("java/lang/ArrayIndexOutOfBoundsException");
Interpreter::_throw_ArrayStoreException_entry = generate_klass_exception_handler("java/lang/ArrayStoreException" );
Interpreter::_throw_ArithmeticException_entry = generate_exception_handler("java/lang/ArithmeticException" , "/ by zero");
Interpreter::_throw_ClassCastException_entry = generate_ClassCastException_handler();
Interpreter::_throw_NullPointerException_entry = generate_exception_handler("java/lang/NullPointerException" , NULL );
Interpreter::_throw_StackOverflowError_entry = generate_StackOverflowError_handler();
Interpreter クラスの各フィールドに入っているのは, ほとんどは InterpreterRuntime が用意しているメソッドへのラッパー. (オペランドスタックを空にし, 引数を C++ の calling convention に合わせてレジスタなどに移した後, call_VM で InterpreterRuntime のメソッドを呼び出すだけ).
ただし generate_exception_handler() と generate_klass_exception_handler() については少し異なり, InterpreterRuntime::create_klass_exception() または InterpreterRuntime::create_exception() で例外を作成し, Interpreter::throw_exception_entry() にジャンプして送出処理を行う.
Interpreter::_throw_ArrayIndexOutOfBoundsException_entry が指しているコード (= TemplateInterpreterGenerator::generate_ArrayIndexOutOfBounds_handler() が生成したコード)
-> InterpreterRuntime::throw_ArrayIndexOutOfBoundsException()
-> THROW_MSG()
-> (See: here for details)
Interpreter::_throw_ArrayStoreException_entry が指しているコード (= TemplateInterpreterGenerator::generate_klass_exception_handler() が生成したコード)
-> TemplateInterpreterGenerator::generate_exception_handler_common() が生成したコード
-> InterpreterRuntime::create_klass_exception()
-> Exceptions::new_exception()
-> JavaThread::set_vm_result()
-> Interpreter::throw_exception_entry() が指しているアドレスにジャンプ
-> (See: here for details)
Interpreter::_throw_ArithmeticException_entry が指しているコード (= TemplateInterpreterGenerator::generate_exception_handler() が生成したコード)
-> TemplateInterpreterGenerator::generate_exception_handler_common() が生成したコード
-> InterpreterRuntime::create_exception()
-> Exceptions::new_exception()
-> JavaThread::set_vm_result()
-> Interpreter::throw_exception_entry() が指しているアドレスにジャンプ
-> (See: here for details)
Interpreter::_throw_ClassCastException_entry が指しているコード (= TemplateInterpreterGenerator::generate_ClassCastException_handler() が生成したコード)
-> InterpreterRuntime::throw_ClassCastException()
-> THROW_MSG()
-> (See: here for details)
Interpreter::_throw_NullPointerException_entry が指しているコード (= TemplateInterpreterGenerator::generate_exception_handler() が生成したコード) -> (同上)
Interpreter::_throw_StackOverflowError_entry が指しているコード (= TemplateInterpreterGenerator::generate_StackOverflowError_handler() が生成したコード)
-> InterpreterRuntime::throw_StackOverflowError()
-> get_preinitialized_exception()
-> THROW_HANDLE()
-> (See: here for details)
See: here for details
See: here for details
See: here for details
See: here for details
See: here for details
See: here for details
See: here for details
See: here for details
See: here for details
See: here for details
See: here for details
See: here for details
See: here for details
See: here for details
See: here for details
(#Under Construction) See: here for details
This document is available under the GNU GENERAL PUBLIC LICENSE Version 2.