Cleanup (deprecates SystemProperties methods in favor of cached constants)

This commit is contained in:
Roman Shevchenko
2018-01-22 18:35:35 +03:00
parent 6cc142ed09
commit 3129a605dc
7 changed files with 36 additions and 69 deletions
@@ -1,6 +1,4 @@
/*
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.compiler.server;
import com.intellij.ProjectTopics;
@@ -222,7 +220,7 @@ public class BuildManager implements Disposable {
final String fallbackSdkHome = getFallbackSdkHome();
if (fallbackSdkHome != null) {
myFallbackJdkParams.add("-D" + GlobalOptions.FALLBACK_JDK_HOME + "=" + fallbackSdkHome);
myFallbackJdkParams.add("-D" + GlobalOptions.FALLBACK_JDK_VERSION + "=" + SystemProperties.getJavaVersion());
myFallbackJdkParams.add("-D" + GlobalOptions.FALLBACK_JDK_VERSION + "=" + SystemInfo.JAVA_VERSION);
}
MessageBusConnection connection = application.getMessageBus().connect();
@@ -8,6 +8,7 @@ import com.intellij.openapi.projectRoots.JavaSdk;
import com.intellij.openapi.projectRoots.ProjectJdkTable;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.projectRoots.SdkTypeId;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.util.SystemProperties;
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
@@ -29,7 +30,7 @@ public class JavaAwareProjectJdkTableImpl extends ProjectJdkTableImpl {
public Sdk getInternalJdk() {
if (myInternalJdk == null) {
final String jdkHome = SystemProperties.getJavaHome();
final String versionName = ProjectBundle.message("sdk.java.name.template", SystemProperties.getJavaVersion());
final String versionName = ProjectBundle.message("sdk.java.name.template", SystemInfo.JAVA_VERSION);
myInternalJdk = myJavaSdk.createJdk(versionName, jdkHome);
}
return myInternalJdk;
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.openapi.application.impl;
import com.google.common.annotations.VisibleForTesting;
@@ -30,7 +16,6 @@ import com.intellij.openapi.util.text.StringUtil;
import com.intellij.ui.JBColor;
import com.intellij.util.ArrayUtil;
import com.intellij.util.PlatformUtils;
import com.intellij.util.SystemProperties;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.JBRectangle;
import org.jdom.Document;
@@ -690,7 +675,7 @@ public class ApplicationInfoImpl extends ApplicationInfoEx {
myMajorVersion + "." + myMinorVersion + "#" + myBuildNumber +
" " + ApplicationNamesInfo.getInstance().getProductName() +
", eap:" + myEAP + ", os:" + SystemInfoRt.OS_NAME + " " + SystemInfoRt.OS_VERSION +
", java-version:" + SystemProperties.getJavaVendor() + " " + SystemInfo.JAVA_RUNTIME_VERSION);
", java-version:" + SystemInfo.JAVA_VENDOR + " " + SystemInfo.JAVA_RUNTIME_VERSION);
Element logoElement = getChild(parentNode, ELEMENT_LOGO);
if (logoElement != null) {
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.errorreport.itn;
import com.google.common.collect.ArrayListMultimap;
@@ -35,11 +21,11 @@ import com.intellij.openapi.progress.Task;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.updateSettings.impl.UpdateSettings;
import com.intellij.openapi.util.BuildNumber;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.security.CompositeX509TrustManager;
import com.intellij.util.Consumer;
import com.intellij.util.SystemProperties;
import com.intellij.util.net.NetUtils;
import com.intellij.util.net.ssl.CertificateUtil;
import org.jetbrains.annotations.NotNull;
@@ -157,9 +143,9 @@ public class ITNProxy {
params.put("user.login", login);
params.put("user.password", password);
params.put("os.name", SystemProperties.getOsName());
params.put("java.version", SystemProperties.getJavaVersion());
params.put("java.vm.vendor", SystemProperties.getJavaVmVendor());
params.put("os.name", SystemInfo.OS_NAME);
params.put("java.version", SystemInfo.JAVA_VERSION);
params.put("java.vm.vendor", SystemInfo.JAVA_VENDOR);
ApplicationInfoEx appInfo = ApplicationInfoEx.getInstanceEx();
ApplicationNamesInfo namesInfo = ApplicationNamesInfo.getInstance();
@@ -4,12 +4,13 @@ package com.intellij.openapi.util;
import com.intellij.openapi.util.io.PathExecLazyValue;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.ObjectUtils;
import com.intellij.util.SystemProperties;
import com.intellij.util.lang.JavaVersion;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import static com.intellij.openapi.util.text.StringUtil.containsIgnoreCase;
@SuppressWarnings({"HardCodedStringLiteral", "UtilityClassWithoutPrivateConstructor", "UnusedDeclaration"})
public class SystemInfo extends SystemInfoRt {
public static final String OS_NAME = SystemInfoRt.OS_NAME;
@@ -17,6 +18,7 @@ public class SystemInfo extends SystemInfoRt {
public static final String OS_ARCH = System.getProperty("os.arch");
public static final String JAVA_VERSION = System.getProperty("java.version");
public static final String JAVA_RUNTIME_VERSION = getRtVersion(JAVA_VERSION);
public static final String JAVA_VENDOR = System.getProperty("java.vm.vendor", "Unknown");
public static final String ARCH_DATA_MODEL = System.getProperty("sun.arch.data.model");
public static final String SUN_DESKTOP = System.getProperty("sun.desktop", "");
@@ -32,11 +34,11 @@ public class SystemInfo extends SystemInfoRt {
public static final boolean isSolaris = SystemInfoRt.isSolaris;
public static final boolean isUnix = SystemInfoRt.isUnix;
public static final boolean isAppleJvm = vendorContains("Apple");
public static final boolean isOracleJvm = vendorContains("Oracle");
public static final boolean isSunJvm = vendorContains("Sun") && vendorContains("Microsystems");
public static final boolean isIbmJvm = vendorContains("IBM");
public static final boolean isJetBrainsJvm = vendorContains("JetBrains");
public static final boolean isAppleJvm = containsIgnoreCase(JAVA_VENDOR, "Apple");
public static final boolean isOracleJvm = containsIgnoreCase(JAVA_VENDOR, "Oracle");
public static final boolean isSunJvm = containsIgnoreCase(JAVA_VENDOR, "Sun") && containsIgnoreCase(JAVA_VENDOR, "Microsystems");
public static final boolean isIbmJvm = containsIgnoreCase(JAVA_VENDOR, "IBM");
public static final boolean isJetBrainsJvm = containsIgnoreCase(JAVA_VENDOR, "JetBrains");
public static final boolean IS_AT_LEAST_JAVA9 = isModularJava();
@@ -176,11 +178,6 @@ public class SystemInfo extends SystemInfoRt {
return JavaVersion.current().compareTo(JavaVersion.compose(major, minor, update, 0, false)) >= 0;
}
private static boolean vendorContains(String s) {
final String vendor = SystemProperties.getJavaVmVendor();
return vendor != null && StringUtil.containsIgnoreCase(vendor, s);
}
//<editor-fold desc="Deprecated stuff.">
/** @deprecated use {@link #isJavaVersionAtLeast(int, int, int)} (to be removed in IDEA 2020) */
public static boolean isJavaVersionAtLeast(String v) {
@@ -1,6 +1,7 @@
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.util;
import com.intellij.openapi.util.SystemInfo;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.TestOnly;
@@ -8,6 +9,7 @@ import org.jetbrains.annotations.TestOnly;
/**
* Utility wrappers for accessing system properties.
*
* @see SystemInfo
* @author yole
*/
public class SystemProperties {
@@ -33,19 +35,19 @@ public class SystemProperties {
return System.getProperty("line.separator");
}
/** @deprecated use {@link SystemInfo#OS_NAME} (to be removed in IDEA 2020) */
public static String getOsName() {
return System.getProperty("os.name");
return SystemInfo.OS_NAME;
}
/**
* If you need to compare the version with some value, use {@link com.intellij.openapi.util.SystemInfo#isJavaVersionAtLeast(int, int, int)}.
*/
/** @deprecated use {@link SystemInfo#JAVA_VERSION} (to be removed in IDEA 2020) */
public static String getJavaVersion() {
return System.getProperty("java.version");
return SystemInfo.JAVA_VERSION;
}
/** @deprecated use {@link SystemInfo#JAVA_VENDOR} (to be removed in IDEA 2020) */
public static String getJavaVmVendor() {
return System.getProperty("java.vm.vendor");
return SystemInfo.JAVA_VENDOR;
}
public static String getJavaHome() {
@@ -79,8 +81,9 @@ public class SystemProperties {
return defaultValue;
}
/** @deprecated use {@link SystemInfo#JAVA_VENDOR} (to be removed in IDEA 2020) */
public static String getJavaVendor() {
return System.getProperty("java.vendor");
return SystemInfo.JAVA_VENDOR;
}
public static boolean is(String key) {
@@ -37,10 +37,7 @@ import com.intellij.openapi.projectRoots.*;
import com.intellij.openapi.roots.ModuleRootManager;
import com.intellij.openapi.roots.ProjectFileIndex;
import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.util.DefaultJDOMExternalizer;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.openapi.util.*;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.pointers.VirtualFilePointer;
@@ -88,7 +85,7 @@ public final class XsltRunConfiguration extends LocatableConfigurationBase imple
public boolean myOpenOutputFile;
public boolean myOpenInBrowser;
public boolean mySmartErrorHandling = true;
@Deprecated // this is only used if the dynamic selection of a port fails
@Deprecated // this is only used if the dynamic selection of a port fails
public int myRunnerPort = 34873;
public String myVmArguments;
public String myWorkingDirectory;
@@ -440,25 +437,25 @@ public final class XsltRunConfiguration extends LocatableConfigurationBase imple
}
private static Sdk ourDefaultSdk;
private static synchronized Sdk getDefaultSdk() {
if (ourDefaultSdk == null) {
final String jdkHome = SystemProperties.getJavaHome();
final String versionName = ProjectBundle.message("sdk.java.name.template", SystemProperties.getJavaVersion());
final String versionName = ProjectBundle.message("sdk.java.name.template", SystemInfo.JAVA_VERSION);
Sdk sdk = ProjectJdkTable.getInstance().createSdk(versionName, new SimpleJavaSdkType());
SdkModificator modificator = sdk.getSdkModificator();
modificator.setHomePath(jdkHome);
modificator.commitChanges();
ourDefaultSdk = sdk;
}
return ourDefaultSdk;
}
@Nullable
public Sdk getEffectiveJDK() {
if (!XsltRunSettingsEditor.ALLOW_CHOOSING_SDK) {
return getDefaultSdk();
return getDefaultSdk();
}
if (myJdkChoice == JdkChoice.JDK) {
return myJdk != null ? ProjectJdkTable.getInstance().findJdk(myJdk) : null;