76 private:
77 const char* _dir; // Name of directory
78 public:
79 const char* name() const { return _dir; }
80 ClassPathDirEntry(const char* dir) {
81 _dir = copy_path(dir);
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 u1* open_entry(JavaThread* current, const char* name, jint* filesize, bool nul_terminate);
97 ClassFileStream* open_stream(JavaThread* current, const char* name);
98 };
99
100
101 // For java image files
102 class ClassPathImageEntry: public ClassPathEntry {
103 private:
104 const char* _name;
105 DEBUG_ONLY(static ClassPathImageEntry* _singleton;)
106 public:
107 bool is_modules_image() const;
108 const char* name() const { return _name == nullptr ? "" : _name; }
109 JImageFile* jimage() const;
110 JImageFile* jimage_non_null() const;
111 void close_jimage();
112 ClassPathImageEntry(JImageFile* jimage, const char* name);
113 virtual ~ClassPathImageEntry() { ShouldNotReachHere(); }
114 ClassFileStream* open_stream(JavaThread* current, const char* name);
115 ClassFileStream* open_stream_for_loader(JavaThread* current, const char* name, ClassLoaderData* loader_data);
131 ModuleClassPathList(Symbol* module_name);
132 ~ModuleClassPathList();
133 void add_to_list(ClassPathEntry* new_entry);
134 };
135
136 class ClassLoader: AllStatic {
137 public:
138 enum ClassLoaderType {
139 OTHER = 0,
140 BOOT_LOADER = 1, /* boot loader */
141 PLATFORM_LOADER = 2, /* PlatformClassLoader */
142 APP_LOADER = 3 /* AppClassLoader */
143 };
144 protected:
145
146 // Performance counters
147 static PerfCounter* _perf_accumulated_time;
148 static PerfCounter* _perf_classes_inited;
149 static PerfCounter* _perf_class_init_time;
150 static PerfCounter* _perf_class_init_selftime;
151 static PerfCounter* _perf_classes_verified;
152 static PerfCounter* _perf_class_verify_time;
153 static PerfCounter* _perf_class_verify_selftime;
154 static PerfCounter* _perf_classes_linked;
155 static PerfCounter* _perf_class_link_time;
156 static PerfCounter* _perf_class_link_selftime;
157 static PerfCounter* _perf_shared_classload_time;
158 static PerfCounter* _perf_sys_classload_time;
159 static PerfCounter* _perf_app_classload_time;
160 static PerfCounter* _perf_app_classload_selftime;
161 static PerfCounter* _perf_app_classload_count;
162 static PerfCounter* _perf_define_appclasses;
163 static PerfCounter* _perf_define_appclass_time;
164 static PerfCounter* _perf_define_appclass_selftime;
165 static PerfCounter* _perf_app_classfile_bytes_read;
166 static PerfCounter* _perf_sys_classfile_bytes_read;
167 static PerfCounter* _perf_ik_link_methods_time;
168 static PerfCounter* _perf_method_adapters_time;
169 static PerfCounter* _perf_ik_link_methods_count;
170 static PerfCounter* _perf_method_adapters_count;
171
172 static PerfCounter* _perf_resolve_indy_time;
173 static PerfCounter* _perf_resolve_invokehandle_time;
174 static PerfCounter* _perf_resolve_mh_time;
175 static PerfCounter* _perf_resolve_mt_time;
176
177 static PerfCounter* _perf_resolve_indy_count;
178 static PerfCounter* _perf_resolve_invokehandle_count;
179 static PerfCounter* _perf_resolve_mh_count;
180 static PerfCounter* _perf_resolve_mt_count;
181
182 static PerfCounter* _unsafe_defineClassCallCounter;
183
184 // Count the time taken to hash the scondary superclass arrays.
185 static PerfCounter* _perf_secondary_hash_time;
186
187 // The boot class path consists of 3 ordered pieces:
188 // 1. the module/path pairs specified to --patch-module
189 // --patch-module=<module>=<file>(<pathsep><file>)*
190 // 2. the base piece
191 // [jimage | build with exploded modules]
192 // 3. boot loader append path
193 // [-Xbootclasspath/a]; [jvmti appended entries]
194 //
195 // The boot loader must obey this order when attempting
260 static PerfCounter* perf_classes_verified() { return _perf_classes_verified; }
261 static PerfCounter* perf_class_verify_time() { return _perf_class_verify_time; }
262 static PerfCounter* perf_class_verify_selftime() { return _perf_class_verify_selftime; }
263 static PerfCounter* perf_classes_linked() { return _perf_classes_linked; }
264 static PerfCounter* perf_class_link_time() { return _perf_class_link_time; }
265 static PerfCounter* perf_class_link_selftime() { return _perf_class_link_selftime; }
266 static PerfCounter* perf_shared_classload_time() { return _perf_shared_classload_time; }
267 static PerfCounter* perf_secondary_hash_time() {
268 return _perf_secondary_hash_time;
269 }
270 static PerfCounter* perf_sys_classload_time() { return _perf_sys_classload_time; }
271 static PerfCounter* perf_app_classload_time() { return _perf_app_classload_time; }
272 static PerfCounter* perf_app_classload_selftime() { return _perf_app_classload_selftime; }
273 static PerfCounter* perf_app_classload_count() { return _perf_app_classload_count; }
274 static PerfCounter* perf_define_appclasses() { return _perf_define_appclasses; }
275 static PerfCounter* perf_define_appclass_time() { return _perf_define_appclass_time; }
276 static PerfCounter* perf_define_appclass_selftime() { return _perf_define_appclass_selftime; }
277 static PerfCounter* perf_app_classfile_bytes_read() { return _perf_app_classfile_bytes_read; }
278 static PerfCounter* perf_sys_classfile_bytes_read() { return _perf_sys_classfile_bytes_read; }
279
280 static PerfCounter* perf_ik_link_methods_time() { return _perf_ik_link_methods_time; }
281 static PerfCounter* perf_method_adapters_time() { return _perf_method_adapters_time; }
282 static PerfCounter* perf_ik_link_methods_count() { return _perf_ik_link_methods_count; }
283 static PerfCounter* perf_method_adapters_count() { return _perf_method_adapters_count; }
284
285 static PerfCounter* perf_resolve_invokedynamic_time() { return _perf_resolve_indy_time; }
286 static PerfCounter* perf_resolve_invokehandle_time() { return _perf_resolve_invokehandle_time; }
287 static PerfCounter* perf_resolve_method_handle_time() { return _perf_resolve_mh_time; }
288 static PerfCounter* perf_resolve_method_type_time() { return _perf_resolve_mt_time; }
289
290 static PerfCounter* perf_resolve_invokedynamic_count() { return _perf_resolve_indy_count; }
291 static PerfCounter* perf_resolve_invokehandle_count() { return _perf_resolve_invokehandle_count; }
292 static PerfCounter* perf_resolve_method_handle_count() { return _perf_resolve_mh_count; }
293 static PerfCounter* perf_resolve_method_type_count() { return _perf_resolve_mt_count; }
294
295 static void print_counters(outputStream *st);
296
297 // Record how many calls to Unsafe_DefineClass
298 static PerfCounter* unsafe_defineClassCallCounter() {
299 return _unsafe_defineClassCallCounter;
300 }
301
302 // Modular java runtime image is present vs. a build with exploded modules
303 static bool has_jrt_entry() { return (_jrt_entry != nullptr); }
304 static ClassPathEntry* get_jrt_entry() { return _jrt_entry; }
305 static void close_jrt_image();
306
307 // Add a module's exploded directory to the boot loader's exploded module build list
308 static void add_to_exploded_build_list(JavaThread* current, Symbol* module_name);
309
310 // Search the module list for the class file stream based on the file name and java package
311 static ClassFileStream* search_module_entries(JavaThread* current,
312 const GrowableArray<ModuleClassPathList*>* const module_list,
313 PackageEntry* pkg_entry, // Java package entry derived from the class name
314 const char* const file_name);
349
350 static char* lookup_vm_options();
351
352 // Determines if the named module is present in the
353 // modules jimage file or in the exploded modules directory.
354 static bool is_module_observable(const char* module_name);
355
356 static JImageLocationRef jimage_find_resource(JImageFile* jf, const char* module_name,
357 const char* file_name, jlong &size);
358
359 static void trace_class_path(const char* msg, const char* name = nullptr);
360
361 // VM monitoring and management support
362 static jlong classloader_time_ms();
363 static jlong class_method_total_size();
364 static jlong class_init_count();
365 static jlong class_init_time_ms();
366 static jlong class_verify_time_ms();
367 static jlong class_link_count();
368 static jlong class_link_time_ms();
369
370 // adds a class path to the boot append entries
371 static void add_to_boot_append_entries(ClassPathEntry* new_entry);
372
373 // creates a class path zip entry (returns null if JAR file cannot be opened)
374 static ClassPathZipEntry* create_class_path_zip_entry(const char *path);
375
376 static bool string_ends_with(const char* str, const char* str_to_find);
377
378 // Extract package name from a fully qualified class name
379 // *bad_class_name is set to true if there's a problem with parsing class_name, to
380 // distinguish from a class_name with no package name, as both cases have a null return value
381 static Symbol* package_from_class_name(const Symbol* class_name, bool* bad_class_name = nullptr);
382
383 // Debugging
384 static void verify() PRODUCT_RETURN;
385 };
386
387 // PerfClassTraceTime is used to measure time for class loading related events.
388 // This class tracks cumulative time and exclusive time for specific event types.
|
76 private:
77 const char* _dir; // Name of directory
78 public:
79 const char* name() const { return _dir; }
80 ClassPathDirEntry(const char* dir) {
81 _dir = copy_path(dir);
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);
132 ModuleClassPathList(Symbol* module_name);
133 ~ModuleClassPathList();
134 void add_to_list(ClassPathEntry* new_entry);
135 };
136
137 class ClassLoader: AllStatic {
138 public:
139 enum ClassLoaderType {
140 OTHER = 0,
141 BOOT_LOADER = 1, /* boot loader */
142 PLATFORM_LOADER = 2, /* PlatformClassLoader */
143 APP_LOADER = 3 /* AppClassLoader */
144 };
145 protected:
146
147 // Performance counters
148 static PerfCounter* _perf_accumulated_time;
149 static PerfCounter* _perf_classes_inited;
150 static PerfCounter* _perf_class_init_time;
151 static PerfCounter* _perf_class_init_selftime;
152 static PerfCounter* _perf_class_init_bytecodes_count;
153 static PerfCounter* _perf_classes_verified;
154 static PerfCounter* _perf_class_verify_time;
155 static PerfCounter* _perf_class_verify_selftime;
156 static PerfCounter* _perf_classes_linked;
157 static PerfCounter* _perf_class_link_time;
158 static PerfCounter* _perf_class_link_selftime;
159 static PerfCounter* _perf_shared_classload_time;
160 static PerfCounter* _perf_sys_classload_time;
161 static PerfCounter* _perf_app_classload_time;
162 static PerfCounter* _perf_app_classload_selftime;
163 static PerfCounter* _perf_app_classload_count;
164 static PerfCounter* _perf_define_appclasses;
165 static PerfCounter* _perf_define_appclass_time;
166 static PerfCounter* _perf_define_appclass_selftime;
167 static PerfCounter* _perf_app_classfile_bytes_read;
168 static PerfCounter* _perf_sys_classfile_bytes_read;
169 static PerfCounter* _perf_preload_total_time;
170 static PerfCounter* _perf_preload_time;
171 static PerfCounter* _perf_prelink_time;
172 static PerfCounter* _perf_preinit_time;
173 static PerfCounter* _perf_preresolve_time;
174 static PerfCounter* _perf_ik_link_methods_time;
175 static PerfCounter* _perf_method_adapters_time;
176 static PerfCounter* _perf_ik_link_methods_count;
177 static PerfCounter* _perf_method_adapters_count;
178
179 static PerfTickCounters* _perf_resolve_indy_time;
180 static PerfTickCounters* _perf_resolve_invokehandle_time;
181 static PerfTickCounters* _perf_resolve_mh_time;
182 static PerfTickCounters* _perf_resolve_mt_time;
183
184 static PerfCounter* _perf_resolve_indy_count;
185 static PerfCounter* _perf_resolve_invokehandle_count;
186 static PerfCounter* _perf_resolve_mh_count;
187 static PerfCounter* _perf_resolve_mt_count;
188
189 static PerfCounter* _unsafe_defineClassCallCounter;
190
191 // Count the time taken to hash the scondary superclass arrays.
192 static PerfCounter* _perf_secondary_hash_time;
193
194 // The boot class path consists of 3 ordered pieces:
195 // 1. the module/path pairs specified to --patch-module
196 // --patch-module=<module>=<file>(<pathsep><file>)*
197 // 2. the base piece
198 // [jimage | build with exploded modules]
199 // 3. boot loader append path
200 // [-Xbootclasspath/a]; [jvmti appended entries]
201 //
202 // The boot loader must obey this order when attempting
267 static PerfCounter* perf_classes_verified() { return _perf_classes_verified; }
268 static PerfCounter* perf_class_verify_time() { return _perf_class_verify_time; }
269 static PerfCounter* perf_class_verify_selftime() { return _perf_class_verify_selftime; }
270 static PerfCounter* perf_classes_linked() { return _perf_classes_linked; }
271 static PerfCounter* perf_class_link_time() { return _perf_class_link_time; }
272 static PerfCounter* perf_class_link_selftime() { return _perf_class_link_selftime; }
273 static PerfCounter* perf_shared_classload_time() { return _perf_shared_classload_time; }
274 static PerfCounter* perf_secondary_hash_time() {
275 return _perf_secondary_hash_time;
276 }
277 static PerfCounter* perf_sys_classload_time() { return _perf_sys_classload_time; }
278 static PerfCounter* perf_app_classload_time() { return _perf_app_classload_time; }
279 static PerfCounter* perf_app_classload_selftime() { return _perf_app_classload_selftime; }
280 static PerfCounter* perf_app_classload_count() { return _perf_app_classload_count; }
281 static PerfCounter* perf_define_appclasses() { return _perf_define_appclasses; }
282 static PerfCounter* perf_define_appclass_time() { return _perf_define_appclass_time; }
283 static PerfCounter* perf_define_appclass_selftime() { return _perf_define_appclass_selftime; }
284 static PerfCounter* perf_app_classfile_bytes_read() { return _perf_app_classfile_bytes_read; }
285 static PerfCounter* perf_sys_classfile_bytes_read() { return _perf_sys_classfile_bytes_read; }
286
287 static PerfCounter* perf_preload_total_time() { return _perf_preload_total_time; }
288 static PerfCounter* perf_preload_time() { return _perf_preload_time; }
289 static PerfCounter* perf_prelink_time() { return _perf_prelink_time; }
290 static PerfCounter* perf_preinit_time() { return _perf_preinit_time; }
291 static PerfCounter* perf_preresolve_time() { return _perf_preresolve_time; }
292 static PerfCounter* perf_ik_link_methods_time() { return _perf_ik_link_methods_time; }
293 static PerfCounter* perf_method_adapters_time() { return _perf_method_adapters_time; }
294 static PerfCounter* perf_ik_link_methods_count() { return _perf_ik_link_methods_count; }
295 static PerfCounter* perf_method_adapters_count() { return _perf_method_adapters_count; }
296
297 static PerfTickCounters* perf_resolve_invokedynamic_time() { return _perf_resolve_indy_time; }
298 static PerfTickCounters* perf_resolve_invokehandle_time() { return _perf_resolve_invokehandle_time; }
299 static PerfTickCounters* perf_resolve_method_handle_time() { return _perf_resolve_mh_time; }
300 static PerfTickCounters* perf_resolve_method_type_time() { return _perf_resolve_mt_time; }
301
302 static PerfCounter* perf_resolve_invokedynamic_count() { return _perf_resolve_indy_count; }
303 static PerfCounter* perf_resolve_invokehandle_count() { return _perf_resolve_invokehandle_count; }
304 static PerfCounter* perf_resolve_method_handle_count() { return _perf_resolve_mh_count; }
305 static PerfCounter* perf_resolve_method_type_count() { return _perf_resolve_mt_count; }
306
307 static PerfCounter* perf_class_init_bytecodes_count() { return _perf_class_init_bytecodes_count; }
308
309 static void print_counters(outputStream *st);
310
311 // Record how many calls to Unsafe_DefineClass
312 static PerfCounter* unsafe_defineClassCallCounter() {
313 return _unsafe_defineClassCallCounter;
314 }
315
316 // Modular java runtime image is present vs. a build with exploded modules
317 static bool has_jrt_entry() { return (_jrt_entry != nullptr); }
318 static ClassPathEntry* get_jrt_entry() { return _jrt_entry; }
319 static void close_jrt_image();
320
321 // Add a module's exploded directory to the boot loader's exploded module build list
322 static void add_to_exploded_build_list(JavaThread* current, Symbol* module_name);
323
324 // Search the module list for the class file stream based on the file name and java package
325 static ClassFileStream* search_module_entries(JavaThread* current,
326 const GrowableArray<ModuleClassPathList*>* const module_list,
327 PackageEntry* pkg_entry, // Java package entry derived from the class name
328 const char* const file_name);
363
364 static char* lookup_vm_options();
365
366 // Determines if the named module is present in the
367 // modules jimage file or in the exploded modules directory.
368 static bool is_module_observable(const char* module_name);
369
370 static JImageLocationRef jimage_find_resource(JImageFile* jf, const char* module_name,
371 const char* file_name, jlong &size);
372
373 static void trace_class_path(const char* msg, const char* name = nullptr);
374
375 // VM monitoring and management support
376 static jlong classloader_time_ms();
377 static jlong class_method_total_size();
378 static jlong class_init_count();
379 static jlong class_init_time_ms();
380 static jlong class_verify_time_ms();
381 static jlong class_link_count();
382 static jlong class_link_time_ms();
383 static jlong class_init_bytecodes_count();
384
385 // adds a class path to the boot append entries
386 static void add_to_boot_append_entries(ClassPathEntry* new_entry);
387
388 // creates a class path zip entry (returns null if JAR file cannot be opened)
389 static ClassPathZipEntry* create_class_path_zip_entry(const char *path);
390
391 static bool string_ends_with(const char* str, const char* str_to_find);
392
393 // Extract package name from a fully qualified class name
394 // *bad_class_name is set to true if there's a problem with parsing class_name, to
395 // distinguish from a class_name with no package name, as both cases have a null return value
396 static Symbol* package_from_class_name(const Symbol* class_name, bool* bad_class_name = nullptr);
397
398 // Debugging
399 static void verify() PRODUCT_RETURN;
400 };
401
402 // PerfClassTraceTime is used to measure time for class loading related events.
403 // This class tracks cumulative time and exclusive time for specific event types.
|