< prev index next >

src/java.base/unix/native/libjava/java_props_md.c

Print this page
rev 52426 : 8185496: Improve performance of system properties initialization in initPhase1
8213424: VersionProps duplicate and skipped initialization


 382 
 383     /* tmp dir */
 384     sprops.tmp_dir = P_tmpdir;
 385 #ifdef MACOSX
 386     /* darwin has a per-user temp dir */
 387     static char tmp_path[PATH_MAX];
 388     int pathSize = confstr(_CS_DARWIN_USER_TEMP_DIR, tmp_path, PATH_MAX);
 389     if (pathSize > 0 && pathSize <= PATH_MAX) {
 390         sprops.tmp_dir = tmp_path;
 391     }
 392 #endif /* MACOSX */
 393 
 394     /* Printing properties */
 395 #ifdef MACOSX
 396     sprops.printerJob = "sun.lwawt.macosx.CPrinterJob";
 397 #else
 398     sprops.printerJob = "sun.print.PSPrinterJob";
 399 #endif
 400 
 401     /* patches/service packs installed */
 402     sprops.patch_level = "unknown";
 403 
 404     /* Java 2D/AWT properties */
 405 #ifdef MACOSX
 406     // Always the same GraphicsEnvironment and Toolkit on Mac OS X
 407     sprops.graphics_env = "sun.awt.CGraphicsEnvironment";
 408     sprops.awt_toolkit = "sun.lwawt.macosx.LWCToolkit";
 409 
 410     // check if we're in a GUI login session and set java.awt.headless=true if not
 411     sprops.awt_headless = isInAquaSession() ? NULL : "true";
 412 #else
 413     sprops.graphics_env = "sun.awt.X11GraphicsEnvironment";
 414     sprops.awt_toolkit = "sun.awt.X11.XToolkit";
 415 #endif
 416 
 417     /* This is used only for debugging of font problems. */
 418     v = getenv("JAVA2D_FONTPATH");
 419     sprops.font_dir = v ? v : NULL;
 420 
 421 #ifdef SI_ISALIST
 422     /* supported instruction sets */


 471             sprops.desktop = NULL;
 472         }
 473     }
 474 
 475     /* ABI property (optional) */
 476 #ifdef JDK_ARCH_ABI_PROP_NAME
 477     sprops.sun_arch_abi = JDK_ARCH_ABI_PROP_NAME;
 478 #endif
 479 
 480     /* Determine the language, country, variant, and encoding from the host,
 481      * and store these in the user.language, user.country, user.variant and
 482      * file.encoding system properties. */
 483     setlocale(LC_ALL, "");
 484     if (ParseLocale(env, LC_CTYPE,
 485                     &(sprops.format_language),
 486                     &(sprops.format_script),
 487                     &(sprops.format_country),
 488                     &(sprops.format_variant),
 489                     &(sprops.encoding))) {
 490         ParseLocale(env, LC_MESSAGES,
 491                     &(sprops.language),
 492                     &(sprops.script),
 493                     &(sprops.country),
 494                     &(sprops.variant),
 495                     NULL);
 496     } else {
 497         sprops.language = "en";
 498         sprops.encoding = "ISO8859-1";
 499     }
 500     sprops.display_language = sprops.language;
 501     sprops.display_script = sprops.script;
 502     sprops.display_country = sprops.country;
 503     sprops.display_variant = sprops.variant;
 504 
 505     /* ParseLocale failed with OOME */
 506     JNU_CHECK_EXCEPTION_RETURN(env, NULL);
 507 
 508 #ifdef MACOSX
 509     sprops.sun_jnu_encoding = "UTF-8";
 510 #else
 511     sprops.sun_jnu_encoding = sprops.encoding;
 512 #endif
 513 
 514 #ifdef _ALLBSD_SOURCE
 515 #if BYTE_ORDER == _LITTLE_ENDIAN
 516      sprops.unicode_encoding = "UnicodeLittle";
 517  #else
 518      sprops.unicode_encoding = "UnicodeBig";
 519  #endif
 520 #else /* !_ALLBSD_SOURCE */
 521 #ifdef __linux__
 522 #if __BYTE_ORDER == __LITTLE_ENDIAN
 523     sprops.unicode_encoding = "UnicodeLittle";


 526 #endif
 527 #else
 528     sprops.unicode_encoding = "UnicodeBig";
 529 #endif
 530 #endif /* _ALLBSD_SOURCE */
 531 
 532     /* user properties */
 533     {
 534         struct passwd *pwent = getpwuid(getuid());
 535         sprops.user_name = pwent ? strdup(pwent->pw_name) : "?";
 536 #ifdef MACOSX
 537         setUserHome(&sprops);
 538 #else
 539         sprops.user_home = pwent ? strdup(pwent->pw_dir) : NULL;
 540 #endif
 541         if (sprops.user_home == NULL) {
 542             sprops.user_home = "?";
 543         }
 544     }
 545 
 546     /* User TIMEZONE */
 547     {
 548         /*
 549          * We defer setting up timezone until it's actually necessary.
 550          * Refer to TimeZone.getDefault(). However, the system
 551          * property is necessary to be able to be set by the command
 552          * line interface -D. Here temporarily set a null string to
 553          * timezone.
 554          */
 555         tzset();        /* for compatibility */
 556         sprops.timezone = "";
 557     }
 558 
 559     /* Current directory */
 560     {
 561         char buf[MAXPATHLEN];
 562         errno = 0;
 563         if (getcwd(buf, sizeof(buf))  == NULL)
 564             JNU_ThrowByName(env, "java/lang/Error",
 565              "Properties init: Could not determine current working directory.");
 566         else
 567             sprops.user_dir = strdup(buf);
 568     }
 569 
 570     sprops.file_separator = "/";
 571     sprops.path_separator = ":";
 572     sprops.line_separator = "\n";
 573 
 574 #ifdef MACOSX
 575     setProxyProperties(&sprops);
 576 #endif
 577 


 382 
 383     /* tmp dir */
 384     sprops.tmp_dir = P_tmpdir;
 385 #ifdef MACOSX
 386     /* darwin has a per-user temp dir */
 387     static char tmp_path[PATH_MAX];
 388     int pathSize = confstr(_CS_DARWIN_USER_TEMP_DIR, tmp_path, PATH_MAX);
 389     if (pathSize > 0 && pathSize <= PATH_MAX) {
 390         sprops.tmp_dir = tmp_path;
 391     }
 392 #endif /* MACOSX */
 393 
 394     /* Printing properties */
 395 #ifdef MACOSX
 396     sprops.printerJob = "sun.lwawt.macosx.CPrinterJob";
 397 #else
 398     sprops.printerJob = "sun.print.PSPrinterJob";
 399 #endif
 400 
 401     /* patches/service packs installed */
 402     sprops.patch_level = NULL;      // leave it undefined
 403 
 404     /* Java 2D/AWT properties */
 405 #ifdef MACOSX
 406     // Always the same GraphicsEnvironment and Toolkit on Mac OS X
 407     sprops.graphics_env = "sun.awt.CGraphicsEnvironment";
 408     sprops.awt_toolkit = "sun.lwawt.macosx.LWCToolkit";
 409 
 410     // check if we're in a GUI login session and set java.awt.headless=true if not
 411     sprops.awt_headless = isInAquaSession() ? NULL : "true";
 412 #else
 413     sprops.graphics_env = "sun.awt.X11GraphicsEnvironment";
 414     sprops.awt_toolkit = "sun.awt.X11.XToolkit";
 415 #endif
 416 
 417     /* This is used only for debugging of font problems. */
 418     v = getenv("JAVA2D_FONTPATH");
 419     sprops.font_dir = v ? v : NULL;
 420 
 421 #ifdef SI_ISALIST
 422     /* supported instruction sets */


 471             sprops.desktop = NULL;
 472         }
 473     }
 474 
 475     /* ABI property (optional) */
 476 #ifdef JDK_ARCH_ABI_PROP_NAME
 477     sprops.sun_arch_abi = JDK_ARCH_ABI_PROP_NAME;
 478 #endif
 479 
 480     /* Determine the language, country, variant, and encoding from the host,
 481      * and store these in the user.language, user.country, user.variant and
 482      * file.encoding system properties. */
 483     setlocale(LC_ALL, "");
 484     if (ParseLocale(env, LC_CTYPE,
 485                     &(sprops.format_language),
 486                     &(sprops.format_script),
 487                     &(sprops.format_country),
 488                     &(sprops.format_variant),
 489                     &(sprops.encoding))) {
 490         ParseLocale(env, LC_MESSAGES,
 491                     &(sprops.display_language),
 492                     &(sprops.display_script),
 493                     &(sprops.display_country),
 494                     &(sprops.display_variant),
 495                     NULL);
 496     } else {
 497         sprops.display_language = "en";
 498         sprops.encoding = "ISO8859-1";
 499     }




 500 
 501     /* ParseLocale failed with OOME */
 502     JNU_CHECK_EXCEPTION_RETURN(env, NULL);
 503 
 504 #ifdef MACOSX
 505     sprops.sun_jnu_encoding = "UTF-8";
 506 #else
 507     sprops.sun_jnu_encoding = sprops.encoding;
 508 #endif
 509 
 510 #ifdef _ALLBSD_SOURCE
 511 #if BYTE_ORDER == _LITTLE_ENDIAN
 512      sprops.unicode_encoding = "UnicodeLittle";
 513  #else
 514      sprops.unicode_encoding = "UnicodeBig";
 515  #endif
 516 #else /* !_ALLBSD_SOURCE */
 517 #ifdef __linux__
 518 #if __BYTE_ORDER == __LITTLE_ENDIAN
 519     sprops.unicode_encoding = "UnicodeLittle";


 522 #endif
 523 #else
 524     sprops.unicode_encoding = "UnicodeBig";
 525 #endif
 526 #endif /* _ALLBSD_SOURCE */
 527 
 528     /* user properties */
 529     {
 530         struct passwd *pwent = getpwuid(getuid());
 531         sprops.user_name = pwent ? strdup(pwent->pw_name) : "?";
 532 #ifdef MACOSX
 533         setUserHome(&sprops);
 534 #else
 535         sprops.user_home = pwent ? strdup(pwent->pw_dir) : NULL;
 536 #endif
 537         if (sprops.user_home == NULL) {
 538             sprops.user_home = "?";
 539         }
 540     }
 541 
 542     /* User TIMEZONE


 543      * We defer setting up timezone until it's actually necessary.
 544      * Refer to TimeZone.getDefault(). The system property
 545      * is able to be set by the command line interface -Duser.timezone.


 546      */
 547     tzset();        /* for compatibility */


 548 
 549     /* Current directory */
 550     {
 551         char buf[MAXPATHLEN];
 552         errno = 0;
 553         if (getcwd(buf, sizeof(buf))  == NULL)
 554             JNU_ThrowByName(env, "java/lang/Error",
 555              "Properties init: Could not determine current working directory.");
 556         else
 557             sprops.user_dir = strdup(buf);
 558     }
 559 
 560     sprops.file_separator = "/";
 561     sprops.path_separator = ":";
 562     sprops.line_separator = "\n";
 563 
 564 #ifdef MACOSX
 565     setProxyProperties(&sprops);
 566 #endif
 567 
< prev index next >