20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "classfile/classFileStream.hpp"
27 #include "classfile/classLoader.hpp"
28 #include "classfile/classLoaderData.inline.hpp"
29 #include "classfile/classLoaderExt.hpp"
30 #include "classfile/javaClasses.hpp"
31 #include "classfile/jimage.hpp"
32 #include "classfile/klassFactory.hpp"
33 #include "classfile/systemDictionary.hpp"
34 #include "classfile/vmSymbols.hpp"
35 #include "compiler/compileBroker.hpp"
36 #include "gc/shared/collectedHeap.inline.hpp"
37 #include "gc/shared/generation.hpp"
38 #include "interpreter/bytecodeStream.hpp"
39 #include "interpreter/oopMapCache.hpp"
40 #include "memory/allocation.inline.hpp"
41 #include "memory/filemap.hpp"
42 #include "memory/oopFactory.hpp"
43 #include "memory/universe.inline.hpp"
44 #include "oops/instanceKlass.hpp"
45 #include "oops/instanceRefKlass.hpp"
46 #include "oops/objArrayOop.inline.hpp"
47 #include "oops/oop.inline.hpp"
48 #include "oops/symbol.hpp"
49 #include "prims/jvm_misc.hpp"
50 #include "runtime/arguments.hpp"
51 #include "runtime/compilationPolicy.hpp"
52 #include "runtime/fprofiler.hpp"
53 #include "runtime/handles.hpp"
54 #include "runtime/handles.inline.hpp"
55 #include "runtime/init.hpp"
56 #include "runtime/interfaceSupport.hpp"
57 #include "runtime/java.hpp"
58 #include "runtime/javaCalls.hpp"
59 #include "runtime/os.hpp"
400 (*JImageResourceIterator)(_jimage, (JImageResourceVisitor_t)ctw_visitor, (void *)&loader);
401 if (HAS_PENDING_EXCEPTION) {
402 if (PENDING_EXCEPTION->is_a(SystemDictionary::OutOfMemoryError_klass())) {
403 CLEAR_PENDING_EXCEPTION;
404 tty->print_cr("\nCompileTheWorld : Ran out of memory\n");
405 tty->print_cr("Increase class metadata storage if a limit was set");
406 } else {
407 tty->print_cr("\nCompileTheWorld : Unexpected exception occurred\n");
408 }
409 }
410 }
411
412 bool ClassPathImageEntry::is_jrt() {
413 return string_ends_with(name(), BOOT_IMAGE_NAME);
414 }
415 #endif
416
417 #if INCLUDE_CDS
418 void ClassLoader::exit_with_path_failure(const char* error, const char* message) {
419 assert(DumpSharedSpaces, "only called at dump time");
420 tty->print_cr("Hint: enable -XX:+TraceClassPaths to diagnose the failure");
421 vm_exit_during_initialization(error, message);
422 }
423 #endif
424
425 void ClassLoader::trace_class_path(outputStream* out, const char* msg, const char* name) {
426 if (!TraceClassPaths) {
427 return;
428 }
429
430 if (msg) {
431 out->print("%s", msg);
432 }
433 if (name) {
434 if (strlen(name) < 256) {
435 out->print("%s", name);
436 } else {
437 // For very long paths, we need to print each character separately,
438 // as print_cr() has a length limit
439 while (name[0] != '\0') {
440 out->print("%c", name[0]);
441 name++;
442 }
443 }
444 }
445 if (msg && msg[0] == '[') {
446 out->print_cr("]");
447 } else {
448 out->cr();
449 }
561 new_entry = new ClassPathZipEntry(zip, path);
562 } else {
563 ResourceMark rm(thread);
564 char *msg;
565 if (error_msg == NULL) {
566 msg = NEW_RESOURCE_ARRAY(char, strlen(path) + 128); ;
567 jio_snprintf(msg, strlen(path) + 127, "error in opening JAR file %s", path);
568 } else {
569 int len = (int)(strlen(path) + strlen(error_msg) + 128);
570 msg = NEW_RESOURCE_ARRAY(char, len); ;
571 jio_snprintf(msg, len - 1, "error in opening JAR file <%s> %s", error_msg, path);
572 }
573 // Don't complain about bad jar files added via -Xbootclasspath/a:.
574 if (throw_exception && is_init_completed()) {
575 THROW_MSG_(vmSymbols::java_lang_ClassNotFoundException(), msg, NULL);
576 } else {
577 return NULL;
578 }
579 }
580 }
581 if (TraceClassPaths) {
582 tty->print_cr("[Opened %s]", path);
583 }
584 log_info(classload)("opened: %s", path);
585 } else {
586 // Directory
587 new_entry = new ClassPathDirEntry(path);
588 log_info(classload)("path: %s", path);
589 }
590 return new_entry;
591 }
592
593
594 // Create a class path zip entry for a given path (return NULL if not found
595 // or zip/JAR file cannot be opened)
596 ClassPathZipEntry* ClassLoader::create_class_path_zip_entry(const char *path) {
597 // check for a regular file
598 struct stat st;
599 if (os::stat(path, &st) == 0) {
600 if ((st.st_mode & S_IFREG) == S_IFREG) {
601 char canonical_path[JVM_MAXPATHLEN];
602 if (get_canonical_path(path, canonical_path, JVM_MAXPATHLEN)) {
603 char* error_msg = NULL;
|
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "classfile/classFileStream.hpp"
27 #include "classfile/classLoader.hpp"
28 #include "classfile/classLoaderData.inline.hpp"
29 #include "classfile/classLoaderExt.hpp"
30 #include "classfile/javaClasses.hpp"
31 #include "classfile/jimage.hpp"
32 #include "classfile/klassFactory.hpp"
33 #include "classfile/systemDictionary.hpp"
34 #include "classfile/vmSymbols.hpp"
35 #include "compiler/compileBroker.hpp"
36 #include "gc/shared/collectedHeap.inline.hpp"
37 #include "gc/shared/generation.hpp"
38 #include "interpreter/bytecodeStream.hpp"
39 #include "interpreter/oopMapCache.hpp"
40 #include "logging/logTag.hpp"
41 #include "memory/allocation.inline.hpp"
42 #include "memory/filemap.hpp"
43 #include "memory/oopFactory.hpp"
44 #include "memory/universe.inline.hpp"
45 #include "oops/instanceKlass.hpp"
46 #include "oops/instanceRefKlass.hpp"
47 #include "oops/objArrayOop.inline.hpp"
48 #include "oops/oop.inline.hpp"
49 #include "oops/symbol.hpp"
50 #include "prims/jvm_misc.hpp"
51 #include "runtime/arguments.hpp"
52 #include "runtime/compilationPolicy.hpp"
53 #include "runtime/fprofiler.hpp"
54 #include "runtime/handles.hpp"
55 #include "runtime/handles.inline.hpp"
56 #include "runtime/init.hpp"
57 #include "runtime/interfaceSupport.hpp"
58 #include "runtime/java.hpp"
59 #include "runtime/javaCalls.hpp"
60 #include "runtime/os.hpp"
401 (*JImageResourceIterator)(_jimage, (JImageResourceVisitor_t)ctw_visitor, (void *)&loader);
402 if (HAS_PENDING_EXCEPTION) {
403 if (PENDING_EXCEPTION->is_a(SystemDictionary::OutOfMemoryError_klass())) {
404 CLEAR_PENDING_EXCEPTION;
405 tty->print_cr("\nCompileTheWorld : Ran out of memory\n");
406 tty->print_cr("Increase class metadata storage if a limit was set");
407 } else {
408 tty->print_cr("\nCompileTheWorld : Unexpected exception occurred\n");
409 }
410 }
411 }
412
413 bool ClassPathImageEntry::is_jrt() {
414 return string_ends_with(name(), BOOT_IMAGE_NAME);
415 }
416 #endif
417
418 #if INCLUDE_CDS
419 void ClassLoader::exit_with_path_failure(const char* error, const char* message) {
420 assert(DumpSharedSpaces, "only called at dump time");
421 tty->print_cr("Hint: enable -Xlog:classpath=info to diagnose the failure");
422 vm_exit_during_initialization(error, message);
423 }
424 #endif
425
426 void ClassLoader::trace_class_path(outputStream* out, const char* msg, const char* name) {
427 if (!log_is_enabled(Info, classpath)) {
428 return;
429 }
430 if (msg) {
431 out->print("%s", msg);
432 }
433 if (name) {
434 if (strlen(name) < 256) {
435 out->print("%s", name);
436 } else {
437 // For very long paths, we need to print each character separately,
438 // as print_cr() has a length limit
439 while (name[0] != '\0') {
440 out->print("%c", name[0]);
441 name++;
442 }
443 }
444 }
445 if (msg && msg[0] == '[') {
446 out->print_cr("]");
447 } else {
448 out->cr();
449 }
561 new_entry = new ClassPathZipEntry(zip, path);
562 } else {
563 ResourceMark rm(thread);
564 char *msg;
565 if (error_msg == NULL) {
566 msg = NEW_RESOURCE_ARRAY(char, strlen(path) + 128); ;
567 jio_snprintf(msg, strlen(path) + 127, "error in opening JAR file %s", path);
568 } else {
569 int len = (int)(strlen(path) + strlen(error_msg) + 128);
570 msg = NEW_RESOURCE_ARRAY(char, len); ;
571 jio_snprintf(msg, len - 1, "error in opening JAR file <%s> %s", error_msg, path);
572 }
573 // Don't complain about bad jar files added via -Xbootclasspath/a:.
574 if (throw_exception && is_init_completed()) {
575 THROW_MSG_(vmSymbols::java_lang_ClassNotFoundException(), msg, NULL);
576 } else {
577 return NULL;
578 }
579 }
580 }
581 log_info(classpath)("opened: %s", path);
582 log_info(classload)("opened: %s", path);
583 } else {
584 // Directory
585 new_entry = new ClassPathDirEntry(path);
586 log_info(classload)("path: %s", path);
587 }
588 return new_entry;
589 }
590
591
592 // Create a class path zip entry for a given path (return NULL if not found
593 // or zip/JAR file cannot be opened)
594 ClassPathZipEntry* ClassLoader::create_class_path_zip_entry(const char *path) {
595 // check for a regular file
596 struct stat st;
597 if (os::stat(path, &st) == 0) {
598 if ((st.st_mode & S_IFREG) == S_IFREG) {
599 char canonical_path[JVM_MAXPATHLEN];
600 if (get_canonical_path(path, canonical_path, JVM_MAXPATHLEN)) {
601 char* error_msg = NULL;
|