if (resolved_klass->is_instance_klass()) {
InstanceKlass* ik = InstanceKlass::cast(resolved_klass);
if (is_vm_class(ik)) { // These are safe to resolve. See is_vm_class declaration.
assert(ik->is_shared_boot_class(), "vmClasses must be loaded by boot loader");
if (cp_holder->is_shared_boot_class()) { // For now, do this for boot loader only. Other loaders // must go through ConstantPool::klass_at_impl at runtime // to put this class in their directory.
// TODO: we can support the platform and app loaders as well, if we // preload the vmClasses into these two loaders during VM bootstrap. returntrue;
}
}
if (cp_holder->is_subtype_of(ik)) { // All super types of ik will be resolved in ik->class_loader() before // ik is defined in this loader, so it's safe to archive the resolved klass reference. returntrue;
}
// TODO -- allow objArray classes, too
}
return false;
}
void ClassPrelinker::dumptime_resolve_constants(InstanceKlass* ik, TRAPS) {
constantPoolHandle cp(THREAD, ik->constants());
if (cp->cache() == NULL || cp->reference_map() == NULL) { // The cache may be NULL if the pool_holder klass fails verification // at dump time due to missing dependencies. return;
}
bool first_time;
_processed_classes->put_if_absent(ik, &first_time);
if (!first_time) { // We have already resolved the constants in class, so no need to do it again. return;
}
for (int cp_index = 1; cp_index < cp->length(); cp_index++) { // Index 0 is unused switch (cp->tag_at(cp_index).value()) { case JVM_CONSTANT_UnresolvedClass:
maybe_resolve_class(cp, cp_index, CHECK); break;
case JVM_CONSTANT_String:
resolve_string(cp, cp_index, CHECK); // may throw OOM when interning strings. break;
}
}
}
Klass* ClassPrelinker::maybe_resolve_class(constantPoolHandle cp, int cp_index, TRAPS) {
assert(!is_in_archivebuilder_buffer(cp()), "sanity");
InstanceKlass* cp_holder = cp->pool_holder();
if (!cp_holder->is_shared_boot_class() &&
!cp_holder->is_shared_platform_class() &&
!cp_holder->is_shared_app_class()) { // Don't trust custom loaders, as they may not be well-behaved // when resolving classes. return NULL;
}
Symbol* name = cp->klass_name_at(cp_index);
Klass* resolved_klass = find_loaded_class(THREAD, cp_holder->class_loader(), name);
if (resolved_klass != NULL && can_archive_resolved_klass(cp_holder, resolved_klass)) {
Klass* k = cp->klass_at(cp_index, CHECK_NULL); // Should fail only with OOM
assert(k == resolved_klass, "must be");
}
return resolved_klass;
}
#if INCLUDE_CDS_JAVA_HEAP void ClassPrelinker::resolve_string(constantPoolHandle cp, int cp_index, TRAPS) {
if (!DumpSharedSpaces) { // The archive heap is not supported for the dynamic archive. return;
}
int cache_index = cp->cp_to_object_index(cp_index);
ConstantPool::string_at_impl(cp, cp_index, cache_index, CHECK);
} #endif
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.