diff --git a/runelite-client/src/main/java/net/runelite/client/ui/ContainableFrame.java b/runelite-client/src/main/java/net/runelite/client/ui/ContainableFrame.java index b03c863dda..0a69897461 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/ContainableFrame.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/ContainableFrame.java @@ -24,6 +24,7 @@ */ package net.runelite.client.ui; +import com.google.common.annotations.VisibleForTesting; import java.awt.Frame; import java.awt.GraphicsConfiguration; import java.awt.GraphicsDevice; @@ -49,6 +50,7 @@ public class ContainableFrame extends JFrame NEVER; } + private static final int SCREEN_EDGE_CLOSE_DISTANCE = 40; private static boolean jdk8231564; static @@ -56,9 +58,7 @@ public class ContainableFrame extends JFrame try { String javaVersion = System.getProperty("java.version"); - String[] s = javaVersion.split("\\."); - int major = Integer.parseInt(s[0]), minor = Integer.parseInt(s[1]), patch = Integer.parseInt(s[2]); - jdk8231564 = major > 11 || (major == 11 && minor > 0) || (major == 11 && minor == 0 && patch >= 8); + jdk8231564 = jdk8231564(javaVersion); } catch (Exception ex) { @@ -66,7 +66,18 @@ public class ContainableFrame extends JFrame } } - private static final int SCREEN_EDGE_CLOSE_DISTANCE = 40; + @VisibleForTesting + static boolean jdk8231564(String javaVersion) + { + int idx = javaVersion.indexOf('_'); + if (idx != -1) + { + javaVersion = javaVersion.substring(0, idx); + } + String[] s = javaVersion.split("\\."); + int major = Integer.parseInt(s[0]), minor = Integer.parseInt(s[1]), patch = Integer.parseInt(s[2]); + return major > 11 || (major == 11 && minor > 0) || (major == 11 && minor == 0 && patch >= 8); + } @Setter private ExpandResizeType expandResizeType; diff --git a/runelite-client/src/test/java/net/runelite/client/ui/ContainableFrameTest.java b/runelite-client/src/test/java/net/runelite/client/ui/ContainableFrameTest.java new file mode 100644 index 0000000000..d0b432ce39 --- /dev/null +++ b/runelite-client/src/test/java/net/runelite/client/ui/ContainableFrameTest.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2020, Adam + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.ui; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import org.junit.Test; + +public class ContainableFrameTest +{ + @Test + public void testJdk8231564() + { + assertTrue(ContainableFrame.jdk8231564("11.0.8")); + assertFalse(ContainableFrame.jdk8231564("11.0.7")); + assertFalse(ContainableFrame.jdk8231564("1.8.0_261")); + } +} \ No newline at end of file