< prev index next >
src/share/vm/classfile/loaderConstraints.cpp
Print this page
*** 21,30 ****
--- 21,31 ----
* questions.
*
*/
#include "precompiled.hpp"
+ #include "classfile/dictionary.hpp"
#include "classfile/classLoaderData.inline.hpp"
#include "classfile/loaderConstraints.hpp"
#include "memory/resourceArea.hpp"
#include "oops/oop.inline.hpp"
#include "runtime/handles.inline.hpp"
*** 33,44 ****
void LoaderConstraintEntry::set_loader(int i, oop p) {
set_loader_data(i, ClassLoaderData::class_loader_data(p));
}
! LoaderConstraintTable::LoaderConstraintTable(int nof_buckets)
! : Hashtable<InstanceKlass*, mtClass>(nof_buckets, sizeof(LoaderConstraintEntry)) {};
LoaderConstraintEntry* LoaderConstraintTable::new_entry(
unsigned int hash, Symbol* name,
InstanceKlass* klass, int num_loaders,
--- 34,45 ----
void LoaderConstraintEntry::set_loader(int i, oop p) {
set_loader_data(i, ClassLoaderData::class_loader_data(p));
}
! LoaderConstraintTable::LoaderConstraintTable(int table_size)
! : Hashtable<InstanceKlass*, mtClass>(table_size, sizeof(LoaderConstraintEntry)) {};
LoaderConstraintEntry* LoaderConstraintTable::new_entry(
unsigned int hash, Symbol* name,
InstanceKlass* klass, int num_loaders,
*** 427,459 ****
free_entry(p2);
return;
}
! void LoaderConstraintTable::verify(Dictionary* dictionary,
! PlaceholderTable* placeholders) {
Thread *thread = Thread::current();
! for (int cindex = 0; cindex < _loader_constraint_size; cindex++) {
for (LoaderConstraintEntry* probe = bucket(cindex);
probe != NULL;
probe = probe->next()) {
if (probe->klass() != NULL) {
InstanceKlass* ik = probe->klass();
guarantee(ik->name() == probe->name(), "name should match");
Symbol* name = ik->name();
ClassLoaderData* loader_data = ik->class_loader_data();
! unsigned int d_hash = dictionary->compute_hash(name, loader_data);
int d_index = dictionary->hash_to_index(d_hash);
! InstanceKlass* k = dictionary->find_class(d_index, d_hash, name, loader_data);
if (k != NULL) {
! // We found the class in the system dictionary, so we should
// make sure that the Klass* matches what we already have.
guarantee(k == probe->klass(), "klass should be in dictionary");
} else {
! // If we don't find the class in the system dictionary, it
// has to be in the placeholders table.
! unsigned int p_hash = placeholders->compute_hash(name, loader_data);
int p_index = placeholders->hash_to_index(p_hash);
PlaceholderEntry* entry = placeholders->get_entry(p_index, p_hash,
name, loader_data);
// The InstanceKlass might not be on the entry, so the only
--- 428,460 ----
free_entry(p2);
return;
}
! void LoaderConstraintTable::verify(PlaceholderTable* placeholders) {
Thread *thread = Thread::current();
! for (int cindex = 0; cindex < table_size(); cindex++) {
for (LoaderConstraintEntry* probe = bucket(cindex);
probe != NULL;
probe = probe->next()) {
if (probe->klass() != NULL) {
InstanceKlass* ik = probe->klass();
guarantee(ik->name() == probe->name(), "name should match");
Symbol* name = ik->name();
ClassLoaderData* loader_data = ik->class_loader_data();
! Dictionary* dictionary = loader_data->dictionary();
! unsigned int d_hash = dictionary->compute_hash(name);
int d_index = dictionary->hash_to_index(d_hash);
! InstanceKlass* k = dictionary->find_class(d_index, d_hash, name);
if (k != NULL) {
! // We found the class in the dictionary, so we should
// make sure that the Klass* matches what we already have.
guarantee(k == probe->klass(), "klass should be in dictionary");
} else {
! // If we don't find the class in the dictionary, it
// has to be in the placeholders table.
! unsigned int p_hash = placeholders->compute_hash(name);
int p_index = placeholders->hash_to_index(p_hash);
PlaceholderEntry* entry = placeholders->get_entry(p_index, p_hash,
name, loader_data);
// The InstanceKlass might not be on the entry, so the only
*** 473,484 ****
// Called with the system dictionary lock held
void LoaderConstraintTable::print() {
ResourceMark rm;
assert_locked_or_safepoint(SystemDictionary_lock);
! tty->print_cr("Java loader constraints (entries=%d)", _loader_constraint_size);
! for (int cindex = 0; cindex < _loader_constraint_size; cindex++) {
for (LoaderConstraintEntry* probe = bucket(cindex);
probe != NULL;
probe = probe->next()) {
tty->print("%4d: ", cindex);
probe->name()->print();
--- 474,486 ----
// Called with the system dictionary lock held
void LoaderConstraintTable::print() {
ResourceMark rm;
assert_locked_or_safepoint(SystemDictionary_lock);
! tty->print_cr("Java loader constraints (entries=%d, constraints=%d)",
! table_size(), number_of_entries());
! for (int cindex = 0; cindex < table_size(); cindex++) {
for (LoaderConstraintEntry* probe = bucket(cindex);
probe != NULL;
probe = probe->next()) {
tty->print("%4d: ", cindex);
probe->name()->print();
< prev index next >