< prev index next >

src/hotspot/share/classfile/classLoader.hpp

Print this page

 82   }
 83   virtual ~ClassPathDirEntry();
 84   ClassFileStream* open_stream(JavaThread* current, const char* name);
 85 };
 86 
 87 class ClassPathZipEntry: public ClassPathEntry {
 88  private:
 89   jzfile* _zip;              // The zip archive
 90   const char*   _zip_name;   // Name of zip archive
 91  public:
 92   bool is_jar_file() const { return true;  }
 93   const char* name() const { return _zip_name; }
 94   ClassPathZipEntry(jzfile* zip, const char* zip_name);
 95   virtual ~ClassPathZipEntry();
 96   bool has_entry(JavaThread* current, const char* name);
 97   u1* open_entry(JavaThread* current, const char* name, jint* filesize, bool nul_terminate);
 98   ClassFileStream* open_stream(JavaThread* current, const char* name);
 99 };
100 
101 
102 // For java image files

103 class ClassPathImageEntry: public ClassPathEntry {
104 private:
105   const char* _name;
106   DEBUG_ONLY(static ClassPathImageEntry* _singleton;)
107 public:
108   bool is_modules_image() const;
109   const char* name() const { return _name == nullptr ? "" : _name; }
110   JImageFile* jimage() const;
111   JImageFile* jimage_non_null() const;
112   void close_jimage();
113   ClassPathImageEntry(JImageFile* jimage, const char* name);

114   virtual ~ClassPathImageEntry() { ShouldNotReachHere(); }

115   ClassFileStream* open_stream(JavaThread* current, const char* name);
116   ClassFileStream* open_stream_for_loader(JavaThread* current, const char* name, ClassLoaderData* loader_data);
117 };
118 
119 // ModuleClassPathList contains a linked list of ClassPathEntry's
120 // that have been specified for a specific module.  Currently,
121 // the only way to specify a module/path pair is via the --patch-module
122 // command line option.
123 class ModuleClassPathList : public CHeapObj<mtClass> {
124 private:
125   Symbol* _module_name;
126   // First and last entries of class path entries for a specific module
127   ClassPathEntry* _module_first_entry;
128   ClassPathEntry* _module_last_entry;
129 public:
130   Symbol* module_name() const { return _module_name; }
131   ClassPathEntry* module_first_entry() const { return _module_first_entry; }
132   ModuleClassPathList(Symbol* module_name);
133   ~ModuleClassPathList();
134   void add_to_list(ClassPathEntry* new_entry);

183   static PerfCounter* _unsafe_defineClassCallCounter;
184 
185   // Count the time taken to hash the scondary superclass arrays.
186   static PerfCounter* _perf_secondary_hash_time;
187 
188   // The boot class path consists of 3 ordered pieces:
189   //  1. the module/path pairs specified to --patch-module
190   //    --patch-module=<module>=<file>(<pathsep><file>)*
191   //  2. the base piece
192   //    [jimage | build with exploded modules]
193   //  3. boot loader append path
194   //    [-Xbootclasspath/a]; [jvmti appended entries]
195   //
196   // The boot loader must obey this order when attempting
197   // to load a class.
198 
199   // 1. Contains the module/path pairs specified to --patch-module
200   static GrowableArray<ModuleClassPathList*>* _patch_mod_entries;
201 
202   // 2. the base piece
203   //    Contains the ClassPathEntry of the modular java runtime image.
204   //    If no java runtime image is present, this indicates a
205   //    build with exploded modules is being used instead.
206   static ClassPathEntry* _jrt_entry;
207   static GrowableArray<ModuleClassPathList*>* _exploded_entries;
208   enum { EXPLODED_ENTRY_SIZE = 80 }; // Initial number of exploded modules
209 
210   // 3. the boot loader's append path
211   //    [-Xbootclasspath/a]; [jvmti appended entries]
212   //    Note: boot loader append path does not support named modules.
213   static ClassPathEntry* volatile _first_append_entry_list;
214   static ClassPathEntry* first_append_entry() {
215     return AtomicAccess::load_acquire(&_first_append_entry_list);
216   }
217 
218   // Last entry in linked list of appended ClassPathEntry instances
219   static ClassPathEntry* volatile _last_append_entry;
220 
221  public:
222 
223   static bool has_bootclasspath_append() { return first_append_entry() != nullptr; }
224 
225  protected:
226   // Initialization:

333 
334   // Initialization
335   static void initialize(TRAPS);
336   static void classLoader_init2(JavaThread* current);
337 
338   static int compute_Object_vtable();
339 
340   static ClassPathEntry* classpath_entry(int n);
341 
342   static bool is_in_patch_mod_entries(Symbol* module_name);
343 
344 #if INCLUDE_CDS
345   static char* uri_to_path(const char* uri);
346   static void  record_result(JavaThread* current, InstanceKlass* ik,
347                              const ClassFileStream* stream, bool redefined);
348   static void record_result_for_builtin_loader(s2 classpath_index, InstanceKlass* result, bool redefined);
349   static void record_hidden_class(InstanceKlass* ik);
350   static void append_boot_classpath(ClassPathEntry* new_entry);
351 #endif
352 



353   static char* lookup_vm_options();
354 





355   // Determines if the named module is present in the
356   // modules jimage file or in the exploded modules directory.
357   static bool is_module_observable(const char* module_name);
358 
359   static JImageLocationRef jimage_find_resource(JImageFile* jf, const char* module_name,
360                                                 const char* file_name, jlong &size);
361 
362   static void  trace_class_path(const char* msg, const char* name = nullptr);
363 
364   // VM monitoring and management support
365   static jlong classloader_time_ms();
366   static jlong class_method_total_size();
367   static jlong class_init_count();
368   static jlong class_init_time_ms();
369   static jlong class_verify_time_ms();
370   static jlong class_link_count();
371   static jlong class_link_time_ms();
372 
373   // adds a class path to the boot append entries
374   static void add_to_boot_append_entries(ClassPathEntry* new_entry);
375 
376   // creates a class path zip entry (returns null if JAR file cannot be opened)
377   static ClassPathZipEntry* create_class_path_zip_entry(const char *path);
378 
379   static bool string_ends_with(const char* str, const char* str_to_find);
380 
381   // Extract package name from a fully qualified class name

 82   }
 83   virtual ~ClassPathDirEntry();
 84   ClassFileStream* open_stream(JavaThread* current, const char* name);
 85 };
 86 
 87 class ClassPathZipEntry: public ClassPathEntry {
 88  private:
 89   jzfile* _zip;              // The zip archive
 90   const char*   _zip_name;   // Name of zip archive
 91  public:
 92   bool is_jar_file() const { return true;  }
 93   const char* name() const { return _zip_name; }
 94   ClassPathZipEntry(jzfile* zip, const char* zip_name);
 95   virtual ~ClassPathZipEntry();
 96   bool has_entry(JavaThread* current, const char* name);
 97   u1* open_entry(JavaThread* current, const char* name, jint* filesize, bool nul_terminate);
 98   ClassFileStream* open_stream(JavaThread* current, const char* name);
 99 };
100 
101 
102 // A singleton path entry which takes ownership of the initialized JImageFile
103 // reference. Not used for exploded builds.
104 class ClassPathImageEntry: public ClassPathEntry {
105 private:
106   const char* _name;
107   DEBUG_ONLY(static ClassPathImageEntry* _singleton;)
108 public:
109   bool is_modules_image() const;
110   const char* name() const { return _name == nullptr ? "" : _name; }
111   // Called to close the JImage during os::abort (normally not called).

112   void close_jimage();
113   // Takes effective ownership of the static JImageFile pointer.
114   ClassPathImageEntry(const char* name);
115   virtual ~ClassPathImageEntry() { ShouldNotReachHere(); }
116 
117   ClassFileStream* open_stream(JavaThread* current, const char* name);
118   ClassFileStream* open_stream_for_loader(JavaThread* current, const char* name, ClassLoaderData* loader_data);
119 };
120 
121 // ModuleClassPathList contains a linked list of ClassPathEntry's
122 // that have been specified for a specific module.  Currently,
123 // the only way to specify a module/path pair is via the --patch-module
124 // command line option.
125 class ModuleClassPathList : public CHeapObj<mtClass> {
126 private:
127   Symbol* _module_name;
128   // First and last entries of class path entries for a specific module
129   ClassPathEntry* _module_first_entry;
130   ClassPathEntry* _module_last_entry;
131 public:
132   Symbol* module_name() const { return _module_name; }
133   ClassPathEntry* module_first_entry() const { return _module_first_entry; }
134   ModuleClassPathList(Symbol* module_name);
135   ~ModuleClassPathList();
136   void add_to_list(ClassPathEntry* new_entry);

185   static PerfCounter* _unsafe_defineClassCallCounter;
186 
187   // Count the time taken to hash the scondary superclass arrays.
188   static PerfCounter* _perf_secondary_hash_time;
189 
190   // The boot class path consists of 3 ordered pieces:
191   //  1. the module/path pairs specified to --patch-module
192   //    --patch-module=<module>=<file>(<pathsep><file>)*
193   //  2. the base piece
194   //    [jimage | build with exploded modules]
195   //  3. boot loader append path
196   //    [-Xbootclasspath/a]; [jvmti appended entries]
197   //
198   // The boot loader must obey this order when attempting
199   // to load a class.
200 
201   // 1. Contains the module/path pairs specified to --patch-module
202   static GrowableArray<ModuleClassPathList*>* _patch_mod_entries;
203 
204   // 2. the base piece
205   //    Contains the ClassPathImageEntry of the modular java runtime image.
206   //    If no java runtime image is present, this indicates a
207   //    build with exploded modules is being used instead.
208   static ClassPathImageEntry* _jrt_entry;
209   static GrowableArray<ModuleClassPathList*>* _exploded_entries;
210   enum { EXPLODED_ENTRY_SIZE = 80 }; // Initial number of exploded modules
211 
212   // 3. the boot loader's append path
213   //    [-Xbootclasspath/a]; [jvmti appended entries]
214   //    Note: boot loader append path does not support named modules.
215   static ClassPathEntry* volatile _first_append_entry_list;
216   static ClassPathEntry* first_append_entry() {
217     return AtomicAccess::load_acquire(&_first_append_entry_list);
218   }
219 
220   // Last entry in linked list of appended ClassPathEntry instances
221   static ClassPathEntry* volatile _last_append_entry;
222 
223  public:
224 
225   static bool has_bootclasspath_append() { return first_append_entry() != nullptr; }
226 
227  protected:
228   // Initialization:

335 
336   // Initialization
337   static void initialize(TRAPS);
338   static void classLoader_init2(JavaThread* current);
339 
340   static int compute_Object_vtable();
341 
342   static ClassPathEntry* classpath_entry(int n);
343 
344   static bool is_in_patch_mod_entries(Symbol* module_name);
345 
346 #if INCLUDE_CDS
347   static char* uri_to_path(const char* uri);
348   static void  record_result(JavaThread* current, InstanceKlass* ik,
349                              const ClassFileStream* stream, bool redefined);
350   static void record_result_for_builtin_loader(s2 classpath_index, InstanceKlass* result, bool redefined);
351   static void record_hidden_class(InstanceKlass* ik);
352   static void append_boot_classpath(ClassPathEntry* new_entry);
353 #endif
354 
355   // Retrieves additional VM options prior to flags processing. Options held
356   // in the JImage file are retrieved without fully initializing it. (this is
357   // the only JImage lookup which can succeed before init_jimage() is called).
358   static char* lookup_vm_options();
359 
360   // Called once, after all flags are processed, to finish initializing the
361   // JImage file. Until this is called, jimage_find_resource(), and any other
362   // JImage resource lookups or access will fail.
363   static void init_jimage(bool enable_preview);
364 
365   // Determines if the named module is present in the
366   // modules jimage file or in the exploded modules directory.
367   static bool is_module_observable(const char* module_name);
368 



369   static void  trace_class_path(const char* msg, const char* name = nullptr);
370 
371   // VM monitoring and management support
372   static jlong classloader_time_ms();
373   static jlong class_method_total_size();
374   static jlong class_init_count();
375   static jlong class_init_time_ms();
376   static jlong class_verify_time_ms();
377   static jlong class_link_count();
378   static jlong class_link_time_ms();
379 
380   // adds a class path to the boot append entries
381   static void add_to_boot_append_entries(ClassPathEntry* new_entry);
382 
383   // creates a class path zip entry (returns null if JAR file cannot be opened)
384   static ClassPathZipEntry* create_class_path_zip_entry(const char *path);
385 
386   static bool string_ends_with(const char* str, const char* str_to_find);
387 
388   // Extract package name from a fully qualified class name
< prev index next >