From 1fa3b2ce7fb1970dd67e5e986a034031561c0afb Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Fri, 18 Jul 2014 10:40:55 -0700 Subject: [PATCH] 8050968: Extension class loader initialization fails on Win7 x64 zh_TW Reviewed-by: alanb, dholmes, sherman --- .../sun/nio/cs/ext/ExtendedCharsets.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/jdk/src/share/classes/sun/nio/cs/ext/ExtendedCharsets.java b/jdk/src/share/classes/sun/nio/cs/ext/ExtendedCharsets.java index 91b676c2c0c..7b1db203305 100644 --- a/jdk/src/share/classes/sun/nio/cs/ext/ExtendedCharsets.java +++ b/jdk/src/share/classes/sun/nio/cs/ext/ExtendedCharsets.java @@ -1173,8 +1173,7 @@ public class ExtendedCharsets if (!sun.misc.VM.isBooted()) return; - String map = AccessController.doPrivileged( - (PrivilegedAction) () -> System.getProperty("sun.nio.cs.map")); + String map = getProperty("sun.nio.cs.map"); boolean sjisIsMS932 = false; boolean iso2022jpIsMS50221 = false; boolean iso2022jpIsMS50220 = false; @@ -1294,8 +1293,7 @@ public class ExtendedCharsets } } - String osName = AccessController.doPrivileged( - (PrivilegedAction) () -> System.getProperty("os.name")); + String osName = getProperty("os.name"); if ("SunOS".equals(osName) || "Linux".equals(osName) || "AIX".equals(osName) || osName.contains("OS X")) { charset("x-COMPOUND_TEXT", "COMPOUND_TEXT", @@ -1308,6 +1306,18 @@ public class ExtendedCharsets initialized = true; } + private static String getProperty(String key) { + // this method may be called during initialization of + // system class loader and thus not using lambda + return AccessController.doPrivileged( + new PrivilegedAction() { + @Override + public String run() { + return System.getProperty(key); + } + }); + } + public static String[] aliasesFor(String charsetName) { if (instance == null) return null;