Skip to content

Commit

Permalink
Deprecate Helper's FILE/PATH separators for removal
Browse files Browse the repository at this point in the history
Signed-off-by: Lukas Jungmann <lukas.jungmann@oracle.com>
  • Loading branch information
lukasj committed Aug 21, 2023
1 parent 9da70bf commit 2b8dd8d
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

import org.eclipse.persistence.testing.framework.*;

import java.io.File;

/**
* Parital test for Bug 2756643.
* Tests to ensure the Helper statics which access System Properties
Expand All @@ -32,11 +34,11 @@ public void verify() {
throw new TestErrorException("System.lineSeparator() returns the incorrect value.");
}

if (!org.eclipse.persistence.internal.helper.Helper.pathSeparator().equals(System.getProperty("path.separator"))) {
if (!org.eclipse.persistence.internal.helper.Helper.pathSeparator().equals(File.pathSeparator)) {
throw new TestErrorException("Helper.pathSeparator() returns the incorrect value.");
}

if (!org.eclipse.persistence.internal.helper.Helper.fileSeparator().equals(System.getProperty("file.separator"))) {
if (!org.eclipse.persistence.internal.helper.Helper.fileSeparator().equals(File.separator)) {
throw new TestErrorException("Helper.fileSeparator() returns the incorrect value.");
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2021 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2023 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand Down Expand Up @@ -89,8 +89,6 @@ public void test() throws Exception {
} catch (Exception e) {
}

String lineSeparator = System.getProperty("file.separator");

method = getDeclaredMethod(clazz, methodName, methodParameterTypes, true);
method.getParameterTypes();
method.getReturnType();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,14 @@ public class Helper extends CoreHelper implements Serializable {
/** Store newline string */
public static final String NL = "\n";

/** Prime the platform-dependent path separator */
/** Prime the platform-dependent path separator
* @deprecated Use {@link File#pathSeparator}. */
@Deprecated(forRemoval = true)
protected static String PATH_SEPARATOR = null;

/** Prime the platform-dependent file separator */
/** Prime the platform-dependent file separator
* @deprecated Use {@link File#separator}. */
@Deprecated(forRemoval = true)
protected static String FILE_SEPARATOR = null;

/** Prime the platform-dependent current working directory */
Expand Down Expand Up @@ -983,11 +987,13 @@ public static String extractJarNameFromURL(java.net.URL url) {
/**
* Return a string containing the platform-appropriate
* characters for separating directory and file names.
* @deprecated Use {@link File#separator}.
*/
@Deprecated(forRemoval = true)
public static String fileSeparator() {
//Bug 2756643
if (FILE_SEPARATOR == null) {
FILE_SEPARATOR = PrivilegedAccessHelper.getSystemProperty("file.separator");
FILE_SEPARATOR = File.separator;
}
return FILE_SEPARATOR;
}
Expand Down Expand Up @@ -1251,11 +1257,13 @@ public static void outputClassFile(String className, byte[] classBytes,
/**
* Return a string containing the platform-appropriate
* characters for separating entries in a path (e.g. the classpath)
* @deprecated Use {@link File#pathSeparator}.
*/
@Deprecated(forRemoval = true)
public static String pathSeparator() {
// Bug 2756643
if (PATH_SEPARATOR == null) {
PATH_SEPARATOR = PrivilegedAccessHelper.getSystemProperty("path.separator");
PATH_SEPARATOR = File.pathSeparator;
}
return PATH_SEPARATOR;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public class PrivilegedAccessHelper {
private static boolean shouldCheckPrivilegedAccess = true;
private static boolean shouldUsePrivilegedAccess = false;

private final static String[] legalProperties = { "file.separator", "java.io.tmpdir", JavaVersion.VM_VERSION_PROPERTY, "path.separator", "user.dir",
private final static String[] legalProperties = { "java.io.tmpdir", JavaVersion.VM_VERSION_PROPERTY, "user.dir",
"org.eclipse.persistence.fetchgroupmonitor", "org.eclipse.persistence.querymonitor", "SAP_J2EE_Engine_Version",
PersistenceUnitProperties.ECLIPSELINK_PERSISTENCE_XML, PersistenceUnitProperties.JAVASE_DB_INTERACTION,
PersistenceUnitProperties.LOGGING_FILE, PersistenceUnitProperties.LOGGING_LEVEL,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2020 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2023 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand Down Expand Up @@ -52,7 +52,7 @@ public static void loadProperties(Map<String, Object> properties) {
public static void loadProperties(Map<String, Object> properties, String filename) {
loadProperties(properties, new File(filename));
String home = System.getProperty("user.home");
loadProperties(properties, new File(home + System.getProperty("file.separator") + filename));
loadProperties(properties, new File(home + File.separator + filename));
for (Object key : System.getProperties().keySet()) {
String keyName = (String) key;
if (keyName.startsWith("jakarta.persistence") || keyName.startsWith("eclipselink")) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2020 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2023 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand Down Expand Up @@ -52,7 +52,7 @@ public static void loadProperties(Map<String, Object> properties) {
public static void loadProperties(Map<String, Object> properties, String filename) {
loadProperties(properties, new File(filename));
String home = System.getProperty("user.home");
loadProperties(properties, new File(home + System.getProperty("file.separator") + filename));
loadProperties(properties, new File(home + File.separator + filename));
for (Object key : System.getProperties().keySet()) {
String keyName = (String) key;
if (keyName.startsWith("jakarta.persistence") || keyName.startsWith("eclipselink")) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2020 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2023 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand All @@ -26,7 +26,7 @@
* @see org.eclipse.persistence.sdo.helper.CodeWriter
*/
public class FileCodeWriter implements CodeWriter {
private static final String fsep = System.getProperty("file.separator");
private static final String fsep = File.separator;

/** The source directory to write the generated files to. This will be prepended to the package. */
private String sourceDir;
Expand Down

0 comments on commit 2b8dd8d

Please sign in to comment.