From f5e029d19c55e43819c409019b371cd9a81f9a10 Mon Sep 17 00:00:00 2001 From: jantje Date: Tue, 9 Jun 2020 19:49:05 +0200 Subject: [PATCH] Bug 564123 delete org.eclipse.cdt.utils.Platform The class overrode org.eclipse.core.runtime.Platform to workaround bugs in the platform that have since been fixed. As 32-bit x86 and PPC support has been removed this class is no longer needed as all the code is now unreachable anyway. Change-Id: I01bb00b9203aa02663ff25ce36c4c14f22dadee5 Signed-off-by: jantje --- .../internal/CMakeBuildConfiguration.java | 2 +- .../internal/macros/MbsMacroSupplier.java | 2 +- .../META-INF/MANIFEST.MF | 2 +- .../meson/core/MesonBuildConfiguration.java | 2 +- .../core/cdtvariables/CdtMacroSupplier.java | 2 +- .../eclipse/cdt/utils/CommandLineUtil.java | 1 + .../utils/org/eclipse/cdt/utils/Platform.java | 114 ------------------ .../guide/deprecated_API_removals.html | 9 ++ 8 files changed, 15 insertions(+), 119 deletions(-) delete mode 100644 core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/Platform.java diff --git a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfiguration.java b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfiguration.java index 31e9d3c8a0f..5e89c87c2f5 100644 --- a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfiguration.java +++ b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfiguration.java @@ -35,12 +35,12 @@ import org.eclipse.cdt.core.envvar.EnvironmentVariable; import org.eclipse.cdt.core.envvar.IEnvironmentVariable; import org.eclipse.cdt.core.model.ICModelMarker; import org.eclipse.cdt.core.resources.IConsole; -import org.eclipse.cdt.utils.Platform; import org.eclipse.core.resources.IBuildConfiguration; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.jobs.Job; import com.google.gson.Gson; diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/MbsMacroSupplier.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/MbsMacroSupplier.java index 2872e375c94..ae90cf4a416 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/MbsMacroSupplier.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/macros/MbsMacroSupplier.java @@ -39,11 +39,11 @@ import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider; import org.eclipse.cdt.managedbuilder.macros.IFileContextBuildMacroValues; import org.eclipse.cdt.managedbuilder.macros.IFileContextData; import org.eclipse.cdt.managedbuilder.macros.IOptionContextData; -import org.eclipse.cdt.utils.Platform; import org.eclipse.cdt.utils.cdtvariables.CdtVariableResolver; import org.eclipse.cdt.utils.cdtvariables.IVariableSubstitutor; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Platform; import org.osgi.framework.Bundle; import org.osgi.framework.Version; diff --git a/build/org.eclipse.cdt.meson.core/META-INF/MANIFEST.MF b/build/org.eclipse.cdt.meson.core/META-INF/MANIFEST.MF index 9d18a0de78b..7a4a9f4b1d0 100644 --- a/build/org.eclipse.cdt.meson.core/META-INF/MANIFEST.MF +++ b/build/org.eclipse.cdt.meson.core/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name.0 Bundle-SymbolicName: org.eclipse.cdt.meson.core;singleton:=true -Bundle-Version: 1.0.300.qualifier +Bundle-Version: 1.0.400.qualifier Bundle-Activator: org.eclipse.cdt.meson.core.Activator Bundle-Vendor: %provider Require-Bundle: org.eclipse.core.runtime, diff --git a/build/org.eclipse.cdt.meson.core/src/org/eclipse/cdt/internal/meson/core/MesonBuildConfiguration.java b/build/org.eclipse.cdt.meson.core/src/org/eclipse/cdt/internal/meson/core/MesonBuildConfiguration.java index 6e9d56bb7f4..2af839e092c 100644 --- a/build/org.eclipse.cdt.meson.core/src/org/eclipse/cdt/internal/meson/core/MesonBuildConfiguration.java +++ b/build/org.eclipse.cdt.meson.core/src/org/eclipse/cdt/internal/meson/core/MesonBuildConfiguration.java @@ -34,13 +34,13 @@ import org.eclipse.cdt.meson.core.Activator; import org.eclipse.cdt.meson.core.IMesonConstants; import org.eclipse.cdt.meson.core.IMesonToolChainFile; import org.eclipse.cdt.meson.core.IMesonToolChainManager; -import org.eclipse.cdt.utils.Platform; import org.eclipse.core.resources.IBuildConfiguration; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.osgi.service.prefs.BackingStoreException; diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/CdtMacroSupplier.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/CdtMacroSupplier.java index 9c44dc9e6f2..4ea7a17fb4c 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/CdtMacroSupplier.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/cdtvariables/CdtMacroSupplier.java @@ -18,7 +18,7 @@ import org.eclipse.cdt.core.cdtvariables.CdtVariable; import org.eclipse.cdt.core.cdtvariables.ICdtVariable; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICProjectDescription; -import org.eclipse.cdt.utils.Platform; +import org.eclipse.core.runtime.Platform; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.ResourcesPlugin; diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/CommandLineUtil.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/CommandLineUtil.java index 7d481c5fb48..bac39b20cb6 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/CommandLineUtil.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/CommandLineUtil.java @@ -16,6 +16,7 @@ package org.eclipse.cdt.utils; import java.util.ArrayList; +import org.eclipse.core.runtime.Platform; import org.eclipse.osgi.service.environment.Constants; /** diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/Platform.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/Platform.java deleted file mode 100644 index cedac0fa86f..00000000000 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/Platform.java +++ /dev/null @@ -1,114 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2011 IBM Corporation and others. - * - * 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: - * IBM Corporation - Initial API and implementation (Corey Ashford) - * Anton Leherbauer (Wind River Systems) - * Markus Schorn (Wind River Systems) - *******************************************************************************/ - -package org.eclipse.cdt.utils; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; - -import org.eclipse.cdt.core.CCorePlugin; -import org.osgi.framework.Bundle; - -/** - * @noinstantiate This class is not intended to be instantiated by clients. - */ -public final class Platform { - - // This class duplicates all of the methods in org.eclipse.core.runtime.Platform - // that are used by the CDT. getOSArch() needs a few tweaks because the value returned - // by org.eclipse.core.runtime.Platform.getOSArch represents what the JVM thinks the - // architecture is. In some cases, we may actually be running on a 64-bit machine, - // but the JVM thinks it's running on a 32-bit machine. Without this change, the CDT - // will not handle 64-bit executables on some ppc64. This method could easily be - // extended to handle other platforms with similar issues. - // - // Unfortunately, the org.eclipse.core.runtime.Platform is final, so we cannot just - // extend it and and then override the getOSArch method, so getBundle and getOS just - // encapsulate calls to the same methods in org.eclipse.core.runtime.Platform. - - public static final String OS_LINUX = org.eclipse.core.runtime.Platform.OS_LINUX; - - private static String cachedArch = null; - - public static Bundle getBundle(String symbolicName) { - return org.eclipse.core.runtime.Platform.getBundle(symbolicName); - } - - public static String getOS() { - return org.eclipse.core.runtime.Platform.getOS(); - } - - public static String getOSArch() { - if (cachedArch == null) { - String arch = org.eclipse.core.runtime.Platform.getOSArch(); - if (arch.equals(org.eclipse.core.runtime.Platform.ARCH_PPC)) { - // Determine if the platform is actually a ppc64 machine - Process unameProcess; - String cmd[] = { "uname", "-p" }; //$NON-NLS-1$//$NON-NLS-2$ - - try { - unameProcess = Runtime.getRuntime().exec(cmd); - - InputStreamReader inputStreamReader = new InputStreamReader(unameProcess.getInputStream()); - BufferedReader bufferedReader = new BufferedReader(inputStreamReader); - String unameOutput = bufferedReader.readLine(); - if (unameOutput != null) { - arch = unameOutput; - } - bufferedReader.close(); - unameProcess.waitFor(); // otherwise the process becomes a zombie - } catch (IOException e) { - CCorePlugin.log(e); - } catch (InterruptedException exc) { - // restore interrupted flag - Thread.currentThread().interrupt(); - } - } else if (arch.equals(org.eclipse.core.runtime.Platform.ARCH_X86)) { - // Determine if the platform is actually a x86_64 machine - Process unameProcess; - String cmd[]; - if (org.eclipse.core.runtime.Platform.OS_WIN32.equals(getOS())) { - cmd = new String[] { "cmd", "/d", "/c", "set", "PROCESSOR_ARCHITECTURE" }; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ - } else { - // We don't use "uname -p" since it returns "unknown" on some Linux systems. - cmd = new String[] { "uname", "-m" }; //$NON-NLS-1$//$NON-NLS-2$ - } - - try { - unameProcess = Runtime.getRuntime().exec(cmd); - unameProcess.getOutputStream().close(); - unameProcess.getErrorStream().close(); - InputStreamReader inputStreamReader = new InputStreamReader(unameProcess.getInputStream()); - BufferedReader bufferedReader = new BufferedReader(inputStreamReader); - String unameOutput = bufferedReader.readLine(); - if (unameOutput != null && unameOutput.endsWith("64")) { //$NON-NLS-1$ - arch = org.eclipse.core.runtime.Platform.ARCH_X86_64; - } - bufferedReader.close(); - unameProcess.waitFor(); // otherwise the process becomes a zombie - } catch (IOException e) { - CCorePlugin.log(e); - } catch (InterruptedException exc) { - // restore interrupted flag - Thread.currentThread().interrupt(); - } - } - cachedArch = arch; - } - return cachedArch; - } -} diff --git a/doc/org.eclipse.cdt.doc.isv/guide/deprecated_API_removals.html b/doc/org.eclipse.cdt.doc.isv/guide/deprecated_API_removals.html index ead65240bf0..220b558c10a 100644 --- a/doc/org.eclipse.cdt.doc.isv/guide/deprecated_API_removals.html +++ b/doc/org.eclipse.cdt.doc.isv/guide/deprecated_API_removals.html @@ -38,6 +38,7 @@
  • NewClassCreationWizardPage breaking changes.
  • Arduino plug-ins and features removed.
  • Remove LRParser, XLC and UPC.
  • +
  • Remove org.eclipse.cdt.utils.Platform.
  • Planned Removals after June 2022 @@ -168,6 +169,14 @@ See Bug 562498.

    +

    7. Remove org.eclipse.cdt.utils.Platform.

    +

    + Class org.eclipse.cdt.utils.Platform has been removed. Use org.eclipse.core.runtime.Platform instead. +

    +

    + See Bug 564123. +

    +

    Future Deletions