320 #ifndef DEFAULT_LIBPATH
321 #ifndef OVERRIDE_LIBPATH
322 #define DEFAULT_LIBPATH "/lib:/usr/lib"
323 #else
324 #define DEFAULT_LIBPATH OVERRIDE_LIBPATH
325 #endif
326 #endif
327
328 // Base path of extensions installed on the system.
329 #define SYS_EXT_DIR "/usr/java/packages"
330 #define EXTENSIONS_DIR "/lib/ext"
331
332 #ifndef __APPLE__
333
334 // Buffer that fits several sprintfs.
335 // Note that the space for the colon and the trailing null are provided
336 // by the nulls included by the sizeof operator.
337 const size_t bufsize =
338 MAX2((size_t)MAXPATHLEN, // For dll_dir & friends.
339 (size_t)MAXPATHLEN + sizeof(EXTENSIONS_DIR) + sizeof(SYS_EXT_DIR) + sizeof(EXTENSIONS_DIR)); // extensions dir
340 char *buf = (char *)NEW_C_HEAP_ARRAY(char, bufsize, mtInternal);
341
342 // sysclasspath, java_home, dll_dir
343 {
344 char *pslash;
345 os::jvm_path(buf, bufsize);
346
347 // Found the full path to libjvm.so.
348 // Now cut the path to <java_home>/jre if we can.
349 *(strrchr(buf, '/')) = '\0'; // Get rid of /libjvm.so.
350 pslash = strrchr(buf, '/');
351 if (pslash != NULL) {
352 *pslash = '\0'; // Get rid of /{client|server|hotspot}.
353 }
354 Arguments::set_dll_dir(buf);
355
356 if (pslash != NULL) {
357 pslash = strrchr(buf, '/');
358 if (pslash != NULL) {
359 *pslash = '\0'; // Get rid of /<arch>.
360 pslash = strrchr(buf, '/');
370 }
371
372 // Where to look for native libraries.
373 //
374 // Note: Due to a legacy implementation, most of the library path
375 // is set in the launcher. This was to accomodate linking restrictions
376 // on legacy Bsd implementations (which are no longer supported).
377 // Eventually, all the library path setting will be done here.
378 //
379 // However, to prevent the proliferation of improperly built native
380 // libraries, the new path component /usr/java/packages is added here.
381 // Eventually, all the library path setting will be done here.
382 {
383 // Get the user setting of LD_LIBRARY_PATH, and prepended it. It
384 // should always exist (until the legacy problem cited above is
385 // addressed).
386 const char *v = ::getenv("LD_LIBRARY_PATH");
387 const char *v_colon = ":";
388 if (v == NULL) { v = ""; v_colon = ""; }
389 // That's +1 for the colon and +1 for the trailing '\0'.
390 char *ld_library_path = (char *)NEW_C_HEAP_ARRAY(char,
391 strlen(v) + 1 +
392 sizeof(SYS_EXT_DIR) + sizeof("/lib/") + strlen(cpu_arch) + sizeof(DEFAULT_LIBPATH) + 1,
393 mtInternal);
394 sprintf(ld_library_path, "%s%s" SYS_EXT_DIR "/lib/%s:" DEFAULT_LIBPATH, v, v_colon, cpu_arch);
395 Arguments::set_library_path(ld_library_path);
396 FREE_C_HEAP_ARRAY(char, ld_library_path);
397 }
398
399 // Extensions directories.
400 sprintf(buf, "%s" EXTENSIONS_DIR ":" SYS_EXT_DIR EXTENSIONS_DIR, Arguments::get_java_home());
401 Arguments::set_ext_dirs(buf);
402
403 FREE_C_HEAP_ARRAY(char, buf);
404
405 #else // __APPLE__
406
407 #define SYS_EXTENSIONS_DIR "/Library/Java/Extensions"
408 #define SYS_EXTENSIONS_DIRS SYS_EXTENSIONS_DIR ":/Network" SYS_EXTENSIONS_DIR ":/System" SYS_EXTENSIONS_DIR ":/usr/lib/java"
409
410 const char *user_home_dir = get_home();
411 // The null in SYS_EXTENSIONS_DIRS counts for the size of the colon after user_home_dir.
412 size_t system_ext_size = strlen(user_home_dir) + sizeof(SYS_EXTENSIONS_DIR) +
413 sizeof(SYS_EXTENSIONS_DIRS);
401 Arguments::set_ext_dirs(buf);
402
403 FREE_C_HEAP_ARRAY(char, buf);
404
405 #else // __APPLE__
406
407 #define SYS_EXTENSIONS_DIR "/Library/Java/Extensions"
408 #define SYS_EXTENSIONS_DIRS SYS_EXTENSIONS_DIR ":/Network" SYS_EXTENSIONS_DIR ":/System" SYS_EXTENSIONS_DIR ":/usr/lib/java"
409
410 const char *user_home_dir = get_home();
411 // The null in SYS_EXTENSIONS_DIRS counts for the size of the colon after user_home_dir.
412 size_t system_ext_size = strlen(user_home_dir) + sizeof(SYS_EXTENSIONS_DIR) +
413 sizeof(SYS_EXTENSIONS_DIRS);
414
415 // Buffer that fits several sprintfs.
416 // Note that the space for the colon and the trailing null are provided
417 // by the nulls included by the sizeof operator.
418 const size_t bufsize =
419 MAX2((size_t)MAXPATHLEN, // for dll_dir & friends.
420 (size_t)MAXPATHLEN + sizeof(EXTENSIONS_DIR) + system_ext_size); // extensions dir
421 char *buf = (char *)NEW_C_HEAP_ARRAY(char, bufsize, mtInternal);
422
423 // sysclasspath, java_home, dll_dir
424 {
425 char *pslash;
426 os::jvm_path(buf, bufsize);
427
428 // Found the full path to libjvm.so.
429 // Now cut the path to <java_home>/jre if we can.
430 *(strrchr(buf, '/')) = '\0'; // Get rid of /libjvm.so.
431 pslash = strrchr(buf, '/');
432 if (pslash != NULL) {
433 *pslash = '\0'; // Get rid of /{client|server|hotspot}.
434 }
435 #ifdef STATIC_BUILD
436 strcat(buf, "/lib");
437 #endif
438
439 Arguments::set_dll_dir(buf);
440
441 if (pslash != NULL) {
463 // should always exist (until the legacy problem cited above is
464 // addressed).
465 // Prepend the default path with the JAVA_LIBRARY_PATH so that the app launcher code
466 // can specify a directory inside an app wrapper
467 const char *l = ::getenv("JAVA_LIBRARY_PATH");
468 const char *l_colon = ":";
469 if (l == NULL) { l = ""; l_colon = ""; }
470
471 const char *v = ::getenv("DYLD_LIBRARY_PATH");
472 const char *v_colon = ":";
473 if (v == NULL) { v = ""; v_colon = ""; }
474
475 // Apple's Java6 has "." at the beginning of java.library.path.
476 // OpenJDK on Windows has "." at the end of java.library.path.
477 // OpenJDK on Linux and Solaris don't have "." in java.library.path
478 // at all. To ease the transition from Apple's Java6 to OpenJDK7,
479 // "." is appended to the end of java.library.path. Yes, this
480 // could cause a change in behavior, but Apple's Java6 behavior
481 // can be achieved by putting "." at the beginning of the
482 // JAVA_LIBRARY_PATH environment variable.
483 char *ld_library_path = (char *)NEW_C_HEAP_ARRAY(char,
484 strlen(v) + 1 + strlen(l) + 1 +
485 system_ext_size + 3,
486 mtInternal);
487 sprintf(ld_library_path, "%s%s%s%s%s" SYS_EXTENSIONS_DIR ":" SYS_EXTENSIONS_DIRS ":.",
488 v, v_colon, l, l_colon, user_home_dir);
489 Arguments::set_library_path(ld_library_path);
490 FREE_C_HEAP_ARRAY(char, ld_library_path);
491 }
492
493 // Extensions directories.
494 //
495 // Note that the space for the colon and the trailing null are provided
496 // by the nulls included by the sizeof operator (so actually one byte more
497 // than necessary is allocated).
498 sprintf(buf, "%s" SYS_EXTENSIONS_DIR ":%s" EXTENSIONS_DIR ":" SYS_EXTENSIONS_DIRS,
499 user_home_dir, Arguments::get_java_home());
500 Arguments::set_ext_dirs(buf);
501
502 FREE_C_HEAP_ARRAY(char, buf);
503
504 #undef SYS_EXTENSIONS_DIR
505 #undef SYS_EXTENSIONS_DIRS
506
|
320 #ifndef DEFAULT_LIBPATH
321 #ifndef OVERRIDE_LIBPATH
322 #define DEFAULT_LIBPATH "/lib:/usr/lib"
323 #else
324 #define DEFAULT_LIBPATH OVERRIDE_LIBPATH
325 #endif
326 #endif
327
328 // Base path of extensions installed on the system.
329 #define SYS_EXT_DIR "/usr/java/packages"
330 #define EXTENSIONS_DIR "/lib/ext"
331
332 #ifndef __APPLE__
333
334 // Buffer that fits several sprintfs.
335 // Note that the space for the colon and the trailing null are provided
336 // by the nulls included by the sizeof operator.
337 const size_t bufsize =
338 MAX2((size_t)MAXPATHLEN, // For dll_dir & friends.
339 (size_t)MAXPATHLEN + sizeof(EXTENSIONS_DIR) + sizeof(SYS_EXT_DIR) + sizeof(EXTENSIONS_DIR)); // extensions dir
340 char *buf = NEW_C_HEAP_ARRAY(char, bufsize, mtInternal);
341
342 // sysclasspath, java_home, dll_dir
343 {
344 char *pslash;
345 os::jvm_path(buf, bufsize);
346
347 // Found the full path to libjvm.so.
348 // Now cut the path to <java_home>/jre if we can.
349 *(strrchr(buf, '/')) = '\0'; // Get rid of /libjvm.so.
350 pslash = strrchr(buf, '/');
351 if (pslash != NULL) {
352 *pslash = '\0'; // Get rid of /{client|server|hotspot}.
353 }
354 Arguments::set_dll_dir(buf);
355
356 if (pslash != NULL) {
357 pslash = strrchr(buf, '/');
358 if (pslash != NULL) {
359 *pslash = '\0'; // Get rid of /<arch>.
360 pslash = strrchr(buf, '/');
370 }
371
372 // Where to look for native libraries.
373 //
374 // Note: Due to a legacy implementation, most of the library path
375 // is set in the launcher. This was to accomodate linking restrictions
376 // on legacy Bsd implementations (which are no longer supported).
377 // Eventually, all the library path setting will be done here.
378 //
379 // However, to prevent the proliferation of improperly built native
380 // libraries, the new path component /usr/java/packages is added here.
381 // Eventually, all the library path setting will be done here.
382 {
383 // Get the user setting of LD_LIBRARY_PATH, and prepended it. It
384 // should always exist (until the legacy problem cited above is
385 // addressed).
386 const char *v = ::getenv("LD_LIBRARY_PATH");
387 const char *v_colon = ":";
388 if (v == NULL) { v = ""; v_colon = ""; }
389 // That's +1 for the colon and +1 for the trailing '\0'.
390 char *ld_library_path = NEW_C_HEAP_ARRAY(char,
391 strlen(v) + 1 +
392 sizeof(SYS_EXT_DIR) + sizeof("/lib/") + strlen(cpu_arch) + sizeof(DEFAULT_LIBPATH) + 1,
393 mtInternal);
394 sprintf(ld_library_path, "%s%s" SYS_EXT_DIR "/lib/%s:" DEFAULT_LIBPATH, v, v_colon, cpu_arch);
395 Arguments::set_library_path(ld_library_path);
396 FREE_C_HEAP_ARRAY(char, ld_library_path);
397 }
398
399 // Extensions directories.
400 sprintf(buf, "%s" EXTENSIONS_DIR ":" SYS_EXT_DIR EXTENSIONS_DIR, Arguments::get_java_home());
401 Arguments::set_ext_dirs(buf);
402
403 FREE_C_HEAP_ARRAY(char, buf);
404
405 #else // __APPLE__
406
407 #define SYS_EXTENSIONS_DIR "/Library/Java/Extensions"
408 #define SYS_EXTENSIONS_DIRS SYS_EXTENSIONS_DIR ":/Network" SYS_EXTENSIONS_DIR ":/System" SYS_EXTENSIONS_DIR ":/usr/lib/java"
409
410 const char *user_home_dir = get_home();
411 // The null in SYS_EXTENSIONS_DIRS counts for the size of the colon after user_home_dir.
412 size_t system_ext_size = strlen(user_home_dir) + sizeof(SYS_EXTENSIONS_DIR) +
413 sizeof(SYS_EXTENSIONS_DIRS);
401 Arguments::set_ext_dirs(buf);
402
403 FREE_C_HEAP_ARRAY(char, buf);
404
405 #else // __APPLE__
406
407 #define SYS_EXTENSIONS_DIR "/Library/Java/Extensions"
408 #define SYS_EXTENSIONS_DIRS SYS_EXTENSIONS_DIR ":/Network" SYS_EXTENSIONS_DIR ":/System" SYS_EXTENSIONS_DIR ":/usr/lib/java"
409
410 const char *user_home_dir = get_home();
411 // The null in SYS_EXTENSIONS_DIRS counts for the size of the colon after user_home_dir.
412 size_t system_ext_size = strlen(user_home_dir) + sizeof(SYS_EXTENSIONS_DIR) +
413 sizeof(SYS_EXTENSIONS_DIRS);
414
415 // Buffer that fits several sprintfs.
416 // Note that the space for the colon and the trailing null are provided
417 // by the nulls included by the sizeof operator.
418 const size_t bufsize =
419 MAX2((size_t)MAXPATHLEN, // for dll_dir & friends.
420 (size_t)MAXPATHLEN + sizeof(EXTENSIONS_DIR) + system_ext_size); // extensions dir
421 char *buf = NEW_C_HEAP_ARRAY(char, bufsize, mtInternal);
422
423 // sysclasspath, java_home, dll_dir
424 {
425 char *pslash;
426 os::jvm_path(buf, bufsize);
427
428 // Found the full path to libjvm.so.
429 // Now cut the path to <java_home>/jre if we can.
430 *(strrchr(buf, '/')) = '\0'; // Get rid of /libjvm.so.
431 pslash = strrchr(buf, '/');
432 if (pslash != NULL) {
433 *pslash = '\0'; // Get rid of /{client|server|hotspot}.
434 }
435 #ifdef STATIC_BUILD
436 strcat(buf, "/lib");
437 #endif
438
439 Arguments::set_dll_dir(buf);
440
441 if (pslash != NULL) {
463 // should always exist (until the legacy problem cited above is
464 // addressed).
465 // Prepend the default path with the JAVA_LIBRARY_PATH so that the app launcher code
466 // can specify a directory inside an app wrapper
467 const char *l = ::getenv("JAVA_LIBRARY_PATH");
468 const char *l_colon = ":";
469 if (l == NULL) { l = ""; l_colon = ""; }
470
471 const char *v = ::getenv("DYLD_LIBRARY_PATH");
472 const char *v_colon = ":";
473 if (v == NULL) { v = ""; v_colon = ""; }
474
475 // Apple's Java6 has "." at the beginning of java.library.path.
476 // OpenJDK on Windows has "." at the end of java.library.path.
477 // OpenJDK on Linux and Solaris don't have "." in java.library.path
478 // at all. To ease the transition from Apple's Java6 to OpenJDK7,
479 // "." is appended to the end of java.library.path. Yes, this
480 // could cause a change in behavior, but Apple's Java6 behavior
481 // can be achieved by putting "." at the beginning of the
482 // JAVA_LIBRARY_PATH environment variable.
483 char *ld_library_path = NEW_C_HEAP_ARRAY(char,
484 strlen(v) + 1 + strlen(l) + 1 +
485 system_ext_size + 3,
486 mtInternal);
487 sprintf(ld_library_path, "%s%s%s%s%s" SYS_EXTENSIONS_DIR ":" SYS_EXTENSIONS_DIRS ":.",
488 v, v_colon, l, l_colon, user_home_dir);
489 Arguments::set_library_path(ld_library_path);
490 FREE_C_HEAP_ARRAY(char, ld_library_path);
491 }
492
493 // Extensions directories.
494 //
495 // Note that the space for the colon and the trailing null are provided
496 // by the nulls included by the sizeof operator (so actually one byte more
497 // than necessary is allocated).
498 sprintf(buf, "%s" SYS_EXTENSIONS_DIR ":%s" EXTENSIONS_DIR ":" SYS_EXTENSIONS_DIRS,
499 user_home_dir, Arguments::get_java_home());
500 Arguments::set_ext_dirs(buf);
501
502 FREE_C_HEAP_ARRAY(char, buf);
503
504 #undef SYS_EXTENSIONS_DIR
505 #undef SYS_EXTENSIONS_DIRS
506
|