Fix the problem of garbled logs on Java 18+ (#1866)
This commit is contained in:
@@ -108,30 +108,16 @@ public class DefaultLauncher extends Launcher {
|
|||||||
res.addAllWithoutParsing(options.getJavaArguments());
|
res.addAllWithoutParsing(options.getJavaArguments());
|
||||||
|
|
||||||
Charset encoding = OperatingSystem.NATIVE_CHARSET;
|
Charset encoding = OperatingSystem.NATIVE_CHARSET;
|
||||||
if (options.getJava().getParsedVersion() < JavaVersion.JAVA_8) {
|
|
||||||
try {
|
|
||||||
String fileEncoding = res.addDefault("-Dfile.encoding=", encoding.name());
|
String fileEncoding = res.addDefault("-Dfile.encoding=", encoding.name());
|
||||||
if (fileEncoding != null)
|
if (fileEncoding != null && !"-Dfile.encoding=COMPAT".equals(fileEncoding)) {
|
||||||
|
try {
|
||||||
encoding = Charset.forName(fileEncoding.substring("-Dfile.encoding=".length()));
|
encoding = Charset.forName(fileEncoding.substring("-Dfile.encoding=".length()));
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
LOG.log(Level.WARNING, "Bad file encoding", ex);
|
LOG.log(Level.WARNING, "Bad file encoding", ex);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if (options.getJava().getParsedVersion() > JavaVersion.JAVA_17
|
|
||||||
&& VersionNumber.VERSION_COMPARATOR.compare(repository.getGameVersion(version).orElse("1.13"), "1.13") < 0) {
|
|
||||||
res.addDefault("-Dfile.encoding=", "COMPAT");
|
|
||||||
}
|
}
|
||||||
|
res.addDefault("-Dsun.stdout.encoding=", encoding.name());
|
||||||
try {
|
|
||||||
String stdoutEncoding = res.addDefault("-Dsun.stdout.encoding=", encoding.name());
|
|
||||||
if (stdoutEncoding != null)
|
|
||||||
encoding = Charset.forName(stdoutEncoding.substring("-Dsun.stdout.encoding=".length()));
|
|
||||||
} catch (Throwable ex) {
|
|
||||||
LOG.log(Level.WARNING, "Bad stdout encoding", ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
res.addDefault("-Dsun.stderr.encoding=", encoding.name());
|
res.addDefault("-Dsun.stderr.encoding=", encoding.name());
|
||||||
}
|
|
||||||
|
|
||||||
// JVM Args
|
// JVM Args
|
||||||
if (!options.isNoGeneratedJVMArgs()) {
|
if (!options.isNoGeneratedJVMArgs()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user