提交 c5761e11 编写于 作者: M mchung

6801467: Defer get the launcher resource bundle until it's needed

Summary: Lazily initialize the launcher resource bundle
Reviewed-by: ksrini, darcy
上级 9b38181f
/* /*
* Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2007-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -55,18 +54,24 @@ public enum LauncherHelper { ...@@ -55,18 +54,24 @@ public enum LauncherHelper {
INSTANCE; INSTANCE;
private static final String defaultBundleName = private static final String defaultBundleName =
"sun.launcher.resources.launcher"; "sun.launcher.resources.launcher";
private static ResourceBundle javarb =
ResourceBundle.getBundle(defaultBundleName);
private static final String MAIN_CLASS = "Main-Class"; private static final String MAIN_CLASS = "Main-Class";
private static StringBuilder outBuf = new StringBuilder(); 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 * A private helper method to get a localized message and also
* apply any arguments that we might pass. * apply any arguments that we might pass.
*/ */
private static String getLocalizedMessage(String key, Object... args) { 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; return (args != null) ? MessageFormat.format(msg, args) : msg;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册