< prev index next >

src/hotspot/share/classfile/systemDictionaryShared.cpp

Print this page

        

@@ -358,13 +358,12 @@
 }
 
 bool SystemDictionaryShared::is_sharing_possible(ClassLoaderData* loader_data) {
   oop class_loader = loader_data->class_loader();
   return (class_loader == NULL ||
-          (UseAppCDS && (SystemDictionary::is_system_class_loader(class_loader) ||
-                         SystemDictionary::is_platform_class_loader(class_loader)))
-          );
+          SystemDictionary::is_system_class_loader(class_loader) ||
+          SystemDictionary::is_platform_class_loader(class_loader));
 }
 
 // Currently AppCDS only archives classes from the run-time image, the
 // -Xbootclasspath/a path, the class path, and the module path.
 //

@@ -506,19 +505,20 @@
 //
 // An alternative is to modify the Java code of AppClassLoader.loadClass().
 //
 InstanceKlass* SystemDictionaryShared::find_or_load_shared_class(
                  Symbol* name, Handle class_loader, TRAPS) {
-  if (DumpSharedSpaces) {
+  InstanceKlass* k = NULL;
+  if (UseSharedSpaces) {
+    FileMapHeaderExt* header = (FileMapHeaderExt*)FileMapInfo::current_info()->header();
+    if (!header->has_platform_or_app_classes()) {
     return NULL;
   }
 
-  InstanceKlass* k = NULL;
   if (shared_dictionary() != NULL &&
-      UseAppCDS && (SystemDictionary::is_system_class_loader(class_loader()) ||
+        (SystemDictionary::is_system_class_loader(class_loader()) ||
                     SystemDictionary::is_platform_class_loader(class_loader()))) {
-
     // Fix for 4474172; see evaluation for more details
     class_loader = Handle(
       THREAD, java_lang_ClassLoader::non_reflection_class_loader(class_loader()));
     ClassLoaderData *loader_data = register_loader(class_loader);
     Dictionary* dictionary = loader_data->dictionary();

@@ -550,17 +550,18 @@
     k = load_shared_class_for_builtin_loader(name, class_loader, THREAD);
     if (k != NULL) {
       define_instance_class(k, CHECK_NULL);
     }
   }
-
+  }
   return k;
 }
 
 InstanceKlass* SystemDictionaryShared::load_shared_class_for_builtin_loader(
                  Symbol* class_name, Handle class_loader, TRAPS) {
-  assert(UseAppCDS && shared_dictionary() != NULL, "already checked");
+  assert(UseSharedSpaces, "must be");
+  assert(shared_dictionary() != NULL, "already checked");
   Klass* k = shared_dictionary()->find_class_for_builtin_loader(class_name);
 
   if (k != NULL) {
     InstanceKlass* ik = InstanceKlass::cast(k);
     if ((ik->is_shared_app_class() &&

@@ -607,26 +608,25 @@
   allocate_shared_protection_domain_array(size, CHECK);
   allocate_shared_jar_url_array(size, CHECK);
   allocate_shared_jar_manifest_array(size, CHECK);
 }
 
-
+// This function is called for loading only UNREGISTERED classes
 InstanceKlass* SystemDictionaryShared::lookup_from_stream(const Symbol* class_name,
                                                           Handle class_loader,
                                                           Handle protection_domain,
                                                           const ClassFileStream* cfs,
                                                           TRAPS) {
-  if (!UseAppCDS || shared_dictionary() == NULL) {
+  if (shared_dictionary() == NULL) {
     return NULL;
   }
   if (class_name == NULL) {  // don't do this for anonymous classes
     return NULL;
   }
   if (class_loader.is_null() ||
       SystemDictionary::is_system_class_loader(class_loader()) ||
       SystemDictionary::is_platform_class_loader(class_loader())) {
-    // This function is called for loading only UNREGISTERED classes.
     // Do nothing for the BUILTIN loaders.
     return NULL;
   }
 
   ClassLoaderData* loader_data = ClassLoaderData::class_loader_data(class_loader());

@@ -684,15 +684,16 @@
   }
 
   return shared_klass;
 }
 
-bool SystemDictionaryShared::add_non_builtin_klass(Symbol* name, ClassLoaderData* loader_data,
+bool SystemDictionaryShared::add_non_builtin_klass(Symbol* name,
+                                                   ClassLoaderData* loader_data,
                                                    InstanceKlass* k,
                                                    TRAPS) {
   assert(DumpSharedSpaces, "only when dumping");
-  assert(UseAppCDS && boot_loader_dictionary() != NULL, "must be");
+  assert(boot_loader_dictionary() != NULL, "must be");
 
   if (boot_loader_dictionary()->add_non_builtin_klass(name, loader_data, k)) {
     MutexLocker mu_r(Compile_lock, THREAD); // not really necessary, but add_to_hierarchy asserts this.
     add_to_hierarchy(k, CHECK_0);
     return true;
< prev index next >