From 36e7d4a5f92ff23e258897eb8f55490b353fa571 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=8A?= =?UTF-8?q?=D1=80=20=D0=9A=D1=83=D1=80=D1=82=D0=B0=D0=BA=D0=BE=D0=B2?= Date: Mon, 20 Jan 2025 07:53:54 +0200 Subject: [PATCH 1/2] Use System.lineSeparator() System.getProperty("line.separator") involves SecurityManager checks (depending on JVM used), key validity check and Properties retrieval while lineSeparator() returns the value used to populate the properties with directly. --- .../runtime/logger/AntProcessBuildLogger.java | 10 ++--- .../launching/remote/InternalAntRunner.java | 6 +-- .../RemoteAntBuildListener.java | 8 ++-- .../formatter/XmlDocumentFormatterTest.java | 4 +- .../ui/editor/formatter/XmlFormatterTest.java | 12 +++--- .../editor/formatter/XmlTagFormatterTest.java | 14 +++---- .../ui/testplugin/AbstractAntUITest.java | 4 +- .../internal/ui/datatransfer/ExportUtil.java | 38 +++++++++---------- .../ant/internal/ui/model/AntTaskNode.java | 10 ++--- .../AbstractAntEditorPreferencePage.java | 4 +- .../internal/ui/CopyFailureListAction.java | 4 +- .../compare/internal/core/patch/Hunk.java | 8 ++-- .../internal/core/patch/LineReader.java | 4 +- .../internal/ComparePreferencePage.java | 9 ++--- .../internal/merge/TextStreamMerger.java | 4 +- .../compare/internal/patch/LineReader.java | 4 +- .../compare/internal/patch/Patcher.java | 4 +- .../core/mapping/TextStorageMerger.java | 4 +- .../actions/CopyToClipboardAction.java | 4 +- .../PessimisticFilesystemProvider.java | 4 +- .../org/eclipse/compare/tests/DiffTest.java | 4 +- .../lucene/demo/html/ParseException.java | 16 ++++---- 22 files changed, 89 insertions(+), 90 deletions(-) diff --git a/ant/org.eclipse.ant.launching/loggers/org/eclipse/ant/internal/launching/runtime/logger/AntProcessBuildLogger.java b/ant/org.eclipse.ant.launching/loggers/org/eclipse/ant/internal/launching/runtime/logger/AntProcessBuildLogger.java index 357bc6b4594..5621f0478ad 100644 --- a/ant/org.eclipse.ant.launching/loggers/org/eclipse/ant/internal/launching/runtime/logger/AntProcessBuildLogger.java +++ b/ant/org.eclipse.ant.launching/loggers/org/eclipse/ant/internal/launching/runtime/logger/AntProcessBuildLogger.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2013 IBM Corporation and others. + * Copyright (c) 2000, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -63,7 +63,7 @@ protected void logMessage(String message, BuildEvent event, int overridePriority StringBuffer fullMessage = new StringBuffer(); if (!loggingToLogFile()) { - fullMessage.append(System.getProperty("line.separator")); //$NON-NLS-1$ + fullMessage.append(System.lineSeparator()); } if (event.getException() == null && event.getTask() != null && !fEmacsMode) { adornMessage(event, fullMessage); @@ -117,7 +117,7 @@ private void adornMessage(BuildEvent event, StringBuffer fullMessage) { appendAndLink(fullMessage, location, label, offset, line); line = r.readLine(); while (line != null) { - fullMessage.append(System.getProperty("line.separator")); //$NON-NLS-1$ + fullMessage.append(System.lineSeparator()); fullMessage.append(column); appendAndLink(fullMessage, location, label, offset, line); line = r.readLine(); @@ -262,7 +262,7 @@ private String getTimeString(long milliseconds) { result.append(RuntimeMessages.AntProcessBuildLogger__milliseconds_6); } - result.append(System.getProperty("line.separator")); //$NON-NLS-1$ + result.append(System.lineSeparator()); return result.toString(); } @@ -282,7 +282,7 @@ public void targetStarted(BuildEvent event) { return; } Target target = event.getTarget(); - StringBuilder msg = new StringBuilder(System.getProperty("line.separator")); //$NON-NLS-1$ + StringBuilder msg = new StringBuilder(System.lineSeparator()); String targetName = target.getName(); msg.append(targetName); msg.append(':'); diff --git a/ant/org.eclipse.ant.launching/remote/org/eclipse/ant/internal/launching/remote/InternalAntRunner.java b/ant/org.eclipse.ant.launching/remote/org/eclipse/ant/internal/launching/remote/InternalAntRunner.java index f5691278a8f..4371223eda7 100644 --- a/ant/org.eclipse.ant.launching/remote/org/eclipse/ant/internal/launching/remote/InternalAntRunner.java +++ b/ant/org.eclipse.ant.launching/remote/org/eclipse/ant/internal/launching/remote/InternalAntRunner.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2023 IBM Corporation and others. + * Copyright (c) 2000, 2025 IBM Corporation and others. * Portions Copyright 2000-2005 The Apache Software Foundation * * This program and the accompanying materials are made @@ -328,7 +328,7 @@ private void printTargets(Project project) { */ private void printTargets(Project project, List names, List descriptions, String heading, int maxlen) { // now, start printing the targets and their descriptions - String lSep = System.getProperty("line.separator"); //$NON-NLS-1$ + String lSep = System.lineSeparator(); String spaces = " "; //$NON-NLS-1$ while (spaces.length() < maxlen) { @@ -1164,7 +1164,7 @@ private void printVersion() { * Logs a message with the client outlining the usage of Ant. */ private void printUsage() { - String lSep = System.getProperty("line.separator"); //$NON-NLS-1$ + String lSep = System.lineSeparator(); StringBuilder msg = new StringBuilder(); msg.append("ant ["); //$NON-NLS-1$ msg.append(RemoteAntMessages.getString("InternalAntRunner.options_13")); //$NON-NLS-1$ diff --git a/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/launchConfigurations/RemoteAntBuildListener.java b/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/launchConfigurations/RemoteAntBuildListener.java index d333af44e09..663ee7e4a93 100644 --- a/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/launchConfigurations/RemoteAntBuildListener.java +++ b/ant/org.eclipse.ant.launching/src/org/eclipse/ant/internal/launching/launchConfigurations/RemoteAntBuildListener.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2016 IBM Corporation and others. + * Copyright (c) 2003, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -192,7 +192,7 @@ protected void receiveMessage(String message) { if (index > 0) { int priority = Integer.parseInt(message.substring(0, index)); String msg = message.substring(index + 1); - writeMessage(msg + System.getProperty("line.separator"), priority); //$NON-NLS-1$ + writeMessage(msg + System.lineSeparator(), priority); if (msg.startsWith("BUILD FAILED")) { //$NON-NLS-1$ fBuildFailed = true; } else if (fBuildFailed) { @@ -222,7 +222,7 @@ private void receiveTargetMessage(String message) { int lineNumber = Integer.parseInt(tokenizer.nextToken()); generateLink(msg, location, lineNumber, 0, msg.length() - 1); } - writeMessage(msg + System.getProperty("line.separator"), Project.MSG_INFO); //$NON-NLS-1$ + writeMessage(msg + System.lineSeparator(), Project.MSG_INFO); } private void receiveTaskMessage(String message) { @@ -269,7 +269,7 @@ private void receiveTaskMessage(String message) { StringBuffer fullMessage = new StringBuffer(); adornMessage(taskName, line, fullMessage); - writeMessage(fullMessage.append(System.getProperty("line.separator")).toString(), priority); //$NON-NLS-1$ + writeMessage(fullMessage.append(System.lineSeparator()).toString(), priority); } private void generateLink(String line, String fileName, int lineNumber, int offset, int length) { diff --git a/ant/org.eclipse.ant.tests.ui/Ant Editor Tests/org/eclipse/ant/tests/ui/editor/formatter/XmlDocumentFormatterTest.java b/ant/org.eclipse.ant.tests.ui/Ant Editor Tests/org/eclipse/ant/tests/ui/editor/formatter/XmlDocumentFormatterTest.java index d8adc57cff5..7511187d9fe 100644 --- a/ant/org.eclipse.ant.tests.ui/Ant Editor Tests/org/eclipse/ant/tests/ui/editor/formatter/XmlDocumentFormatterTest.java +++ b/ant/org.eclipse.ant.tests.ui/Ant Editor Tests/org/eclipse/ant/tests/ui/editor/formatter/XmlDocumentFormatterTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2005 John-Mason P. Shackelford and others. + * Copyright (c) 2004, 2025 John-Mason P. Shackelford and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -93,7 +93,7 @@ public boolean useSpacesInsteadOfTabs() { private void simpleTest(String sourceFileName, String targetFileName, FormattingPreferences prefs) throws Exception { XmlDocumentFormatter xmlFormatter = new XmlDocumentFormatter(); - xmlFormatter.setDefaultLineDelimiter(System.getProperty("line.separator")); //$NON-NLS-1$ + xmlFormatter.setDefaultLineDelimiter(System.lineSeparator()); String result = xmlFormatter.format(Files.readString(getBuildFile(sourceFileName).toPath()), prefs); String expectedResult = Files.readString(getBuildFile(targetFileName).toPath()); diff --git a/ant/org.eclipse.ant.tests.ui/Ant Editor Tests/org/eclipse/ant/tests/ui/editor/formatter/XmlFormatterTest.java b/ant/org.eclipse.ant.tests.ui/Ant Editor Tests/org/eclipse/ant/tests/ui/editor/formatter/XmlFormatterTest.java index a39b04a6875..608d9eb9d84 100644 --- a/ant/org.eclipse.ant.tests.ui/Ant Editor Tests/org/eclipse/ant/tests/ui/editor/formatter/XmlFormatterTest.java +++ b/ant/org.eclipse.ant.tests.ui/Ant Editor Tests/org/eclipse/ant/tests/ui/editor/formatter/XmlFormatterTest.java @@ -1,13 +1,13 @@ /******************************************************************************* - * Copyright (c) 2004, 2013 John-Mason P. Shackelford and others. + * Copyright (c) 2004, 2025 John-Mason P. Shackelford and others. * - * This program and the accompanying materials + * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * John-Mason P. Shackelford - initial API and implementation * IBM Corporation - bug 84342 @@ -37,7 +37,7 @@ public final void testFormatUsingPreferenceStore() throws Exception { node.putInt(AntEditorPreferenceConstants.FORMATTER_TAB_SIZE, 4); node.flush(); } - String lineSep = System.getProperty("line.separator"); //$NON-NLS-1$ + String lineSep = System.lineSeparator(); String xmlDoc = "hi"; //$NON-NLS-1$ String formattedDoc = XmlFormatter.format(xmlDoc); String expected = "" + lineSep + "\thi"; //$NON-NLS-1$ String formattedDoc = XmlFormatter.format(xmlDoc, prefs); String expected = "" + lineSep + " hi" //$NON-NLS-1$ + lineSep + lineSep + ""; //$NON-NLS-1$ String formattedDoc = XmlFormatter.format(xmlDoc, prefs); diff --git a/ant/org.eclipse.ant.tests.ui/Ant Editor Tests/org/eclipse/ant/tests/ui/editor/formatter/XmlTagFormatterTest.java b/ant/org.eclipse.ant.tests.ui/Ant Editor Tests/org/eclipse/ant/tests/ui/editor/formatter/XmlTagFormatterTest.java index 75cc0a3cda7..4b43f113bc8 100644 --- a/ant/org.eclipse.ant.tests.ui/Ant Editor Tests/org/eclipse/ant/tests/ui/editor/formatter/XmlTagFormatterTest.java +++ b/ant/org.eclipse.ant.tests.ui/Ant Editor Tests/org/eclipse/ant/tests/ui/editor/formatter/XmlTagFormatterTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2013 John-Mason P. Shackelford and others. + * Copyright (c) 2004, 2025 John-Mason P. Shackelford and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * John-Mason P. Shackelford - initial API and implementation * IBM Corporation - Bug 84342 @@ -192,7 +192,7 @@ public void testParserGetAttributes() throws Exception { @Test public void testFormat01() throws Exception { - String lineSep = System.getProperty("line.separator"); //$NON-NLS-1$ + String lineSep = System.lineSeparator(); String indent = "\t"; //$NON-NLS-1$ String source = ""; //$NON-NLS-1$ String target = ""; //$NON-NLS-1$ String target = ""; //$NON-NLS-1$ String target = "", //$NON-NLS-1$ tagFormatter.wrapTag(tag, dontAlignCloseChar, "\t\t ", lineSep)); //$NON-NLS-1$ @@ -334,7 +334,7 @@ public void testBug63558() throws Exception { // Ordinarily the double space after the element name would be repaired // but if the formatter is working correctly these examples will be // considered malformed and will be passed through untouched. - String lineSep = System.getProperty("line.separator"); //$NON-NLS-1$ + String lineSep = System.lineSeparator(); String source1 = "" + lineSep + "<html><body><pre>" //$NON-NLS-1$ //$NON-NLS-2$ + "${compilelog}</pre></body></html>"; //$NON-NLS-1$ FormattingPreferences prefs = getPreferences(true, false, 60); diff --git a/ant/org.eclipse.ant.tests.ui/test plugin/org/eclipse/ant/tests/ui/testplugin/AbstractAntUITest.java b/ant/org.eclipse.ant.tests.ui/test plugin/org/eclipse/ant/tests/ui/testplugin/AbstractAntUITest.java index 6c4960543b0..de0ea41d671 100644 --- a/ant/org.eclipse.ant.tests.ui/test plugin/org/eclipse/ant/tests/ui/testplugin/AbstractAntUITest.java +++ b/ant/org.eclipse.ant.tests.ui/test plugin/org/eclipse/ant/tests/ui/testplugin/AbstractAntUITest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2021 IBM Corporation and others. + * Copyright (c) 2003, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -285,7 +285,7 @@ protected String getReaderContentAsString(BufferedReader bufferedReader) { while (line != null) { if (result.length() != 0) { - result.append(System.getProperty("line.separator")); //$NON-NLS-1$ + result.append(System.lineSeparator()); } result.append(line); line = bufferedReader.readLine(); diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/datatransfer/ExportUtil.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/datatransfer/ExportUtil.java index 8f3bda6e71d..33d915e8308 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/datatransfer/ExportUtil.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/datatransfer/ExportUtil.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2017 Richard Hoefter and others. + * Copyright (c) 2004, 2025 Richard Hoefter and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -7,11 +7,11 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: - * Richard Hoefter (richard.hoefter@web.de) - initial API and implementation, bug 95300, bug 95297, bug 128104, bug 201180, bug 288830 - * IBM Corporation - NLS'ing and incorporating into Eclipse. - * - Bug 177833 Class created from combination of all utility classes of contribution + * Richard Hoefter (richard.hoefter@web.de) - initial API and implementation, bug 95300, bug 95297, bug 128104, bug 201180, bug 288830 + * IBM Corporation - NLS'ing and incorporating into Eclipse. + * - Bug 177833 Class created from combination of all utility classes of contribution * - Bug 267459 Java project with an external jar file from C:\ on the build path throws a NPE during the Ant Buildfile generation. * - bug fixing *******************************************************************************/ @@ -134,7 +134,7 @@ public static String getProjectRoot(IJavaProject project) { /** * Convert Eclipse path to absolute filename. - * + * * @param file * Project root optionally followed by resource name. An absolute path is simply converted to a string. * @return full qualified path @@ -192,7 +192,7 @@ public static String removeProjectRoot(String file, IProject project) { /** * Remove project root from given project file. - * + * * @param newProjectRoot * replace project root, e.g. with a variable ${project.location} */ @@ -213,7 +213,7 @@ public static String replaceProjectRoot(String file, IProject project, String ne /** * Get for given project all directly dependent projects. - * + * * @return set of IJavaProject objects */ public static List getClasspathProjects(IJavaProject project) throws JavaModelException { @@ -239,7 +239,7 @@ private static void addClasspathProjects(List projects, IClasspath /** * Get for given project all directly and indirectly dependent projects. - * + * * @return set of IJavaProject objects */ public static List getClasspathProjectsRecursive(IJavaProject project) throws JavaModelException { @@ -259,7 +259,7 @@ private static void getClasspathProjectsRecursive(IJavaProject project, LinkedLi /** * Sort projects according to General -> Workspace -> Build Order. - * + * * @param javaProjects * list of IJavaProject objects * @return list of IJavaProject objects with new order @@ -303,10 +303,10 @@ private static List sortProjectsUsingBuildOrder(List /** * Returns cyclic dependency marker for a given project. - * + * *

* See org.eclipse.jdt.core.tests.model.ClasspathTests.numberOfCycleMarkers. - * + * * @param javaProject * project for which cyclic dependency marker should be found * @return cyclic dependency marker for a given project or null if there is no such marker @@ -324,7 +324,7 @@ public static IMarker getCyclicDependencyMarker(IJavaProject javaProject) throws /** * Find JUnit tests. Same tests are also returned by Eclipse run configuration wizard. - * + * * @param containerHandle * project, package or source folder */ @@ -411,7 +411,7 @@ public int compare(IType o1, IType o2) { /** * Platform specific newline character(s). */ - public static final String NEWLINE = System.getProperty("line.separator"); //$NON-NLS-1$ + public static final String NEWLINE = System.lineSeparator(); public static String removePrefix(String s, String prefix) { if (s == null) { @@ -483,7 +483,7 @@ public static String toString(Document doc) throws TransformerConfigurationExcep /** * Converts collection to a separated string. - * + * * @param c * collection * @param separator @@ -504,7 +504,7 @@ public static String toString(Collection c, String separator) { /** * Remove duplicates preserving original order. - * + * * @param l * list to remove duplicates from * @return new list without duplicates @@ -548,7 +548,7 @@ public static boolean existsUserFile(String filename) { /** * Request write access to given file. Depending on the version control plug-in opens a confirm checkout dialog. - * + * * @param shell * parent instance for dialogs * @param file @@ -561,7 +561,7 @@ public static boolean validateEdit(Shell shell, IFile file) { /** * Request write access to given files. Depending on the version control plug-in opens a confirm checkout dialog. - * + * * @param shell * parent instance for dialogs * @return IFile objects for which user confirmed checkout @@ -633,7 +633,7 @@ public static boolean isDefaultClasspath(IJavaProject project, EclipseClasspath /** * Add variable/value for Eclipse variable. If given string is no variable, nothing is added. - * + * * @param variable2valueMap * property map to add variable/value * @param s diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntTaskNode.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntTaskNode.java index 240c18c8e47..21606de2f18 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntTaskNode.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/model/AntTaskNode.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2013 IBM Corporation and others. + * Copyright (c) 2004, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -88,7 +88,7 @@ protected ImageDescriptor getBaseImageDescriptor() { /** * The reference id for this task - * + * * @param id * The reference id for this task */ @@ -98,7 +98,7 @@ public void setId(String id) { /** * Returns the reference id for this task or null if it has no reference id. - * + * * @return The reference id for this task */ public String getId() { @@ -108,7 +108,7 @@ public String getId() { /** * Configures the associated task if required. Allows subclasses to do specific configuration (such as executing the task) by calling * nodeSpecificConfigure - * + * * @return whether the configuration of this node could have impact on other nodes */ public boolean configure(boolean validateFully) { @@ -187,7 +187,7 @@ public List computeIdentifierOffsets(String identifier) { List results = new ArrayList<>(); RuntimeConfigurable wrapper = getTask().getRuntimeConfigurableWrapper(); Map attributeMap = wrapper.getAttributeMap(); - String lineSep = System.getProperty("line.separator"); //$NON-NLS-1$ + String lineSep = System.lineSeparator(); for (String key : attributeMap.keySet()) { String value = (String) attributeMap.get(key); int identifierCorrection = 1; diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AbstractAntEditorPreferencePage.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AbstractAntEditorPreferencePage.java index 1dfc8fa7a81..b64de120551 100644 --- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AbstractAntEditorPreferencePage.java +++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AbstractAntEditorPreferencePage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2013 IBM Corporation and others. + * Copyright (c) 2000, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -330,7 +330,7 @@ protected Control[] addLabelledTextField(Composite composite, String label, Stri protected String loadPreviewContentFromFile(String filename) { String line; - String separator = System.getProperty("line.separator"); //$NON-NLS-1$ + String separator = System.lineSeparator(); StringBuilder buffer = new StringBuilder(512); try (BufferedReader reader = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(filename)))) { while ((line = reader.readLine()) != null) { diff --git a/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/CopyFailureListAction.java b/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/CopyFailureListAction.java index 68cf68bcc95..6479c7ad144 100644 --- a/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/CopyFailureListAction.java +++ b/debug/org.eclipse.unittest.ui/src/org/eclipse/unittest/internal/ui/CopyFailureListAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2010 IBM Corporation and others. + * Copyright (c) 2000, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -71,7 +71,7 @@ public void run() { */ public String getAllFailureTraces() { StringBuilder buf = new StringBuilder(); - String lineDelim = System.getProperty("line.separator", "\n"); //$NON-NLS-1$//$NON-NLS-2$ + String lineDelim = System.lineSeparator(); for (TestElement failure : fRunner.getCurrentTestRunSession().getAllFailedTestElements()) { buf.append(failure.getTestName()).append(lineDelim); FailureTrace failureTrace = failure.getFailureTrace(); diff --git a/team/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/Hunk.java b/team/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/Hunk.java index ad0c51c9716..2f02cb86240 100644 --- a/team/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/Hunk.java +++ b/team/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/Hunk.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2011 IBM Corporation and others. + * Copyright (c) 2000, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -17,7 +17,9 @@ import java.util.ArrayList; import java.util.List; -import org.eclipse.compare.patch.*; +import org.eclipse.compare.patch.IFilePatchResult; +import org.eclipse.compare.patch.IHunk; +import org.eclipse.compare.patch.PatchConfiguration; import org.eclipse.core.runtime.Assert; /** @@ -438,7 +440,7 @@ private String getLineDelimiter(List lines) { // if the file doesn't exist use a line separator from the patch return this.fLines[0].substring(LineReader.length(this.fLines[0])); } - return System.getProperty("line.separator"); //$NON-NLS-1$ + return System.lineSeparator(); } /* diff --git a/team/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/LineReader.java b/team/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/LineReader.java index 12a2d647a9f..60042dca919 100644 --- a/team/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/LineReader.java +++ b/team/bundles/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/patch/LineReader.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2018 IBM Corporation and others. + * Copyright (c) 2000, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -66,7 +66,7 @@ public static String createString(boolean preserveLineDelimeters, List l while (iter.hasNext()) sb.append(iter.next()); } else { - String lineSeparator= System.getProperty("line.separator"); //$NON-NLS-1$ + String lineSeparator = System.lineSeparator(); while (iter.hasNext()) { String line= iter.next(); int l= length(line); diff --git a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java index 53fd4d2f6e0..3e67f3ffdc4 100644 --- a/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java +++ b/team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2017 IBM Corporation and others. + * Copyright (c) 2000, 2025 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -19,7 +19,6 @@ import java.io.InputStream; import java.util.ArrayList; import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Map; @@ -91,7 +90,7 @@ public String getCharset() { private String loadPreviewContentFromFile(String key) { String preview= Utilities.getString(key); - String separator= System.getProperty("line.separator"); //$NON-NLS-1$ + String separator = System.lineSeparator(); StringBuilder buffer= new StringBuilder(); for (int i= 0; i < preview.length(); i++) { char c= preview.charAt(i); @@ -474,9 +473,7 @@ private Control create2WayPreviewer(Composite parent) { private void initializeFields() { - Iterator