< prev index next >

src/hotspot/share/classfile/systemDictionary.cpp

Print this page




  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "jvm.h"
  27 #include "aot/aotLoader.hpp"
  28 #include "classfile/classFileParser.hpp"
  29 #include "classfile/classFileStream.hpp"
  30 #include "classfile/classLoader.hpp"
  31 #include "classfile/classLoaderData.inline.hpp"
  32 #include "classfile/classLoaderDataGraph.inline.hpp"
  33 #include "classfile/classLoaderExt.hpp"
  34 #include "classfile/dictionary.hpp"
  35 #include "classfile/javaClasses.inline.hpp"
  36 #include "classfile/klassFactory.hpp"
  37 #include "classfile/loaderConstraints.hpp"
  38 #include "classfile/packageEntry.hpp"
  39 #include "classfile/placeholders.hpp"
  40 #include "classfile/protectionDomainCache.hpp"
  41 #include "classfile/resolutionErrors.hpp"
  42 #include "classfile/stringTable.hpp"
  43 #include "classfile/symbolTable.hpp"
  44 #include "classfile/systemDictionary.hpp"
  45 #include "classfile/vmSymbols.hpp"
  46 #include "code/codeCache.hpp"
  47 #include "compiler/compileBroker.hpp"
  48 #include "gc/shared/gcTraceTime.inline.hpp"
  49 #include "gc/shared/oopStorage.inline.hpp"
  50 #include "interpreter/bytecodeStream.hpp"
  51 #include "interpreter/interpreter.hpp"
  52 #include "jfr/jfrEvents.hpp"
  53 #include "logging/log.hpp"
  54 #include "logging/logStream.hpp"
  55 #include "memory/filemap.hpp"
  56 #include "memory/heapShared.hpp"
  57 #include "memory/metaspaceClosure.hpp"
  58 #include "memory/oopFactory.hpp"
  59 #include "memory/resourceArea.hpp"
  60 #include "memory/universe.hpp"
  61 #include "oops/access.inline.hpp"
  62 #include "oops/instanceKlass.hpp"
  63 #include "oops/instanceRefKlass.hpp"
  64 #include "oops/klass.inline.hpp"
  65 #include "oops/method.inline.hpp"
  66 #include "oops/methodData.hpp"
  67 #include "oops/objArrayKlass.hpp"
  68 #include "oops/objArrayOop.inline.hpp"
  69 #include "oops/oop.inline.hpp"
  70 #include "oops/symbol.hpp"
  71 #include "oops/typeArrayKlass.hpp"
  72 #include "prims/jvmtiExport.hpp"

  73 #include "prims/methodHandles.hpp"
  74 #include "runtime/arguments.hpp"
  75 #include "runtime/biasedLocking.hpp"
  76 #include "runtime/fieldType.hpp"
  77 #include "runtime/handles.inline.hpp"
  78 #include "runtime/java.hpp"
  79 #include "runtime/javaCalls.hpp"
  80 #include "runtime/mutexLocker.hpp"
  81 #include "runtime/orderAccess.hpp"
  82 #include "runtime/sharedRuntime.hpp"
  83 #include "runtime/signature.hpp"
  84 #include "services/classLoadingService.hpp"
  85 #include "services/diagnosticCommand.hpp"
  86 #include "services/threadService.hpp"
  87 #include "utilities/macros.hpp"
  88 #if INCLUDE_CDS
  89 #include "classfile/systemDictionaryShared.hpp"
  90 #endif



  91 #if INCLUDE_JFR
  92 #include "jfr/jfr.hpp"
  93 #endif
  94 
  95 PlaceholderTable*      SystemDictionary::_placeholders        = NULL;
  96 LoaderConstraintTable* SystemDictionary::_loader_constraints  = NULL;
  97 ResolutionErrorTable*  SystemDictionary::_resolution_errors   = NULL;
  98 SymbolPropertyTable*   SystemDictionary::_invoke_method_table = NULL;
  99 ProtectionDomainCacheTable*   SystemDictionary::_pd_cache_table = NULL;
 100 
 101 int         SystemDictionary::_number_of_modifications = 0;
 102 oop         SystemDictionary::_system_loader_lock_obj     =  NULL;
 103 
 104 InstanceKlass*      SystemDictionary::_well_known_klasses[SystemDictionary::WKID_LIMIT]
 105                                                           =  { NULL /*, NULL...*/ };
 106 
 107 InstanceKlass*      SystemDictionary::_box_klasses[T_VOID+1]      =  { NULL /*, NULL...*/ };
 108 
 109 oop         SystemDictionary::_java_system_loader         =  NULL;
 110 oop         SystemDictionary::_java_platform_loader       =  NULL;


 246 // Forwards to resolve_array_class_or_null or resolve_instance_class_or_null
 247 
 248 Klass* SystemDictionary::resolve_or_null(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS) {
 249   if (FieldType::is_array(class_name)) {
 250     return resolve_array_class_or_null(class_name, class_loader, protection_domain, THREAD);
 251   } else {
 252     return resolve_instance_class_or_null_helper(class_name, class_loader, protection_domain, THREAD);
 253   }
 254 }
 255 
 256 // name may be in the form of "java/lang/Object" or "Ljava/lang/Object;"
 257 InstanceKlass* SystemDictionary::resolve_instance_class_or_null_helper(Symbol* class_name,
 258                                                                        Handle class_loader,
 259                                                                        Handle protection_domain,
 260                                                                        TRAPS) {
 261   assert(class_name != NULL && !FieldType::is_array(class_name), "must be");
 262   if (FieldType::is_obj(class_name)) {
 263     ResourceMark rm(THREAD);
 264     // Ignore wrapping L and ;.
 265     TempNewSymbol name = SymbolTable::new_symbol(class_name->as_C_string() + 1,
 266                                                  class_name->utf8_length() - 2);
 267     return resolve_instance_class_or_null(name, class_loader, protection_domain, THREAD);
 268   } else {
 269     return resolve_instance_class_or_null(class_name, class_loader, protection_domain, THREAD);
 270   }
 271 }
 272 
 273 Klass* SystemDictionary::resolve_or_null(Symbol* class_name, TRAPS) {
 274   return resolve_or_null(class_name, Handle(), Handle(), THREAD);
 275 }
 276 
 277 // Forwards to resolve_instance_class_or_null
 278 
 279 Klass* SystemDictionary::resolve_array_class_or_null(Symbol* class_name,
 280                                                      Handle class_loader,
 281                                                      Handle protection_domain,
 282                                                      TRAPS) {
 283   assert(FieldType::is_array(class_name), "must be array");
 284   Klass* k = NULL;
 285   FieldArrayInfo fd;
 286   // dimension and object_key in FieldArrayInfo are assigned as a side-effect


1806   // Now flush all code that depended on old class hierarchy.
1807   // Note: must be done *after* linking k into the hierarchy (was bug 12/9/97)
1808   CodeCache::flush_dependents_on(k);
1809 }
1810 
1811 // ----------------------------------------------------------------------------
1812 // GC support
1813 
1814 // Assumes classes in the SystemDictionary are only unloaded at a safepoint
1815 // Note: anonymous classes are not in the SD.
1816 bool SystemDictionary::do_unloading(GCTimer* gc_timer) {
1817 
1818   bool unloading_occurred;
1819   bool is_concurrent = !SafepointSynchronize::is_at_safepoint();
1820   {
1821     GCTraceTime(Debug, gc, phases) t("ClassLoaderData", gc_timer);
1822     assert_locked_or_safepoint(ClassLoaderDataGraph_lock);  // caller locks.
1823     // First, mark for unload all ClassLoaderData referencing a dead class loader.
1824     unloading_occurred = ClassLoaderDataGraph::do_unloading();
1825     if (unloading_occurred) {
1826       MutexLocker ml2(is_concurrent ? Module_lock : NULL);
1827       JFR_ONLY(Jfr::on_unloading_classes();)
1828 
1829       MutexLocker ml1(is_concurrent ? SystemDictionary_lock : NULL);
1830       ClassLoaderDataGraph::clean_module_and_package_info();
1831       constraints()->purge_loader_constraints();
1832       resolution_errors()->purge_resolution_errors();
1833     }
1834   }
1835 
1836   GCTraceTime(Debug, gc, phases) t("Trigger cleanups", gc_timer);


1837 
1838   if (unloading_occurred) {
1839     SymbolTable::trigger_cleanup();
1840 
1841     // Oops referenced by the protection domain cache table may get unreachable independently
1842     // of the class loader (eg. cached protection domain oops). So we need to
1843     // explicitly unlink them here.
1844     // All protection domain oops are linked to the caller class, so if nothing
1845     // unloads, this is not needed.
1846     _pd_cache_table->trigger_cleanup();
1847   }
1848 
1849   return unloading_occurred;
1850 }
1851 
1852 void SystemDictionary::oops_do(OopClosure* f) {
1853   f->do_oop(&_java_system_loader);
1854   f->do_oop(&_java_platform_loader);
1855   f->do_oop(&_system_loader_lock_obj);
1856   CDS_ONLY(SystemDictionaryShared::oops_do(f);)


1904 
1905 #ifdef ASSERT
1906 bool SystemDictionary::is_well_known_klass(Symbol* class_name) {
1907   int sid;
1908   for (int i = 0; (sid = wk_init_info[i]) != 0; i++) {
1909     Symbol* symbol = vmSymbols::symbol_at((vmSymbols::SID)sid);
1910     if (class_name == symbol) {
1911       return true;
1912     }
1913   }
1914   return false;
1915 }
1916 #endif
1917 
1918 bool SystemDictionary::resolve_wk_klass(WKID id, TRAPS) {
1919   assert(id >= (int)FIRST_WKID && id < (int)WKID_LIMIT, "oob");
1920   int sid = wk_init_info[id - FIRST_WKID];
1921   Symbol* symbol = vmSymbols::symbol_at((vmSymbols::SID)sid);
1922   InstanceKlass** klassp = &_well_known_klasses[id];
1923 







1924   if ((*klassp) == NULL) {
1925     Klass* k = resolve_or_fail(symbol, true, CHECK_0);
1926     (*klassp) = InstanceKlass::cast(k);
1927   }
1928   return ((*klassp) != NULL);
1929 }
1930 
1931 void SystemDictionary::resolve_wk_klasses_until(WKID limit_id, WKID &start_id, TRAPS) {
1932   assert((int)start_id <= (int)limit_id, "IDs are out of order!");
1933   for (int id = (int)start_id; id < (int)limit_id; id++) {
1934     assert(id >= (int)FIRST_WKID && id < (int)WKID_LIMIT, "oob");
1935     resolve_wk_klass((WKID)id, CHECK);
1936   }
1937 
1938   // move the starting value forward to the limit:
1939   start_id = limit_id;
1940 }
1941 
1942 void SystemDictionary::resolve_well_known_classes(TRAPS) {
1943   assert(WK_KLASS(Object_klass) == NULL, "well-known classes should only be initialized once");


1992   Universe::fixup_mirrors(CHECK);
1993 
1994   // do a bunch more:
1995   resolve_wk_klasses_through(WK_KLASS_ENUM_NAME(Reference_klass), scan, CHECK);
1996 
1997   // Preload ref klasses and set reference types
1998   InstanceKlass::cast(WK_KLASS(Reference_klass))->set_reference_type(REF_OTHER);
1999   InstanceRefKlass::update_nonstatic_oop_maps(WK_KLASS(Reference_klass));
2000 
2001   resolve_wk_klasses_through(WK_KLASS_ENUM_NAME(PhantomReference_klass), scan, CHECK);
2002   InstanceKlass::cast(WK_KLASS(SoftReference_klass))->set_reference_type(REF_SOFT);
2003   InstanceKlass::cast(WK_KLASS(WeakReference_klass))->set_reference_type(REF_WEAK);
2004   InstanceKlass::cast(WK_KLASS(FinalReference_klass))->set_reference_type(REF_FINAL);
2005   InstanceKlass::cast(WK_KLASS(PhantomReference_klass))->set_reference_type(REF_PHANTOM);
2006 
2007   // JSR 292 classes
2008   WKID jsr292_group_start = WK_KLASS_ENUM_NAME(MethodHandle_klass);
2009   WKID jsr292_group_end   = WK_KLASS_ENUM_NAME(VolatileCallSite_klass);
2010   resolve_wk_klasses_until(jsr292_group_start, scan, CHECK);
2011   resolve_wk_klasses_through(jsr292_group_end, scan, CHECK);
2012   WKID last = WKID_LIMIT;
2013   resolve_wk_klasses_until(last, scan, CHECK);
2014 
2015   _box_klasses[T_BOOLEAN] = WK_KLASS(Boolean_klass);
2016   _box_klasses[T_CHAR]    = WK_KLASS(Character_klass);
2017   _box_klasses[T_FLOAT]   = WK_KLASS(Float_klass);
2018   _box_klasses[T_DOUBLE]  = WK_KLASS(Double_klass);
2019   _box_klasses[T_BYTE]    = WK_KLASS(Byte_klass);
2020   _box_klasses[T_SHORT]   = WK_KLASS(Short_klass);
2021   _box_klasses[T_INT]     = WK_KLASS(Integer_klass);
2022   _box_klasses[T_LONG]    = WK_KLASS(Long_klass);
2023   //_box_klasses[T_OBJECT]  = WK_KLASS(object_klass);
2024   //_box_klasses[T_ARRAY]   = WK_KLASS(object_klass);
2025 
2026   { // Compute whether we should use checkPackageAccess or NOT
2027     Method* method = InstanceKlass::cast(ClassLoader_klass())->find_method(vmSymbols::checkPackageAccess_name(), vmSymbols::class_protectiondomain_signature());
2028     _has_checkPackageAccess = (method != NULL);
2029   }
2030 
2031 #ifdef ASSERT
2032   if (UseSharedSpaces) {


2339 //
2340 //
2341 // SystemDictionary::check_signature_loaders(sig, l1, l2)
2342 //
2343 // Make sure all class components (including arrays) in the given
2344 // signature will be resolved to the same class in both loaders.
2345 // Returns the name of the type that failed a loader constraint check, or
2346 // NULL if no constraint failed.  No exception except OOME is thrown.
2347 // Arrays are not added to the loader constraint table, their elements are.
2348 Symbol* SystemDictionary::check_signature_loaders(Symbol* signature,
2349                                                Handle loader1, Handle loader2,
2350                                                bool is_method, TRAPS)  {
2351   // Nothing to do if loaders are the same.
2352   if (oopDesc::equals(loader1(), loader2())) {
2353     return NULL;
2354   }
2355 
2356   SignatureStream sig_strm(signature, is_method);
2357   while (!sig_strm.is_done()) {
2358     if (sig_strm.is_object()) {
2359       Symbol* sig = sig_strm.as_symbol();
2360       if (!add_loader_constraint(sig, loader1, loader2, THREAD)) {
2361         return sig;
2362       }
2363     }
2364     sig_strm.next();
2365   }
2366   return NULL;
2367 }
2368 
2369 
2370 methodHandle SystemDictionary::find_method_handle_intrinsic(vmIntrinsics::ID iid,
2371                                                             Symbol* signature,
2372                                                             TRAPS) {
2373   methodHandle empty;
2374   assert(MethodHandles::is_signature_polymorphic(iid) &&
2375          MethodHandles::is_signature_polymorphic_intrinsic(iid) &&
2376          iid != vmIntrinsics::_invokeGeneric,
2377          "must be a known MH intrinsic iid=%d: %s", iid, vmIntrinsics::name_at(iid));
2378 
2379   unsigned int hash  = invoke_method_table()->compute_hash(signature, iid);


2609   objArrayHandle pts = oopFactory::new_objArray_handle(SystemDictionary::Class_klass(), npts, CHECK_(empty));
2610   int arg = 0;
2611   Handle rt; // the return type from the signature
2612   ResourceMark rm(THREAD);
2613   for (SignatureStream ss(signature); !ss.is_done(); ss.next()) {
2614     oop mirror = NULL;
2615     if (can_be_cached) {
2616       // Use neutral class loader to lookup candidate classes to be placed in the cache.
2617       mirror = ss.as_java_mirror(Handle(), Handle(),
2618                                  SignatureStream::ReturnNull, CHECK_(empty));
2619       if (mirror == NULL || (ss.is_object() && !is_always_visible_class(mirror))) {
2620         // Fall back to accessing_klass context.
2621         can_be_cached = false;
2622       }
2623     }
2624     if (!can_be_cached) {
2625       // Resolve, throwing a real error if it doesn't work.
2626       mirror = ss.as_java_mirror(class_loader, protection_domain,
2627                                  SignatureStream::NCDFError, CHECK_(empty));
2628     }
2629     assert(mirror != NULL, "%s", ss.as_symbol()->as_C_string());
2630     if (ss.at_return_type())
2631       rt = Handle(THREAD, mirror);
2632     else
2633       pts->obj_at_put(arg++, mirror);
2634 
2635     // Check accessibility.
2636     if (!java_lang_Class::is_primitive(mirror) && accessing_klass != NULL) {
2637       Klass* sel_klass = java_lang_Class::as_Klass(mirror);
2638       mirror = NULL;  // safety
2639       // Emulate ConstantPool::verify_constant_pool_resolve.
2640       bool fold_type_to_class = true;
2641       LinkResolver::check_klass_accessability(accessing_klass, sel_klass,
2642                                               fold_type_to_class, CHECK_(empty));
2643     }
2644   }
2645   assert(arg == npts, "");
2646 
2647   // call java.lang.invoke.MethodHandleNatives::findMethodHandleType(Class rt, Class[] pts) -> MethodType
2648   JavaCallArguments args(Handle(THREAD, rt()));
2649   args.push_oop(pts);


2725 
2726   // After method/field resolution succeeded, it's safe to resolve MH signature as well.
2727   Handle type = MethodHandles::resolve_MemberName_type(mname, caller, CHECK_(empty));
2728 
2729   // call java.lang.invoke.MethodHandleNatives::linkMethodHandleConstant(Class caller, int refKind, Class callee, String name, Object type) -> MethodHandle
2730   JavaCallArguments args;
2731   args.push_oop(Handle(THREAD, caller->java_mirror()));  // the referring class
2732   args.push_int(ref_kind);
2733   args.push_oop(Handle(THREAD, callee->java_mirror()));  // the target class
2734   args.push_oop(name_str);
2735   args.push_oop(type);
2736   JavaValue result(T_OBJECT);
2737   JavaCalls::call_static(&result,
2738                          SystemDictionary::MethodHandleNatives_klass(),
2739                          vmSymbols::linkMethodHandleConstant_name(),
2740                          vmSymbols::linkMethodHandleConstant_signature(),
2741                          &args, CHECK_(empty));
2742   return Handle(THREAD, (oop) result.get_jobject());
2743 }
2744 
2745 // Ask Java to run a bootstrap method, in order to create a dynamic call site
2746 // while linking an invokedynamic op, or compute a constant for Dynamic_info CP entry
2747 // with linkage results being stored back into the bootstrap specifier.
2748 void SystemDictionary::invoke_bootstrap_method(BootstrapInfo& bootstrap_specifier, TRAPS) {
2749   // Resolve the bootstrap specifier, its name, type, and static arguments
2750   bootstrap_specifier.resolve_bsm(CHECK);














2751 
2752   // This should not happen.  JDK code should take care of that.
2753   if (bootstrap_specifier.caller() == NULL || bootstrap_specifier.type_arg().is_null()) {
2754     THROW_MSG(vmSymbols::java_lang_InternalError(), "Invalid bootstrap method invocation with no caller or type argument");
2755   }
2756 
2757   bool is_indy = bootstrap_specifier.is_method_call();
2758   objArrayHandle appendix_box;
2759   if (is_indy) {
2760     // Some method calls may require an appendix argument.  Arrange to receive it.
2761     appendix_box = oopFactory::new_objArray_handle(SystemDictionary::Object_klass(), 1, CHECK);
2762     assert(appendix_box->obj_at(0) == NULL, "");
2763   }
2764 
2765   // call condy: java.lang.invoke.MethodHandleNatives::linkDynamicConstant(caller, condy_index, bsm, type, info)
2766   //       indy: java.lang.invoke.MethodHandleNatives::linkCallSite(caller, indy_index, bsm, name, mtype, info, &appendix)



2767   JavaCallArguments args;
2768   args.push_oop(Handle(THREAD, bootstrap_specifier.caller_mirror()));
2769   args.push_int(bootstrap_specifier.bss_index());
2770   args.push_oop(bootstrap_specifier.bsm());
2771   args.push_oop(bootstrap_specifier.name_arg());
2772   args.push_oop(bootstrap_specifier.type_arg());
2773   args.push_oop(bootstrap_specifier.arg_values());
2774   if (is_indy) {
2775     args.push_oop(appendix_box);
2776   }
2777   JavaValue result(T_OBJECT);
2778   JavaCalls::call_static(&result,
2779                          SystemDictionary::MethodHandleNatives_klass(),
2780                          is_indy ? vmSymbols::linkCallSite_name() : vmSymbols::linkDynamicConstant_name(),
2781                          is_indy ? vmSymbols::linkCallSite_signature() : vmSymbols::linkDynamicConstant_signature(),
2782                          &args, CHECK);
2783 
2784   Handle value(THREAD, (oop) result.get_jobject());
2785   if (is_indy) {
2786     Handle appendix;
2787     methodHandle method = unpack_method_and_appendix(value,
2788                                                      bootstrap_specifier.caller(),
2789                                                      appendix_box,
2790                                                      &appendix, CHECK);
2791     bootstrap_specifier.set_resolved_method(method, appendix);








2792   } else {
2793     bootstrap_specifier.set_resolved_value(value);



2794   }


2795 
2796   // sanity check
2797   assert(bootstrap_specifier.is_resolved() ||
2798          (bootstrap_specifier.is_method_call() &&
2799           bootstrap_specifier.resolved_method().not_null()), "bootstrap method call failed");
























2800 }
2801 
2802 // Protection domain cache table handling
2803 
2804 ProtectionDomainCacheEntry* SystemDictionary::cache_get(Handle protection_domain) {
2805   return _pd_cache_table->get(protection_domain);
2806 }
2807 
2808 // ----------------------------------------------------------------------------
2809 
2810 void SystemDictionary::print_on(outputStream *st) {
2811   CDS_ONLY(SystemDictionaryShared::print_on(st));
2812   GCMutexLocker mu(SystemDictionary_lock);
2813 
2814   ClassLoaderDataGraph::print_dictionary(st);
2815 
2816   // Placeholders
2817   placeholders()->print_on(st);
2818   st->cr();
2819 
2820   // loader constraints - print under SD_lock
2821   constraints()->print_on(st);
2822   st->cr();
2823 
2824   _pd_cache_table->print_on(st);
2825   st->cr();
2826 }
2827 
2828 void SystemDictionary::print() { print_on(tty); }
2829 
2830 void SystemDictionary::verify() {
2831   guarantee(constraints() != NULL,
2832             "Verify of loader constraints failed");
2833   guarantee(placeholders()->number_of_entries() >= 0,
2834             "Verify of placeholders failed");
2835 
2836   GCMutexLocker mu(SystemDictionary_lock);
2837 
2838   // Verify dictionary
2839   ClassLoaderDataGraph::verify_dictionary();
2840 
2841   placeholders()->verify();
2842 
2843   // Verify constraint table
2844   guarantee(constraints() != NULL, "Verify of loader constraints failed");
2845   constraints()->verify(placeholders());
2846 
2847   _pd_cache_table->verify();
2848 }
2849 
2850 void SystemDictionary::dump(outputStream *st, bool verbose) {
2851   assert_locked_or_safepoint(SystemDictionary_lock);
2852   if (verbose) {
2853     print_on(st);
2854   } else {
2855     CDS_ONLY(SystemDictionaryShared::print_table_statistics(st));
2856     ClassLoaderDataGraph::print_table_statistics(st);
2857     placeholders()->print_table_statistics(st, "Placeholder Table");
2858     constraints()->print_table_statistics(st, "LoaderConstraints Table");
2859     pd_cache_table()->print_table_statistics(st, "ProtectionDomainCache Table");
2860   }
2861 }
2862 
2863 TableStatistics SystemDictionary::placeholders_statistics() {
2864   return placeholders()->statistics_calculate();
2865 }
2866 
2867 TableStatistics SystemDictionary::loader_constraints_statistics() {
2868   return constraints()->statistics_calculate();
2869 }
2870 
2871 TableStatistics SystemDictionary::protection_domain_cache_statistics() {
2872   return pd_cache_table()->statistics_calculate();
2873 }
2874 
2875 // Utility for dumping dictionaries.
2876 SystemDictionaryDCmd::SystemDictionaryDCmd(outputStream* output, bool heap) :
2877                                  DCmdWithParser(output, heap),
2878   _verbose("-verbose", "Dump the content of each dictionary entry for all class loaders",
2879            "BOOLEAN", false, "false") {
2880   _dcmdparser.add_dcmd_option(&_verbose);
2881 }
2882 
2883 void SystemDictionaryDCmd::execute(DCmdSource source, TRAPS) {
2884   VM_DumpHashtable dumper(output(), VM_DumpHashtable::DumpSysDict,
2885                          _verbose.value());
2886   VMThread::execute(&dumper);
2887 }
2888 
2889 int SystemDictionaryDCmd::num_arguments() {
2890   ResourceMark rm;
2891   SystemDictionaryDCmd* dcmd = new SystemDictionaryDCmd(NULL, false);
2892   if (dcmd != NULL) {


  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "jvm.h"
  27 #include "aot/aotLoader.hpp"
  28 #include "classfile/classFileParser.hpp"
  29 #include "classfile/classFileStream.hpp"
  30 #include "classfile/classLoader.hpp"
  31 #include "classfile/classLoaderData.inline.hpp"
  32 #include "classfile/classLoaderDataGraph.inline.hpp"
  33 #include "classfile/classLoaderExt.hpp"
  34 #include "classfile/dictionary.hpp"
  35 #include "classfile/javaClasses.inline.hpp"
  36 #include "classfile/klassFactory.hpp"
  37 #include "classfile/loaderConstraints.hpp"
  38 #include "classfile/packageEntry.hpp"
  39 #include "classfile/placeholders.hpp"
  40 #include "classfile/protectionDomainCache.hpp"
  41 #include "classfile/resolutionErrors.hpp"
  42 #include "classfile/stringTable.hpp"

  43 #include "classfile/systemDictionary.hpp"
  44 #include "classfile/vmSymbols.hpp"
  45 #include "code/codeCache.hpp"
  46 #include "compiler/compileBroker.hpp"
  47 #include "gc/shared/gcTraceTime.inline.hpp"
  48 #include "gc/shared/oopStorage.inline.hpp"
  49 #include "interpreter/bytecodeStream.hpp"
  50 #include "interpreter/interpreter.hpp"
  51 #include "jfr/jfrEvents.hpp"
  52 #include "logging/log.hpp"
  53 #include "logging/logStream.hpp"
  54 #include "memory/filemap.hpp"
  55 #include "memory/heapShared.hpp"
  56 #include "memory/metaspaceClosure.hpp"
  57 #include "memory/oopFactory.hpp"
  58 #include "memory/resourceArea.hpp"

  59 #include "oops/access.inline.hpp"
  60 #include "oops/instanceKlass.hpp"
  61 #include "oops/instanceRefKlass.hpp"
  62 #include "oops/klass.inline.hpp"
  63 #include "oops/method.inline.hpp"
  64 #include "oops/methodData.hpp"
  65 #include "oops/objArrayKlass.hpp"
  66 #include "oops/objArrayOop.inline.hpp"
  67 #include "oops/oop.inline.hpp"
  68 #include "oops/symbol.hpp"
  69 #include "oops/typeArrayKlass.hpp"
  70 #include "prims/jvmtiExport.hpp"
  71 #include "prims/resolvedMethodTable.hpp"
  72 #include "prims/methodHandles.hpp"
  73 #include "runtime/arguments.hpp"
  74 #include "runtime/biasedLocking.hpp"
  75 #include "runtime/fieldType.hpp"
  76 #include "runtime/handles.inline.hpp"
  77 #include "runtime/java.hpp"
  78 #include "runtime/javaCalls.hpp"
  79 #include "runtime/mutexLocker.hpp"
  80 #include "runtime/orderAccess.hpp"
  81 #include "runtime/sharedRuntime.hpp"
  82 #include "runtime/signature.hpp"
  83 #include "services/classLoadingService.hpp"
  84 #include "services/diagnosticCommand.hpp"
  85 #include "services/threadService.hpp"
  86 #include "utilities/macros.hpp"
  87 #if INCLUDE_CDS
  88 #include "classfile/systemDictionaryShared.hpp"
  89 #endif
  90 #if INCLUDE_JVMCI
  91 #include "jvmci/jvmciRuntime.hpp"
  92 #endif
  93 #if INCLUDE_JFR
  94 #include "jfr/jfr.hpp"
  95 #endif
  96 
  97 PlaceholderTable*      SystemDictionary::_placeholders        = NULL;
  98 LoaderConstraintTable* SystemDictionary::_loader_constraints  = NULL;
  99 ResolutionErrorTable*  SystemDictionary::_resolution_errors   = NULL;
 100 SymbolPropertyTable*   SystemDictionary::_invoke_method_table = NULL;
 101 ProtectionDomainCacheTable*   SystemDictionary::_pd_cache_table = NULL;
 102 
 103 int         SystemDictionary::_number_of_modifications = 0;
 104 oop         SystemDictionary::_system_loader_lock_obj     =  NULL;
 105 
 106 InstanceKlass*      SystemDictionary::_well_known_klasses[SystemDictionary::WKID_LIMIT]
 107                                                           =  { NULL /*, NULL...*/ };
 108 
 109 InstanceKlass*      SystemDictionary::_box_klasses[T_VOID+1]      =  { NULL /*, NULL...*/ };
 110 
 111 oop         SystemDictionary::_java_system_loader         =  NULL;
 112 oop         SystemDictionary::_java_platform_loader       =  NULL;


 248 // Forwards to resolve_array_class_or_null or resolve_instance_class_or_null
 249 
 250 Klass* SystemDictionary::resolve_or_null(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS) {
 251   if (FieldType::is_array(class_name)) {
 252     return resolve_array_class_or_null(class_name, class_loader, protection_domain, THREAD);
 253   } else {
 254     return resolve_instance_class_or_null_helper(class_name, class_loader, protection_domain, THREAD);
 255   }
 256 }
 257 
 258 // name may be in the form of "java/lang/Object" or "Ljava/lang/Object;"
 259 InstanceKlass* SystemDictionary::resolve_instance_class_or_null_helper(Symbol* class_name,
 260                                                                        Handle class_loader,
 261                                                                        Handle protection_domain,
 262                                                                        TRAPS) {
 263   assert(class_name != NULL && !FieldType::is_array(class_name), "must be");
 264   if (FieldType::is_obj(class_name)) {
 265     ResourceMark rm(THREAD);
 266     // Ignore wrapping L and ;.
 267     TempNewSymbol name = SymbolTable::new_symbol(class_name->as_C_string() + 1,
 268                                    class_name->utf8_length() - 2, CHECK_NULL);
 269     return resolve_instance_class_or_null(name, class_loader, protection_domain, THREAD);
 270   } else {
 271     return resolve_instance_class_or_null(class_name, class_loader, protection_domain, THREAD);
 272   }
 273 }
 274 
 275 Klass* SystemDictionary::resolve_or_null(Symbol* class_name, TRAPS) {
 276   return resolve_or_null(class_name, Handle(), Handle(), THREAD);
 277 }
 278 
 279 // Forwards to resolve_instance_class_or_null
 280 
 281 Klass* SystemDictionary::resolve_array_class_or_null(Symbol* class_name,
 282                                                      Handle class_loader,
 283                                                      Handle protection_domain,
 284                                                      TRAPS) {
 285   assert(FieldType::is_array(class_name), "must be array");
 286   Klass* k = NULL;
 287   FieldArrayInfo fd;
 288   // dimension and object_key in FieldArrayInfo are assigned as a side-effect


1808   // Now flush all code that depended on old class hierarchy.
1809   // Note: must be done *after* linking k into the hierarchy (was bug 12/9/97)
1810   CodeCache::flush_dependents_on(k);
1811 }
1812 
1813 // ----------------------------------------------------------------------------
1814 // GC support
1815 
1816 // Assumes classes in the SystemDictionary are only unloaded at a safepoint
1817 // Note: anonymous classes are not in the SD.
1818 bool SystemDictionary::do_unloading(GCTimer* gc_timer) {
1819 
1820   bool unloading_occurred;
1821   bool is_concurrent = !SafepointSynchronize::is_at_safepoint();
1822   {
1823     GCTraceTime(Debug, gc, phases) t("ClassLoaderData", gc_timer);
1824     assert_locked_or_safepoint(ClassLoaderDataGraph_lock);  // caller locks.
1825     // First, mark for unload all ClassLoaderData referencing a dead class loader.
1826     unloading_occurred = ClassLoaderDataGraph::do_unloading();
1827     if (unloading_occurred) {
1828       MutexLockerEx ml2(is_concurrent ? Module_lock : NULL);
1829       JFR_ONLY(Jfr::on_unloading_classes();)
1830 
1831       MutexLockerEx ml1(is_concurrent ? SystemDictionary_lock : NULL);
1832       ClassLoaderDataGraph::clean_module_and_package_info();
1833       constraints()->purge_loader_constraints();
1834       resolution_errors()->purge_resolution_errors();
1835     }
1836   }
1837 
1838   GCTraceTime(Debug, gc, phases) t("Trigger cleanups", gc_timer);
1839   // Trigger cleaning the ResolvedMethodTable even if no unloading occurred.
1840   ResolvedMethodTable::trigger_cleanup();
1841 
1842   if (unloading_occurred) {
1843     SymbolTable::trigger_cleanup();
1844 
1845     // Oops referenced by the protection domain cache table may get unreachable independently
1846     // of the class loader (eg. cached protection domain oops). So we need to
1847     // explicitly unlink them here.
1848     // All protection domain oops are linked to the caller class, so if nothing
1849     // unloads, this is not needed.
1850     _pd_cache_table->trigger_cleanup();
1851   }
1852 
1853   return unloading_occurred;
1854 }
1855 
1856 void SystemDictionary::oops_do(OopClosure* f) {
1857   f->do_oop(&_java_system_loader);
1858   f->do_oop(&_java_platform_loader);
1859   f->do_oop(&_system_loader_lock_obj);
1860   CDS_ONLY(SystemDictionaryShared::oops_do(f);)


1908 
1909 #ifdef ASSERT
1910 bool SystemDictionary::is_well_known_klass(Symbol* class_name) {
1911   int sid;
1912   for (int i = 0; (sid = wk_init_info[i]) != 0; i++) {
1913     Symbol* symbol = vmSymbols::symbol_at((vmSymbols::SID)sid);
1914     if (class_name == symbol) {
1915       return true;
1916     }
1917   }
1918   return false;
1919 }
1920 #endif
1921 
1922 bool SystemDictionary::resolve_wk_klass(WKID id, TRAPS) {
1923   assert(id >= (int)FIRST_WKID && id < (int)WKID_LIMIT, "oob");
1924   int sid = wk_init_info[id - FIRST_WKID];
1925   Symbol* symbol = vmSymbols::symbol_at((vmSymbols::SID)sid);
1926   InstanceKlass** klassp = &_well_known_klasses[id];
1927 
1928 
1929 #if INCLUDE_JVMCI
1930   if (id >= FIRST_JVMCI_WKID) {
1931     assert(EnableJVMCI, "resolve JVMCI classes only when EnableJVMCI is true");
1932   }
1933 #endif
1934 
1935   if ((*klassp) == NULL) {
1936     Klass* k = resolve_or_fail(symbol, true, CHECK_0);
1937     (*klassp) = InstanceKlass::cast(k);
1938   }
1939   return ((*klassp) != NULL);
1940 }
1941 
1942 void SystemDictionary::resolve_wk_klasses_until(WKID limit_id, WKID &start_id, TRAPS) {
1943   assert((int)start_id <= (int)limit_id, "IDs are out of order!");
1944   for (int id = (int)start_id; id < (int)limit_id; id++) {
1945     assert(id >= (int)FIRST_WKID && id < (int)WKID_LIMIT, "oob");
1946     resolve_wk_klass((WKID)id, CHECK);
1947   }
1948 
1949   // move the starting value forward to the limit:
1950   start_id = limit_id;
1951 }
1952 
1953 void SystemDictionary::resolve_well_known_classes(TRAPS) {
1954   assert(WK_KLASS(Object_klass) == NULL, "well-known classes should only be initialized once");


2003   Universe::fixup_mirrors(CHECK);
2004 
2005   // do a bunch more:
2006   resolve_wk_klasses_through(WK_KLASS_ENUM_NAME(Reference_klass), scan, CHECK);
2007 
2008   // Preload ref klasses and set reference types
2009   InstanceKlass::cast(WK_KLASS(Reference_klass))->set_reference_type(REF_OTHER);
2010   InstanceRefKlass::update_nonstatic_oop_maps(WK_KLASS(Reference_klass));
2011 
2012   resolve_wk_klasses_through(WK_KLASS_ENUM_NAME(PhantomReference_klass), scan, CHECK);
2013   InstanceKlass::cast(WK_KLASS(SoftReference_klass))->set_reference_type(REF_SOFT);
2014   InstanceKlass::cast(WK_KLASS(WeakReference_klass))->set_reference_type(REF_WEAK);
2015   InstanceKlass::cast(WK_KLASS(FinalReference_klass))->set_reference_type(REF_FINAL);
2016   InstanceKlass::cast(WK_KLASS(PhantomReference_klass))->set_reference_type(REF_PHANTOM);
2017 
2018   // JSR 292 classes
2019   WKID jsr292_group_start = WK_KLASS_ENUM_NAME(MethodHandle_klass);
2020   WKID jsr292_group_end   = WK_KLASS_ENUM_NAME(VolatileCallSite_klass);
2021   resolve_wk_klasses_until(jsr292_group_start, scan, CHECK);
2022   resolve_wk_klasses_through(jsr292_group_end, scan, CHECK);
2023   WKID last = NOT_JVMCI(WKID_LIMIT) JVMCI_ONLY(FIRST_JVMCI_WKID);
2024   resolve_wk_klasses_until(last, scan, CHECK);
2025 
2026   _box_klasses[T_BOOLEAN] = WK_KLASS(Boolean_klass);
2027   _box_klasses[T_CHAR]    = WK_KLASS(Character_klass);
2028   _box_klasses[T_FLOAT]   = WK_KLASS(Float_klass);
2029   _box_klasses[T_DOUBLE]  = WK_KLASS(Double_klass);
2030   _box_klasses[T_BYTE]    = WK_KLASS(Byte_klass);
2031   _box_klasses[T_SHORT]   = WK_KLASS(Short_klass);
2032   _box_klasses[T_INT]     = WK_KLASS(Integer_klass);
2033   _box_klasses[T_LONG]    = WK_KLASS(Long_klass);
2034   //_box_klasses[T_OBJECT]  = WK_KLASS(object_klass);
2035   //_box_klasses[T_ARRAY]   = WK_KLASS(object_klass);
2036 
2037   { // Compute whether we should use checkPackageAccess or NOT
2038     Method* method = InstanceKlass::cast(ClassLoader_klass())->find_method(vmSymbols::checkPackageAccess_name(), vmSymbols::class_protectiondomain_signature());
2039     _has_checkPackageAccess = (method != NULL);
2040   }
2041 
2042 #ifdef ASSERT
2043   if (UseSharedSpaces) {


2350 //
2351 //
2352 // SystemDictionary::check_signature_loaders(sig, l1, l2)
2353 //
2354 // Make sure all class components (including arrays) in the given
2355 // signature will be resolved to the same class in both loaders.
2356 // Returns the name of the type that failed a loader constraint check, or
2357 // NULL if no constraint failed.  No exception except OOME is thrown.
2358 // Arrays are not added to the loader constraint table, their elements are.
2359 Symbol* SystemDictionary::check_signature_loaders(Symbol* signature,
2360                                                Handle loader1, Handle loader2,
2361                                                bool is_method, TRAPS)  {
2362   // Nothing to do if loaders are the same.
2363   if (oopDesc::equals(loader1(), loader2())) {
2364     return NULL;
2365   }
2366 
2367   SignatureStream sig_strm(signature, is_method);
2368   while (!sig_strm.is_done()) {
2369     if (sig_strm.is_object()) {
2370       Symbol* sig = sig_strm.as_symbol(CHECK_NULL);
2371       if (!add_loader_constraint(sig, loader1, loader2, THREAD)) {
2372         return sig;
2373       }
2374     }
2375     sig_strm.next();
2376   }
2377   return NULL;
2378 }
2379 
2380 
2381 methodHandle SystemDictionary::find_method_handle_intrinsic(vmIntrinsics::ID iid,
2382                                                             Symbol* signature,
2383                                                             TRAPS) {
2384   methodHandle empty;
2385   assert(MethodHandles::is_signature_polymorphic(iid) &&
2386          MethodHandles::is_signature_polymorphic_intrinsic(iid) &&
2387          iid != vmIntrinsics::_invokeGeneric,
2388          "must be a known MH intrinsic iid=%d: %s", iid, vmIntrinsics::name_at(iid));
2389 
2390   unsigned int hash  = invoke_method_table()->compute_hash(signature, iid);


2620   objArrayHandle pts = oopFactory::new_objArray_handle(SystemDictionary::Class_klass(), npts, CHECK_(empty));
2621   int arg = 0;
2622   Handle rt; // the return type from the signature
2623   ResourceMark rm(THREAD);
2624   for (SignatureStream ss(signature); !ss.is_done(); ss.next()) {
2625     oop mirror = NULL;
2626     if (can_be_cached) {
2627       // Use neutral class loader to lookup candidate classes to be placed in the cache.
2628       mirror = ss.as_java_mirror(Handle(), Handle(),
2629                                  SignatureStream::ReturnNull, CHECK_(empty));
2630       if (mirror == NULL || (ss.is_object() && !is_always_visible_class(mirror))) {
2631         // Fall back to accessing_klass context.
2632         can_be_cached = false;
2633       }
2634     }
2635     if (!can_be_cached) {
2636       // Resolve, throwing a real error if it doesn't work.
2637       mirror = ss.as_java_mirror(class_loader, protection_domain,
2638                                  SignatureStream::NCDFError, CHECK_(empty));
2639     }
2640     assert(mirror != NULL, "%s", ss.as_symbol(THREAD)->as_C_string());
2641     if (ss.at_return_type())
2642       rt = Handle(THREAD, mirror);
2643     else
2644       pts->obj_at_put(arg++, mirror);
2645 
2646     // Check accessibility.
2647     if (!java_lang_Class::is_primitive(mirror) && accessing_klass != NULL) {
2648       Klass* sel_klass = java_lang_Class::as_Klass(mirror);
2649       mirror = NULL;  // safety
2650       // Emulate ConstantPool::verify_constant_pool_resolve.
2651       bool fold_type_to_class = true;
2652       LinkResolver::check_klass_accessability(accessing_klass, sel_klass,
2653                                               fold_type_to_class, CHECK_(empty));
2654     }
2655   }
2656   assert(arg == npts, "");
2657 
2658   // call java.lang.invoke.MethodHandleNatives::findMethodHandleType(Class rt, Class[] pts) -> MethodType
2659   JavaCallArguments args(Handle(THREAD, rt()));
2660   args.push_oop(pts);


2736 
2737   // After method/field resolution succeeded, it's safe to resolve MH signature as well.
2738   Handle type = MethodHandles::resolve_MemberName_type(mname, caller, CHECK_(empty));
2739 
2740   // call java.lang.invoke.MethodHandleNatives::linkMethodHandleConstant(Class caller, int refKind, Class callee, String name, Object type) -> MethodHandle
2741   JavaCallArguments args;
2742   args.push_oop(Handle(THREAD, caller->java_mirror()));  // the referring class
2743   args.push_int(ref_kind);
2744   args.push_oop(Handle(THREAD, callee->java_mirror()));  // the target class
2745   args.push_oop(name_str);
2746   args.push_oop(type);
2747   JavaValue result(T_OBJECT);
2748   JavaCalls::call_static(&result,
2749                          SystemDictionary::MethodHandleNatives_klass(),
2750                          vmSymbols::linkMethodHandleConstant_name(),
2751                          vmSymbols::linkMethodHandleConstant_signature(),
2752                          &args, CHECK_(empty));
2753   return Handle(THREAD, (oop) result.get_jobject());
2754 }
2755 
2756 // Ask Java to compute a constant by invoking a BSM given a Dynamic_info CP entry
2757 Handle SystemDictionary::link_dynamic_constant(Klass* caller,
2758                                                int condy_index,
2759                                                Handle bootstrap_specifier,
2760                                                Symbol* name,
2761                                                Symbol* type,
2762                                                TRAPS) {
2763   Handle empty;
2764   Handle bsm, info;
2765   if (java_lang_invoke_MethodHandle::is_instance(bootstrap_specifier())) {
2766     bsm = bootstrap_specifier;
2767   } else {
2768     assert(bootstrap_specifier->is_objArray(), "");
2769     objArrayOop args = (objArrayOop) bootstrap_specifier();
2770     assert(args->length() == 2, "");
2771     bsm  = Handle(THREAD, args->obj_at(0));
2772     info = Handle(THREAD, args->obj_at(1));
2773   }
2774   guarantee(java_lang_invoke_MethodHandle::is_instance(bsm()),
2775             "caller must supply a valid BSM");
2776 
2777   // This should not happen.  JDK code should take care of that.
2778   if (caller == NULL) {
2779     THROW_MSG_(vmSymbols::java_lang_InternalError(), "bad dynamic constant", empty);
2780   }
2781 
2782   Handle constant_name = java_lang_String::create_from_symbol(name, CHECK_(empty));






2783 
2784   // Resolve the constant type in the context of the caller class
2785   Handle type_mirror = find_java_mirror_for_type(type, caller, SignatureStream::NCDFError,
2786                                                  CHECK_(empty));
2787 
2788   // call java.lang.invoke.MethodHandleNatives::linkConstantDyanmic(caller, condy_index, bsm, type, info)
2789   JavaCallArguments args;
2790   args.push_oop(Handle(THREAD, caller->java_mirror()));
2791   args.push_int(condy_index);
2792   args.push_oop(bsm);
2793   args.push_oop(constant_name);
2794   args.push_oop(type_mirror);
2795   args.push_oop(info);



2796   JavaValue result(T_OBJECT);
2797   JavaCalls::call_static(&result,
2798                          SystemDictionary::MethodHandleNatives_klass(),
2799                          vmSymbols::linkDynamicConstant_name(),
2800                          vmSymbols::linkDynamicConstant_signature(),
2801                          &args, CHECK_(empty));
2802 
2803   return Handle(THREAD, (oop) result.get_jobject());
2804 }
2805 
2806 // Ask Java code to find or construct a java.lang.invoke.CallSite for the given
2807 // name and signature, as interpreted relative to the given class loader.
2808 methodHandle SystemDictionary::find_dynamic_call_site_invoker(Klass* caller,
2809                                                               int indy_index,
2810                                                               Handle bootstrap_specifier,
2811                                                               Symbol* name,
2812                                                               Symbol* type,
2813                                                               Handle *appendix_result,
2814                                                               TRAPS) {
2815   methodHandle empty;
2816   Handle bsm, info;
2817   if (java_lang_invoke_MethodHandle::is_instance(bootstrap_specifier())) {
2818     bsm = bootstrap_specifier;
2819   } else {
2820     objArrayOop args = (objArrayOop) bootstrap_specifier();
2821     assert(args->length() == 2, "");
2822     bsm  = Handle(THREAD, args->obj_at(0));
2823     info = Handle(THREAD, args->obj_at(1));
2824   }
2825   guarantee(java_lang_invoke_MethodHandle::is_instance(bsm()),
2826             "caller must supply a valid BSM");
2827 
2828   Handle method_name = java_lang_String::create_from_symbol(name, CHECK_(empty));
2829   Handle method_type = find_method_handle_type(type, caller, CHECK_(empty));
2830 
2831   // This should not happen.  JDK code should take care of that.
2832   if (caller == NULL || method_type.is_null()) {
2833     THROW_MSG_(vmSymbols::java_lang_InternalError(), "bad invokedynamic", empty);
2834   }
2835 
2836   objArrayHandle appendix_box = oopFactory::new_objArray_handle(SystemDictionary::Object_klass(), 1, CHECK_(empty));
2837   assert(appendix_box->obj_at(0) == NULL, "");
2838 
2839   // call java.lang.invoke.MethodHandleNatives::linkCallSite(caller, indy_index, bsm, name, mtype, info, &appendix)
2840   JavaCallArguments args;
2841   args.push_oop(Handle(THREAD, caller->java_mirror()));
2842   args.push_int(indy_index);
2843   args.push_oop(bsm);
2844   args.push_oop(method_name);
2845   args.push_oop(method_type);
2846   args.push_oop(info);
2847   args.push_oop(appendix_box);
2848   JavaValue result(T_OBJECT);
2849   JavaCalls::call_static(&result,
2850                          SystemDictionary::MethodHandleNatives_klass(),
2851                          vmSymbols::linkCallSite_name(),
2852                          vmSymbols::linkCallSite_signature(),
2853                          &args, CHECK_(empty));
2854   Handle mname(THREAD, (oop) result.get_jobject());
2855   return unpack_method_and_appendix(mname, caller, appendix_box, appendix_result, THREAD);
2856 }
2857 
2858 // Protection domain cache table handling
2859 
2860 ProtectionDomainCacheEntry* SystemDictionary::cache_get(Handle protection_domain) {
2861   return _pd_cache_table->get(protection_domain);
2862 }
2863 
2864 // ----------------------------------------------------------------------------
2865 
2866 void SystemDictionary::print_on(outputStream *st) {
2867   CDS_ONLY(SystemDictionaryShared::print_on(st));
2868   GCMutexLocker mu(SystemDictionary_lock);
2869 
2870   ClassLoaderDataGraph::print_dictionary(st);
2871 
2872   // Placeholders
2873   placeholders()->print_on(st);
2874   st->cr();
2875 
2876   // loader constraints - print under SD_lock
2877   constraints()->print_on(st);
2878   st->cr();
2879 
2880   _pd_cache_table->print_on(st);
2881   st->cr();
2882 }
2883 


2884 void SystemDictionary::verify() {
2885   guarantee(constraints() != NULL,
2886             "Verify of loader constraints failed");
2887   guarantee(placeholders()->number_of_entries() >= 0,
2888             "Verify of placeholders failed");
2889 
2890   GCMutexLocker mu(SystemDictionary_lock);
2891 
2892   // Verify dictionary
2893   ClassLoaderDataGraph::verify_dictionary();
2894 
2895   placeholders()->verify();
2896 
2897   // Verify constraint table
2898   guarantee(constraints() != NULL, "Verify of loader constraints failed");
2899   constraints()->verify(placeholders());
2900 
2901   _pd_cache_table->verify();
2902 }
2903 
2904 void SystemDictionary::dump(outputStream *st, bool verbose) {
2905   assert_locked_or_safepoint(SystemDictionary_lock);
2906   if (verbose) {
2907     print_on(st);
2908   } else {
2909     CDS_ONLY(SystemDictionaryShared::print_table_statistics(st));
2910     ClassLoaderDataGraph::print_dictionary_statistics(st);
2911     placeholders()->print_table_statistics(st, "Placeholder Table");
2912     constraints()->print_table_statistics(st, "LoaderConstraints Table");
2913     _pd_cache_table->print_table_statistics(st, "ProtectionDomainCache Table");
2914   }












2915 }
2916 
2917 // Utility for dumping dictionaries.
2918 SystemDictionaryDCmd::SystemDictionaryDCmd(outputStream* output, bool heap) :
2919                                  DCmdWithParser(output, heap),
2920   _verbose("-verbose", "Dump the content of each dictionary entry for all class loaders",
2921            "BOOLEAN", false, "false") {
2922   _dcmdparser.add_dcmd_option(&_verbose);
2923 }
2924 
2925 void SystemDictionaryDCmd::execute(DCmdSource source, TRAPS) {
2926   VM_DumpHashtable dumper(output(), VM_DumpHashtable::DumpSysDict,
2927                          _verbose.value());
2928   VMThread::execute(&dumper);
2929 }
2930 
2931 int SystemDictionaryDCmd::num_arguments() {
2932   ResourceMark rm;
2933   SystemDictionaryDCmd* dcmd = new SystemDictionaryDCmd(NULL, false);
2934   if (dcmd != NULL) {
< prev index next >