8185160: -XX:DumpLoadedClassList omits graal classes
authoriklam
Sat, 21 Oct 2017 15:15:46 -0700
changeset 47673 6126617b8508
parent 47672 50aa24ce898c
child 47674 1587ffa1496a
8185160: -XX:DumpLoadedClassList omits graal classes Reviewed-by: jiangli, dholmes, lfoltan
src/hotspot/share/classfile/classFileParser.cpp
src/hotspot/share/classfile/classLoader.cpp
src/hotspot/share/classfile/classLoader.hpp
src/hotspot/share/classfile/systemDictionary.cpp
src/hotspot/share/memory/filemap.hpp
src/hotspot/share/oops/instanceKlass.cpp
--- a/src/hotspot/share/classfile/classFileParser.cpp	Sun Oct 22 00:10:29 2017 +0200
+++ b/src/hotspot/share/classfile/classFileParser.cpp	Sat Oct 21 15:15:46 2017 -0700
@@ -5924,20 +5924,31 @@
 
 #if INCLUDE_CDS
     if (DumpLoadedClassList != NULL && stream->source() != NULL && classlist_file->is_open()) {
-      // Only dump the classes that can be stored into CDS archive.
-      // Anonymous classes such as generated LambdaForm classes are also not included.
-      if (SystemDictionaryShared::is_sharing_possible(_loader_data) &&
+      if (!ClassLoader::has_jrt_entry()) {
+        warning("DumpLoadedClassList and CDS are not supported in exploded build");
+        DumpLoadedClassList = NULL;
+      } else if (SystemDictionaryShared::is_sharing_possible(_loader_data) &&
           _host_klass == NULL) {
+        // Only dump the classes that can be stored into CDS archive.
+        // Anonymous classes such as generated LambdaForm classes are also not included.
         oop class_loader = _loader_data->class_loader();
         ResourceMark rm(THREAD);
-        // For the boot and platform class loaders, check if the class is not found in the
-        // java runtime image. Additional check for the boot class loader is if the class
-        // is not found in the boot loader's appended entries. This indicates that the class
-        // is not useable during run time, such as the ones found in the --patch-module entries,
-        // so it should not be included in the classlist file.
-        if (((class_loader == NULL && !ClassLoader::contains_append_entry(stream->source())) ||
-             SystemDictionary::is_platform_class_loader(class_loader)) &&
-            !ClassLoader::is_jrt(stream->source())) {
+        bool skip = false;
+        if (class_loader == NULL || SystemDictionary::is_platform_class_loader(class_loader)) {
+          // For the boot and platform class loaders, skip classes that are not found in the
+          // java runtime image, such as those found in the --patch-module entries.
+          // These classes can't be loaded from the archive during runtime.
+          if (!ClassLoader::is_modules_image(stream->source()) && strncmp(stream->source(), "jrt:", 4) != 0) {
+            skip = true;
+          }
+
+          if (class_loader == NULL && ClassLoader::contains_append_entry(stream->source())) {
+            // .. but don't skip the boot classes that are loaded from -Xbootclasspath/a
+            // as they can be loaded from the archive during runtime.
+            skip = false;
+          }
+        }
+        if (skip) {
           tty->print_cr("skip writing class %s from source %s to classlist file",
             _class_name->as_C_string(), stream->source());
         } else {
--- a/src/hotspot/share/classfile/classLoader.cpp	Sun Oct 22 00:10:29 2017 +0200
+++ b/src/hotspot/share/classfile/classLoader.cpp	Sat Oct 21 15:15:46 2017 -0700
@@ -578,8 +578,8 @@
 }
 #endif
 
-bool ClassPathImageEntry::is_jrt() {
-  return ClassLoader::is_jrt(name());
+bool ClassPathImageEntry::is_modules_image() const {
+  return ClassLoader::is_modules_image(name());
 }
 
 #if INCLUDE_CDS
@@ -795,7 +795,7 @@
         // Check for a jimage
         if (Arguments::has_jimage()) {
           assert(_jrt_entry == NULL, "should not setup bootstrap class search path twice");
-          assert(new_entry != NULL && new_entry->is_jrt(), "No java runtime image present");
+          assert(new_entry != NULL && new_entry->is_modules_image(), "No java runtime image present");
           _jrt_entry = new_entry;
           ++_num_entries;
 #if INCLUDE_CDS
@@ -1846,7 +1846,7 @@
   // Iterate over all bootstrap class path appended entries
   ClassPathEntry* e = _first_append_entry;
   while (e != NULL) {
-    assert(!e->is_jrt(), "A modular java runtime image is present on the list of appended entries");
+    assert(!e->is_modules_image(), "A modular java runtime image is present on the list of appended entries");
     e->compile_the_world(system_class_loader, CATCH);
     e = e->next();
   }
--- a/src/hotspot/share/classfile/classLoader.hpp	Sun Oct 22 00:10:29 2017 +0200
+++ b/src/hotspot/share/classfile/classLoader.hpp	Sat Oct 21 15:15:46 2017 -0700
@@ -54,7 +54,7 @@
     // may have unlocked readers, so ensure visibility.
     OrderAccess::release_store(&_next, next);
   }
-  virtual bool is_jrt() = 0;
+  virtual bool is_modules_image() const = 0;
   virtual bool is_jar_file() const = 0;
   virtual const char* name() const = 0;
   virtual JImageFile* jimage() const = 0;
@@ -71,7 +71,7 @@
  private:
   const char* _dir;           // Name of directory
  public:
-  bool is_jrt()            { return false; }
+  bool is_modules_image() const { return false; }
   bool is_jar_file() const { return false;  }
   const char* name() const { return _dir; }
   JImageFile* jimage() const { return NULL; }
@@ -109,7 +109,7 @@
   u1 _multi_versioned;       // indicates if the jar file has multi-versioned entries.
                              // It can have value of "_unknown", "_yes", or "_no"
  public:
-  bool is_jrt()            { return false; }
+  bool is_modules_image() const { return false; }
   bool is_jar_file() const { return true;  }
   const char* name() const { return _zip_name; }
   JImageFile* jimage() const { return NULL; }
@@ -131,7 +131,7 @@
   JImageFile* _jimage;
   const char* _name;
 public:
-  bool is_jrt();
+  bool is_modules_image() const;
   bool is_jar_file() const { return false; }
   bool is_open() const { return _jimage != NULL; }
   const char* name() const { return _name == NULL ? "" : _name; }
@@ -467,7 +467,7 @@
   // distinguish from a class_name with no package name, as both cases have a NULL return value
   static const char* package_from_name(const char* const class_name, bool* bad_class_name = NULL);
 
-  static bool is_jrt(const char* name) { return string_ends_with(name, MODULES_IMAGE_NAME); }
+  static bool is_modules_image(const char* name) { return string_ends_with(name, MODULES_IMAGE_NAME); }
 
   // Debugging
   static void verify()              PRODUCT_RETURN;
--- a/src/hotspot/share/classfile/systemDictionary.cpp	Sun Oct 22 00:10:29 2017 +0200
+++ b/src/hotspot/share/classfile/systemDictionary.cpp	Sat Oct 21 15:15:46 2017 -0700
@@ -1250,7 +1250,7 @@
   SharedClassPathEntry* ent =
             (SharedClassPathEntry*)FileMapInfo::shared_classpath(path_index);
   if (!Universe::is_module_initialized()) {
-    assert(ent != NULL && ent->is_jrt(),
+    assert(ent != NULL && ent->is_modules_image(),
            "Loading non-bootstrap classes before the module system is initialized");
     assert(class_loader.is_null(), "sanity");
     return true;
@@ -1286,7 +1286,7 @@
     if (mod_entry != NULL) {
       // PackageEntry/ModuleEntry is found in the classloader. Check if the
       // ModuleEntry's location agrees with the archived class' origination.
-      if (ent->is_jrt() && mod_entry->location()->starts_with("jrt:")) {
+      if (ent->is_modules_image() && mod_entry->location()->starts_with("jrt:")) {
         return true; // Module class from the "module" jimage
       }
     }
@@ -1297,7 +1297,7 @@
     // 1. the class is from the unamed package
     // 2. or, the class is not from a module defined in the NULL classloader
     // 3. or, the class is from an unamed module
-    if (!ent->is_jrt() && ik->is_shared_boot_class()) {
+    if (!ent->is_modules_image() && ik->is_shared_boot_class()) {
       // the class is from the -Xbootclasspath/a
       if (pkg_string == NULL ||
           pkg_entry == NULL ||
--- a/src/hotspot/share/memory/filemap.hpp	Sun Oct 22 00:10:29 2017 +0200
+++ b/src/hotspot/share/memory/filemap.hpp	Sat Oct 21 15:15:46 2017 -0700
@@ -60,7 +60,7 @@
     return _timestamp != 0;
   }
   bool is_dir() { return _is_dir; }
-  bool is_jrt() { return ClassLoader::is_jrt(name()); }
+  bool is_modules_image() { return ClassLoader::is_modules_image(name()); }
   time_t timestamp() const { return _timestamp; }
   long   filesize()  const { return _filesize; }
   const char* name() const { return _name->data(); }
--- a/src/hotspot/share/oops/instanceKlass.cpp	Sun Oct 22 00:10:29 2017 +0200
+++ b/src/hotspot/share/oops/instanceKlass.cpp	Sat Oct 21 15:15:46 2017 -0700
@@ -3113,7 +3113,7 @@
   if (cfs != NULL) {
     if (cfs->source() != NULL) {
       if (module_name != NULL) {
-        if (ClassLoader::is_jrt(cfs->source())) {
+        if (ClassLoader::is_modules_image(cfs->source())) {
           info_stream.print(" source: jrt:/%s", module_name);
         } else {
           info_stream.print(" source: %s", cfs->source());