From 03d72ab48ddd551dd055be43b161c8dd630b1963 Mon Sep 17 00:00:00 2001 From: Alexey Ushakov Date: Thu, 26 Nov 2015 18:40:22 +0300 Subject: [PATCH] IDEA-57233 Editor font antialising/appearance problems on Linux Corrected JdkBundle tests to skip pure jres. Added Nullables and checks. --- .../com/intellij/openapi/util/SwitchBootJdkAction.java | 9 +++++++-- platform/lang-impl/src/com/intellij/util/JdkBundle.java | 1 + .../lang-impl/src/com/intellij/util/JdkBundleList.java | 8 ++++---- .../testSrc/com/intellij/util/JdkBundleTest.java | 8 ++++++++ 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/openapi/util/SwitchBootJdkAction.java b/platform/lang-impl/src/com/intellij/openapi/util/SwitchBootJdkAction.java index d5d2d8095163..97ac68b45011 100644 --- a/platform/lang-impl/src/com/intellij/openapi/util/SwitchBootJdkAction.java +++ b/platform/lang-impl/src/com/intellij/openapi/util/SwitchBootJdkAction.java @@ -238,15 +238,20 @@ public class SwitchBootJdkAction extends AnAction implements DumbAware { private static final Version JDK8_VERSION = new Version(1, 8, 0); + @NotNull private static JdkBundleList findJdkPaths() { JdkBundle bootJdk = JdkBundle.createBoot(); JdkBundleList jdkBundleList = new JdkBundleList(); - jdkBundleList.addBundle(bootJdk, true); + if (bootJdk != null) { + jdkBundleList.addBundle(bootJdk, true); + } if (bundledJdkFile.exists()) { JdkBundle bundledJdk = JdkBundle.createBundle(bundledJdkFile, false, true); - jdkBundleList.addBundle(bundledJdk, true); + if (bundledJdk != null) { + jdkBundleList.addBundle(bundledJdk, true); + } } if (SystemInfo.isMac) { diff --git a/platform/lang-impl/src/com/intellij/util/JdkBundle.java b/platform/lang-impl/src/com/intellij/util/JdkBundle.java index 511ede378fe4..ffddabc3b233 100644 --- a/platform/lang-impl/src/com/intellij/util/JdkBundle.java +++ b/platform/lang-impl/src/com/intellij/util/JdkBundle.java @@ -63,6 +63,7 @@ public class JdkBundle { return new JdkBundle(jvm, nameVersionAndUpdate.first, nameVersionAndUpdate.second, boot, bundled); } + @Nullable public static JdkBundle createBoot() { File bootJDK = new File(System.getProperty("java.home")).getParentFile(); if (SystemInfo.isMac) { diff --git a/platform/lang-impl/src/com/intellij/util/JdkBundleList.java b/platform/lang-impl/src/com/intellij/util/JdkBundleList.java index c7cf5a7cba57..2ab00e883c28 100644 --- a/platform/lang-impl/src/com/intellij/util/JdkBundleList.java +++ b/platform/lang-impl/src/com/intellij/util/JdkBundleList.java @@ -32,7 +32,7 @@ public class JdkBundleList { private HashMap bundleMap = new HashMap(); private HashMap nameVersionMap = new HashMap(); - public void addBundle(JdkBundle bundle, boolean forceOldVersion) { + public void addBundle(@NotNull JdkBundle bundle, boolean forceOldVersion) { JdkBundle bundleDescr = bundleMap.get(bundle.getBundleAsFile().getAbsolutePath()); if (bundleDescr == null) { addMostRecent(bundle, forceOldVersion); @@ -43,7 +43,7 @@ public class JdkBundleList { } } - private void addMostRecent(JdkBundle bundleDescriptor, boolean forceOldVersion) { + private void addMostRecent(@NotNull JdkBundle bundleDescriptor, boolean forceOldVersion) { Pair versionUpdate = bundleDescriptor.getVersionUpdate(); boolean updateVersionMap = versionUpdate != null; if (!bundleList.isEmpty() && updateVersionMap) { @@ -73,7 +73,7 @@ public class JdkBundleList { } } - public void addBundlesFromLocation(String location, @Nullable Version minVer, @Nullable Version maxVer) { + public void addBundlesFromLocation(@NotNull String location, @Nullable Version minVer, @Nullable Version maxVer) { File jvmLocation = new File(location); if (!jvmLocation.exists()) { @@ -111,7 +111,7 @@ public class JdkBundleList { return bundleList; } - public boolean contains(String path) { + public boolean contains(@NotNull String path) { return bundleMap.keySet().contains(path); } } diff --git a/platform/platform-tests/testSrc/com/intellij/util/JdkBundleTest.java b/platform/platform-tests/testSrc/com/intellij/util/JdkBundleTest.java index 5bfc5255cab9..86fbf5609a30 100644 --- a/platform/platform-tests/testSrc/com/intellij/util/JdkBundleTest.java +++ b/platform/platform-tests/testSrc/com/intellij/util/JdkBundleTest.java @@ -23,6 +23,7 @@ import org.junit.Test; import java.io.File; +import static junit.framework.Assert.assertNotNull; import static junit.framework.TestCase.*; public class JdkBundleTest { @@ -31,6 +32,9 @@ public class JdkBundleTest { public void testCreateBundle() throws Exception { if (SystemInfo.isWindows) return; // Windows is not supported so far File bootJDK = new File(System.getProperty("java.home")).getParentFile(); + + if (!new File(bootJDK, "lib/tools.jar").exists()) return; // Skip pure jre + if (SystemInfo.isMac) { bootJDK = bootJDK.getParentFile().getParentFile(); } @@ -54,6 +58,9 @@ public class JdkBundleTest { public void testCreateBoot() throws Exception { if (SystemInfo.isWindows) return; // Windows is not supported so far File bootJDK = new File(System.getProperty("java.home")).getParentFile(); + + if (!new File(bootJDK, "lib/tools.jar").exists()) return; // Skip pure jre + if (SystemInfo.isMac) { bootJDK = bootJDK.getParentFile().getParentFile(); } @@ -61,6 +68,7 @@ public class JdkBundleTest { JdkBundle bundle = JdkBundle.createBoot(); + assertNotNull(bundle); assertTrue(bundle.isBoot()); assertFalse(bundle.isBundled());