--- old/src/java.base/share/classes/java/nio/charset/Charset.java 2015-07-07 17:00:17.259449600 +0300 +++ new/src/java.base/share/classes/java/nio/charset/Charset.java 2015-07-07 17:00:17.008839600 +0300 @@ -593,6 +593,7 @@ } private static volatile Charset defaultCharset; + private static volatile Charset defaultUnicodeCharset; /** * Returns the default charset of this Java virtual machine. @@ -620,6 +621,34 @@ return defaultCharset; } + /** + * Returns the default unicode charset of this Java virtual machine. + * + *

The default unicode charset is determined during virtual-machine startup + * and depends on command line option "file.encoding.unicode". + * UTF8 is used by default. + * + * @return A charset object for the default unicode charset + * + */ + public static Charset defaultUnicodeCharset() { + if (defaultUnicodeCharset == null) { + synchronized (Charset.class) { + defaultUnicodeCharset = forName("UTF-8"); + + String csn = AccessController.doPrivileged( + new GetPropertyAction("file.encoding.unicode")); + if (csn != null) { + Charset cs = lookup(csn); + if (cs != null) { + defaultUnicodeCharset = cs; + } + } + } + } + return defaultUnicodeCharset; + } + /* -- Instance fields and methods -- */