< prev index next >

src/hotspot/share/cds/cdsConfig.cpp

Print this page
@@ -80,17 +80,24 @@
    if (_default_archive_path == nullptr) {
      char jvm_path[JVM_MAXPATHLEN];
      os::jvm_path(jvm_path, sizeof(jvm_path));
      char *end = strrchr(jvm_path, *os::file_separator());
      if (end != nullptr) *end = '\0';
-     size_t jvm_path_len = strlen(jvm_path);
-     size_t file_sep_len = strlen(os::file_separator());
-     const size_t len = jvm_path_len + file_sep_len + 20;
-     _default_archive_path = NEW_C_HEAP_ARRAY(char, len, mtArguments);
-     jio_snprintf(_default_archive_path, len,
-                 LP64_ONLY(!UseCompressedOops ? "%s%sclasses_nocoops.jsa":) "%s%sclasses.jsa",
-                 jvm_path, os::file_separator());
+     stringStream tmp;
+     tmp.print("%s%sclasses", jvm_path, os::file_separator());
+ #ifdef _LP64
+     if (!UseCompressedOops) {
+       tmp.print_raw("_nocoops");
+     }
+     if (UseCompactObjectHeaders) {
+       // Note that generation of xxx_coh.jsa variants require
+       // --enable-cds-archive-coh at build time
+       tmp.print_raw("_coh");
+     }
+ #endif
+     tmp.print_raw(".jsa");
+     _default_archive_path = os::strdup(tmp.base());
    }
    return _default_archive_path;
  }
  
  int CDSConfig::num_archives(const char* archive_path) {
< prev index next >