8068498: Remove constructor dependency on line.separator from PrintWriter and BufferedWriter
Reviewed-by: alanb, sherman
--- a/jdk/src/java.base/share/classes/java/io/BufferedWriter.java Wed Jan 14 13:43:12 2015 +0300
+++ b/jdk/src/java.base/share/classes/java/io/BufferedWriter.java Tue Jan 06 06:49:52 2015 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -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());
}
/**
--- a/jdk/src/java.base/share/classes/java/io/PrintWriter.java Wed Jan 14 13:43:12 2015 +0300
+++ b/jdk/src/java.base/share/classes/java/io/PrintWriter.java Tue Jan 06 06:49:52 2015 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -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();
}