src/share/vm/classfile/classLoader.cpp

Print this page
rev 9245 : [mq]: class_loading_log


  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/classFileParser.hpp"
  27 #include "classfile/classFileStream.hpp"
  28 #include "classfile/classLoader.hpp"
  29 #include "classfile/classLoaderData.inline.hpp"
  30 #include "classfile/classLoaderExt.hpp"
  31 #include "classfile/javaClasses.hpp"
  32 #include "classfile/jimage.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/oop.inline.hpp"
  47 #include "oops/symbol.hpp"
  48 #include "prims/jvm_misc.hpp"
  49 #include "runtime/arguments.hpp"
  50 #include "runtime/compilationPolicy.hpp"
  51 #include "runtime/fprofiler.hpp"
  52 #include "runtime/handles.hpp"
  53 #include "runtime/handles.inline.hpp"
  54 #include "runtime/init.hpp"
  55 #include "runtime/interfaceSupport.hpp"
  56 #include "runtime/java.hpp"
  57 #include "runtime/javaCalls.hpp"
  58 #include "runtime/os.hpp"
  59 #include "runtime/threadCritical.hpp"


 556         char *msg;
 557         if (error_msg == NULL) {
 558           msg = NEW_RESOURCE_ARRAY(char, strlen(path) + 128); ;
 559           jio_snprintf(msg, strlen(path) + 127, "error in opening JAR file %s", path);
 560         } else {
 561           int len = (int)(strlen(path) + strlen(error_msg) + 128);
 562           msg = NEW_RESOURCE_ARRAY(char, len); ;
 563           jio_snprintf(msg, len - 1, "error in opening JAR file <%s> %s", error_msg, path);
 564         }
 565         // Don't complain about bad jar files added via -Xbootclasspath/a:.
 566         if (throw_exception && is_init_completed()) {
 567           THROW_MSG_(vmSymbols::java_lang_ClassNotFoundException(), msg, NULL);
 568         } else {
 569           return NULL;
 570         }
 571       }
 572     }
 573     if (TraceClassLoading || TraceClassPaths) {
 574       tty->print_cr("[Opened %s]", path);
 575     }




 576   } else {
 577     // Directory
 578     new_entry = new ClassPathDirEntry(path);
 579     if (TraceClassLoading) {
 580       tty->print_cr("[Path %s]", path);




 581     }
 582   }
 583   return new_entry;
 584 }
 585 
 586 
 587 // Create a class path zip entry for a given path (return NULL if not found
 588 // or zip/JAR file cannot be opened)
 589 ClassPathZipEntry* ClassLoader::create_class_path_zip_entry(const char *path) {
 590   // check for a regular file
 591   struct stat st;
 592   if (os::stat(path, &st) == 0) {
 593     if ((st.st_mode & S_IFREG) == S_IFREG) {
 594       char canonical_path[JVM_MAXPATHLEN];
 595       if (get_canonical_path(path, canonical_path, JVM_MAXPATHLEN)) {
 596         char* error_msg = NULL;
 597         jzfile* zip;
 598         {
 599           // enable call to C land
 600           JavaThread* thread = JavaThread::current();




  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/classFileParser.hpp"
  27 #include "classfile/classFileStream.hpp"
  28 #include "classfile/classLoader.hpp"
  29 #include "classfile/classLoaderData.inline.hpp"
  30 #include "classfile/classLoaderExt.hpp"
  31 #include "classfile/javaClasses.hpp"
  32 #include "classfile/jimage.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/log.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/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"
  60 #include "runtime/threadCritical.hpp"


 557         char *msg;
 558         if (error_msg == NULL) {
 559           msg = NEW_RESOURCE_ARRAY(char, strlen(path) + 128); ;
 560           jio_snprintf(msg, strlen(path) + 127, "error in opening JAR file %s", path);
 561         } else {
 562           int len = (int)(strlen(path) + strlen(error_msg) + 128);
 563           msg = NEW_RESOURCE_ARRAY(char, len); ;
 564           jio_snprintf(msg, len - 1, "error in opening JAR file <%s> %s", error_msg, path);
 565         }
 566         // Don't complain about bad jar files added via -Xbootclasspath/a:.
 567         if (throw_exception && is_init_completed()) {
 568           THROW_MSG_(vmSymbols::java_lang_ClassNotFoundException(), msg, NULL);
 569         } else {
 570           return NULL;
 571         }
 572       }
 573     }
 574     if (TraceClassLoading || TraceClassPaths) {
 575       tty->print_cr("[Opened %s]", path);
 576     }
 577     if (log_is_enabled(Debug, classload)) {
 578       outputStream* log = LogHandle(classload)::debug_stream();
 579       log->print_cr("[Opened %s]", path);
 580     }
 581   } else {
 582     // Directory
 583     new_entry = new ClassPathDirEntry(path);
 584     if (TraceClassLoading) {
 585       tty->print_cr("[Path %s]", path);
 586     }
 587     if (log_is_enabled(Debug, classload)) {
 588       outputStream* log = LogHandle(classload)::debug_stream();
 589       log->print_cr("[Path %s]", path);
 590     }
 591   }
 592   return new_entry;
 593 }
 594 
 595 
 596 // Create a class path zip entry for a given path (return NULL if not found
 597 // or zip/JAR file cannot be opened)
 598 ClassPathZipEntry* ClassLoader::create_class_path_zip_entry(const char *path) {
 599   // check for a regular file
 600   struct stat st;
 601   if (os::stat(path, &st) == 0) {
 602     if ((st.st_mode & S_IFREG) == S_IFREG) {
 603       char canonical_path[JVM_MAXPATHLEN];
 604       if (get_canonical_path(path, canonical_path, JVM_MAXPATHLEN)) {
 605         char* error_msg = NULL;
 606         jzfile* zip;
 607         {
 608           // enable call to C land
 609           JavaThread* thread = JavaThread::current();