comparison src/share/vm/classfile/classLoader.cpp @ 3546:4aa80ca3dbec

Separate compiler bootstrappath from application bootstrappath.
author Thomas Wuerthinger <thomas@wuerthinger.net>
date Sun, 14 Aug 2011 00:55:28 +0200
parents 0654ee04b214
children 22d11b3bc561
comparison
equal deleted inserted replaced
3545:d8c27956ec6e 3546:4aa80ca3dbec
179 } 179 }
180 180
181 181
182 ClassPathEntry::ClassPathEntry() { 182 ClassPathEntry::ClassPathEntry() {
183 set_next(NULL); 183 set_next(NULL);
184 _compiler_thread_only = false;
184 } 185 }
185 186
186 187
187 bool ClassPathEntry::is_lazy() { 188 bool ClassPathEntry::is_lazy() {
188 return false; 189 return false;
437 } 438 }
438 439
439 void ClassLoader::setup_bootstrap_search_path() { 440 void ClassLoader::setup_bootstrap_search_path() {
440 assert(_first_entry == NULL, "should not setup bootstrap class search path twice"); 441 assert(_first_entry == NULL, "should not setup bootstrap class search path twice");
441 char* sys_class_path = os::strdup(Arguments::get_sysclasspath()); 442 char* sys_class_path = os::strdup(Arguments::get_sysclasspath());
443 char* compiler_class_path = os::strdup(Arguments::get_compilerclasspath());
442 if (TraceClassLoading && Verbose) { 444 if (TraceClassLoading && Verbose) {
443 tty->print_cr("[Bootstrap loader class path=%s]", sys_class_path); 445 tty->print_cr("[Bootstrap loader class path=%s]", sys_class_path);
444 } 446 tty->print_cr("[Compiler loader class path=%s]", compiler_class_path);
445 447 }
448
449 setup_bootstrap_search_path(sys_class_path, false);
450 setup_bootstrap_search_path(compiler_class_path, true);
451 }
452
453 void ClassLoader::setup_bootstrap_search_path(char* sys_class_path, bool compiler_cp) {
446 int len = (int)strlen(sys_class_path); 454 int len = (int)strlen(sys_class_path);
447 int end = 0; 455 int end = 0;
448 456
449 // Iterate over class path entries 457 // Iterate over class path entries
450 for (int start = 0; start < len; start = end) { 458 for (int start = 0; start < len; start = end) {
452 end++; 460 end++;
453 } 461 }
454 char* path = NEW_C_HEAP_ARRAY(char, end-start+1); 462 char* path = NEW_C_HEAP_ARRAY(char, end-start+1);
455 strncpy(path, &sys_class_path[start], end-start); 463 strncpy(path, &sys_class_path[start], end-start);
456 path[end-start] = '\0'; 464 path[end-start] = '\0';
457 update_class_path_entry_list(path, false); 465 update_class_path_entry_list(path, false, compiler_cp);
458 FREE_C_HEAP_ARRAY(char, path); 466 FREE_C_HEAP_ARRAY(char, path);
459 while (sys_class_path[end] == os::path_separator()[0]) { 467 while (sys_class_path[end] == os::path_separator()[0]) {
460 end++; 468 end++;
461 } 469 }
462 } 470 }
548 // returns true if entry already on class path 556 // returns true if entry already on class path
549 bool ClassLoader::contains_entry(ClassPathEntry *entry) { 557 bool ClassLoader::contains_entry(ClassPathEntry *entry) {
550 ClassPathEntry* e = _first_entry; 558 ClassPathEntry* e = _first_entry;
551 while (e != NULL) { 559 while (e != NULL) {
552 // assume zip entries have been canonicalized 560 // assume zip entries have been canonicalized
553 if (strcmp(entry->name(), e->name()) == 0) { 561 if (e->compiler_thread_only() == entry->compiler_thread_only() && strcmp(entry->name(), e->name()) == 0) {
554 return true; 562 return true;
555 } 563 }
556 e = e->next(); 564 e = e->next();
557 } 565 }
558 return false; 566 return false;
568 } 576 }
569 } 577 }
570 } 578 }
571 579
572 void ClassLoader::update_class_path_entry_list(const char *path, 580 void ClassLoader::update_class_path_entry_list(const char *path,
573 bool check_for_duplicates) { 581 bool check_for_duplicates,
582 bool compiler_cp) {
574 struct stat st; 583 struct stat st;
575 if (os::stat((char *)path, &st) == 0) { 584 if (os::stat((char *)path, &st) == 0) {
576 // File or directory found 585 // File or directory found
577 ClassPathEntry* new_entry = NULL; 586 ClassPathEntry* new_entry = NULL;
578 create_class_path_entry((char *)path, st, &new_entry, LazyBootClassLoader); 587 create_class_path_entry((char *)path, st, &new_entry, LazyBootClassLoader);
588 new_entry->set_compiler_thread_only(compiler_cp);
579 // The kernel VM adds dynamically to the end of the classloader path and 589 // The kernel VM adds dynamically to the end of the classloader path and
580 // doesn't reorder the bootclasspath which would break java.lang.Package 590 // doesn't reorder the bootclasspath which would break java.lang.Package
581 // (see PackageInfo). 591 // (see PackageInfo).
582 // Add new entry to linked list 592 // Add new entry to linked list
583 if (!check_for_duplicates || !contains_entry(new_entry)) { 593 if (!check_for_duplicates || !contains_entry(new_entry)) {
888 int classpath_index = 0; 898 int classpath_index = 0;
889 { 899 {
890 PerfClassTraceTime vmtimer(perf_sys_class_lookup_time(), 900 PerfClassTraceTime vmtimer(perf_sys_class_lookup_time(),
891 ((JavaThread*) THREAD)->get_thread_stat()->perf_timers_addr(), 901 ((JavaThread*) THREAD)->get_thread_stat()->perf_timers_addr(),
892 PerfClassTraceTime::CLASS_LOAD); 902 PerfClassTraceTime::CLASS_LOAD);
893 ClassPathEntry* e = _first_entry; 903 ClassPathEntry* e = _first_entry;
894 while (e != NULL) { 904 while (e != NULL) {
895 stream = e->open_stream(name); 905 if (THREAD->is_Compiler_thread() || !Universe::_fully_initialized || !e->compiler_thread_only()) {
906 stream = e->open_stream(name);
907 }
896 if (stream != NULL) { 908 if (stream != NULL) {
897 break; 909 break;
898 } 910 }
899 e = e->next(); 911 e = e->next();
900 ++classpath_index; 912 ++classpath_index;