1 /*
  2  * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
  3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4  *
  5  * This code is free software; you can redistribute it and/or modify it
  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.
  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #ifndef SHARE_CDS_FILEMAP_HPP
 26 #define SHARE_CDS_FILEMAP_HPP
 27 
 28 #include "cds/metaspaceShared.hpp"
 29 #include "include/cds.h"
 30 #include "logging/logLevel.hpp"
 31 #include "memory/allocation.hpp"
 32 #include "oops/array.hpp"
 33 #include "oops/compressedOops.hpp"
 34 #include "utilities/align.hpp"
 35 
 36 // To understand the layout of the CDS archive file:
 37 //
 38 // java -Xlog:cds+map=info:file=cds.map:none:filesize=0
 39 // java -Xlog:cds+map=debug:file=cds.map:none:filesize=0
 40 // java -Xlog:cds+map=trace:file=cds.map:none:filesize=0
 41 
 42 static const int JVM_IDENT_MAX = 256;
 43 
 44 class ArchiveHeapInfo;
 45 class BitMapView;
 46 class CHeapBitMap;
 47 class ClassFileStream;
 48 class ClassLoaderData;
 49 class ClassPathEntry;
 50 class outputStream;
 51 
 52 class SharedClassPathEntry : public MetaspaceObj {
 53   enum {
 54     modules_image_entry,
 55     jar_entry,
 56     signed_jar_entry,
 57     dir_entry,
 58     non_existent_entry,
 59     unknown_entry
 60   };
 61 
 62   void set_name(const char* name, TRAPS);
 63 
 64   u1     _type;
 65   bool   _is_module_path;
 66   bool   _from_class_path_attr;
 67   time_t _timestamp;          // jar timestamp,  0 if is directory, modules image or other
 68   int64_t      _filesize;     // jar/jimage file size, -1 if is directory, -2 if other
 69   Array<char>* _name;
 70   Array<u1>*   _manifest;
 71 
 72 public:
 73   SharedClassPathEntry() : _type(0), _is_module_path(false),
 74                            _from_class_path_attr(false), _timestamp(0),
 75                            _filesize(0), _name(nullptr), _manifest(nullptr) {}
 76   static int size() {
 77     static_assert(is_aligned(sizeof(SharedClassPathEntry), wordSize), "must be");
 78     return (int)(sizeof(SharedClassPathEntry) / wordSize);
 79   }
 80   void init(bool is_modules_image, bool is_module_path, ClassPathEntry* cpe, TRAPS);
 81   void init_as_non_existent(const char* path, TRAPS);
 82   void metaspace_pointers_do(MetaspaceClosure* it);
 83   MetaspaceObj::Type type() const { return SharedClassPathEntryType; }
 84   bool validate(bool is_class_path = true) const;
 85 
 86   // The _timestamp only gets set for jar files.
 87   bool has_timestamp() const {
 88     return _timestamp != 0;
 89   }
 90   bool is_dir()           const { return _type == dir_entry; }
 91   bool is_modules_image() const { return _type == modules_image_entry; }
 92   bool is_jar()           const { return _type == jar_entry; }
 93   bool is_signed()        const { return _type == signed_jar_entry; }
 94   void set_is_signed() {
 95     _type = signed_jar_entry;
 96   }
 97   bool from_class_path_attr() { return _from_class_path_attr; }
 98   time_t timestamp() const { return _timestamp; }
 99   const char* name() const;
100   const char* manifest() const {
101     return (_manifest == nullptr) ? nullptr : (const char*)_manifest->data();
102   }
103   int manifest_size() const {
104     return (_manifest == nullptr) ? 0 : _manifest->length();
105   }
106   void set_manifest(Array<u1>* manifest) {
107     _manifest = manifest;
108   }
109   bool check_non_existent() const;
110   void copy_from(SharedClassPathEntry* ent, ClassLoaderData* loader_data, TRAPS);
111   bool in_named_module() {
112     return is_modules_image() || // modules image doesn't contain unnamed modules
113            _is_module_path;      // module path doesn't contain unnamed modules
114   }
115 };
116 
117 class SharedPathTable {
118   Array<SharedClassPathEntry*>* _entries;
119 public:
120   SharedPathTable() : _entries(nullptr) {}
121   SharedPathTable(Array<SharedClassPathEntry*>* entries) : _entries(entries) {}
122 
123   void dumptime_init(ClassLoaderData* loader_data, TRAPS);
124   void metaspace_pointers_do(MetaspaceClosure* it);
125 
126   int size() {
127     return _entries == nullptr ? 0 : _entries->length();
128   }
129   SharedClassPathEntry* path_at(int index) {
130     return _entries->at(index);
131   }
132   Array<SharedClassPathEntry*>* table() {return _entries;}
133   void set_table(Array<SharedClassPathEntry*>* table) {_entries = table;}
134 };
135 
136 
137 class FileMapRegion: private CDSFileMapRegion {
138   BitMapView bitmap_view(bool is_oopmap);
139 public:
140   void assert_is_heap_region() const {
141     assert(_is_heap_region, "must be heap region");
142   }
143   void assert_is_not_heap_region() const {
144     assert(!_is_heap_region, "must not be heap region");
145   }
146 
147   static FileMapRegion* cast(CDSFileMapRegion* p) {
148     return (FileMapRegion*)p;
149   }
150 
151   // Accessors
152   int crc()                         const { return _crc; }
153   size_t file_offset()              const { return _file_offset; }
154   size_t mapping_offset()           const { return _mapping_offset; }
155   size_t mapping_end_offset()       const { return _mapping_offset + used_aligned(); }
156   size_t used()                     const { return _used; }
157   size_t used_aligned()             const; // aligned up to MetaspaceShared::core_region_alignment()
158   char*  mapped_base()              const { return _mapped_base; }
159   char*  mapped_end()               const { return mapped_base()        + used_aligned(); }
160   bool   read_only()                const { return _read_only != 0; }
161   bool   allow_exec()               const { return _allow_exec != 0; }
162   bool   mapped_from_file()         const { return _mapped_from_file != 0; }
163   size_t oopmap_offset()            const { assert_is_heap_region();     return _oopmap_offset; }
164   size_t oopmap_size_in_bits()      const { assert_is_heap_region();     return _oopmap_size_in_bits; }
165 
166   void set_file_offset(size_t s)     { _file_offset = s; }
167   void set_read_only(bool v)         { _read_only = v; }
168   void set_mapped_base(char* p)      { _mapped_base = p; }
169   void set_mapped_from_file(bool v)  { _mapped_from_file = v; }
170   void init(int region_index, size_t mapping_offset, size_t size, bool read_only,
171             bool allow_exec, int crc);
172   void init_oopmap(size_t offset, size_t size_in_bits);
173   void init_ptrmap(size_t offset, size_t size_in_bits);
174   BitMapView oopmap_view();
175   BitMapView ptrmap_view();
176   bool has_ptrmap()                  { return _ptrmap_size_in_bits != 0; }
177 
178   bool check_region_crc() const;
179   void print(outputStream* st, int region_index);
180 };
181 
182 class FileMapHeader: private CDSFileMapHeaderBase {
183   friend class CDSConstants;
184   friend class VMStructs;
185 
186 private:
187   // The following fields record the states of the VM during dump time.
188   // They are compared with the runtime states to see if the archive
189   // can be used.
190   size_t _core_region_alignment;                  // how shared archive should be aligned
191   int    _obj_alignment;                          // value of ObjectAlignmentInBytes
192   address _narrow_oop_base;                       // compressed oop encoding base
193   int    _narrow_oop_shift;                       // compressed oop encoding shift
194   bool   _compact_strings;                        // value of CompactStrings
195   uintx  _max_heap_size;                          // java max heap size during dumping
196   CompressedOops::Mode _narrow_oop_mode;          // compressed oop encoding mode
197   int     _narrow_klass_shift;                    // save narrow klass base and shift
198   bool    _compressed_oops;                       // save the flag UseCompressedOops
199   bool    _compressed_class_ptrs;                 // save the flag UseCompressedClassPointers
200   size_t  _cloned_vtables_offset;                 // The address of the first cloned vtable
201   size_t  _serialized_data_offset;                // Data accessed using {ReadClosure,WriteClosure}::serialize()
202   address _heap_begin;                            // heap begin at dump time.
203   address _heap_end;                              // heap end at dump time.
204   bool _has_non_jar_in_classpath;                 // non-jar file entry exists in classpath
205   unsigned int _common_app_classpath_prefix_size; // size of the common prefix of app class paths
206                                                   //    0 if no common prefix exists
207 
208   // The following fields are all sanity checks for whether this archive
209   // will function correctly with this JVM and the bootclasspath it's
210   // invoked with.
211   char  _jvm_ident[JVM_IDENT_MAX];  // identifier string of the jvm that created this dump
212 
213   // The following is a table of all the boot/app/module path entries that were used
214   // during dumping. At run time, we validate these entries according to their
215   // SharedClassPathEntry::_type. See:
216   //      check_nonempty_dir_in_shared_path_table()
217   //      validate_shared_path_table()
218   //      validate_non_existent_class_paths()
219   size_t _shared_path_table_offset;
220 
221   jshort _app_class_paths_start_index;  // Index of first app classpath entry
222   jshort _app_module_paths_start_index; // Index of first module path entry
223   jshort _num_module_paths;             // number of module path entries
224   jshort _max_used_path_index;          // max path index referenced during CDS dump
225   bool   _verify_local;                 // BytecodeVerificationLocal setting
226   bool   _verify_remote;                // BytecodeVerificationRemote setting
227   bool   _has_platform_or_app_classes;  // Archive contains app classes
228   char*  _requested_base_address;       // Archive relocation is not necessary if we map with this base address.
229   char*  _mapped_base_address;          // Actual base address where archive is mapped.
230 
231   bool   _allow_archiving_with_java_agent; // setting of the AllowArchivingWithJavaAgent option
232   bool   _use_optimized_module_handling;// No module-relation VM options were specified, so we can skip
233                                         // some expensive operations.
234   bool   _use_full_module_graph;        // Can we use the full archived module graph?
235   size_t _ptrmap_size_in_bits;          // Size of pointer relocation bitmap
236   char* from_mapped_offset(size_t offset) const {
237     return mapped_base_address() + offset;
238   }
239   void set_as_offset(char* p, size_t *offset);
240 public:
241   // Accessors -- fields declared in GenericCDSFileMapHeader
242   unsigned int magic()                            const { return _generic_header._magic;                    }
243   int crc()                                       const { return _generic_header._crc;                      }
244   int version()                                   const { return _generic_header._version;                  }
245   unsigned int header_size()                      const { return _generic_header._header_size;              }
246   unsigned int base_archive_name_offset()         const { return _generic_header._base_archive_name_offset; }
247   unsigned int base_archive_name_size()           const { return _generic_header._base_archive_name_size;   }
248   unsigned int common_app_classpath_prefix_size() const { return _common_app_classpath_prefix_size;         }
249 
250   void set_magic(unsigned int m)                            { _generic_header._magic = m;                    }
251   void set_crc(int crc_value)                               { _generic_header._crc = crc_value;              }
252   void set_version(int v)                                   { _generic_header._version = v;                  }
253   void set_header_size(unsigned int s)                      { _generic_header._header_size = s;              }
254   void set_base_archive_name_offset(unsigned int s)         { _generic_header._base_archive_name_offset = s; }
255   void set_base_archive_name_size(unsigned int s)           { _generic_header._base_archive_name_size = s;   }
256   void set_common_app_classpath_prefix_size(unsigned int s) { _common_app_classpath_prefix_size = s;         }
257 
258   size_t core_region_alignment()           const { return _core_region_alignment; }
259   int obj_alignment()                      const { return _obj_alignment; }
260   address narrow_oop_base()                const { return _narrow_oop_base; }
261   int narrow_oop_shift()                   const { return _narrow_oop_shift; }
262   bool compact_strings()                   const { return _compact_strings; }
263   uintx max_heap_size()                    const { return _max_heap_size; }
264   CompressedOops::Mode narrow_oop_mode()   const { return _narrow_oop_mode; }
265   int narrow_klass_shift()                 const { return _narrow_klass_shift; }
266   address narrow_klass_base()              const { return (address)mapped_base_address(); }
267   char* cloned_vtables()                   const { return from_mapped_offset(_cloned_vtables_offset); }
268   char* serialized_data()                  const { return from_mapped_offset(_serialized_data_offset); }
269   address heap_begin()                     const { return _heap_begin; }
270   address heap_end()                       const { return _heap_end; }
271   const char* jvm_ident()                  const { return _jvm_ident; }
272   char* requested_base_address()           const { return _requested_base_address; }
273   char* mapped_base_address()              const { return _mapped_base_address; }
274   bool has_platform_or_app_classes()       const { return _has_platform_or_app_classes; }
275   bool has_non_jar_in_classpath()          const { return _has_non_jar_in_classpath; }
276   size_t ptrmap_size_in_bits()             const { return _ptrmap_size_in_bits; }
277   bool compressed_oops()                   const { return _compressed_oops; }
278   bool compressed_class_pointers()         const { return _compressed_class_ptrs; }
279   // FIXME: These should really return int
280   jshort max_used_path_index()             const { return _max_used_path_index; }
281   jshort app_module_paths_start_index()    const { return _app_module_paths_start_index; }
282   jshort app_class_paths_start_index()     const { return _app_class_paths_start_index; }
283   jshort num_module_paths()                const { return _num_module_paths; }
284 
285   void set_has_platform_or_app_classes(bool v)   { _has_platform_or_app_classes = v; }
286   void set_cloned_vtables(char* p)               { set_as_offset(p, &_cloned_vtables_offset); }
287   void set_serialized_data(char* p)              { set_as_offset(p, &_serialized_data_offset); }
288   void set_ptrmap_size_in_bits(size_t s)         { _ptrmap_size_in_bits = s; }
289   void set_mapped_base_address(char* p)          { _mapped_base_address = p; }
290   void copy_base_archive_name(const char* name);
291 
292   void set_shared_path_table(SharedPathTable table) {
293     set_as_offset((char*)table.table(), &_shared_path_table_offset);
294   }
295 
296   void set_requested_base(char* b) {
297     _requested_base_address = b;
298     _mapped_base_address = 0;
299   }
300 
301   SharedPathTable shared_path_table() const {
302     return SharedPathTable((Array<SharedClassPathEntry*>*)
303                            from_mapped_offset(_shared_path_table_offset));
304   }
305 
306   bool validate();
307   int compute_crc();
308 
309   FileMapRegion* region_at(int i) {
310     assert(is_valid_region(i), "invalid region");
311     return FileMapRegion::cast(&_regions[i]);
312   }
313 
314   void populate(FileMapInfo *info, size_t core_region_alignment, size_t header_size,
315                 size_t base_archive_name_size, size_t base_archive_name_offset,
316                 size_t common_app_classpath_size);
317   static bool is_valid_region(int region) {
318     return (0 <= region && region < NUM_CDS_REGIONS);
319   }
320 
321   void print(outputStream* st);
322 };
323 
324 class FileMapInfo : public CHeapObj<mtInternal> {
325 private:
326   friend class ManifestStream;
327   friend class VMStructs;
328   friend class ArchiveBuilder;
329   friend class CDSOffsets;
330   friend class FileMapHeader;
331 
332   bool           _is_static;
333   bool           _file_open;
334   bool           _is_mapped;
335   int            _fd;
336   size_t         _file_offset;
337   const char*    _full_path;
338   const char*    _base_archive_name;
339   FileMapHeader* _header;
340 
341   static SharedPathTable       _shared_path_table;
342   static bool                  _validating_shared_path_table;
343 
344   // FileMapHeader describes the shared space data in the file to be
345   // mapped.  This structure gets written to a file.  It is not a class, so
346   // that the compilers don't add any compiler-private data to it.
347 
348   static FileMapInfo* _current_info;
349   static FileMapInfo* _dynamic_archive_info;
350   static bool _heap_pointers_need_patching;
351   static bool _memory_mapping_failed;
352   static GrowableArray<const char*>* _non_existent_class_paths;
353 
354 public:
355   FileMapHeader *header() const       { return _header; }
356   static bool get_base_archive_name_from_header(const char* archive_name,
357                                                 char** base_archive_name);
358   static SharedPathTable shared_path_table() {
359     return _shared_path_table;
360   }
361 
362   bool init_from_file(int fd);
363   static void metaspace_pointers_do(MetaspaceClosure* it) {
364     _shared_path_table.metaspace_pointers_do(it);
365   }
366 
367   void log_paths(const char* msg, int start_idx, int end_idx);
368 
369   FileMapInfo(const char* full_apth, bool is_static);
370   ~FileMapInfo();
371 
372   // Accessors
373   int    compute_header_crc()  const { return header()->compute_crc(); }
374   void   set_header_crc(int crc)     { header()->set_crc(crc); }
375   int    region_crc(int i)     const { return region_at(i)->crc(); }
376   void   populate_header(size_t core_region_alignment);
377   bool   validate_header();
378   void   invalidate();
379   int    crc()                 const { return header()->crc(); }
380   int    version()             const { return header()->version(); }
381   unsigned int magic()         const { return header()->magic(); }
382   address narrow_oop_base()    const { return header()->narrow_oop_base(); }
383   int     narrow_oop_shift()   const { return header()->narrow_oop_shift(); }
384   uintx   max_heap_size()      const { return header()->max_heap_size(); }
385   address narrow_klass_base()  const { return header()->narrow_klass_base(); }
386   int     narrow_klass_shift() const { return header()->narrow_klass_shift(); }
387   size_t  core_region_alignment() const { return header()->core_region_alignment(); }
388 
389   CompressedOops::Mode narrow_oop_mode()      const { return header()->narrow_oop_mode(); }
390   jshort app_module_paths_start_index()       const { return header()->app_module_paths_start_index(); }
391   jshort app_class_paths_start_index()        const { return header()->app_class_paths_start_index(); }
392 
393   char* cloned_vtables()                      const { return header()->cloned_vtables(); }
394   void  set_cloned_vtables(char* p)           const { header()->set_cloned_vtables(p); }
395   char* serialized_data()                     const { return header()->serialized_data(); }
396   void  set_serialized_data(char* p)          const { header()->set_serialized_data(p); }
397 
398   bool  is_file_position_aligned() const;
399   void  align_file_position();
400 
401   bool is_static()                            const { return _is_static; }
402   bool is_mapped()                            const { return _is_mapped; }
403   void set_is_mapped(bool v)                        { _is_mapped = v; }
404   const char* full_path()                     const { return _full_path; }
405 
406   void set_requested_base(char* b)                  { header()->set_requested_base(b); }
407   char* requested_base_address()           const    { return header()->requested_base_address(); }
408 
409   class DynamicArchiveHeader* dynamic_header() const {
410     assert(!is_static(), "must be");
411     return (DynamicArchiveHeader*)header();
412   }
413 
414   void set_has_platform_or_app_classes(bool v) {
415     header()->set_has_platform_or_app_classes(v);
416   }
417   bool has_platform_or_app_classes() const {
418     return header()->has_platform_or_app_classes();
419   }
420 
421   static FileMapInfo* current_info() {
422     CDS_ONLY(return _current_info;)
423     NOT_CDS(return nullptr;)
424   }
425 
426   static void set_current_info(FileMapInfo* info) {
427     CDS_ONLY(_current_info = info;)
428   }
429 
430   static FileMapInfo* dynamic_info() {
431     CDS_ONLY(return _dynamic_archive_info;)
432     NOT_CDS(return nullptr;)
433   }
434 
435   static void assert_mark(bool check);
436 
437   // File manipulation.
438   bool  initialize() NOT_CDS_RETURN_(false);
439   bool  open_for_read();
440   void  open_for_write();
441   void  write_header();
442   void  write_region(int region, char* base, size_t size,
443                      bool read_only, bool allow_exec);
444   char* write_bitmap_region(const CHeapBitMap* ptrmap, ArchiveHeapInfo* heap_info,
445                             size_t &size_in_bytes);
446   size_t write_heap_region(ArchiveHeapInfo* heap_info);
447   void  write_bytes(const void* buffer, size_t count);
448   void  write_bytes_aligned(const void* buffer, size_t count);
449   size_t  read_bytes(void* buffer, size_t count);
450   static size_t readonly_total();
451   MapArchiveResult map_regions(int regions[], int num_regions, char* mapped_base_address, ReservedSpace rs);
452   void  unmap_regions(int regions[], int num_regions);
453   void  map_or_load_heap_region() NOT_CDS_JAVA_HEAP_RETURN;
454   void  fixup_mapped_heap_region() NOT_CDS_JAVA_HEAP_RETURN;
455   void  patch_heap_embedded_pointers() NOT_CDS_JAVA_HEAP_RETURN;
456   bool  has_heap_region()  NOT_CDS_JAVA_HEAP_RETURN_(false);
457   MemRegion get_heap_region_requested_range() NOT_CDS_JAVA_HEAP_RETURN_(MemRegion());
458   bool  read_region(int i, char* base, size_t size, bool do_commit);
459   char* map_bitmap_region();
460   void  unmap_region(int i);
461   void  close();
462   bool  is_open() { return _file_open; }
463   ReservedSpace reserve_shared_memory();
464 
465   // JVM/TI RedefineClasses() support:
466   // Remap the shared readonly space to shared readwrite, private.
467   bool  remap_shared_readonly_as_readwrite();
468 
469   static bool memory_mapping_failed() {
470     CDS_ONLY(return _memory_mapping_failed;)
471     NOT_CDS(return false;)
472   }
473 
474   static void allocate_shared_path_table(TRAPS);
475   static int add_shared_classpaths(int i, const char* which, ClassPathEntry *cpe, TRAPS);
476   static void check_nonempty_dir_in_shared_path_table();
477   bool check_module_paths();
478   bool validate_shared_path_table();
479   void validate_non_existent_class_paths();
480   static void set_shared_path_table(FileMapInfo* info) {
481     _shared_path_table = info->header()->shared_path_table();
482   }
483   static void update_jar_manifest(ClassPathEntry *cpe, SharedClassPathEntry* ent, TRAPS);
484   static int num_non_existent_class_paths();
485   static void record_non_existent_class_path_entry(const char* path);
486 
487 #if INCLUDE_JVMTI
488   // Caller needs a ResourceMark because parts of the returned cfs are resource-allocated.
489   static ClassFileStream* open_stream_for_jvmti(InstanceKlass* ik, Handle class_loader, TRAPS);
490 #endif
491 
492   static SharedClassPathEntry* shared_path(int index) {
493     return _shared_path_table.path_at(index);
494   }
495 
496   static const char* shared_path_name(int index) {
497     assert(index >= 0, "Sanity");
498     return shared_path(index)->name();
499   }
500 
501   static int get_number_of_shared_paths() {
502     return _shared_path_table.size();
503   }
504 
505   static int get_module_shared_path_index(Symbol* location) NOT_CDS_RETURN_(-1);
506 
507   // The offset of the first core region in the archive, relative to SharedBaseAddress
508   size_t mapping_base_offset() const { return first_core_region()->mapping_offset();    }
509   // The offset of the (exclusive) end of the last core region in this archive, relative to SharedBaseAddress
510   size_t mapping_end_offset()  const { return last_core_region()->mapping_end_offset(); }
511 
512   char* mapped_base()    const { return first_core_region()->mapped_base(); }
513   char* mapped_end()     const { return last_core_region()->mapped_end();   }
514 
515   // Non-zero if the archive needs to be mapped a non-default location due to ASLR.
516   intx relocation_delta() const {
517     return header()->mapped_base_address() - header()->requested_base_address();
518   }
519 
520   FileMapRegion* first_core_region() const;
521   FileMapRegion* last_core_region()  const;
522 
523   FileMapRegion* region_at(int i) const {
524     return header()->region_at(i);
525   }
526 
527   void print(outputStream* st) const;
528 
529   const char* vm_version() {
530     return header()->jvm_ident();
531   }
532 
533  private:
534   void  seek_to_position(size_t pos);
535   char* skip_first_path_entry(const char* path) NOT_CDS_RETURN_(nullptr);
536   int   num_paths(const char* path) NOT_CDS_RETURN_(0);
537   bool  check_paths_existence(const char* paths) NOT_CDS_RETURN_(false);
538   GrowableArray<const char*>* create_dumptime_app_classpath_array() NOT_CDS_RETURN_(nullptr);
539   GrowableArray<const char*>* create_path_array(const char* path) NOT_CDS_RETURN_(nullptr);
540   bool  classpath_failure(const char* msg, const char* name) NOT_CDS_RETURN_(false);
541   unsigned int longest_common_app_classpath_prefix_len(int num_paths,
542                                                        GrowableArray<const char*>* rp_array)
543                                                        NOT_CDS_RETURN_(0);
544   bool  check_paths(int shared_path_start_idx, int num_paths,
545                     GrowableArray<const char*>* rp_array,
546                     unsigned int dumptime_prefix_len,
547                     unsigned int runtime_prefix_len) NOT_CDS_RETURN_(false);
548   bool  validate_boot_class_paths() NOT_CDS_RETURN_(false);
549   bool  validate_app_class_paths(int shared_app_paths_len) NOT_CDS_RETURN_(false);
550   bool  map_heap_region_impl() NOT_CDS_JAVA_HEAP_RETURN_(false);
551   void  dealloc_heap_region() NOT_CDS_JAVA_HEAP_RETURN;
552   bool  can_use_heap_region();
553   bool  load_heap_region() NOT_CDS_JAVA_HEAP_RETURN_(false);
554   bool  map_heap_region() NOT_CDS_JAVA_HEAP_RETURN_(false);
555   void  init_heap_region_relocation();
556   MapArchiveResult map_region(int i, intx addr_delta, char* mapped_base_address, ReservedSpace rs);
557   bool  relocate_pointers_in_core_regions(intx addr_delta);
558 
559   static MemRegion _mapped_heap_memregion;
560 
561 public:
562   address heap_region_dumptime_address() NOT_CDS_JAVA_HEAP_RETURN_(nullptr);
563   address heap_region_requested_address() NOT_CDS_JAVA_HEAP_RETURN_(nullptr);
564   address heap_region_mapped_address() NOT_CDS_JAVA_HEAP_RETURN_(nullptr);
565   narrowOop encoded_heap_region_dumptime_address();
566 
567 private:
568 
569 #if INCLUDE_JVMTI
570   static ClassPathEntry** _classpath_entries_for_jvmti;
571   static ClassPathEntry* get_classpath_entry_for_jvmti(int i, TRAPS);
572 #endif
573 };
574 
575 #endif // SHARE_CDS_FILEMAP_HPP