8035310: The line.separator property can be retrieved via public API

Reviewed-by: alexsch, serb
This commit is contained in:
Sergey Malenkov 2014-02-21 15:28:09 +04:00
parent 083589648a
commit aaea8f4c7c
5 changed files with 5 additions and 13 deletions

View File

@ -109,8 +109,7 @@ public class BasicOptionPaneUI extends OptionPaneUI {
static {
newline = java.security.AccessController.doPrivileged(
new GetPropertyAction("line.separator"));
newline = System.lineSeparator();
if (newline == null) {
newline = "\n";
}

View File

@ -141,10 +141,7 @@ public abstract class AbstractWriter {
setLineSeparator((String)docNewline);
}
else {
String newline = null;
try {
newline = System.getProperty("line.separator");
} catch (SecurityException se) {}
String newline = System.lineSeparator();
if (newline == null) {
// Should not get here, but if we do it means we could not
// find a newline string, use \n in this case.

View File

@ -317,9 +317,7 @@ public class DefaultEditorKit extends EditorKit {
int offs = pos;
Object endOfLineProperty = doc.getProperty(EndOfLineStringProperty);
if (endOfLineProperty == null) {
try {
endOfLineProperty = System.getProperty("line.separator");
} catch (SecurityException se) { }
endOfLineProperty = System.lineSeparator();
}
String endOfLine;
if (endOfLineProperty instanceof String) {

View File

@ -447,8 +447,7 @@ public final class CompositeFont extends Font2D {
}
public String toString() {
String ls = java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction("line.separator"));
String ls = System.lineSeparator();
String componentsStr = "";
for (int i=0; i<numSlots; i++) {
componentsStr += " Slot["+i+"]="+getSlotFont(i)+ls;

View File

@ -43,8 +43,7 @@ public class XAWTFormatter extends java.util.logging.Formatter {
// Line separator string. This is the value of the line.separator
// property at the moment that the SimpleFormatter was created.
private String lineSeparator = java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction("line.separator"));
private String lineSeparator = System.lineSeparator();
boolean displayFullRecord = false;
boolean useANSI = false;