src/share/vm/classfile/classLoader.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File classload.01 Sdiff src/share/vm/classfile

src/share/vm/classfile/classLoader.cpp

Print this page


   1 /*
   2  * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  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/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"


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

 582     }
 583   } else {
 584     // Directory
 585     new_entry = new ClassPathDirEntry(path);
 586     if (TraceClassLoading) {
 587       tty->print_cr("[Path %s]", path);

 588     }
 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;
 604         jzfile* zip;
 605         {
 606           // enable call to C land
 607           JavaThread* thread = JavaThread::current();


   1 /*
   2  * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  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/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"


 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 (log_is_enabled(Info, classload)) {
 582       outputStream* log = LogHandle(classload)::info_stream();
 583       log->print_cr("[Opened %s]", path);
 584     }
 585   } else {
 586     // Directory
 587     new_entry = new ClassPathDirEntry(path);
 588     if (log_is_enabled(Info, classload)) {
 589       outputStream* log = LogHandle(classload)::info_stream();
 590       log->print_cr("[Path %s]", path);
 591     }
 592   }
 593   return new_entry;
 594 }
 595 
 596 
 597 // Create a class path zip entry for a given path (return NULL if not found
 598 // or zip/JAR file cannot be opened)
 599 ClassPathZipEntry* ClassLoader::create_class_path_zip_entry(const char *path) {
 600   // check for a regular file
 601   struct stat st;
 602   if (os::stat(path, &st) == 0) {
 603     if ((st.st_mode & S_IFREG) == S_IFREG) {
 604       char canonical_path[JVM_MAXPATHLEN];
 605       if (get_canonical_path(path, canonical_path, JVM_MAXPATHLEN)) {
 606         char* error_msg = NULL;
 607         jzfile* zip;
 608         {
 609           // enable call to C land
 610           JavaThread* thread = JavaThread::current();


src/share/vm/classfile/classLoader.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File