mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-23 12:34:32 +02:00
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282 Co-authored-by: Alex Buckley <alex.buckley@oracle.com> Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com> Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com> Co-authored-by: Mandy Chung <mandy.chung@oracle.com> Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com> Co-authored-by: Harold Seigel <harold.seigel@oracle.com> Co-authored-by: Lois Foltan <lois.foltan@oracle.com> Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com> Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com> Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com> Co-authored-by: George Triantafillou <george.triantafillou@oracle.com> Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com> Co-authored-by: Ioi Lam <ioi.lam@oracle.com> Co-authored-by: James Laskey <james.laskey@oracle.com> Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com> Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com> Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com> Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com> Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com> Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com> Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
This commit is contained in:
parent
007b0fa3db
commit
f30fc1c88b
297 changed files with 15848 additions and 2302 deletions
|
@ -1193,67 +1193,14 @@ char* os::format_boot_path(const char* format_string,
|
|||
return formatted_path;
|
||||
}
|
||||
|
||||
// returns a PATH of all entries in the given directory that do not start with a '.'
|
||||
static char* expand_entries_to_path(char* directory, char fileSep, char pathSep) {
|
||||
DIR* dir = os::opendir(directory);
|
||||
if (dir == NULL) return NULL;
|
||||
|
||||
char* path = NULL;
|
||||
size_t path_len = 0; // path length including \0 terminator
|
||||
|
||||
size_t directory_len = strlen(directory);
|
||||
struct dirent *entry;
|
||||
char* dbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(directory), mtInternal);
|
||||
while ((entry = os::readdir(dir, (dirent *) dbuf)) != NULL) {
|
||||
const char* name = entry->d_name;
|
||||
if (name[0] == '.') continue;
|
||||
|
||||
size_t name_len = strlen(name);
|
||||
size_t needed = directory_len + name_len + 2;
|
||||
size_t new_len = path_len + needed;
|
||||
if (path == NULL) {
|
||||
path = NEW_C_HEAP_ARRAY(char, new_len, mtInternal);
|
||||
} else {
|
||||
path = REALLOC_C_HEAP_ARRAY(char, path, new_len, mtInternal);
|
||||
}
|
||||
if (path == NULL)
|
||||
break;
|
||||
|
||||
// append <pathSep>directory<fileSep>name
|
||||
char* p = path;
|
||||
if (path_len > 0) {
|
||||
p += (path_len -1);
|
||||
*p = pathSep;
|
||||
p++;
|
||||
}
|
||||
|
||||
strcpy(p, directory);
|
||||
p += directory_len;
|
||||
|
||||
*p = fileSep;
|
||||
p++;
|
||||
|
||||
strcpy(p, name);
|
||||
p += name_len;
|
||||
|
||||
path_len = new_len;
|
||||
}
|
||||
|
||||
FREE_C_HEAP_ARRAY(char, dbuf);
|
||||
os::closedir(dir);
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
bool os::set_boot_path(char fileSep, char pathSep) {
|
||||
const char* home = Arguments::get_java_home();
|
||||
int home_len = (int)strlen(home);
|
||||
|
||||
char* sysclasspath = NULL;
|
||||
struct stat st;
|
||||
|
||||
// modular image if bootmodules.jimage exists
|
||||
char* jimage = format_boot_path("%/lib/modules/" BOOT_IMAGE_NAME, home, home_len, fileSep, pathSep);
|
||||
// modular image if "modules" jimage exists
|
||||
char* jimage = format_boot_path("%/lib/" MODULES_IMAGE_NAME, home, home_len, fileSep, pathSep);
|
||||
if (jimage == NULL) return false;
|
||||
bool has_jimage = (os::stat(jimage, &st) == 0);
|
||||
if (has_jimage) {
|
||||
|
@ -1264,23 +1211,16 @@ bool os::set_boot_path(char fileSep, char pathSep) {
|
|||
FREE_C_HEAP_ARRAY(char, jimage);
|
||||
|
||||
// check if developer build with exploded modules
|
||||
char* modules_dir = format_boot_path("%/modules", home, home_len, fileSep, pathSep);
|
||||
if (os::stat(modules_dir, &st) == 0) {
|
||||
if ((st.st_mode & S_IFDIR) == S_IFDIR) {
|
||||
sysclasspath = expand_entries_to_path(modules_dir, fileSep, pathSep);
|
||||
}
|
||||
char* base_classes = format_boot_path("%/modules/java.base", home, home_len, fileSep, pathSep);
|
||||
if (base_classes == NULL) return false;
|
||||
if (os::stat(base_classes, &st) == 0) {
|
||||
Arguments::set_sysclasspath(base_classes);
|
||||
FREE_C_HEAP_ARRAY(char, base_classes);
|
||||
return true;
|
||||
}
|
||||
FREE_C_HEAP_ARRAY(char, modules_dir);
|
||||
FREE_C_HEAP_ARRAY(char, base_classes);
|
||||
|
||||
// fallback to classes
|
||||
if (sysclasspath == NULL)
|
||||
sysclasspath = format_boot_path("%/classes", home, home_len, fileSep, pathSep);
|
||||
|
||||
if (sysclasspath == NULL) return false;
|
||||
Arguments::set_sysclasspath(sysclasspath);
|
||||
FREE_C_HEAP_ARRAY(char, sysclasspath);
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue