cache: Properly produce \n only on windows on jdk9+

Setting `line.separator` is considered bad so now it is only read during JVM startup. Preferred behavior is to override println on the PrintWriter.
See http://mail.openjdk.java.net/pipermail/core-libs-dev/2015-January/030567.html
This commit is contained in:
Max Weber
2018-08-08 22:13:58 -06:00
parent 0e55362b81
commit f6e34b7e16

View File

@@ -40,11 +40,10 @@ public class IDClass extends PrintWriter
public static IDClass create(File directory, String name) throws IOException
{
System.setProperty("line.separator", "\n");
IDClass c = new IDClass(new File(directory, name + ".java"));
c.println("/* This file is automatically generated. Do not edit. */");
c.println("package net.runelite.api;");
c.println("");
c.println();
c.print("public final class ");
c.println(name);
c.println("{");
@@ -62,6 +61,13 @@ public class IDClass extends PrintWriter
println(" public static final int " + javaName + " = " + id + ";");
}
@Override
public void println()
{
// Java 9+ only reads line.separator on startup, so we have to override it here
write('\n');
}
@Override
public void close()
{