src/hotspot/share/classfile/systemDictionary.cpp
changeset 52319 625f6c742392
parent 52195 f08c1d7a5c53
child 52335 6507eeb6f047
equal deleted inserted replaced
52318:124af9276e44 52319:625f6c742392
    65 #include "oops/objArrayKlass.hpp"
    65 #include "oops/objArrayKlass.hpp"
    66 #include "oops/objArrayOop.inline.hpp"
    66 #include "oops/objArrayOop.inline.hpp"
    67 #include "oops/oop.inline.hpp"
    67 #include "oops/oop.inline.hpp"
    68 #include "oops/symbol.hpp"
    68 #include "oops/symbol.hpp"
    69 #include "oops/typeArrayKlass.hpp"
    69 #include "oops/typeArrayKlass.hpp"
    70 #include "prims/jvmtiEnvBase.hpp"
    70 #include "prims/jvmtiExport.hpp"
    71 #include "prims/resolvedMethodTable.hpp"
    71 #include "prims/resolvedMethodTable.hpp"
    72 #include "prims/methodHandles.hpp"
    72 #include "prims/methodHandles.hpp"
    73 #include "runtime/arguments.hpp"
    73 #include "runtime/arguments.hpp"
    74 #include "runtime/arguments_ext.hpp"
    74 #include "runtime/arguments_ext.hpp"
    75 #include "runtime/biasedLocking.hpp"
    75 #include "runtime/biasedLocking.hpp"
  1487     // of the boot loader's module path
  1487     // of the boot loader's module path
  1488     assert(Universe::is_module_initialized() ||
  1488     assert(Universe::is_module_initialized() ||
  1489            !search_only_bootloader_append,
  1489            !search_only_bootloader_append,
  1490            "Attempt to load a class outside of boot loader's module path");
  1490            "Attempt to load a class outside of boot loader's module path");
  1491 
  1491 
  1492     // Search the shared system dictionary for classes preloaded into the
  1492     // Search for classes in the CDS archive.
  1493     // shared spaces.
       
  1494     InstanceKlass* k = NULL;
  1493     InstanceKlass* k = NULL;
  1495     {
  1494     {
  1496 #if INCLUDE_CDS
  1495 #if INCLUDE_CDS
  1497       PerfTraceTime vmtimer(ClassLoader::perf_shared_classload_time());
  1496       PerfTraceTime vmtimer(ClassLoader::perf_shared_classload_time());
  1498       k = load_shared_class(class_name, class_loader, THREAD);
  1497       k = load_shared_class(class_name, class_loader, THREAD);
  1956   _pd_cache_table = new ProtectionDomainCacheTable(defaultProtectionDomainCacheSize);
  1955   _pd_cache_table = new ProtectionDomainCacheTable(defaultProtectionDomainCacheSize);
  1957 
  1956 
  1958   // Allocate private object used as system class loader lock
  1957   // Allocate private object used as system class loader lock
  1959   _system_loader_lock_obj = oopFactory::new_intArray(0, CHECK);
  1958   _system_loader_lock_obj = oopFactory::new_intArray(0, CHECK);
  1960   // Initialize basic classes
  1959   // Initialize basic classes
  1961   resolve_preloaded_classes(CHECK);
  1960   resolve_well_known_classes(CHECK);
  1962 }
  1961 }
  1963 
  1962 
  1964 // Compact table of directions on the initialization of klasses:
  1963 // Compact table of directions on the initialization of klasses:
  1965 static const short wk_init_info[] = {
  1964 static const short wk_init_info[] = {
  1966   #define WK_KLASS_INIT_INFO(name, symbol) \
  1965   #define WK_KLASS_INIT_INFO(name, symbol) \
  1968 
  1967 
  1969   WK_KLASSES_DO(WK_KLASS_INIT_INFO)
  1968   WK_KLASSES_DO(WK_KLASS_INIT_INFO)
  1970   #undef WK_KLASS_INIT_INFO
  1969   #undef WK_KLASS_INIT_INFO
  1971   0
  1970   0
  1972 };
  1971 };
       
  1972 
       
  1973 #ifdef ASSERT
       
  1974 bool SystemDictionary::is_well_known_klass(Symbol* class_name) {
       
  1975   int sid;
       
  1976   for (int i = 0; (sid = wk_init_info[i]) != 0; i++) {
       
  1977     Symbol* symbol = vmSymbols::symbol_at((vmSymbols::SID)sid);
       
  1978     if (class_name == symbol) {
       
  1979       return true;
       
  1980     }
       
  1981   }
       
  1982   return false;
       
  1983 }
       
  1984 #endif
  1973 
  1985 
  1974 bool SystemDictionary::resolve_wk_klass(WKID id, TRAPS) {
  1986 bool SystemDictionary::resolve_wk_klass(WKID id, TRAPS) {
  1975   assert(id >= (int)FIRST_WKID && id < (int)WKID_LIMIT, "oob");
  1987   assert(id >= (int)FIRST_WKID && id < (int)WKID_LIMIT, "oob");
  1976   int sid = wk_init_info[id - FIRST_WKID];
  1988   int sid = wk_init_info[id - FIRST_WKID];
  1977   Symbol* symbol = vmSymbols::symbol_at((vmSymbols::SID)sid);
  1989   Symbol* symbol = vmSymbols::symbol_at((vmSymbols::SID)sid);
  2000 
  2012 
  2001   // move the starting value forward to the limit:
  2013   // move the starting value forward to the limit:
  2002   start_id = limit_id;
  2014   start_id = limit_id;
  2003 }
  2015 }
  2004 
  2016 
  2005 void SystemDictionary::resolve_preloaded_classes(TRAPS) {
  2017 void SystemDictionary::resolve_well_known_classes(TRAPS) {
  2006   assert(WK_KLASS(Object_klass) == NULL, "preloaded classes should only be initialized once");
  2018   assert(WK_KLASS(Object_klass) == NULL, "well-known classes should only be initialized once");
  2007 
  2019 
  2008   // Create the ModuleEntry for java.base.  This call needs to be done here,
  2020   // Create the ModuleEntry for java.base.  This call needs to be done here,
  2009   // after vmSymbols::initialize() is called but before any classes are pre-loaded.
  2021   // after vmSymbols::initialize() is called but before any classes are pre-loaded.
  2010   ClassLoader::classLoader_init2(CHECK);
  2022   ClassLoader::classLoader_init2(CHECK);
  2011 
  2023 
  2069   // JSR 292 classes
  2081   // JSR 292 classes
  2070   WKID jsr292_group_start = WK_KLASS_ENUM_NAME(MethodHandle_klass);
  2082   WKID jsr292_group_start = WK_KLASS_ENUM_NAME(MethodHandle_klass);
  2071   WKID jsr292_group_end   = WK_KLASS_ENUM_NAME(VolatileCallSite_klass);
  2083   WKID jsr292_group_end   = WK_KLASS_ENUM_NAME(VolatileCallSite_klass);
  2072   resolve_wk_klasses_until(jsr292_group_start, scan, CHECK);
  2084   resolve_wk_klasses_until(jsr292_group_start, scan, CHECK);
  2073   resolve_wk_klasses_through(jsr292_group_end, scan, CHECK);
  2085   resolve_wk_klasses_through(jsr292_group_end, scan, CHECK);
  2074   resolve_wk_klasses_until(NOT_JVMCI(WKID_LIMIT) JVMCI_ONLY(FIRST_JVMCI_WKID), scan, CHECK);
  2086   WKID last = NOT_JVMCI(WKID_LIMIT) JVMCI_ONLY(FIRST_JVMCI_WKID);
       
  2087   resolve_wk_klasses_until(last, scan, CHECK);
  2075 
  2088 
  2076   _box_klasses[T_BOOLEAN] = WK_KLASS(Boolean_klass);
  2089   _box_klasses[T_BOOLEAN] = WK_KLASS(Boolean_klass);
  2077   _box_klasses[T_CHAR]    = WK_KLASS(Character_klass);
  2090   _box_klasses[T_CHAR]    = WK_KLASS(Character_klass);
  2078   _box_klasses[T_FLOAT]   = WK_KLASS(Float_klass);
  2091   _box_klasses[T_FLOAT]   = WK_KLASS(Float_klass);
  2079   _box_klasses[T_DOUBLE]  = WK_KLASS(Double_klass);
  2092   _box_klasses[T_DOUBLE]  = WK_KLASS(Double_klass);
  2086 
  2099 
  2087   { // Compute whether we should use checkPackageAccess or NOT
  2100   { // Compute whether we should use checkPackageAccess or NOT
  2088     Method* method = InstanceKlass::cast(ClassLoader_klass())->find_method(vmSymbols::checkPackageAccess_name(), vmSymbols::class_protectiondomain_signature());
  2101     Method* method = InstanceKlass::cast(ClassLoader_klass())->find_method(vmSymbols::checkPackageAccess_name(), vmSymbols::class_protectiondomain_signature());
  2089     _has_checkPackageAccess = (method != NULL);
  2102     _has_checkPackageAccess = (method != NULL);
  2090   }
  2103   }
       
  2104 
       
  2105 #ifdef ASSERT
       
  2106   if (UseSharedSpaces) {
       
  2107     assert(JvmtiExport::is_early_phase(),
       
  2108            "All well known classes must be resolved in JVMTI early phase");
       
  2109     for (int i = FIRST_WKID; i < last; i++) {
       
  2110       InstanceKlass* k = _well_known_klasses[i];
       
  2111       assert(k->is_shared(), "must not be replaced by JVMTI class file load hook");
       
  2112     }
       
  2113   }
       
  2114 #endif
  2091 }
  2115 }
  2092 
  2116 
  2093 // Tells if a given klass is a box (wrapper class, such as java.lang.Integer).
  2117 // Tells if a given klass is a box (wrapper class, such as java.lang.Integer).
  2094 // If so, returns the basic type it holds.  If not, returns T_OBJECT.
  2118 // If so, returns the basic type it holds.  If not, returns T_OBJECT.
  2095 BasicType SystemDictionary::box_klass_type(Klass* k) {
  2119 BasicType SystemDictionary::box_klass_type(Klass* k) {