containableframe: fix parsing Oracle Java 8 version string
This commit is contained in:
@@ -24,6 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client.ui;
|
package net.runelite.client.ui;
|
||||||
|
|
||||||
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import java.awt.Frame;
|
import java.awt.Frame;
|
||||||
import java.awt.GraphicsConfiguration;
|
import java.awt.GraphicsConfiguration;
|
||||||
import java.awt.GraphicsDevice;
|
import java.awt.GraphicsDevice;
|
||||||
@@ -49,6 +50,7 @@ public class ContainableFrame extends JFrame
|
|||||||
NEVER;
|
NEVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final int SCREEN_EDGE_CLOSE_DISTANCE = 40;
|
||||||
private static boolean jdk8231564;
|
private static boolean jdk8231564;
|
||||||
|
|
||||||
static
|
static
|
||||||
@@ -56,9 +58,7 @@ public class ContainableFrame extends JFrame
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
String javaVersion = System.getProperty("java.version");
|
String javaVersion = System.getProperty("java.version");
|
||||||
String[] s = javaVersion.split("\\.");
|
jdk8231564 = jdk8231564(javaVersion);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
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
|
@Setter
|
||||||
private ExpandResizeType expandResizeType;
|
private ExpandResizeType expandResizeType;
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2020, Adam <Adam@sigterm.info>
|
||||||
|
* 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"));
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user