src/share/vm/classfile/classLoader.cpp

Print this page

        

*** 187,199 **** bool ClassPathEntry::is_lazy() { return false; } ! ClassPathDirEntry::ClassPathDirEntry(char* dir) : ClassPathEntry() { ! _dir = NEW_C_HEAP_ARRAY(char, strlen(dir)+1, mtClass); ! strcpy(_dir, dir); } ClassFileStream* ClassPathDirEntry::open_stream(const char* name, TRAPS) { // construct full path name --- 187,200 ---- bool ClassPathEntry::is_lazy() { return false; } ! ClassPathDirEntry::ClassPathDirEntry(const char* dir) : ClassPathEntry() { ! char* copy = NEW_C_HEAP_ARRAY(char, strlen(dir)+1, mtClass); ! strcpy(copy, dir); ! _dir = copy; } ClassFileStream* ClassPathDirEntry::open_stream(const char* name, TRAPS) { // construct full path name
*** 233,244 **** } ClassPathZipEntry::ClassPathZipEntry(jzfile* zip, const char* zip_name) : ClassPathEntry() { _zip = zip; ! _zip_name = NEW_C_HEAP_ARRAY(char, strlen(zip_name)+1, mtClass); ! strcpy(_zip_name, zip_name); } ClassPathZipEntry::~ClassPathZipEntry() { if (ZipClose != NULL) { (*ZipClose)(_zip); --- 234,246 ---- } ClassPathZipEntry::ClassPathZipEntry(jzfile* zip, const char* zip_name) : ClassPathEntry() { _zip = zip; ! char *copy = NEW_C_HEAP_ARRAY(char, strlen(zip_name)+1, mtClass); ! strcpy(copy, zip_name); ! _zip_name = copy; } ClassPathZipEntry::~ClassPathZipEntry() { if (ZipClose != NULL) { (*ZipClose)(_zip);
*** 302,322 **** if (ze == NULL) break; (*f)(ze->name, context); } } ! LazyClassPathEntry::LazyClassPathEntry(char* path, const struct stat* st, bool throw_exception) : ClassPathEntry() { _path = os::strdup_check_oom(path); _st = *st; _meta_index = NULL; _resolved_entry = NULL; _has_error = false; _throw_exception = throw_exception; } LazyClassPathEntry::~LazyClassPathEntry() { ! os::free(_path); } bool LazyClassPathEntry::is_jar_file() { return ((_st.st_mode & S_IFREG) == S_IFREG); } --- 304,324 ---- if (ze == NULL) break; (*f)(ze->name, context); } } ! LazyClassPathEntry::LazyClassPathEntry(const char* path, const struct stat* st, bool throw_exception) : ClassPathEntry() { _path = os::strdup_check_oom(path); _st = *st; _meta_index = NULL; _resolved_entry = NULL; _has_error = false; _throw_exception = throw_exception; } LazyClassPathEntry::~LazyClassPathEntry() { ! os::free((void*)_path); } bool LazyClassPathEntry::is_jar_file() { return ((_st.st_mode & S_IFREG) == S_IFREG); }
*** 561,581 **** } #endif void ClassLoader::setup_bootstrap_search_path() { assert(_first_entry == NULL, "should not setup bootstrap class search path twice"); ! char* sys_class_path = os::strdup_check_oom(Arguments::get_sysclasspath()); ! if (!PrintSharedArchiveAndExit) { trace_class_path("[Bootstrap loader class path=", sys_class_path); } #if INCLUDE_CDS if (DumpSharedSpaces) { ! _shared_paths_misc_info->add_boot_classpath(Arguments::get_sysclasspath()); } #endif setup_search_path(sys_class_path); - os::free(sys_class_path); } #if INCLUDE_CDS int ClassLoader::get_shared_paths_misc_info_size() { return _shared_paths_misc_info->get_used_bytes(); --- 563,585 ---- } #endif void ClassLoader::setup_bootstrap_search_path() { assert(_first_entry == NULL, "should not setup bootstrap class search path twice"); ! const char* sys_class_path = Arguments::get_sysclasspath(); ! if (PrintSharedArchiveAndExit) { ! // Don't print sys_class_path - this is the bootcp of this current VM process, not necessarily ! // the same as the bootcp of the shared archive. ! } else { trace_class_path("[Bootstrap loader class path=", sys_class_path); } #if INCLUDE_CDS if (DumpSharedSpaces) { ! _shared_paths_misc_info->add_boot_classpath(sys_class_path); } #endif setup_search_path(sys_class_path); } #if INCLUDE_CDS int ClassLoader::get_shared_paths_misc_info_size() { return _shared_paths_misc_info->get_used_bytes();
*** 591,601 **** delete checker; return result; } #endif ! void ClassLoader::setup_search_path(char *class_path) { int offset = 0; int len = (int)strlen(class_path); int end = 0; // Iterate over class path entries --- 595,605 ---- delete checker; return result; } #endif ! void ClassLoader::setup_search_path(const char *class_path) { int offset = 0; int len = (int)strlen(class_path); int end = 0; // Iterate over class path entries
*** 618,628 **** end++; } } } ! ClassPathEntry* ClassLoader::create_class_path_entry(char *path, const struct stat* st, bool lazy, bool throw_exception, TRAPS) { JavaThread* thread = JavaThread::current(); if (lazy) { return new LazyClassPathEntry(path, st, throw_exception); } --- 622,632 ---- end++; } } } ! ClassPathEntry* ClassLoader::create_class_path_entry(const char *path, const struct stat* st, bool lazy, bool throw_exception, TRAPS) { JavaThread* thread = JavaThread::current(); if (lazy) { return new LazyClassPathEntry(path, st, throw_exception); }
*** 685,699 **** ClassPathZipEntry* ClassLoader::create_class_path_zip_entry(const char *path) { // check for a regular file struct stat st; if (os::stat(path, &st) == 0) { if ((st.st_mode & S_IFREG) == S_IFREG) { - char orig_path[JVM_MAXPATHLEN]; char canonical_path[JVM_MAXPATHLEN]; ! ! strcpy(orig_path, path); ! if (get_canonical_path(orig_path, canonical_path, JVM_MAXPATHLEN)) { char* error_msg = NULL; jzfile* zip; { // enable call to C land JavaThread* thread = JavaThread::current(); --- 689,700 ---- ClassPathZipEntry* ClassLoader::create_class_path_zip_entry(const char *path) { // check for a regular file struct stat st; if (os::stat(path, &st) == 0) { if ((st.st_mode & S_IFREG) == S_IFREG) { char canonical_path[JVM_MAXPATHLEN]; ! if (get_canonical_path(path, canonical_path, JVM_MAXPATHLEN)) { char* error_msg = NULL; jzfile* zip; { // enable call to C land JavaThread* thread = JavaThread::current();
*** 735,745 **** } _num_entries ++; } // Returns true IFF the file/dir exists and the entry was successfully created. ! bool ClassLoader::update_class_path_entry_list(char *path, bool check_for_duplicates, bool throw_exception) { struct stat st; if (os::stat(path, &st) == 0) { // File or directory found --- 736,746 ---- } _num_entries ++; } // Returns true IFF the file/dir exists and the entry was successfully created. ! bool ClassLoader::update_class_path_entry_list(const char *path, bool check_for_duplicates, bool throw_exception) { struct stat st; if (os::stat(path, &st) == 0) { // File or directory found
*** 760,771 **** } else { #if INCLUDE_CDS if (DumpSharedSpaces) { _shared_paths_misc_info->add_nonexist_path(path); } - return false; #endif } } void ClassLoader::print_bootclasspath() { ClassPathEntry* e = _first_entry; --- 761,772 ---- } else { #if INCLUDE_CDS if (DumpSharedSpaces) { _shared_paths_misc_info->add_nonexist_path(path); } #endif + return false; } } void ClassLoader::print_bootclasspath() { ClassPathEntry* e = _first_entry;
*** 1267,1281 **** void classLoader_init() { ClassLoader::initialize(); } ! bool ClassLoader::get_canonical_path(char* orig, char* out, int len) { assert(orig != NULL && out != NULL && len > 0, "bad arguments"); if (CanonicalizeEntry != NULL) { ! JNIEnv* env = JavaThread::current()->jni_environment(); ! if ((CanonicalizeEntry)(env, os::native_path(orig), out, len) < 0) { return false; } } else { // On JDK 1.2.2 the Canonicalize does not exist, so just do nothing strncpy(out, orig, len); --- 1268,1288 ---- void classLoader_init() { ClassLoader::initialize(); } ! bool ClassLoader::get_canonical_path(const char* orig, char* out, int len) { assert(orig != NULL && out != NULL && len > 0, "bad arguments"); if (CanonicalizeEntry != NULL) { ! JavaThread* THREAD = JavaThread::current(); ! JNIEnv* env = THREAD->jni_environment(); ! ResourceMark rm(THREAD); ! ! // os::native_path writes into orig_copy ! char* orig_copy = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, strlen(orig)+1); ! strcpy(orig_copy, orig); ! if ((CanonicalizeEntry)(env, os::native_path(orig_copy), out, len) < 0) { return false; } } else { // On JDK 1.2.2 the Canonicalize does not exist, so just do nothing strncpy(out, orig, len);