On Fri, 22 Oct 2021 04:54:35 GMT, Glavo <d...@openjdk.java.net> wrote:
>> Naoto Sato has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Moved the null sentence into @param tag. > > Oh, I found that I checked the outdated source code. Now this problem does > not exist in `StringCoding`. > > I simply browsed the latest source code of JDK and found that this idiom no > longer appears outside jline. I believe that the source code of jline does > not need to be modified in openjdk. > > But I noticed `LauncherHelper.makePlatformString` > (https://github.com/openjdk/jdk/blob/c978ca87de2d9152345dfd85983278c42bb28cd3/src/java.base/share/classes/sun/launcher/LauncherHelper.java#L887) > > I don't understand why it stores `encoding` string and `isCharsetSupported` > boolean values. Nor do I find references to these two fields in native code. > I think it may be improved in this PR like this: > > > > private static final String encprop = "sun.jnu.encoding"; > private static Charset charset = null; > > /* > * converts a c or a byte array to a platform specific string, > * previously implemented as a native method in the launcher. > */ > static String makePlatformString(boolean printToStderr, byte[] inArray) { > initOutput(printToStderr); > if (charset == null) { > charset = Charset.forName(System.getProperty(encprop), > Charset.defaultCharset()); > } > return new String(inArray, charset); > } @Glavo, thank you for the suggestions. Although applying the new method in the JDK code would be useful, I'd keep this PR just to introduce this new method. ------------- PR: https://git.openjdk.java.net/jdk/pull/6045