< prev index next >
src/hotspot/share/classfile/classLoader.cpp
Print this page
*** 166,175 ****
--- 166,210 ----
VM_Version::vm_major_version(), VM_Version::vm_minor_version());
}
return (const char*)version_string;
}
+ class ClasspathStream : public StackObj {
+ const char* _class_path;
+ int _len;
+ int _start;
+ int _end;
+
+ public:
+ ClasspathStream(const char* class_path) {
+ _class_path = class_path;
+ _len = (int)strlen(class_path);
+ _start = 0;
+ _end = 0;
+ }
+
+ bool has_next() {
+ return _start < _len;
+ }
+
+ const char* get_next() {
+ while (_class_path[_end] && _class_path[_end] != os::path_separator()[0]) {
+ _end++;
+ }
+ int path_len = _end - _start;
+ char* path = NEW_RESOURCE_ARRAY(char, path_len + 1);
+ strncpy(path, &_class_path[_start], path_len);
+ path[path_len] = '\0';
+
+ while (_class_path[_end] == os::path_separator()[0]) {
+ _end++;
+ }
+ _start = _end;
+ return path;
+ }
+ };
+
bool ClassLoader::string_ends_with(const char* str, const char* str_to_find) {
size_t str_len = strlen(str);
size_t str_to_find_len = strlen(str_to_find);
if (str_to_find_len > str_len) {
return false;
*** 559,591 ****
delete checker;
return result;
}
void ClassLoader::setup_app_search_path(const char *class_path) {
-
assert(DumpSharedSpaces || DynamicDumpSharedSpaces, "Sanity");
! Thread* THREAD = Thread::current();
! int len = (int)strlen(class_path);
! int end = 0;
!
! // Iterate over class path entries
! for (int start = 0; start < len; start = end) {
! while (class_path[end] && class_path[end] != os::path_separator()[0]) {
! end++;
! }
! EXCEPTION_MARK;
! ResourceMark rm(THREAD);
! char* path = NEW_RESOURCE_ARRAY(char, end - start + 1);
! strncpy(path, &class_path[start], end - start);
! path[end - start] = '\0';
update_class_path_entry_list(path, false, false, false);
-
- while (class_path[end] == os::path_separator()[0]) {
- end++;
- }
}
}
void ClassLoader::add_to_module_path_entries(const char* path,
ClassPathEntry* entry) {
--- 594,611 ----
delete checker;
return result;
}
void ClassLoader::setup_app_search_path(const char *class_path) {
assert(DumpSharedSpaces || DynamicDumpSharedSpaces, "Sanity");
! ResourceMark rm;
! ClasspathStream cp_stream(class_path);
+ while (cp_stream.has_next()) {
+ const char* path = cp_stream.get_next();
update_class_path_entry_list(path, false, false, false);
}
}
void ClassLoader::add_to_module_path_entries(const char* path,
ClassPathEntry* entry) {
*** 641,687 ****
void ClassLoader::setup_patch_mod_entries() {
Thread* THREAD = Thread::current();
GrowableArray<ModulePatchPath*>* patch_mod_args = Arguments::get_patch_mod_prefix();
int num_of_entries = patch_mod_args->length();
-
// Set up the boot loader's _patch_mod_entries list
_patch_mod_entries = new (ResourceObj::C_HEAP, mtModule) GrowableArray<ModuleClassPathList*>(num_of_entries, true);
for (int i = 0; i < num_of_entries; i++) {
const char* module_name = (patch_mod_args->at(i))->module_name();
Symbol* const module_sym = SymbolTable::new_symbol(module_name);
assert(module_sym != NULL, "Failed to obtain Symbol for module name");
ModuleClassPathList* module_cpl = new ModuleClassPathList(module_sym);
char* class_path = (patch_mod_args->at(i))->path_string();
- int len = (int)strlen(class_path);
- int end = 0;
- // Iterate over the module's class path entries
- for (int start = 0; start < len; start = end) {
- while (class_path[end] && class_path[end] != os::path_separator()[0]) {
- end++;
- }
- EXCEPTION_MARK;
ResourceMark rm(THREAD);
! char* path = NEW_RESOURCE_ARRAY(char, end - start + 1);
! strncpy(path, &class_path[start], end - start);
! path[end - start] = '\0';
struct stat st;
if (os::stat(path, &st) == 0) {
// File or directory found
ClassPathEntry* new_entry = create_class_path_entry(path, &st, false, false, false, CHECK);
// If the path specification is valid, enter it into this module's list
if (new_entry != NULL) {
module_cpl->add_to_list(new_entry);
}
}
-
- while (class_path[end] == os::path_separator()[0]) {
- end++;
- }
}
// Record the module into the list of --patch-module entries only if
// valid ClassPathEntrys have been created
if (module_cpl->module_first_entry() != NULL) {
--- 661,694 ----
void ClassLoader::setup_patch_mod_entries() {
Thread* THREAD = Thread::current();
GrowableArray<ModulePatchPath*>* patch_mod_args = Arguments::get_patch_mod_prefix();
int num_of_entries = patch_mod_args->length();
// Set up the boot loader's _patch_mod_entries list
_patch_mod_entries = new (ResourceObj::C_HEAP, mtModule) GrowableArray<ModuleClassPathList*>(num_of_entries, true);
for (int i = 0; i < num_of_entries; i++) {
const char* module_name = (patch_mod_args->at(i))->module_name();
Symbol* const module_sym = SymbolTable::new_symbol(module_name);
assert(module_sym != NULL, "Failed to obtain Symbol for module name");
ModuleClassPathList* module_cpl = new ModuleClassPathList(module_sym);
char* class_path = (patch_mod_args->at(i))->path_string();
ResourceMark rm(THREAD);
! ClasspathStream cp_stream(class_path);
+ while (cp_stream.has_next()) {
+ const char* path = cp_stream.get_next();
struct stat st;
if (os::stat(path, &st) == 0) {
// File or directory found
ClassPathEntry* new_entry = create_class_path_entry(path, &st, false, false, false, CHECK);
// If the path specification is valid, enter it into this module's list
if (new_entry != NULL) {
module_cpl->add_to_list(new_entry);
}
}
}
// Record the module into the list of --patch-module entries only if
// valid ClassPathEntrys have been created
if (module_cpl->module_first_entry() != NULL) {
*** 705,736 ****
return false;
}
// Set up the _jrt_entry if present and boot append path
void ClassLoader::setup_boot_search_path(const char *class_path) {
! int len = (int)strlen(class_path);
! int end = 0;
bool set_base_piece = true;
#if INCLUDE_CDS
if (DumpSharedSpaces || DynamicDumpSharedSpaces) {
if (!Arguments::has_jimage()) {
vm_exit_during_initialization("CDS is not supported in exploded JDK build", NULL);
}
}
#endif
! // Iterate over class path entries
! for (int start = 0; start < len; start = end) {
! while (class_path[end] && class_path[end] != os::path_separator()[0]) {
! end++;
! }
! EXCEPTION_MARK;
! ResourceMark rm(THREAD);
! char* path = NEW_RESOURCE_ARRAY(char, end - start + 1);
! strncpy(path, &class_path[start], end - start);
! path[end - start] = '\0';
if (set_base_piece) {
// The first time through the bootstrap_search setup, it must be determined
// what the base or core piece of the boot loader search is. Either a java runtime
// image is present or this is an exploded module build situation.
--- 712,736 ----
return false;
}
// Set up the _jrt_entry if present and boot append path
void ClassLoader::setup_boot_search_path(const char *class_path) {
! EXCEPTION_MARK;
! ResourceMark rm(THREAD);
! ClasspathStream cp_stream(class_path);
bool set_base_piece = true;
#if INCLUDE_CDS
if (DumpSharedSpaces || DynamicDumpSharedSpaces) {
if (!Arguments::has_jimage()) {
vm_exit_during_initialization("CDS is not supported in exploded JDK build", NULL);
}
}
#endif
! while (cp_stream.has_next()) {
! const char* path = cp_stream.get_next();
if (set_base_piece) {
// The first time through the bootstrap_search setup, it must be determined
// what the base or core piece of the boot loader search is. Either a java runtime
// image is present or this is an exploded module build situation.
*** 756,769 ****
} else {
// Every entry on the system boot class path after the initial base piece,
// which is set by os::set_boot_path(), is considered an appended entry.
update_class_path_entry_list(path, false, true, false);
}
-
- while (class_path[end] == os::path_separator()[0]) {
- end++;
- }
}
}
// During an exploded modules build, each module defined to the boot loader
// will be added to the ClassLoader::_exploded_entries array.
--- 756,765 ----
< prev index next >