8198645: Use System.lineSeparator() instead of getProperty("line.separator")
authorrriggs
Fri, 23 Feb 2018 16:00:44 -0500
changeset 48944 25aa8b9f1dae
parent 48943 e61816fc5276
child 48945 6e6c777a37a2
8198645: Use System.lineSeparator() instead of getProperty("line.separator") Reviewed-by: lancea, xuelei, sherman
src/java.base/share/classes/com/sun/crypto/provider/BlockCipherParamsCore.java
src/java.base/share/classes/com/sun/crypto/provider/DHParameters.java
src/java.base/share/classes/com/sun/crypto/provider/DHPublicKey.java
src/java.base/share/classes/com/sun/crypto/provider/GCMParameters.java
src/java.base/share/classes/com/sun/crypto/provider/PBEParameters.java
src/java.base/share/classes/com/sun/crypto/provider/RC2Parameters.java
src/java.base/share/classes/java/util/regex/PatternSyntaxException.java
src/java.base/share/classes/jdk/internal/util/xml/impl/XMLStreamWriterImpl.java
src/java.base/share/classes/jdk/internal/util/xml/impl/XMLWriter.java
src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/ToStream.java
src/java.xml/share/classes/jdk/xml/internal/SecuritySupport.java
--- a/src/java.base/share/classes/com/sun/crypto/provider/BlockCipherParamsCore.java	Fri Feb 23 22:09:16 2018 +0100
+++ b/src/java.base/share/classes/com/sun/crypto/provider/BlockCipherParamsCore.java	Fri Feb 23 16:00:44 2018 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2018, 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
@@ -115,7 +115,7 @@
      * Returns a formatted string describing the parameters.
      */
     public String toString() {
-        String LINE_SEP = System.getProperty("line.separator");
+        String LINE_SEP = System.lineSeparator();
 
         String ivString = LINE_SEP + "    iv:" + LINE_SEP + "[";
         HexDumpEncoder encoder = new HexDumpEncoder();
--- a/src/java.base/share/classes/com/sun/crypto/provider/DHParameters.java	Fri Feb 23 22:09:16 2018 +0100
+++ b/src/java.base/share/classes/com/sun/crypto/provider/DHParameters.java	Fri Feb 23 16:00:44 2018 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2018, 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
@@ -129,7 +129,7 @@
      * Returns a formatted string describing the parameters.
      */
     protected String engineToString() {
-        String LINE_SEP = System.getProperty("line.separator");
+        String LINE_SEP = System.lineSeparator();
 
         StringBuilder sb
             = new StringBuilder("SunJCE Diffie-Hellman Parameters:"
--- a/src/java.base/share/classes/com/sun/crypto/provider/DHPublicKey.java	Fri Feb 23 22:09:16 2018 +0100
+++ b/src/java.base/share/classes/com/sun/crypto/provider/DHPublicKey.java	Fri Feb 23 16:00:44 2018 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2018, 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
@@ -43,7 +43,7 @@
  *
  *
  * @see DHPrivateKey
- * @see java.security.KeyAgreement
+ * @see javax.crypto.KeyAgreement
  */
 final class DHPublicKey implements PublicKey,
 javax.crypto.interfaces.DHPublicKey, Serializable {
@@ -258,7 +258,7 @@
     }
 
     public String toString() {
-        String LINE_SEP = System.getProperty("line.separator");
+        String LINE_SEP = System.lineSeparator();
 
         StringBuilder sb
             = new StringBuilder("SunJCE Diffie-Hellman Public Key:"
--- a/src/java.base/share/classes/com/sun/crypto/provider/GCMParameters.java	Fri Feb 23 22:09:16 2018 +0100
+++ b/src/java.base/share/classes/com/sun/crypto/provider/GCMParameters.java	Fri Feb 23 16:00:44 2018 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2018, 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
@@ -134,7 +134,7 @@
      * Returns a formatted string describing the parameters.
      */
     protected String engineToString() {
-        String LINE_SEP = System.getProperty("line.separator");
+        String LINE_SEP = System.lineSeparator();
         HexDumpEncoder encoder = new HexDumpEncoder();
         StringBuilder sb
             = new StringBuilder(LINE_SEP + "    iv:" + LINE_SEP + "["
--- a/src/java.base/share/classes/com/sun/crypto/provider/PBEParameters.java	Fri Feb 23 22:09:16 2018 +0100
+++ b/src/java.base/share/classes/com/sun/crypto/provider/PBEParameters.java	Fri Feb 23 16:00:44 2018 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2018, 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
@@ -135,7 +135,7 @@
      * Returns a formatted string describing the parameters.
      */
     protected String engineToString() {
-        String LINE_SEP = System.getProperty("line.separator");
+        String LINE_SEP = System.lineSeparator();
         String saltString = LINE_SEP + "    salt:" + LINE_SEP + "[";
         HexDumpEncoder encoder = new HexDumpEncoder();
         saltString += encoder.encodeBuffer(salt);
--- a/src/java.base/share/classes/com/sun/crypto/provider/RC2Parameters.java	Fri Feb 23 22:09:16 2018 +0100
+++ b/src/java.base/share/classes/com/sun/crypto/provider/RC2Parameters.java	Fri Feb 23 16:00:44 2018 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2018, 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
@@ -214,7 +214,7 @@
      * Returns a formatted string describing the parameters.
      */
     protected String engineToString() {
-        String LINE_SEP = System.getProperty("line.separator");
+        String LINE_SEP = System.lineSeparator();
         HexDumpEncoder encoder = new HexDumpEncoder();
         StringBuilder sb
             = new StringBuilder(LINE_SEP + "    iv:" + LINE_SEP + "["
--- a/src/java.base/share/classes/java/util/regex/PatternSyntaxException.java	Fri Feb 23 22:09:16 2018 +0100
+++ b/src/java.base/share/classes/java/util/regex/PatternSyntaxException.java	Fri Feb 23 16:00:44 2018 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2018, 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
@@ -25,9 +25,6 @@
 
 package java.util.regex;
 
-import sun.security.action.GetPropertyAction;
-
-
 /**
  * Unchecked exception thrown to indicate a syntax error in a
  * regular-expression pattern.
@@ -93,9 +90,6 @@
         return pattern;
     }
 
-    private static final String nl =
-            GetPropertyAction.privilegedGetProperty("line.separator");
-
     /**
      * Returns a multi-line string containing the description of the syntax
      * error and its index, the erroneous regular-expression pattern, and a
@@ -110,10 +104,10 @@
             sb.append(" near index ");
             sb.append(index);
         }
-        sb.append(nl);
+        sb.append(System.lineSeparator());
         sb.append(pattern);
         if (index >= 0) {
-            sb.append(nl);
+            sb.append(System.lineSeparator());
             for (int i = 0; i < index; i++) sb.append(' ');
             sb.append('^');
         }
--- a/src/java.base/share/classes/jdk/internal/util/xml/impl/XMLStreamWriterImpl.java	Fri Feb 23 22:09:16 2018 +0100
+++ b/src/java.base/share/classes/jdk/internal/util/xml/impl/XMLStreamWriterImpl.java	Fri Feb 23 16:00:44 2018 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2018, 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
@@ -75,8 +75,7 @@
     //pretty print by default
     private boolean _doIndent = true;
     //The system line separator for writing out line breaks.
-    private char[] _lineSep =
-            System.getProperty("line.separator").toCharArray();
+    private char[] _lineSep = System.lineSeparator().toCharArray();
 
     public XMLStreamWriterImpl(OutputStream os) throws XMLStreamException {
         this(os, XMLStreamWriter.DEFAULT_CHARSET);
--- a/src/java.base/share/classes/jdk/internal/util/xml/impl/XMLWriter.java	Fri Feb 23 22:09:16 2018 +0100
+++ b/src/java.base/share/classes/jdk/internal/util/xml/impl/XMLWriter.java	Fri Feb 23 16:00:44 2018 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2018, 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
@@ -123,7 +123,7 @@
     }
 
     private void nl() throws XMLStreamException {
-        String lineEnd = System.getProperty("line.separator");
+        String lineEnd = System.lineSeparator();
         try {
             _writer.write(lineEnd);
         } catch (IOException e) {
--- a/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/ToStream.java	Fri Feb 23 22:09:16 2018 +0100
+++ b/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/ToStream.java	Fri Feb 23 16:00:44 2018 -0500
@@ -138,8 +138,7 @@
      * but this value can be set through the xsl:output
      * extension attribute xalan:line-separator.
      */
-    protected char[] m_lineSep =
-        SecuritySupport.getSystemProperty("line.separator").toCharArray();
+    protected char[] m_lineSep = System.lineSeparator().toCharArray();
 
     /**
      * True if the the system line separator is to be used.
--- a/src/java.xml/share/classes/jdk/xml/internal/SecuritySupport.java	Fri Feb 23 22:09:16 2018 +0100
+++ b/src/java.xml/share/classes/jdk/xml/internal/SecuritySupport.java	Fri Feb 23 16:00:44 2018 -0500
@@ -45,7 +45,7 @@
  * This class contains utility methods for reading resources in the JAXP packages
  */
 public class SecuritySupport {
-    public final static String NEWLINE = getSystemProperty("line.separator", "\n");
+    public final static String NEWLINE = System.lineSeparator();
 
     /**
      * Cache for properties in java.home/conf/jaxp.properties