1206
1207 *p = fileSep;
1208 p++;
1209
1210 strcpy(p, name);
1211 p += name_len;
1212
1213 path_len = new_len;
1214 }
1215
1216 FREE_C_HEAP_ARRAY(char, dbuf);
1217 os::closedir(dir);
1218
1219 return path;
1220 }
1221
1222 bool os::set_boot_path(char fileSep, char pathSep) {
1223 const char* home = Arguments::get_java_home();
1224 int home_len = (int)strlen(home);
1225
1226 static const char* meta_index_dir_format = "%/lib/";
1227 static const char* meta_index_format = "%/lib/meta-index";
1228 char* meta_index = format_boot_path(meta_index_format, home, home_len, fileSep, pathSep);
1229 if (meta_index == NULL) return false;
1230 char* meta_index_dir = format_boot_path(meta_index_dir_format, home, home_len, fileSep, pathSep);
1231 if (meta_index_dir == NULL) return false;
1232 Arguments::set_meta_index_path(meta_index, meta_index_dir);
1233
1234 char* sysclasspath = NULL;
1235 struct stat st;
1236
1237 // modular image if bootmodules.jimage exists
1238 char* jimage = format_boot_path("%/lib/modules/bootmodules.jimage", home, home_len, fileSep, pathSep);
1239 if (jimage == NULL) return false;
1240 bool has_jimage = (os::stat(jimage, &st) == 0);
1241 if (has_jimage) {
1242 Arguments::set_sysclasspath(jimage);
1243 return true;
1244 }
1245 FREE_C_HEAP_ARRAY(char, jimage);
1246
1247 // images build if rt.jar exists
1248 char* rt_jar = format_boot_path("%/lib/rt.jar", home, home_len, fileSep, pathSep);
1249 if (rt_jar == NULL) return false;
1250 bool has_rt_jar = (os::stat(rt_jar, &st) == 0);
1251 FREE_C_HEAP_ARRAY(char, rt_jar);
1252
1253 if (has_rt_jar) {
1254 // Any modification to the JAR-file list, for the boot classpath must be
1255 // aligned with install/install/make/common/Pack.gmk. Note: boot class
1256 // path class JARs, are stripped for StackMapTable to reduce download size.
1257 static const char classpath_format[] =
1258 "%/lib/resources.jar:"
1259 "%/lib/rt.jar:"
1260 "%/lib/jsse.jar:"
1261 "%/lib/jce.jar:"
1262 "%/lib/charsets.jar:"
1263 "%/lib/jfr.jar:"
1264 "%/classes";
1265 sysclasspath = format_boot_path(classpath_format, home, home_len, fileSep, pathSep);
1266 } else {
1267 // no rt.jar, check if developer build with exploded modules
1268 char* modules_dir = format_boot_path("%/modules", home, home_len, fileSep, pathSep);
1269 if (os::stat(modules_dir, &st) == 0) {
1270 if ((st.st_mode & S_IFDIR) == S_IFDIR) {
1271 sysclasspath = expand_entries_to_path(modules_dir, fileSep, pathSep);
1272 }
1273 }
1274
1275 // fallback to classes
1276 if (sysclasspath == NULL)
1277 sysclasspath = format_boot_path("%/classes", home, home_len, fileSep, pathSep);
1278 }
1279
1280 if (sysclasspath == NULL) return false;
1281 Arguments::set_sysclasspath(sysclasspath);
1282
1283 return true;
1284 }
1285
1286 /*
1287 * Splits a path, based on its separator, the number of
1288 * elements is returned back in n.
1289 * It is the callers responsibility to:
1290 * a> check the value of n, and n may be 0.
1291 * b> ignore any empty path elements
1292 * c> free up the data.
1293 */
1294 char** os::split_path(const char* path, int* n) {
1295 *n = 0;
1296 if (path == NULL || strlen(path) == 0) {
1297 return NULL;
1298 }
|
1206
1207 *p = fileSep;
1208 p++;
1209
1210 strcpy(p, name);
1211 p += name_len;
1212
1213 path_len = new_len;
1214 }
1215
1216 FREE_C_HEAP_ARRAY(char, dbuf);
1217 os::closedir(dir);
1218
1219 return path;
1220 }
1221
1222 bool os::set_boot_path(char fileSep, char pathSep) {
1223 const char* home = Arguments::get_java_home();
1224 int home_len = (int)strlen(home);
1225
1226 char* sysclasspath = NULL;
1227 struct stat st;
1228
1229 // modular image if bootmodules.jimage exists
1230 char* jimage = format_boot_path("%/lib/modules/bootmodules.jimage", home, home_len, fileSep, pathSep);
1231 if (jimage == NULL) return false;
1232 bool has_jimage = (os::stat(jimage, &st) == 0);
1233 if (has_jimage) {
1234 Arguments::set_sysclasspath(jimage);
1235 return true;
1236 }
1237 FREE_C_HEAP_ARRAY(char, jimage);
1238
1239 // check if developer build with exploded modules
1240 char* modules_dir = format_boot_path("%/modules", home, home_len, fileSep, pathSep);
1241 if (os::stat(modules_dir, &st) == 0) {
1242 if ((st.st_mode & S_IFDIR) == S_IFDIR) {
1243 sysclasspath = expand_entries_to_path(modules_dir, fileSep, pathSep);
1244 }
1245 }
1246
1247 // fallback to classes
1248 if (sysclasspath == NULL)
1249 sysclasspath = format_boot_path("%/classes", home, home_len, fileSep, pathSep);
1250
1251 if (sysclasspath == NULL) return false;
1252 Arguments::set_sysclasspath(sysclasspath);
1253
1254 return true;
1255 }
1256
1257 /*
1258 * Splits a path, based on its separator, the number of
1259 * elements is returned back in n.
1260 * It is the callers responsibility to:
1261 * a> check the value of n, and n may be 0.
1262 * b> ignore any empty path elements
1263 * c> free up the data.
1264 */
1265 char** os::split_path(const char* path, int* n) {
1266 *n = 0;
1267 if (path == NULL || strlen(path) == 0) {
1268 return NULL;
1269 }
|