From 12ef5fea76be4d6e77689984ecb4098298c76e70 Mon Sep 17 00:00:00 2001 From: Alexey Ushakov Date: Thu, 12 Jan 2017 00:50:39 +0300 Subject: [PATCH] IDEA-166362 Show warning notification concerning outdated boot java runtime Corrected warning message. Suggested switching to bundled java only if it exist in IDEA bundle and supported by underlying OS --- .../com/intellij/ide/SystemHealthMonitor.java | 18 ++++++++++++---- .../src/com/intellij/util/JdkBundle.java | 21 +++++++++++++++++-- .../src/messages/IdeBundle.properties | 3 ++- 3 files changed, 35 insertions(+), 7 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/ide/SystemHealthMonitor.java b/platform/platform-impl/src/com/intellij/ide/SystemHealthMonitor.java index ecd181b263ef..288440624530 100644 --- a/platform/platform-impl/src/com/intellij/ide/SystemHealthMonitor.java +++ b/platform/platform-impl/src/com/intellij/ide/SystemHealthMonitor.java @@ -28,6 +28,7 @@ import com.intellij.openapi.ui.MessageType; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.ui.popup.Balloon; import com.intellij.openapi.ui.popup.JBPopupFactory; +import com.intellij.openapi.util.Bitness; import com.intellij.openapi.util.Ref; import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.Version; @@ -61,6 +62,7 @@ public class SystemHealthMonitor extends ApplicationComponent.Adapter { private static final NotificationGroup GROUP = new NotificationGroup("System Health", NotificationDisplayType.STICKY_BALLOON, false); private static final NotificationGroup LOG_GROUP = NotificationGroup.logOnlyGroup("System Health (minor)"); private static final String SWITCH_JDK_ACTION = "SwitchBootJdk"; + public static final String LATEST_JDK_RELEASE = "1.8.0u112"; private final PropertiesComponent myProperties; @@ -82,11 +84,15 @@ public class SystemHealthMonitor extends ApplicationComponent.Adapter { showNotification(new KeyHyperlinkAdapter("unsupported.jvm.ea.message")); } JdkBundle bundle = JdkBundle.createBoot(); - if (bundle != null) { + if (bundle != null && !bundle.isBundled()) { Version version = bundle.getVersion(); Integer updateNumber = bundle.getUpdateNumber(); if (version != null && (version.lessThan(1, 8, 0) || (updateNumber != null && updateNumber < 112))) { - showNotification(new KeyHyperlinkAdapter("outdated.jvm.version.message") { + final String bundleVersion = version.toCompactString() + (updateNumber != null ? "u" + updateNumber : ""); + if (JdkBundle.getBundledJDKAbsoluteLocation().exists() && + (bundle.getBitness() == Bitness.x64 && (SystemInfo.isMacIntel64 || SystemInfo.isWindows || SystemInfo.isLinux))) + { + showNotification(new KeyHyperlinkAdapter("outdated.jvm.version.message1") { @Override protected void hyperlinkActivated(HyperlinkEvent e) { String url = e.getDescription(); @@ -100,8 +106,12 @@ public class SystemHealthMonitor extends ApplicationComponent.Adapter { BrowserUtil.browse(url); } } - }, - version.toCompactString() + (updateNumber != null ? "u" + updateNumber : ""), "1.8.0u112"); + }, bundleVersion, LATEST_JDK_RELEASE); + } + else { + showNotification(new KeyHyperlinkAdapter("outdated.jvm.version.message2"), + bundleVersion, LATEST_JDK_RELEASE); + } } } } diff --git a/platform/platform-impl/src/com/intellij/util/JdkBundle.java b/platform/platform-impl/src/com/intellij/util/JdkBundle.java index f6f90e546c07..c8316472fedb 100644 --- a/platform/platform-impl/src/com/intellij/util/JdkBundle.java +++ b/platform/platform-impl/src/com/intellij/util/JdkBundle.java @@ -21,6 +21,7 @@ import com.intellij.execution.util.ExecUtil; import com.intellij.openapi.application.PathManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.*; +import com.intellij.openapi.util.io.FileUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -113,11 +114,27 @@ public class JdkBundle { @Nullable static JdkBundle createBoot(boolean adjustToMacBundle) { File bootJDK = new File(System.getProperty("java.home")).getParentFile(); + JdkBundle bundle; if (SystemInfo.isMac && adjustToMacBundle) { bootJDK = bootJDK.getParentFile().getParentFile(); - return createBundle(bootJDK, true, false); + bundle = createBundle(bootJDK, true, false); } - return createBundle(bootJDK, "", true, false, true); + else { + bundle = createBundle(bootJDK, "", true, false, true); + } + if (bundle != null) { + if (isBundledJDK(bundle)) bundle.setBundled(true); + } + return bundle; + } + + @NotNull + public static File getBundledJDKAbsoluteLocation() { + return new File(PathManager.getHomePath(), SystemInfo.isMac ? "jdk" : "jre"); + } + + static public boolean isBundledJDK(@NotNull JdkBundle bundle) { + return FileUtil.filesEqual(bundle.getAbsoluteLocation(), getBundledJDKAbsoluteLocation()); } @NotNull diff --git a/platform/platform-resources-en/src/messages/IdeBundle.properties b/platform/platform-resources-en/src/messages/IdeBundle.properties index e7db490a2f0e..e50786ce6533 100644 --- a/platform/platform-resources-en/src/messages/IdeBundle.properties +++ b/platform/platform-resources-en/src/messages/IdeBundle.properties @@ -1143,7 +1143,8 @@ browsers.settings=Web Browsers updates.check.period.on.exit=On every exit unsupported.jvm.ea.message=Early Access Java versions may cause compatibility issues. Please use stable release. -outdated.jvm.version.message=Your java version ({0}) is outdated. It may cause stability issues. Please update to {1}+ or switch to the bundled java runtime +outdated.jvm.version.message1=IDE''s Java runtime ({0}) is outdated - this may cause stability issues. Please update to {1} or newer, or switch to the bundled Java runtime +outdated.jvm.version.message2=IDE''s Java runtime ({0}) is outdated - this may cause stability issues. Please update to {1} or newer ibus.blocking.warn.message=IBus prior to 1.5.11 may cause input problems. See IDEA-78860 for details. ide.sigint.ignored.message=The IDE ignores SIGINT - "Stop" button in run configurations may not work. \ See IDEA-157989 for details.