Skip to content

Commit

Permalink
Use new Platform.OS API to determine the running platform
Browse files Browse the repository at this point in the history
  • Loading branch information
HannesWell committed Dec 15, 2024
1 parent ddf0a0a commit 5dd4c25
Show file tree
Hide file tree
Showing 25 changed files with 35 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2661,7 +2661,7 @@ protected IJavaVariable findVariable(IJavaStackFrame frame, String name) throws
* @return true if the local filesystem is case-sensitive, false otherwise
*/
protected boolean isFileSystemCaseSensitive() {
return Platform.OS_MACOSX.equals(Platform.getOS()) ? false : new File("a").compareTo(new File("A")) != 0; //$NON-NLS-1$ //$NON-NLS-2$
return Platform.OS.isMac() ? false : new File("a").compareTo(new File("A")) != 0; //$NON-NLS-1$ //$NON-NLS-2$
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public AutomatedSuite() {
addTest(new TestSuite(ProjectClasspathVariableTests.class));

//mac specific tests
if(Platform.OS_MACOSX.equals(Platform.getOS())) {
if (Platform.OS.isMac()) {
addTest(new TestSuite(PListParserTests.class));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public void testCanUpdate() throws CoreException {
public void testLibraryCaseSensitivity() {
IVMInstall def = JavaRuntime.getDefaultVMInstall();
LibraryLocation[] libs = JavaRuntime.getLibraryLocations(def);
boolean caseSensitive = !Platform.getOS().equals(Platform.WS_WIN32);
boolean caseSensitive = !Platform.OS.isWindows();
LibraryLocation[] set1 = new LibraryLocation[libs.length];
LibraryLocation[] set2 = new LibraryLocation[libs.length];
for (int i = 0; i < libs.length; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ private void waitStarted() throws InterruptedException {
}
}
assertNotNull("Console is null", fConsole);
if (Platform.OS_MACOSX.equals(Platform.getOS())) {
if (Platform.OS.isMac()) {
// on OSX java process writes unexpected message to stderr due to https://bugs.openjdk.java.net/browse/JDK-8022291
// need to wait for the message to fully appear so it can be filtered in #lineAppended above
Thread.sleep(1000L);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.jdt.debug.tests.AbstractDebugTest;
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
import org.eclipse.osgi.service.environment.Constants;

public class EnvironmentTests extends AbstractDebugTest {

Expand All @@ -36,8 +35,7 @@ public EnvironmentTests(String name) {
* Tests that we resolve environment variables as case insenitive on Windows.
*/
public void testWinOSCaseInsensitiveVariable() throws Exception {
boolean win32= Platform.getOS().equals(Constants.OS_WIN32);
if (win32) {
if (Platform.OS.isWindows()) {
IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager();
String path1 = manager.performStringSubstitution("${env_var:pAth}");
String path2 = manager.performStringSubstitution("${env_var:PaTh}");
Expand All @@ -49,8 +47,7 @@ public void testWinOSCaseInsensitiveVariable() throws Exception {
* Test that we can override a variable in a case insensitive way on Windows
*/
public void testWinOSCaseInsensitiveOverride() throws Exception {
boolean win32= Platform.getOS().equals(Constants.OS_WIN32);
if (win32) {
if (Platform.OS.isWindows()) {
ILaunchConfigurationType type = getLaunchManager().getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION);
ILaunchConfigurationWorkingCopy workingCopy = type.newInstance(null, "testWinOSCaseInsensitiveOverride");
Map<String, String> override = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class JavaOutputHelpers {
* </pre>
*/
public static boolean isKnownExtraneousOutput(String txt) {
if (!Platform.OS_MACOSX.equals(Platform.getOS())) {
if (!Platform.OS.isMac()) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void testExitValueNormal() throws Exception {
* wrapped in an IProcess.
*/
public void testAlreadyTerminatedProcess() throws Exception {
if (Platform.getOS().equals(Platform.OS_LINUX)) {
if (Platform.OS.isLinux()) {
return;
}
Process process = DebugPlugin.exec(new String[]{"java"}, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public void testLibraryResolver2() throws Exception {
VMInstallTestsLibraryLocationResolver.isTesting = true;
try {
String filename = "/testfiles/test-jre/bin/test-resolver.ee";
if(Platform.OS_WIN32.equals(Platform.getOS())) {
if (Platform.OS.isWindows()) {
filename = "/testfiles/test-jre/bin/test-resolver-win32.ee";
}
VMStandin vm = getEEStandin(filename);
Expand Down Expand Up @@ -195,7 +195,7 @@ public void testLibraryResolver4() throws Exception {
VMInstallTestsLibraryLocationResolver.isTesting = true;
try {
String filename = "/testfiles/test-jre/bin/test-resolver2.ee";
if(Platform.OS_WIN32.equals(Platform.getOS())) {
if (Platform.OS.isWindows()) {
filename = "/testfiles/test-jre/bin/test-resolver-win32-2.ee";
}
VMStandin vm = getEEStandin(filename);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public void testEvaluateMethodParameter_DeepInTwoNestedClasses() throws Exceptio
}

public void testCompleteMethodParameter_DeepInTwoNestedClasses() throws Exception {
if (Platform.getOS().equals(Platform.OS_MACOSX)) {
if (Platform.OS.isMac()) {
return;
}
addClasses();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
*******************************************************************************/
package org.eclipse.jdt.debug.tests.launching;

import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assume.assumeFalse;
import static org.junit.Assume.assumeThat;
import static org.junit.Assume.assumeTrue;

import java.io.File;
Expand Down Expand Up @@ -77,7 +75,7 @@ public static Test suite() {
suite.addTest(new LongClassPathTests("testVeryLongClasspathWithClasspathOnlyJar"));
if (JavaProjectHelper.isJava9Compatible()) {
suite.addTest(new LongClassPathTests("testVeryLongClasspathWithArgumentFile"));
} else if (Platform.getOS().equals(Platform.OS_WIN32)) {
} else if (Platform.OS.isWindows()) {
suite.addTest(new LongClassPathTests("testVeryLongClasspathWithEnvironmentVariable"));
}
return suite;
Expand Down Expand Up @@ -129,7 +127,7 @@ public void testVeryLongClasspathWithClasspathOnlyJar() throws Exception {
resumeAndExit(thread);

// Then
if (!Platform.getOS().equals(Platform.OS_WIN32)) {
if (!Platform.OS.isWindows()) {
// On windows, temp file deletion may fail
assertFalse(tempFile.exists());
}
Expand Down Expand Up @@ -161,7 +159,7 @@ public void testVeryLongClasspathWithArgumentFile() throws Exception {
resumeAndExit(thread);

// Then
if (!Platform.getOS().equals(Platform.OS_WIN32)) {
if (!Platform.OS.isWindows()) {
// On windows, temp file deletion may fail
assertFalse(tempFile.exists());
}
Expand All @@ -171,7 +169,7 @@ public void testVeryLongClasspathWithArgumentFile() throws Exception {
* On Windows, for JVM < 9, the CLASSPATH env variable is used if classpath is too long
*/
public void testVeryLongClasspathWithEnvironmentVariable() throws Exception {
assumeThat(Platform.getOS(), equalTo(Platform.OS_WIN32));
assumeTrue("Not on Windows", Platform.OS.isWindows());

// Given
javaProject = createJavaProjectClone("testVeryLongClasspath", CLASSPATH_PROJECT_CONTENT_PATH.toString(), JavaProjectHelper.JAVA_SE_1_6_EE_NAME, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void testVeryLongSystemPropertiesWithArgumentFile() throws Exception {
resumeAndExit(thread);

// Then
if (!Platform.getOS().equals(Platform.OS_WIN32)) {
if (!Platform.OS.isWindows()) {
// On windows, temp file deletion may fail
assertFalse(tempFile.exists());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ protected void tearDown() throws Exception {
*/

public void testVeryLongModulepathWithArgumentFile() throws Exception {
if (!Platform.getOS().equals(Platform.OS_WIN32)) {
if (!Platform.OS.isWindows()) {
return;
}
// Given
Expand All @@ -107,7 +107,7 @@ public void testVeryLongModulepathWithArgumentFile() throws Exception {
resumeAndExit(thread);

// Then
if (!Platform.getOS().equals(Platform.OS_WIN32)) {
if (!Platform.OS.isWindows()) {
// On windows, temp file deletion may fail
assertFalse(tempFile.exists());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public void testCaseSensitiveQualifiedSourceLookup() throws Exception {
} else {
// case insensitive - should find the file
assertEquals("Expected 1 result", 1, objects.length);
if (Platform.OS_MACOSX.equals(Platform.getOS())) {
if (Platform.OS.isMac()) {
assertEquals("Wrong file", new File(container.getDirectory(), "oRg/eClIpSe/dEbUg/tEsTs/tArGeTs/INfInItELOop.jaVa"), ((LocalFileStorage)objects[0]).getFile());
} else {
assertEquals("Wrong file", new File(container.getDirectory(), "org/eclipse/debug/tests/targets/InfiniteLoop.java"), ((LocalFileStorage)objects[0]).getFile());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ protected void assertStackFrameIsSelected(String breakpointMethodName) throws Ex
TreeItem[] selected = getSelectedItemsFromDebugView(true);
Object[] selectedText = selectedText(selected);
if (selected.length != 1) {
if (Platform.getOS().equals(Platform.OS_MACOSX)) {
if (Platform.OS.isMac()) {
// skip this test on Mac - see bug 516024
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void testLastStackElementShown() throws Exception {
TreeItem[] selected = getSelectedItemsFromDebugView(true);
Object[] selectedText = selectedText(selected);
if (selected.length != 1) {
if (Platform.getOS().equals(Platform.OS_MACOSX)) {
if (Platform.OS.isMac()) {
// skip this test on Mac - see bug 516024
return;
}
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.jdt.debug.ui/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Require-Bundle: org.eclipse.ui.ide;bundle-version="[3.5.0,4.0.0)",
org.eclipse.jdt.debug;bundle-version="[3.21.0,4.0.0)",
org.eclipse.jdt.launching;bundle-version="[3.23.0,4.0.0)",
org.eclipse.jdt.ui;bundle-version="[3.33.0,4.0.0)",
org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)",
org.eclipse.core.runtime;bundle-version="[3.30.0,4.0.0)",
org.eclipse.ltk.core.refactoring;bundle-version="[3.5.0,4.0.0)",
org.eclipse.ui.console;bundle-version="[3.4.0,4.0.0)",
org.eclipse.jdt.core.manipulation;bundle-version="[1.16.0,2.0.0)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,7 @@ protected void search() {
dialog.setText(JREMessages.InstalledJREsBlock_10);

String path = null;
if (Platform.OS_MACOSX.equals(Platform.getOS())) {
if (Platform.OS.isMac()) {
String MAC_JAVA_SEARCH_PATH = "/Library/Java/JavaVirtualMachines"; //$NON-NLS-1$
dialog.setFilterPath(MAC_JAVA_SEARCH_PATH);
path = dialog.open();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public void widgetSelected(SelectionEvent e) {
}
});

if(Platform.OS_MACOSX.equals(Platform.getOS())) {
if (Platform.OS.isMac()) {
fUseStartOnFirstThread = SWTFactory.createCheckButton(group, LauncherMessages.VMArgumentsBlock_0, null, false, 1);
fUseStartOnFirstThread.addSelectionListener(new SelectionAdapter() {
@Override
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.jdt.launching/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Require-Bundle: org.eclipse.core.resources;bundle-version="[3.14.0,4.0.0)",
org.eclipse.debug.core;bundle-version="[3.22.0,4.0.0)",
org.eclipse.jdt.debug;bundle-version="[3.21.0,4.0.0)",
org.eclipse.core.variables;bundle-version="[3.2.0,4.0.0)",
org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)",
org.eclipse.core.runtime;bundle-version="[3.30.0,4.0.0)",
org.eclipse.osgi;bundle-version="[3.8.0,4.0.0)",
org.eclipse.core.expressions;bundle-version="[3.4.0,4.0.0)"
Bundle-ActivationPolicy: lazy
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.eclipse.jdt.internal.launching;

import org.eclipse.core.runtime.Platform;
import org.eclipse.osgi.service.environment.Constants;

/**
* Utility for quoting of command line Arguments
Expand All @@ -14,7 +13,7 @@ private CommandLineQuoting() {

public static String[] quoteWindowsArgs(String[] cmdLine) {
// see https://bugs.eclipse.org/387504 , workaround for http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6511002
if (Platform.getOS().equals(Constants.OS_WIN32)) {
if (Platform.OS.isWindows()) {
String[] winCmdLine = new String[cmdLine.length];
if (cmdLine.length > 0) {
winCmdLine[0] = cmdLine[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public IStatus run(IProgressMonitor monitor) {
candidates.removeIf(knownVMs::contains);
Collection<VMStandin> systemVMs = Collections.EMPTY_LIST;
// for MacOS, system installed VMs need a special command to locate
if (Platform.OS_MACOSX.equals(Platform.getOS())) {
if (Platform.OS.isMac()) {
try {
systemVMs = new ArrayList<>(Arrays.asList(MacInstalledJREs.getInstalledJREs(monitor)));
systemVMs.removeIf(t -> knownVMs.contains(t.getInstallLocation()));
Expand Down Expand Up @@ -130,7 +130,7 @@ private boolean isDuplicateName(String name) {
private Collection<File> computeCandidateVMs(StandardVMType standardType) {
// parent directories containing a collection of VM installations
Collection<File> rootDirectories = new HashSet<>();
if (Platform.OS_WIN32.equals(Platform.getOS())) {
if (Platform.OS.isWindows()) {
computeWindowsCandidates(rootDirectories);
} else {
rootDirectories.add(new File("/usr/lib/jvm")); //$NON-NLS-1$
Expand Down Expand Up @@ -187,7 +187,7 @@ private static File miseDataDir() {

private static File xdgDataHome() {
String xdgDataHome = System.getenv("XDG_DATA_HOME"); //$NON-NLS-1$
if (Platform.OS_WIN32.equals(Platform.getOS())) {
if (Platform.OS.isWindows()) {
if (xdgDataHome == null) {
xdgDataHome = System.getenv("LOCALAPPDATA"); //$NON-NLS-1$
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public static boolean isSameArchives(LibraryLocation[] libs, LibraryLocation[] d
for (int i = 0; i < defaultLibs.length; i++) {
dpath = defaultLibs[i].getSystemLibraryPath();
lpath = libs[i].getSystemLibraryPath();
if(Platform.getOS().equals(Platform.OS_WIN32)) {
if (Platform.OS.isWindows()) {
//the .equals method of IPath ignores trailing separators so we must as well
if (!dpath.removeTrailingSeparator().toOSString().equalsIgnoreCase(lpath.removeTrailingSeparator().toOSString())) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ public void run(VMRunnerConfiguration config, ILaunch launch, IProgressMonitor m
* @since 3.3
*/
protected String[] prependJREPath(String[] env, IPath jdkpath) {
if(Platform.OS_WIN32.equals(Platform.getOS())) {
if (Platform.OS.isWindows()) {
IPath jrepath = jdkpath.removeLastSegments(1);
if(jrepath.lastSegment().equals(BIN)) {
int count = jrepath.segmentCount();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ protected String[] validateCommandLine(ILaunchConfiguration configuration, Strin
* @return the (possibly) modified command line to launch with
*/
private String[] wrap(ILaunchConfiguration config, String[] cmdLine) throws CoreException {
if(config != null && Platform.OS_MACOSX.equals(Platform.getOS())) {
if (config != null && Platform.OS.isMac()) {
for (String element : cmdLine) {
if ("-ws".equals(element) || element.contains("swt.jar") || element.contains("org.eclipse.swt")) { //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
return createSWTlauncher(cmdLine,
Expand Down Expand Up @@ -593,7 +593,7 @@ int getCPIndex(String[] env) {
* @since 3.3
*/
protected String[] prependJREPath(String[] env) {
if (Platform.OS_MACOSX.equals(Platform.getOS())) {
if (Platform.OS.isMac()) {
if (fVMInstance instanceof IVMInstall2 vm) {
String javaVersion = vm.getJavaVersion();
if (javaVersion != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ protected String getVMVersion(File javaHome, File javaExecutable) {
@Override
public File detectInstallLocation() {
// We want a Mac OSX VM install so don't process the install location for this type
if(Platform.OS_MACOSX.equals(Platform.getOS())) {
if (Platform.OS.isMac()) {
return null;
}
return getJavaHomeLocation();
Expand Down Expand Up @@ -677,7 +677,7 @@ protected LibraryInfo generateLibraryInfo(File javaHome, File javaExecutable) {
Process p = null;
try {
String envp[] = null;
if (Platform.OS_MACOSX.equals(Platform.getOS())) {
if (Platform.OS.isMac()) {
Map<String, String> map = DebugPlugin.getDefault().getLaunchManager().getNativeEnvironmentCasePreserved();
if (map.remove(StandardVMDebugger.JAVA_JVM_VERSION) != null) {
envp = new String[map.size()];
Expand Down

0 comments on commit 5dd4c25

Please sign in to comment.