comparison src/share/vm/classfile/classLoader.cpp @ 23462:f46ffa934a46

8143963: improve ClassLoader::trace_class_path to accept an additional outputStream* arg Summary: for fixing a truncation problem on the output from -XX:+TraceClassPaths Reviewed-by: coleenp, jiangli, cjplummer, minqi
author ccheung
date Wed, 02 Dec 2015 17:48:20 -0800
parents 3375833a603e
children b5f3a471e646
comparison
equal deleted inserted replaced
23461:dce765c2ff7d 23462:f46ffa934a46
412 tty->print_cr("Hint: enable -XX:+TraceClassPaths to diagnose the failure"); 412 tty->print_cr("Hint: enable -XX:+TraceClassPaths to diagnose the failure");
413 vm_exit_during_initialization(error, message); 413 vm_exit_during_initialization(error, message);
414 } 414 }
415 #endif 415 #endif
416 416
417 void ClassLoader::trace_class_path(const char* msg, const char* name) { 417 void ClassLoader::trace_class_path(outputStream* out, const char* msg, const char* name) {
418 if (!TraceClassPaths) { 418 if (!TraceClassPaths) {
419 return; 419 return;
420 } 420 }
421 421
422 if (msg) { 422 if (msg) {
423 tty->print("%s", msg); 423 out->print("%s", msg);
424 } 424 }
425 if (name) { 425 if (name) {
426 if (strlen(name) < 256) { 426 if (strlen(name) < 256) {
427 tty->print("%s", name); 427 out->print("%s", name);
428 } else { 428 } else {
429 // For very long paths, we need to print each character separately, 429 // For very long paths, we need to print each character separately,
430 // as print_cr() has a length limit 430 // as print_cr() has a length limit
431 while (name[0] != '\0') { 431 while (name[0] != '\0') {
432 tty->print("%c", name[0]); 432 out->print("%c", name[0]);
433 name++; 433 name++;
434 } 434 }
435 } 435 }
436 } 436 }
437 if (msg && msg[0] == '[') { 437 if (msg && msg[0] == '[') {
438 tty->print_cr("]"); 438 out->print_cr("]");
439 } else { 439 } else {
440 tty->cr(); 440 out->cr();
441 } 441 }
442 } 442 }
443 443
444 void ClassLoader::setup_bootstrap_meta_index() { 444 void ClassLoader::setup_bootstrap_meta_index() {
445 // Set up meta index which allows us to open boot jars lazily if 445 // Set up meta index which allows us to open boot jars lazily if
581 const char* sys_class_path = Arguments::get_sysclasspath(); 581 const char* sys_class_path = Arguments::get_sysclasspath();
582 if (PrintSharedArchiveAndExit) { 582 if (PrintSharedArchiveAndExit) {
583 // Don't print sys_class_path - this is the bootcp of this current VM process, not necessarily 583 // Don't print sys_class_path - this is the bootcp of this current VM process, not necessarily
584 // the same as the bootcp of the shared archive. 584 // the same as the bootcp of the shared archive.
585 } else { 585 } else {
586 trace_class_path("[Bootstrap loader class path=", sys_class_path); 586 trace_class_path(tty, "[Bootstrap loader class path=", sys_class_path);
587 } 587 }
588 #if INCLUDE_CDS 588 #if INCLUDE_CDS
589 if (DumpSharedSpaces) { 589 if (DumpSharedSpaces) {
590 _shared_paths_misc_info->add_boot_classpath(sys_class_path); 590 _shared_paths_misc_info->add_boot_classpath(sys_class_path);
591 } 591 }