172 char* pkg = _meta_package_names[i];
173 size_t pkg_len = strlen(pkg);
174 size_t min_len = MIN2(class_name_len, pkg_len);
175 if (!strncmp(class_name, pkg, min_len)) {
176 return true;
177 }
178 }
179 return false;
180 }
181
182
183 ClassPathEntry::ClassPathEntry() {
184 set_next(NULL);
185 }
186
187
188 bool ClassPathEntry::is_lazy() {
189 return false;
190 }
191
192 ClassPathDirEntry::ClassPathDirEntry(char* dir) : ClassPathEntry() {
193 _dir = NEW_C_HEAP_ARRAY(char, strlen(dir)+1, mtClass);
194 strcpy(_dir, dir);
195 }
196
197
198 ClassFileStream* ClassPathDirEntry::open_stream(const char* name, TRAPS) {
199 // construct full path name
200 char path[JVM_MAXPATHLEN];
201 if (jio_snprintf(path, sizeof(path), "%s%s%s", _dir, os::file_separator(), name) == -1) {
202 return NULL;
203 }
204 // check if file exists
205 struct stat st;
206 if (os::stat(path, &st) == 0) {
207 #if INCLUDE_CDS
208 if (DumpSharedSpaces) {
209 // We have already check in ClassLoader::check_shared_classpath() that the directory is empty, so
210 // we should never find a file underneath it -- unless user has added a new file while we are running
211 // the dump, in which case let's quit!
212 ShouldNotReachHere();
213 }
214 #endif
218 // read contents into resource array
219 u1* buffer = NEW_RESOURCE_ARRAY(u1, st.st_size);
220 size_t num_read = os::read(file_handle, (char*) buffer, st.st_size);
221 // close file
222 os::close(file_handle);
223 // construct ClassFileStream
224 if (num_read == (size_t)st.st_size) {
225 if (UsePerfData) {
226 ClassLoader::perf_sys_classfile_bytes_read()->inc(num_read);
227 }
228 return new ClassFileStream(buffer, st.st_size, _dir); // Resource allocated
229 }
230 }
231 }
232 return NULL;
233 }
234
235
236 ClassPathZipEntry::ClassPathZipEntry(jzfile* zip, const char* zip_name) : ClassPathEntry() {
237 _zip = zip;
238 _zip_name = NEW_C_HEAP_ARRAY(char, strlen(zip_name)+1, mtClass);
239 strcpy(_zip_name, zip_name);
240 }
241
242 ClassPathZipEntry::~ClassPathZipEntry() {
243 if (ZipClose != NULL) {
244 (*ZipClose)(_zip);
245 }
246 FREE_C_HEAP_ARRAY(char, _zip_name, mtClass);
247 }
248
249 u1* ClassPathZipEntry::open_entry(const char* name, jint* filesize, bool nul_terminate, TRAPS) {
250 // enable call to C land
251 JavaThread* thread = JavaThread::current();
252 ThreadToNativeFromVM ttn(thread);
253 // check whether zip archive contains name
254 jint name_len;
255 jzentry* entry = (*FindEntry)(_zip, name, filesize, &name_len);
256 if (entry == NULL) return NULL;
257 u1* buffer;
258 char name_buf[128];
259 char* filename;
287 return NULL;
288 }
289 if (UsePerfData) {
290 ClassLoader::perf_sys_classfile_bytes_read()->inc(filesize);
291 }
292 return new ClassFileStream(buffer, filesize, _zip_name); // Resource allocated
293 }
294
295 // invoke function for each entry in the zip file
296 void ClassPathZipEntry::contents_do(void f(const char* name, void* context), void* context) {
297 JavaThread* thread = JavaThread::current();
298 HandleMark handle_mark(thread);
299 ThreadToNativeFromVM ttn(thread);
300 for (int n = 0; ; n++) {
301 jzentry * ze = ((*GetNextEntry)(_zip, n));
302 if (ze == NULL) break;
303 (*f)(ze->name, context);
304 }
305 }
306
307 LazyClassPathEntry::LazyClassPathEntry(char* path, const struct stat* st, bool throw_exception) : ClassPathEntry() {
308 _path = os::strdup_check_oom(path);
309 _st = *st;
310 _meta_index = NULL;
311 _resolved_entry = NULL;
312 _has_error = false;
313 _throw_exception = throw_exception;
314 }
315
316 LazyClassPathEntry::~LazyClassPathEntry() {
317 os::free(_path);
318 }
319
320 bool LazyClassPathEntry::is_jar_file() {
321 return ((_st.st_mode & S_IFREG) == S_IFREG);
322 }
323
324 ClassPathEntry* LazyClassPathEntry::resolve_entry(TRAPS) {
325 if (_resolved_entry != NULL) {
326 return (ClassPathEntry*) _resolved_entry;
327 }
328 ClassPathEntry* new_entry = NULL;
329 new_entry = ClassLoader::create_class_path_entry(_path, &_st, false, _throw_exception, CHECK_NULL);
330 if (!_throw_exception && new_entry == NULL) {
331 assert(!HAS_PENDING_EXCEPTION, "must be");
332 return NULL;
333 }
334 {
335 ThreadCritical tc;
336 if (_resolved_entry == NULL) {
337 _resolved_entry = new_entry;
546 #if INCLUDE_CDS
547 void ClassLoader::check_shared_classpath(const char *path) {
548 if (strcmp(path, "") == 0) {
549 exit_with_path_failure("Cannot have empty path in archived classpaths", NULL);
550 }
551
552 struct stat st;
553 if (os::stat(path, &st) == 0) {
554 if ((st.st_mode & S_IFREG) != S_IFREG) { // is directory
555 if (!os::dir_is_empty(path)) {
556 tty->print_cr("Error: non-empty directory '%s'", path);
557 exit_with_path_failure("CDS allows only empty directories in archived classpaths", NULL);
558 }
559 }
560 }
561 }
562 #endif
563
564 void ClassLoader::setup_bootstrap_search_path() {
565 assert(_first_entry == NULL, "should not setup bootstrap class search path twice");
566 char* sys_class_path = os::strdup_check_oom(Arguments::get_sysclasspath());
567 if (!PrintSharedArchiveAndExit) {
568 trace_class_path("[Bootstrap loader class path=", sys_class_path);
569 }
570 #if INCLUDE_CDS
571 if (DumpSharedSpaces) {
572 _shared_paths_misc_info->add_boot_classpath(Arguments::get_sysclasspath());
573 }
574 #endif
575 setup_search_path(sys_class_path);
576 os::free(sys_class_path);
577 }
578
579 #if INCLUDE_CDS
580 int ClassLoader::get_shared_paths_misc_info_size() {
581 return _shared_paths_misc_info->get_used_bytes();
582 }
583
584 void* ClassLoader::get_shared_paths_misc_info() {
585 return _shared_paths_misc_info->buffer();
586 }
587
588 bool ClassLoader::check_shared_paths_misc_info(void *buf, int size) {
589 SharedPathsMiscInfo* checker = SharedClassUtil::allocate_shared_paths_misc_info((char*)buf, size);
590 bool result = checker->check();
591 delete checker;
592 return result;
593 }
594 #endif
595
596 void ClassLoader::setup_search_path(char *class_path) {
597 int offset = 0;
598 int len = (int)strlen(class_path);
599 int end = 0;
600
601 // Iterate over class path entries
602 for (int start = 0; start < len; start = end) {
603 while (class_path[end] && class_path[end] != os::path_separator()[0]) {
604 end++;
605 }
606 EXCEPTION_MARK;
607 ResourceMark rm(THREAD);
608 char* path = NEW_RESOURCE_ARRAY(char, end - start + 1);
609 strncpy(path, &class_path[start], end - start);
610 path[end - start] = '\0';
611 update_class_path_entry_list(path, false);
612 #if INCLUDE_CDS
613 if (DumpSharedSpaces) {
614 check_shared_classpath(path);
615 }
616 #endif
617 while (class_path[end] == os::path_separator()[0]) {
618 end++;
619 }
620 }
621 }
622
623 ClassPathEntry* ClassLoader::create_class_path_entry(char *path, const struct stat* st,
624 bool lazy, bool throw_exception, TRAPS) {
625 JavaThread* thread = JavaThread::current();
626 if (lazy) {
627 return new LazyClassPathEntry(path, st, throw_exception);
628 }
629 ClassPathEntry* new_entry = NULL;
630 if ((st->st_mode & S_IFREG) == S_IFREG) {
631 // Regular file, should be a zip file
632 // Canonicalized filename
633 char canonical_path[JVM_MAXPATHLEN];
634 if (!get_canonical_path(path, canonical_path, JVM_MAXPATHLEN)) {
635 // This matches the classic VM
636 if (throw_exception) {
637 THROW_MSG_(vmSymbols::java_io_IOException(), "Bad pathname", NULL);
638 } else {
639 return NULL;
640 }
641 }
642 char* error_msg = NULL;
643 jzfile* zip;
670 }
671 }
672 } else {
673 // Directory
674 new_entry = new ClassPathDirEntry(path);
675 if (TraceClassLoading || TraceClassPaths) {
676 tty->print_cr("[Path %s]", path);
677 }
678 }
679 return new_entry;
680 }
681
682
683 // Create a class path zip entry for a given path (return NULL if not found
684 // or zip/JAR file cannot be opened)
685 ClassPathZipEntry* ClassLoader::create_class_path_zip_entry(const char *path) {
686 // check for a regular file
687 struct stat st;
688 if (os::stat(path, &st) == 0) {
689 if ((st.st_mode & S_IFREG) == S_IFREG) {
690 char orig_path[JVM_MAXPATHLEN];
691 char canonical_path[JVM_MAXPATHLEN];
692
693 strcpy(orig_path, path);
694 if (get_canonical_path(orig_path, canonical_path, JVM_MAXPATHLEN)) {
695 char* error_msg = NULL;
696 jzfile* zip;
697 {
698 // enable call to C land
699 JavaThread* thread = JavaThread::current();
700 ThreadToNativeFromVM ttn(thread);
701 HandleMark hm(thread);
702 zip = (*ZipOpen)(canonical_path, &error_msg);
703 }
704 if (zip != NULL && error_msg == NULL) {
705 // create using canonical path
706 return new ClassPathZipEntry(zip, canonical_path);
707 }
708 }
709 }
710 }
711 return NULL;
712 }
713
714 // returns true if entry already on class path
720 return true;
721 }
722 e = e->next();
723 }
724 return false;
725 }
726
727 void ClassLoader::add_to_list(ClassPathEntry *new_entry) {
728 if (new_entry != NULL) {
729 if (_last_entry == NULL) {
730 _first_entry = _last_entry = new_entry;
731 } else {
732 _last_entry->set_next(new_entry);
733 _last_entry = new_entry;
734 }
735 }
736 _num_entries ++;
737 }
738
739 // Returns true IFF the file/dir exists and the entry was successfully created.
740 bool ClassLoader::update_class_path_entry_list(char *path,
741 bool check_for_duplicates,
742 bool throw_exception) {
743 struct stat st;
744 if (os::stat(path, &st) == 0) {
745 // File or directory found
746 ClassPathEntry* new_entry = NULL;
747 Thread* THREAD = Thread::current();
748 new_entry = create_class_path_entry(path, &st, LazyBootClassLoader, throw_exception, CHECK_(false));
749 if (new_entry == NULL) {
750 return false;
751 }
752 // The kernel VM adds dynamically to the end of the classloader path and
753 // doesn't reorder the bootclasspath which would break java.lang.Package
754 // (see PackageInfo).
755 // Add new entry to linked list
756 if (!check_for_duplicates || !contains_entry(new_entry)) {
757 ClassLoaderExt::add_class_path_entry(path, check_for_duplicates, new_entry);
758 }
759 return true;
760 } else {
761 #if INCLUDE_CDS
762 if (DumpSharedSpaces) {
763 _shared_paths_misc_info->add_nonexist_path(path);
764 }
765 return false;
766 #endif
767 }
768 }
769
770 void ClassLoader::print_bootclasspath() {
771 ClassPathEntry* e = _first_entry;
772 tty->print("[bootclasspath= ");
773 while (e != NULL) {
774 tty->print("%s ;", e->name());
775 e = e->next();
776 }
777 tty->print_cr("]");
778 }
779
780 void ClassLoader::load_zip_library() {
781 assert(ZipOpen == NULL, "should not load zip library twice");
782 // First make sure native library is loaded
783 os::native_java_library();
784 // Load zip library
785 char path[JVM_MAXPATHLEN];
786 char ebuf[1024];
1252
1253 jlong ClassLoader::class_link_time_ms() {
1254 return UsePerfData ?
1255 Management::ticks_to_ms(_perf_class_link_time->get_value()) : -1;
1256 }
1257
1258 int ClassLoader::compute_Object_vtable() {
1259 // hardwired for JDK1.2 -- would need to duplicate class file parsing
1260 // code to determine actual value from file
1261 // Would be value '11' if finals were in vtable
1262 int JDK_1_2_Object_vtable_size = 5;
1263 return JDK_1_2_Object_vtable_size * vtableEntry::size();
1264 }
1265
1266
1267 void classLoader_init() {
1268 ClassLoader::initialize();
1269 }
1270
1271
1272 bool ClassLoader::get_canonical_path(char* orig, char* out, int len) {
1273 assert(orig != NULL && out != NULL && len > 0, "bad arguments");
1274 if (CanonicalizeEntry != NULL) {
1275 JNIEnv* env = JavaThread::current()->jni_environment();
1276 if ((CanonicalizeEntry)(env, os::native_path(orig), out, len) < 0) {
1277 return false;
1278 }
1279 } else {
1280 // On JDK 1.2.2 the Canonicalize does not exist, so just do nothing
1281 strncpy(out, orig, len);
1282 out[len - 1] = '\0';
1283 }
1284 return true;
1285 }
1286
1287 #ifndef PRODUCT
1288
1289 void ClassLoader::verify() {
1290 _package_hash_table->verify();
1291 }
1292
1293
1294 // CompileTheWorld
1295 //
1296 // Iterates over all class path entries and forces compilation of all methods
|
172 char* pkg = _meta_package_names[i];
173 size_t pkg_len = strlen(pkg);
174 size_t min_len = MIN2(class_name_len, pkg_len);
175 if (!strncmp(class_name, pkg, min_len)) {
176 return true;
177 }
178 }
179 return false;
180 }
181
182
183 ClassPathEntry::ClassPathEntry() {
184 set_next(NULL);
185 }
186
187
188 bool ClassPathEntry::is_lazy() {
189 return false;
190 }
191
192 ClassPathDirEntry::ClassPathDirEntry(const char* dir) : ClassPathEntry() {
193 char* copy = NEW_C_HEAP_ARRAY(char, strlen(dir)+1, mtClass);
194 strcpy(copy, dir);
195 _dir = copy;
196 }
197
198
199 ClassFileStream* ClassPathDirEntry::open_stream(const char* name, TRAPS) {
200 // construct full path name
201 char path[JVM_MAXPATHLEN];
202 if (jio_snprintf(path, sizeof(path), "%s%s%s", _dir, os::file_separator(), name) == -1) {
203 return NULL;
204 }
205 // check if file exists
206 struct stat st;
207 if (os::stat(path, &st) == 0) {
208 #if INCLUDE_CDS
209 if (DumpSharedSpaces) {
210 // We have already check in ClassLoader::check_shared_classpath() that the directory is empty, so
211 // we should never find a file underneath it -- unless user has added a new file while we are running
212 // the dump, in which case let's quit!
213 ShouldNotReachHere();
214 }
215 #endif
219 // read contents into resource array
220 u1* buffer = NEW_RESOURCE_ARRAY(u1, st.st_size);
221 size_t num_read = os::read(file_handle, (char*) buffer, st.st_size);
222 // close file
223 os::close(file_handle);
224 // construct ClassFileStream
225 if (num_read == (size_t)st.st_size) {
226 if (UsePerfData) {
227 ClassLoader::perf_sys_classfile_bytes_read()->inc(num_read);
228 }
229 return new ClassFileStream(buffer, st.st_size, _dir); // Resource allocated
230 }
231 }
232 }
233 return NULL;
234 }
235
236
237 ClassPathZipEntry::ClassPathZipEntry(jzfile* zip, const char* zip_name) : ClassPathEntry() {
238 _zip = zip;
239 char *copy = NEW_C_HEAP_ARRAY(char, strlen(zip_name)+1, mtClass);
240 strcpy(copy, zip_name);
241 _zip_name = copy;
242 }
243
244 ClassPathZipEntry::~ClassPathZipEntry() {
245 if (ZipClose != NULL) {
246 (*ZipClose)(_zip);
247 }
248 FREE_C_HEAP_ARRAY(char, _zip_name, mtClass);
249 }
250
251 u1* ClassPathZipEntry::open_entry(const char* name, jint* filesize, bool nul_terminate, TRAPS) {
252 // enable call to C land
253 JavaThread* thread = JavaThread::current();
254 ThreadToNativeFromVM ttn(thread);
255 // check whether zip archive contains name
256 jint name_len;
257 jzentry* entry = (*FindEntry)(_zip, name, filesize, &name_len);
258 if (entry == NULL) return NULL;
259 u1* buffer;
260 char name_buf[128];
261 char* filename;
289 return NULL;
290 }
291 if (UsePerfData) {
292 ClassLoader::perf_sys_classfile_bytes_read()->inc(filesize);
293 }
294 return new ClassFileStream(buffer, filesize, _zip_name); // Resource allocated
295 }
296
297 // invoke function for each entry in the zip file
298 void ClassPathZipEntry::contents_do(void f(const char* name, void* context), void* context) {
299 JavaThread* thread = JavaThread::current();
300 HandleMark handle_mark(thread);
301 ThreadToNativeFromVM ttn(thread);
302 for (int n = 0; ; n++) {
303 jzentry * ze = ((*GetNextEntry)(_zip, n));
304 if (ze == NULL) break;
305 (*f)(ze->name, context);
306 }
307 }
308
309 LazyClassPathEntry::LazyClassPathEntry(const char* path, const struct stat* st, bool throw_exception) : ClassPathEntry() {
310 _path = os::strdup_check_oom(path);
311 _st = *st;
312 _meta_index = NULL;
313 _resolved_entry = NULL;
314 _has_error = false;
315 _throw_exception = throw_exception;
316 }
317
318 LazyClassPathEntry::~LazyClassPathEntry() {
319 os::free((void*)_path);
320 }
321
322 bool LazyClassPathEntry::is_jar_file() {
323 return ((_st.st_mode & S_IFREG) == S_IFREG);
324 }
325
326 ClassPathEntry* LazyClassPathEntry::resolve_entry(TRAPS) {
327 if (_resolved_entry != NULL) {
328 return (ClassPathEntry*) _resolved_entry;
329 }
330 ClassPathEntry* new_entry = NULL;
331 new_entry = ClassLoader::create_class_path_entry(_path, &_st, false, _throw_exception, CHECK_NULL);
332 if (!_throw_exception && new_entry == NULL) {
333 assert(!HAS_PENDING_EXCEPTION, "must be");
334 return NULL;
335 }
336 {
337 ThreadCritical tc;
338 if (_resolved_entry == NULL) {
339 _resolved_entry = new_entry;
548 #if INCLUDE_CDS
549 void ClassLoader::check_shared_classpath(const char *path) {
550 if (strcmp(path, "") == 0) {
551 exit_with_path_failure("Cannot have empty path in archived classpaths", NULL);
552 }
553
554 struct stat st;
555 if (os::stat(path, &st) == 0) {
556 if ((st.st_mode & S_IFREG) != S_IFREG) { // is directory
557 if (!os::dir_is_empty(path)) {
558 tty->print_cr("Error: non-empty directory '%s'", path);
559 exit_with_path_failure("CDS allows only empty directories in archived classpaths", NULL);
560 }
561 }
562 }
563 }
564 #endif
565
566 void ClassLoader::setup_bootstrap_search_path() {
567 assert(_first_entry == NULL, "should not setup bootstrap class search path twice");
568 const char* sys_class_path = Arguments::get_sysclasspath();
569 if (PrintSharedArchiveAndExit) {
570 // Don't print sys_class_path - this is the bootcp of this current VM process, not necessarily
571 // the same as the bootcp of the shared archive.
572 } else {
573 trace_class_path("[Bootstrap loader class path=", sys_class_path);
574 }
575 #if INCLUDE_CDS
576 if (DumpSharedSpaces) {
577 _shared_paths_misc_info->add_boot_classpath(sys_class_path);
578 }
579 #endif
580 setup_search_path(sys_class_path);
581 }
582
583 #if INCLUDE_CDS
584 int ClassLoader::get_shared_paths_misc_info_size() {
585 return _shared_paths_misc_info->get_used_bytes();
586 }
587
588 void* ClassLoader::get_shared_paths_misc_info() {
589 return _shared_paths_misc_info->buffer();
590 }
591
592 bool ClassLoader::check_shared_paths_misc_info(void *buf, int size) {
593 SharedPathsMiscInfo* checker = SharedClassUtil::allocate_shared_paths_misc_info((char*)buf, size);
594 bool result = checker->check();
595 delete checker;
596 return result;
597 }
598 #endif
599
600 void ClassLoader::setup_search_path(const char *class_path) {
601 int offset = 0;
602 int len = (int)strlen(class_path);
603 int end = 0;
604
605 // Iterate over class path entries
606 for (int start = 0; start < len; start = end) {
607 while (class_path[end] && class_path[end] != os::path_separator()[0]) {
608 end++;
609 }
610 EXCEPTION_MARK;
611 ResourceMark rm(THREAD);
612 char* path = NEW_RESOURCE_ARRAY(char, end - start + 1);
613 strncpy(path, &class_path[start], end - start);
614 path[end - start] = '\0';
615 update_class_path_entry_list(path, false);
616 #if INCLUDE_CDS
617 if (DumpSharedSpaces) {
618 check_shared_classpath(path);
619 }
620 #endif
621 while (class_path[end] == os::path_separator()[0]) {
622 end++;
623 }
624 }
625 }
626
627 ClassPathEntry* ClassLoader::create_class_path_entry(const char *path, const struct stat* st,
628 bool lazy, bool throw_exception, TRAPS) {
629 JavaThread* thread = JavaThread::current();
630 if (lazy) {
631 return new LazyClassPathEntry(path, st, throw_exception);
632 }
633 ClassPathEntry* new_entry = NULL;
634 if ((st->st_mode & S_IFREG) == S_IFREG) {
635 // Regular file, should be a zip file
636 // Canonicalized filename
637 char canonical_path[JVM_MAXPATHLEN];
638 if (!get_canonical_path(path, canonical_path, JVM_MAXPATHLEN)) {
639 // This matches the classic VM
640 if (throw_exception) {
641 THROW_MSG_(vmSymbols::java_io_IOException(), "Bad pathname", NULL);
642 } else {
643 return NULL;
644 }
645 }
646 char* error_msg = NULL;
647 jzfile* zip;
674 }
675 }
676 } else {
677 // Directory
678 new_entry = new ClassPathDirEntry(path);
679 if (TraceClassLoading || TraceClassPaths) {
680 tty->print_cr("[Path %s]", path);
681 }
682 }
683 return new_entry;
684 }
685
686
687 // Create a class path zip entry for a given path (return NULL if not found
688 // or zip/JAR file cannot be opened)
689 ClassPathZipEntry* ClassLoader::create_class_path_zip_entry(const char *path) {
690 // check for a regular file
691 struct stat st;
692 if (os::stat(path, &st) == 0) {
693 if ((st.st_mode & S_IFREG) == S_IFREG) {
694 char canonical_path[JVM_MAXPATHLEN];
695 if (get_canonical_path(path, canonical_path, JVM_MAXPATHLEN)) {
696 char* error_msg = NULL;
697 jzfile* zip;
698 {
699 // enable call to C land
700 JavaThread* thread = JavaThread::current();
701 ThreadToNativeFromVM ttn(thread);
702 HandleMark hm(thread);
703 zip = (*ZipOpen)(canonical_path, &error_msg);
704 }
705 if (zip != NULL && error_msg == NULL) {
706 // create using canonical path
707 return new ClassPathZipEntry(zip, canonical_path);
708 }
709 }
710 }
711 }
712 return NULL;
713 }
714
715 // returns true if entry already on class path
721 return true;
722 }
723 e = e->next();
724 }
725 return false;
726 }
727
728 void ClassLoader::add_to_list(ClassPathEntry *new_entry) {
729 if (new_entry != NULL) {
730 if (_last_entry == NULL) {
731 _first_entry = _last_entry = new_entry;
732 } else {
733 _last_entry->set_next(new_entry);
734 _last_entry = new_entry;
735 }
736 }
737 _num_entries ++;
738 }
739
740 // Returns true IFF the file/dir exists and the entry was successfully created.
741 bool ClassLoader::update_class_path_entry_list(const char *path,
742 bool check_for_duplicates,
743 bool throw_exception) {
744 struct stat st;
745 if (os::stat(path, &st) == 0) {
746 // File or directory found
747 ClassPathEntry* new_entry = NULL;
748 Thread* THREAD = Thread::current();
749 new_entry = create_class_path_entry(path, &st, LazyBootClassLoader, throw_exception, CHECK_(false));
750 if (new_entry == NULL) {
751 return false;
752 }
753 // The kernel VM adds dynamically to the end of the classloader path and
754 // doesn't reorder the bootclasspath which would break java.lang.Package
755 // (see PackageInfo).
756 // Add new entry to linked list
757 if (!check_for_duplicates || !contains_entry(new_entry)) {
758 ClassLoaderExt::add_class_path_entry(path, check_for_duplicates, new_entry);
759 }
760 return true;
761 } else {
762 #if INCLUDE_CDS
763 if (DumpSharedSpaces) {
764 _shared_paths_misc_info->add_nonexist_path(path);
765 }
766 #endif
767 return false;
768 }
769 }
770
771 void ClassLoader::print_bootclasspath() {
772 ClassPathEntry* e = _first_entry;
773 tty->print("[bootclasspath= ");
774 while (e != NULL) {
775 tty->print("%s ;", e->name());
776 e = e->next();
777 }
778 tty->print_cr("]");
779 }
780
781 void ClassLoader::load_zip_library() {
782 assert(ZipOpen == NULL, "should not load zip library twice");
783 // First make sure native library is loaded
784 os::native_java_library();
785 // Load zip library
786 char path[JVM_MAXPATHLEN];
787 char ebuf[1024];
1253
1254 jlong ClassLoader::class_link_time_ms() {
1255 return UsePerfData ?
1256 Management::ticks_to_ms(_perf_class_link_time->get_value()) : -1;
1257 }
1258
1259 int ClassLoader::compute_Object_vtable() {
1260 // hardwired for JDK1.2 -- would need to duplicate class file parsing
1261 // code to determine actual value from file
1262 // Would be value '11' if finals were in vtable
1263 int JDK_1_2_Object_vtable_size = 5;
1264 return JDK_1_2_Object_vtable_size * vtableEntry::size();
1265 }
1266
1267
1268 void classLoader_init() {
1269 ClassLoader::initialize();
1270 }
1271
1272
1273 bool ClassLoader::get_canonical_path(const char* orig, char* out, int len) {
1274 assert(orig != NULL && out != NULL && len > 0, "bad arguments");
1275 if (CanonicalizeEntry != NULL) {
1276 JavaThread* THREAD = JavaThread::current();
1277 JNIEnv* env = THREAD->jni_environment();
1278 ResourceMark rm(THREAD);
1279
1280 // os::native_path writes into orig_copy
1281 char* orig_copy = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, strlen(orig)+1);
1282 strcpy(orig_copy, orig);
1283 if ((CanonicalizeEntry)(env, os::native_path(orig_copy), out, len) < 0) {
1284 return false;
1285 }
1286 } else {
1287 // On JDK 1.2.2 the Canonicalize does not exist, so just do nothing
1288 strncpy(out, orig, len);
1289 out[len - 1] = '\0';
1290 }
1291 return true;
1292 }
1293
1294 #ifndef PRODUCT
1295
1296 void ClassLoader::verify() {
1297 _package_hash_table->verify();
1298 }
1299
1300
1301 // CompileTheWorld
1302 //
1303 // Iterates over all class path entries and forces compilation of all methods
|