< prev index next >

src/hotspot/share/classfile/dictionary.cpp

Print this page
rev 58565 : 8238358: Implementation of JEP 371: Hidden Classes
Reviewed-by: duke
Contributed-by: mandy.chung@oracle.com, lois.foltan@oracle.com, david.holmes@oracle.com, harold.seigel@oracle.com, serguei.spitsyn@oracle.com, alex.buckley@oracle.com, jamsheed.c.m@oracle.com
   1 /*
   2  * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 337   assert(loader_data() != ClassLoaderData::the_null_class_loader_data(), "doesn't make sense");
 338 #endif
 339 
 340   assert(entry->contains_protection_domain(protection_domain()),
 341          "now protection domain should be present");
 342 }
 343 
 344 
 345 bool Dictionary::is_valid_protection_domain(unsigned int hash,
 346                                             Symbol* name,
 347                                             Handle protection_domain) {
 348   int index = hash_to_index(hash);
 349   DictionaryEntry* entry = get_entry(index, hash, name);
 350   return entry->is_valid_protection_domain(protection_domain);
 351 }
 352 
 353 // During class loading we may have cached a protection domain that has
 354 // since been unreferenced, so this entry should be cleared.
 355 void Dictionary::clean_cached_protection_domains() {
 356   assert_locked_or_safepoint(SystemDictionary_lock);

 357 
 358   if (loader_data()->is_the_null_class_loader_data()) {
 359     // Classes in the boot loader are not loaded with protection domains
 360     return;
 361   }
 362 
 363   for (int index = 0; index < table_size(); index++) {
 364     for (DictionaryEntry* probe = bucket(index);
 365                           probe != NULL;
 366                           probe = probe->next()) {
 367       Klass* e = probe->instance_klass();
 368 
 369       MutexLocker ml(ProtectionDomainSet_lock, Mutex::_no_safepoint_check_flag);
 370       ProtectionDomainEntry* current = probe->pd_set();
 371       ProtectionDomainEntry* prev = NULL;
 372       while (current != NULL) {
 373         if (current->object_no_keepalive() == NULL) {
 374           LogTarget(Debug, protectiondomain) lt;
 375           if (lt.is_enabled()) {
 376             ResourceMark rm;


 465   }
 466 }
 467 
 468 void DictionaryEntry::print_count(outputStream *st) {
 469   MutexLocker ml(ProtectionDomainSet_lock, Mutex::_no_safepoint_check_flag);
 470   int count = 0;
 471   for (ProtectionDomainEntry* current = pd_set();  // accessed inside SD lock
 472                               current != NULL;
 473                               current = current->_next) {
 474     count++;
 475   }
 476   st->print_cr("pd set count = #%d", count);
 477 }
 478 
 479 // ----------------------------------------------------------------------------
 480 
 481 void Dictionary::print_on(outputStream* st) const {
 482   ResourceMark rm;
 483 
 484   assert(loader_data() != NULL, "loader data should not be null");

 485   st->print_cr("Java dictionary (table_size=%d, classes=%d, resizable=%s)",
 486                table_size(), number_of_entries(), BOOL_TO_STR(_resizable));
 487   st->print_cr("^ indicates that initiating loader is different from defining loader");
 488 
 489   for (int index = 0; index < table_size(); index++) {
 490     for (DictionaryEntry* probe = bucket(index);
 491                           probe != NULL;
 492                           probe = probe->next()) {
 493       Klass* e = probe->instance_klass();
 494       bool is_defining_class =
 495          (loader_data() == e->class_loader_data());
 496       st->print("%4d: %s%s", index, is_defining_class ? " " : "^", e->external_name());
 497       ClassLoaderData* cld = e->class_loader_data();
 498       if (!loader_data()->is_the_null_class_loader_data()) {
 499         // Class loader output for the dictionary for the null class loader data is
 500         // redundant and obvious.
 501         st->print(", ");
 502         cld->print_value_on(st);
 503       }
 504       st->cr();


   1 /*
   2  * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 337   assert(loader_data() != ClassLoaderData::the_null_class_loader_data(), "doesn't make sense");
 338 #endif
 339 
 340   assert(entry->contains_protection_domain(protection_domain()),
 341          "now protection domain should be present");
 342 }
 343 
 344 
 345 bool Dictionary::is_valid_protection_domain(unsigned int hash,
 346                                             Symbol* name,
 347                                             Handle protection_domain) {
 348   int index = hash_to_index(hash);
 349   DictionaryEntry* entry = get_entry(index, hash, name);
 350   return entry->is_valid_protection_domain(protection_domain);
 351 }
 352 
 353 // During class loading we may have cached a protection domain that has
 354 // since been unreferenced, so this entry should be cleared.
 355 void Dictionary::clean_cached_protection_domains() {
 356   assert_locked_or_safepoint(SystemDictionary_lock);
 357   assert(!loader_data()->has_class_mirror_holder(), "cld should have a ClassLoader holder not a Class holder");
 358 
 359   if (loader_data()->is_the_null_class_loader_data()) {
 360     // Classes in the boot loader are not loaded with protection domains
 361     return;
 362   }
 363 
 364   for (int index = 0; index < table_size(); index++) {
 365     for (DictionaryEntry* probe = bucket(index);
 366                           probe != NULL;
 367                           probe = probe->next()) {
 368       Klass* e = probe->instance_klass();
 369 
 370       MutexLocker ml(ProtectionDomainSet_lock, Mutex::_no_safepoint_check_flag);
 371       ProtectionDomainEntry* current = probe->pd_set();
 372       ProtectionDomainEntry* prev = NULL;
 373       while (current != NULL) {
 374         if (current->object_no_keepalive() == NULL) {
 375           LogTarget(Debug, protectiondomain) lt;
 376           if (lt.is_enabled()) {
 377             ResourceMark rm;


 466   }
 467 }
 468 
 469 void DictionaryEntry::print_count(outputStream *st) {
 470   MutexLocker ml(ProtectionDomainSet_lock, Mutex::_no_safepoint_check_flag);
 471   int count = 0;
 472   for (ProtectionDomainEntry* current = pd_set();  // accessed inside SD lock
 473                               current != NULL;
 474                               current = current->_next) {
 475     count++;
 476   }
 477   st->print_cr("pd set count = #%d", count);
 478 }
 479 
 480 // ----------------------------------------------------------------------------
 481 
 482 void Dictionary::print_on(outputStream* st) const {
 483   ResourceMark rm;
 484 
 485   assert(loader_data() != NULL, "loader data should not be null");
 486   assert(!loader_data()->has_class_mirror_holder(), "cld should have a ClassLoader holder not a Class holder");
 487   st->print_cr("Java dictionary (table_size=%d, classes=%d, resizable=%s)",
 488                table_size(), number_of_entries(), BOOL_TO_STR(_resizable));
 489   st->print_cr("^ indicates that initiating loader is different from defining loader");
 490 
 491   for (int index = 0; index < table_size(); index++) {
 492     for (DictionaryEntry* probe = bucket(index);
 493                           probe != NULL;
 494                           probe = probe->next()) {
 495       Klass* e = probe->instance_klass();
 496       bool is_defining_class =
 497          (loader_data() == e->class_loader_data());
 498       st->print("%4d: %s%s", index, is_defining_class ? " " : "^", e->external_name());
 499       ClassLoaderData* cld = e->class_loader_data();
 500       if (!loader_data()->is_the_null_class_loader_data()) {
 501         // Class loader output for the dictionary for the null class loader data is
 502         // redundant and obvious.
 503         st->print(", ");
 504         cld->print_value_on(st);
 505       }
 506       st->cr();


< prev index next >