hotspot/src/share/vm/oops/constantPoolOop.cpp
// This is an interface for the compiler that allows accessing non-resolved entries
// in the constant pool - but still performs the validations tests. Must be used
// in a pre-parse of the compiler - to determine what it can do and not do.
// Note: We cannot update the ConstantPool from the vm_thread.
klassOop constantPoolOopDesc::klass_ref_at_if_loaded_check(constantPoolHandle this_oop, int index, TRAPS) {
{- -------------------------------------------
(1) constantPoolOopDesc::klass_ref_index_at() を呼んで
class_index と name_and_type index からなる constant pool 情報から
class_index 部分のみを取得する.
---------------------------------------- -}
int which = this_oop->klass_ref_index_at(index);
{- -------------------------------------------
(1) 取得した index に対応する klassOop を取得しリターンする.
(対象クラスが constantPoolOopDesc 中でまだ解決されてなくても
解決が実行されないよう
constantPoolOopDesc::klass_at() ではなく自前で klassOop を探している
(未だ解決されてない場合は SystemDictionary::find() で取得))
---------------------------------------- -}
CPSlot entry = this_oop->slot_at(which);
if (entry.is_oop()) {
assert(entry.get_oop()->is_klass(), "must be");
return (klassOop)entry.get_oop();
} else {
assert(entry.is_metadata(), "must be either symbol or klass");
Symbol* name = entry.get_symbol();
oop loader = instanceKlass::cast(this_oop->pool_holder())->class_loader();
oop protection_domain = Klass::cast(this_oop->pool_holder())->protection_domain();
Handle h_loader(THREAD, loader);
Handle h_prot (THREAD, protection_domain);
KlassHandle k(THREAD, SystemDictionary::find(name, h_loader, h_prot, THREAD));
// Do access check for klasses
if( k.not_null() ) verify_constant_pool_resolve(this_oop, k, CHECK_NULL);
return k();
}
}
This document is available under the GNU GENERAL PUBLIC LICENSE Version 2.