src/hotspot/share/classfile/systemDictionary.cpp
changeset 47614 0ecfd6c951a6
parent 47216 71c04702a3d5
child 47673 6126617b8508
equal deleted inserted replaced
47613:af241e3e5a13 47614:0ecfd6c951a6
   102                                                           =  { NULL /*, NULL...*/ };
   102                                                           =  { NULL /*, NULL...*/ };
   103 
   103 
   104 InstanceKlass*      SystemDictionary::_box_klasses[T_VOID+1]      =  { NULL /*, NULL...*/ };
   104 InstanceKlass*      SystemDictionary::_box_klasses[T_VOID+1]      =  { NULL /*, NULL...*/ };
   105 
   105 
   106 oop         SystemDictionary::_java_system_loader         =  NULL;
   106 oop         SystemDictionary::_java_system_loader         =  NULL;
       
   107 oop         SystemDictionary::_java_platform_loader       =  NULL;
   107 
   108 
   108 bool        SystemDictionary::_has_loadClassInternal      =  false;
   109 bool        SystemDictionary::_has_loadClassInternal      =  false;
   109 bool        SystemDictionary::_has_checkPackageAccess     =  false;
   110 bool        SystemDictionary::_has_checkPackageAccess     =  false;
   110 
   111 
   111 // lazily initialized klass variables
   112 // lazily initialized klass variables
   115 
   116 
   116 const int defaultProtectionDomainCacheSize = 1009;
   117 const int defaultProtectionDomainCacheSize = 1009;
   117 
   118 
   118 
   119 
   119 // ----------------------------------------------------------------------------
   120 // ----------------------------------------------------------------------------
   120 // Java-level SystemLoader
   121 // Java-level SystemLoader and PlatformLoader
   121 
   122 
   122 oop SystemDictionary::java_system_loader() {
   123 oop SystemDictionary::java_system_loader() {
   123   return _java_system_loader;
   124   return _java_system_loader;
   124 }
   125 }
   125 
   126 
   126 void SystemDictionary::compute_java_system_loader(TRAPS) {
   127 oop SystemDictionary::java_platform_loader() {
   127   Klass* system_klass = WK_KLASS(ClassLoader_klass);
   128   return _java_platform_loader;
       
   129 }
       
   130 
       
   131 void SystemDictionary::compute_java_loaders(TRAPS) {
   128   JavaValue result(T_OBJECT);
   132   JavaValue result(T_OBJECT);
       
   133   InstanceKlass* class_loader_klass = SystemDictionary::ClassLoader_klass();
   129   JavaCalls::call_static(&result,
   134   JavaCalls::call_static(&result,
   130                          WK_KLASS(ClassLoader_klass),
   135                          class_loader_klass,
   131                          vmSymbols::getSystemClassLoader_name(),
   136                          vmSymbols::getSystemClassLoader_name(),
   132                          vmSymbols::void_classloader_signature(),
   137                          vmSymbols::void_classloader_signature(),
   133                          CHECK);
   138                          CHECK);
   134 
   139 
   135   _java_system_loader = (oop)result.get_jobject();
   140   _java_system_loader = (oop)result.get_jobject();
   136 
   141 
       
   142   JavaCalls::call_static(&result,
       
   143                          class_loader_klass,
       
   144                          vmSymbols::getPlatformClassLoader_name(),
       
   145                          vmSymbols::void_classloader_signature(),
       
   146                          CHECK);
       
   147 
       
   148   _java_platform_loader = (oop)result.get_jobject();
       
   149 
   137   CDS_ONLY(SystemDictionaryShared::initialize(CHECK);)
   150   CDS_ONLY(SystemDictionaryShared::initialize(CHECK);)
   138 }
   151 }
   139 
       
   140 
   152 
   141 ClassLoaderData* SystemDictionary::register_loader(Handle class_loader, TRAPS) {
   153 ClassLoaderData* SystemDictionary::register_loader(Handle class_loader, TRAPS) {
   142   if (class_loader() == NULL) return ClassLoaderData::the_null_class_loader_data();
   154   if (class_loader() == NULL) return ClassLoaderData::the_null_class_loader_data();
   143   return ClassLoaderDataGraph::find_or_create(class_loader, THREAD);
   155   return ClassLoaderDataGraph::find_or_create(class_loader, THREAD);
   144 }
   156 }
   167 bool SystemDictionary::is_system_class_loader(oop class_loader) {
   179 bool SystemDictionary::is_system_class_loader(oop class_loader) {
   168   if (class_loader == NULL) {
   180   if (class_loader == NULL) {
   169     return false;
   181     return false;
   170   }
   182   }
   171   return (class_loader->klass() == SystemDictionary::jdk_internal_loader_ClassLoaders_AppClassLoader_klass() ||
   183   return (class_loader->klass() == SystemDictionary::jdk_internal_loader_ClassLoaders_AppClassLoader_klass() ||
   172           class_loader == _java_system_loader);
   184        class_loader == _java_system_loader);
   173 }
   185 }
   174 
   186 
   175 // Returns true if the passed class loader is the platform class loader.
   187 // Returns true if the passed class loader is the platform class loader.
   176 bool SystemDictionary::is_platform_class_loader(oop class_loader) {
   188 bool SystemDictionary::is_platform_class_loader(oop class_loader) {
   177   if (class_loader == NULL) {
   189   if (class_loader == NULL) {
  1938   return unloading_occurred;
  1950   return unloading_occurred;
  1939 }
  1951 }
  1940 
  1952 
  1941 void SystemDictionary::roots_oops_do(OopClosure* strong, OopClosure* weak) {
  1953 void SystemDictionary::roots_oops_do(OopClosure* strong, OopClosure* weak) {
  1942   strong->do_oop(&_java_system_loader);
  1954   strong->do_oop(&_java_system_loader);
       
  1955   strong->do_oop(&_java_platform_loader);
  1943   strong->do_oop(&_system_loader_lock_obj);
  1956   strong->do_oop(&_system_loader_lock_obj);
  1944   CDS_ONLY(SystemDictionaryShared::roots_oops_do(strong);)
  1957   CDS_ONLY(SystemDictionaryShared::roots_oops_do(strong);)
  1945 
  1958 
  1946   // Do strong roots marking if the closures are the same.
  1959   // Do strong roots marking if the closures are the same.
  1947   if (strong == weak || !ClassUnloading) {
  1960   if (strong == weak || !ClassUnloading) {
  1962   }
  1975   }
  1963 }
  1976 }
  1964 
  1977 
  1965 void SystemDictionary::oops_do(OopClosure* f) {
  1978 void SystemDictionary::oops_do(OopClosure* f) {
  1966   f->do_oop(&_java_system_loader);
  1979   f->do_oop(&_java_system_loader);
       
  1980   f->do_oop(&_java_platform_loader);
  1967   f->do_oop(&_system_loader_lock_obj);
  1981   f->do_oop(&_system_loader_lock_obj);
  1968   CDS_ONLY(SystemDictionaryShared::oops_do(f);)
  1982   CDS_ONLY(SystemDictionaryShared::oops_do(f);)
  1969 
  1983 
  1970   // Only the protection domain oops contain references into the heap. Iterate
  1984   // Only the protection domain oops contain references into the heap. Iterate
  1971   // over all of them.
  1985   // over all of them.