JDK-6801467 : Defer get the launcher resource bundle until it's needed
Type:Enhancement
Component:tools
Sub-Component:launcher
Affected Version:7
Priority:P4
Status:Closed
Resolution:Fixed
OS:generic
CPU:generic
Submitted:2009-02-04
Updated:2011-07-15
Resolved:2011-07-15
The Version table provides details related to the release that this issue/RFE will be addressed.
Unresolved : Release in which this issue/RFE will be addressed. Resolved: Release in which this issue/RFE has been resolved. Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.
The launcher resource bundle is only needed when an error occurs. sun.launcher.LauncherHelper class can lazily load the resource bundle instead of by the static initializer.
Comments
SUGGESTED FIX
src/share/classes/sun/launcher/LauncherHelper.java
@@ -53,22 +53,28 @@
public enum LauncherHelper {
INSTANCE;
private static final String defaultBundleName =
"sun.launcher.resources.launcher";
- private static ResourceBundle javarb =
- ResourceBundle.getBundle(defaultBundleName);
private static final String MAIN_CLASS = "Main-Class";
private static StringBuilder outBuf = new StringBuilder();
+ private static ResourceBundle javarb = null;
+ private static synchronized ResourceBundle getLauncherResourceBundle() {
+ if (javarb == null) {
+ javarb = ResourceBundle.getBundle(defaultBundleName);
+ }
+ return javarb;
+ }
+
/**
* A private helper method to get a localized message and also
* apply any arguments that we might pass.
*/
private static String getLocalizedMessage(String key, Object... args) {
- String msg = javarb.getString(key);
+ String msg = getLauncherResourceBundle().getString(key);
return (args != null) ? MessageFormat.format(msg, args) : msg;
}
/**
* The java -help message is split into 3 parts, an invariant, followed
28-02-2009
EVALUATION
Load the launcher resource bundle when it's used instead of at class initialization time.