105 public: |
105 public: |
106 bool is_jar_file() { return true; } |
106 bool is_jar_file() { return true; } |
107 const char* name() { return _zip_name; } |
107 const char* name() { return _zip_name; } |
108 ClassPathZipEntry(jzfile* zip, const char* zip_name); |
108 ClassPathZipEntry(jzfile* zip, const char* zip_name); |
109 ~ClassPathZipEntry(); |
109 ~ClassPathZipEntry(); |
|
110 u1* open_entry(const char* name, jint* filesize, bool nul_terminate, TRAPS); |
110 ClassFileStream* open_stream(const char* name, TRAPS); |
111 ClassFileStream* open_stream(const char* name, TRAPS); |
111 void contents_do(void f(const char* name, void* context), void* context); |
112 void contents_do(void f(const char* name, void* context), void* context); |
112 // Debugging |
113 // Debugging |
113 NOT_PRODUCT(void compile_the_world(Handle loader, TRAPS);) |
114 NOT_PRODUCT(void compile_the_world(Handle loader, TRAPS);) |
114 NOT_PRODUCT(void compile_the_world12(Handle loader, TRAPS);) // JDK 1.2 version |
115 NOT_PRODUCT(void compile_the_world12(Handle loader, TRAPS);) // JDK 1.2 version |
124 private: |
125 private: |
125 char* _path; // dir or file |
126 char* _path; // dir or file |
126 struct stat _st; |
127 struct stat _st; |
127 MetaIndex* _meta_index; |
128 MetaIndex* _meta_index; |
128 bool _has_error; |
129 bool _has_error; |
|
130 bool _throw_exception; |
129 volatile ClassPathEntry* _resolved_entry; |
131 volatile ClassPathEntry* _resolved_entry; |
130 ClassPathEntry* resolve_entry(TRAPS); |
132 ClassPathEntry* resolve_entry(TRAPS); |
131 public: |
133 public: |
132 bool is_jar_file(); |
134 bool is_jar_file(); |
133 const char* name() { return _path; } |
135 const char* name() { return _path; } |
134 LazyClassPathEntry(char* path, const struct stat* st); |
136 LazyClassPathEntry(char* path, const struct stat* st, bool throw_exception); |
|
137 u1* open_entry(const char* name, jint* filesize, bool nul_terminate, TRAPS); |
135 ClassFileStream* open_stream(const char* name, TRAPS); |
138 ClassFileStream* open_stream(const char* name, TRAPS); |
136 void set_meta_index(MetaIndex* meta_index) { _meta_index = meta_index; } |
139 void set_meta_index(MetaIndex* meta_index) { _meta_index = meta_index; } |
137 virtual bool is_lazy(); |
140 virtual bool is_lazy(); |
138 // Debugging |
141 // Debugging |
139 NOT_PRODUCT(void compile_the_world(Handle loader, TRAPS);) |
142 NOT_PRODUCT(void compile_the_world(Handle loader, TRAPS);) |
140 NOT_PRODUCT(bool is_rt_jar();) |
143 NOT_PRODUCT(bool is_rt_jar();) |
141 }; |
144 }; |
142 |
145 |
143 class PackageHashtable; |
146 class PackageHashtable; |
144 class PackageInfo; |
147 class PackageInfo; |
|
148 class SharedPathsMiscInfo; |
145 template <MEMFLAGS F> class HashtableBucket; |
149 template <MEMFLAGS F> class HashtableBucket; |
146 |
150 |
147 class ClassLoader: AllStatic { |
151 class ClassLoader: AllStatic { |
148 public: |
152 public: |
149 enum SomeConstants { |
153 enum SomeConstants { |
150 package_hash_table_size = 31 // Number of buckets |
154 package_hash_table_size = 31 // Number of buckets |
151 }; |
155 }; |
152 private: |
156 protected: |
153 friend class LazyClassPathEntry; |
157 friend class LazyClassPathEntry; |
154 |
158 |
155 // Performance counters |
159 // Performance counters |
156 static PerfCounter* _perf_accumulated_time; |
160 static PerfCounter* _perf_accumulated_time; |
157 static PerfCounter* _perf_classes_inited; |
161 static PerfCounter* _perf_classes_inited; |
189 |
193 |
190 // First entry in linked list of ClassPathEntry instances |
194 // First entry in linked list of ClassPathEntry instances |
191 static ClassPathEntry* _first_entry; |
195 static ClassPathEntry* _first_entry; |
192 // Last entry in linked list of ClassPathEntry instances |
196 // Last entry in linked list of ClassPathEntry instances |
193 static ClassPathEntry* _last_entry; |
197 static ClassPathEntry* _last_entry; |
|
198 static int _num_entries; |
|
199 |
194 // Hash table used to keep track of loaded packages |
200 // Hash table used to keep track of loaded packages |
195 static PackageHashtable* _package_hash_table; |
201 static PackageHashtable* _package_hash_table; |
196 static const char* _shared_archive; |
202 static const char* _shared_archive; |
|
203 |
|
204 // Info used by CDS |
|
205 CDS_ONLY(static SharedPathsMiscInfo * _shared_paths_misc_info;) |
197 |
206 |
198 // Hash function |
207 // Hash function |
199 static unsigned int hash(const char *s, int n); |
208 static unsigned int hash(const char *s, int n); |
200 // Returns the package file name corresponding to the specified package |
209 // Returns the package file name corresponding to the specified package |
201 // or class name, or null if not found. |
210 // or class name, or null if not found. |
203 // Adds a new package entry for the specified class or package name and |
212 // Adds a new package entry for the specified class or package name and |
204 // corresponding directory or jar file name. |
213 // corresponding directory or jar file name. |
205 static bool add_package(const char *pkgname, int classpath_index, TRAPS); |
214 static bool add_package(const char *pkgname, int classpath_index, TRAPS); |
206 |
215 |
207 // Initialization |
216 // Initialization |
208 static void setup_meta_index(); |
217 static void setup_bootstrap_meta_index(); |
|
218 static void setup_meta_index(const char* meta_index_path, const char* meta_index_dir, |
|
219 int start_index); |
209 static void setup_bootstrap_search_path(); |
220 static void setup_bootstrap_search_path(); |
|
221 static void setup_search_path(char *class_path); |
|
222 |
210 static void load_zip_library(); |
223 static void load_zip_library(); |
211 static ClassPathEntry* create_class_path_entry(char *path, const struct stat* st, |
224 static ClassPathEntry* create_class_path_entry(char *path, const struct stat* st, |
212 bool lazy, TRAPS); |
225 bool lazy, bool throw_exception, TRAPS); |
213 |
226 |
214 // Canonicalizes path names, so strcmp will work properly. This is mainly |
227 // Canonicalizes path names, so strcmp will work properly. This is mainly |
215 // to avoid confusing the zip library |
228 // to avoid confusing the zip library |
216 static bool get_canonical_path(char* orig, char* out, int len); |
229 static bool get_canonical_path(char* orig, char* out, int len); |
217 public: |
230 public: |
218 // Used by the kernel jvm. |
231 static bool update_class_path_entry_list(char *path, |
219 static void update_class_path_entry_list(char *path, |
232 bool check_for_duplicates, |
220 bool check_for_duplicates); |
233 bool throw_exception=true); |
221 static void print_bootclasspath(); |
234 static void print_bootclasspath(); |
222 |
235 |
223 // Timing |
236 // Timing |
224 static PerfCounter* perf_accumulated_time() { return _perf_accumulated_time; } |
237 static PerfCounter* perf_accumulated_time() { return _perf_accumulated_time; } |
225 static PerfCounter* perf_classes_inited() { return _perf_classes_inited; } |
238 static PerfCounter* perf_classes_inited() { return _perf_classes_inited; } |
298 // trailing "/". |
311 // trailing "/". |
299 static objArrayOop get_system_packages(TRAPS); |
312 static objArrayOop get_system_packages(TRAPS); |
300 |
313 |
301 // Initialization |
314 // Initialization |
302 static void initialize(); |
315 static void initialize(); |
|
316 CDS_ONLY(static void initialize_shared_path();) |
303 static void create_package_info_table(); |
317 static void create_package_info_table(); |
304 static void create_package_info_table(HashtableBucket<mtClass> *t, int length, |
318 static void create_package_info_table(HashtableBucket<mtClass> *t, int length, |
305 int number_of_entries); |
319 int number_of_entries); |
306 static int compute_Object_vtable(); |
320 static int compute_Object_vtable(); |
307 |
321 |
312 e = e->next(); |
326 e = e->next(); |
313 } |
327 } |
314 return e; |
328 return e; |
315 } |
329 } |
316 |
330 |
|
331 #if INCLUDE_CDS |
317 // Sharing dump and restore |
332 // Sharing dump and restore |
318 static void copy_package_info_buckets(char** top, char* end); |
333 static void copy_package_info_buckets(char** top, char* end); |
319 static void copy_package_info_table(char** top, char* end); |
334 static void copy_package_info_table(char** top, char* end); |
|
335 |
|
336 static void check_shared_classpath(const char *path); |
|
337 static void finalize_shared_paths_misc_info(); |
|
338 static int get_shared_paths_misc_info_size(); |
|
339 static void* get_shared_paths_misc_info(); |
|
340 static bool check_shared_paths_misc_info(void* info, int size); |
|
341 static void exit_with_path_failure(const char* error, const char* message); |
|
342 #endif |
|
343 |
|
344 static void trace_class_path(const char* msg, const char* name = NULL); |
320 |
345 |
321 // VM monitoring and management support |
346 // VM monitoring and management support |
322 static jlong classloader_time_ms(); |
347 static jlong classloader_time_ms(); |
323 static jlong class_method_total_size(); |
348 static jlong class_method_total_size(); |
324 static jlong class_init_count(); |
349 static jlong class_init_count(); |
339 // Debugging |
364 // Debugging |
340 static void verify() PRODUCT_RETURN; |
365 static void verify() PRODUCT_RETURN; |
341 |
366 |
342 // Force compilation of all methods in all classes in bootstrap class path (stress test) |
367 // Force compilation of all methods in all classes in bootstrap class path (stress test) |
343 #ifndef PRODUCT |
368 #ifndef PRODUCT |
344 private: |
369 protected: |
345 static int _compile_the_world_class_counter; |
370 static int _compile_the_world_class_counter; |
346 static int _compile_the_world_method_counter; |
371 static int _compile_the_world_method_counter; |
347 public: |
372 public: |
348 static void compile_the_world(); |
373 static void compile_the_world(); |
349 static void compile_the_world_in(char* name, Handle loader, TRAPS); |
374 static void compile_the_world_in(char* name, Handle loader, TRAPS); |