# HG changeset patch # User redestad # Date 1420523392 -3600 # Tue Jan 06 06:49:52 2015 +0100 # Node ID 33025c9a470f5f635e776e24273fb6145efc7059 # Parent bc74cc84c49e11af49e0b751f46f7eb5828e8605 8068498: Remove constructor dependency on line.separator from PrintWriter and BufferedWriter diff --git a/src/java.base/share/classes/java/io/BufferedWriter.java b/src/java.base/share/classes/java/io/BufferedWriter.java --- a/src/java.base/share/classes/java/io/BufferedWriter.java +++ b/src/java.base/share/classes/java/io/BufferedWriter.java @@ -73,12 +73,6 @@ private static int defaultCharBufferSize = 8192; /** - * Line separator string. This is the value of the line.separator - * property at the moment that the stream was created. - */ - private String lineSeparator; - - /** * Creates a buffered character-output stream that uses a default-sized * output buffer. * @@ -105,9 +99,6 @@ cb = new char[sz]; nChars = sz; nextChar = 0; - - lineSeparator = java.security.AccessController.doPrivileged( - new sun.security.action.GetPropertyAction("line.separator")); } /** Checks to make sure that the stream has not been closed */ @@ -240,7 +231,7 @@ * @exception IOException If an I/O error occurs */ public void newLine() throws IOException { - write(lineSeparator); + write(System.lineSeparator()); } /** diff --git a/src/java.base/share/classes/java/io/PrintWriter.java b/src/java.base/share/classes/java/io/PrintWriter.java --- a/src/java.base/share/classes/java/io/PrintWriter.java +++ b/src/java.base/share/classes/java/io/PrintWriter.java @@ -69,12 +69,6 @@ private PrintStream psOut = null; /** - * Line separator string. This is the value of the line.separator - * property at the moment that the stream was created. - */ - private final String lineSeparator; - - /** * Returns a charset object for the given charset name. * @throws NullPointerException is csn is null * @throws UnsupportedEncodingException if the charset is not supported @@ -113,8 +107,6 @@ super(out); this.out = out; this.autoFlush = autoFlush; - lineSeparator = java.security.AccessController.doPrivileged( - new sun.security.action.GetPropertyAction("line.separator")); } /** @@ -477,7 +469,7 @@ try { synchronized (lock) { ensureOpen(); - out.write(lineSeparator); + out.write(System.lineSeparator()); if (autoFlush) out.flush(); }