98 public:
99 bool is_modules_image() const { return false; }
100 bool is_jar_file() const { return true; }
101 const char* name() const { return _zip_name; }
102 JImageFile* jimage() const { return NULL; }
103 void close_jimage() {}
104 ClassPathZipEntry(jzfile* zip, const char* zip_name, bool is_boot_append);
105 virtual ~ClassPathZipEntry();
106 u1* open_entry(const char* name, jint* filesize, bool nul_terminate, TRAPS);
107 ClassFileStream* open_stream(const char* name, TRAPS);
108 void contents_do(void f(const char* name, void* context), void* context);
109 };
110
111
112 // For java image files
113 class ClassPathImageEntry: public ClassPathEntry {
114 private:
115 JImageFile* _jimage;
116 const char* _name;
117 public:
118 bool is_modules_image() const;
119 bool is_jar_file() const { return false; }
120 bool is_open() const { return _jimage != NULL; }
121 const char* name() const { return _name == NULL ? "" : _name; }
122 JImageFile* jimage() const { return _jimage; }
123 void close_jimage();
124 ClassPathImageEntry(JImageFile* jimage, const char* name);
125 virtual ~ClassPathImageEntry();
126 ClassFileStream* open_stream(const char* name, TRAPS);
127 };
128
129 // ModuleClassPathList contains a linked list of ClassPathEntry's
130 // that have been specified for a specific module. Currently,
131 // the only way to specify a module/path pair is via the --patch-module
132 // command line option.
133 class ModuleClassPathList : public CHeapObj<mtClass> {
134 private:
135 Symbol* _module_name;
136 // First and last entries of class path entries for a specific module
137 ClassPathEntry* _module_first_entry;
138 ClassPathEntry* _module_last_entry;
421 static jlong class_init_time_ms();
422 static jlong class_verify_time_ms();
423 static jlong class_link_count();
424 static jlong class_link_time_ms();
425
426 // indicates if class path already contains a entry (exact match by name)
427 static bool contains_append_entry(const char* name);
428
429 // adds a class path to the boot append entries
430 static void add_to_boot_append_entries(ClassPathEntry* new_entry);
431
432 // creates a class path zip entry (returns NULL if JAR file cannot be opened)
433 static ClassPathZipEntry* create_class_path_zip_entry(const char *apath, bool is_boot_append);
434
435 static bool string_ends_with(const char* str, const char* str_to_find);
436
437 // obtain package name from a fully qualified class name
438 // *bad_class_name is set to true if there's a problem with parsing class_name, to
439 // distinguish from a class_name with no package name, as both cases have a NULL return value
440 static const char* package_from_name(const char* const class_name, bool* bad_class_name = NULL);
441
442 static bool is_modules_image(const char* name) { return string_ends_with(name, MODULES_IMAGE_NAME); }
443
444 // Debugging
445 static void verify() PRODUCT_RETURN;
446 };
447
448 // PerfClassTraceTime is used to measure time for class loading related events.
449 // This class tracks cumulative time and exclusive time for specific event types.
450 // During the execution of one event, other event types (e.g. class loading and
451 // resolution) as well as recursive calls of the same event type could happen.
452 // Only one elapsed timer (cumulative) and one thread-local self timer (exclusive)
453 // (i.e. only one event type) are active at a time even multiple PerfClassTraceTime
454 // instances have been created as multiple events are happening.
455 class PerfClassTraceTime {
456 public:
457 enum {
458 CLASS_LOAD = 0,
459 PARSE_CLASS = 1,
460 CLASS_LINK = 2,
461 CLASS_VERIFY = 3,
462 CLASS_CLINIT = 4,
|
98 public:
99 bool is_modules_image() const { return false; }
100 bool is_jar_file() const { return true; }
101 const char* name() const { return _zip_name; }
102 JImageFile* jimage() const { return NULL; }
103 void close_jimage() {}
104 ClassPathZipEntry(jzfile* zip, const char* zip_name, bool is_boot_append);
105 virtual ~ClassPathZipEntry();
106 u1* open_entry(const char* name, jint* filesize, bool nul_terminate, TRAPS);
107 ClassFileStream* open_stream(const char* name, TRAPS);
108 void contents_do(void f(const char* name, void* context), void* context);
109 };
110
111
112 // For java image files
113 class ClassPathImageEntry: public ClassPathEntry {
114 private:
115 JImageFile* _jimage;
116 const char* _name;
117 public:
118 bool is_modules_image() const { return true; }
119 bool is_jar_file() const { return false; }
120 bool is_open() const { return _jimage != NULL; }
121 const char* name() const { return _name == NULL ? "" : _name; }
122 JImageFile* jimage() const { return _jimage; }
123 void close_jimage();
124 ClassPathImageEntry(JImageFile* jimage, const char* name);
125 virtual ~ClassPathImageEntry();
126 ClassFileStream* open_stream(const char* name, TRAPS);
127 };
128
129 // ModuleClassPathList contains a linked list of ClassPathEntry's
130 // that have been specified for a specific module. Currently,
131 // the only way to specify a module/path pair is via the --patch-module
132 // command line option.
133 class ModuleClassPathList : public CHeapObj<mtClass> {
134 private:
135 Symbol* _module_name;
136 // First and last entries of class path entries for a specific module
137 ClassPathEntry* _module_first_entry;
138 ClassPathEntry* _module_last_entry;
421 static jlong class_init_time_ms();
422 static jlong class_verify_time_ms();
423 static jlong class_link_count();
424 static jlong class_link_time_ms();
425
426 // indicates if class path already contains a entry (exact match by name)
427 static bool contains_append_entry(const char* name);
428
429 // adds a class path to the boot append entries
430 static void add_to_boot_append_entries(ClassPathEntry* new_entry);
431
432 // creates a class path zip entry (returns NULL if JAR file cannot be opened)
433 static ClassPathZipEntry* create_class_path_zip_entry(const char *apath, bool is_boot_append);
434
435 static bool string_ends_with(const char* str, const char* str_to_find);
436
437 // obtain package name from a fully qualified class name
438 // *bad_class_name is set to true if there's a problem with parsing class_name, to
439 // distinguish from a class_name with no package name, as both cases have a NULL return value
440 static const char* package_from_name(const char* const class_name, bool* bad_class_name = NULL);
441
442 // Debugging
443 static void verify() PRODUCT_RETURN;
444 };
445
446 // PerfClassTraceTime is used to measure time for class loading related events.
447 // This class tracks cumulative time and exclusive time for specific event types.
448 // During the execution of one event, other event types (e.g. class loading and
449 // resolution) as well as recursive calls of the same event type could happen.
450 // Only one elapsed timer (cumulative) and one thread-local self timer (exclusive)
451 // (i.e. only one event type) are active at a time even multiple PerfClassTraceTime
452 // instances have been created as multiple events are happening.
453 class PerfClassTraceTime {
454 public:
455 enum {
456 CLASS_LOAD = 0,
457 PARSE_CLASS = 1,
458 CLASS_LINK = 2,
459 CLASS_VERIFY = 3,
460 CLASS_CLINIT = 4,
|