<commit_before>/*
 * Copyright (c) 2018, Woox <https://github.com/wooxsolo>
 * 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 com.google.common.annotations.VisibleForTesting;
import java.awt.Frame;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Insets;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.util.Arrays;
import java.util.Comparator;
import javax.swing.JFrame;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import net.runelite.client.config.ExpandResizeType;
import net.runelite.client.util.OSType;

@Slf4j
public class ContainableFrame extends JFrame
{
	public enum Mode
	{
		ALWAYS,
		RESIZING,
		NEVER;
	}

	private static final int SCREEN_EDGE_CLOSE_DISTANCE = 40;
	/**
	 * JDK-8231564 changes Frame#setMaximizedBounds() to apply ui scaling
	 */
	private static boolean jdk8231564;
	/**
	 * JDK-8243925 changes Toolkit#getScreenInsets() to apply ui scaling
	 */
	private static boolean jdk8243925;

	static
	{
		try
		{
			String javaVersion = System.getProperty("java.version");
			jdk8231564 = jdk8231564(javaVersion);
			jdk8243925 = jdk8243925(javaVersion);
		}
		catch (Exception ex)
		{
			log.error("error checking java version", ex);
		}
	}

	@VisibleForTesting
	static boolean jdk8231564(String javaVersion)
	{
		if (isVersionOrGreater(javaVersion, 15, -1, -1))
		{
			return true; // JDK-8231564
		}
		if (isVersionOrGreater(javaVersion, 14, -1, -1))
		{
			return false; // unpatched
		}
		if (isVersionOrGreater(javaVersion, 13, 0, 4))
		{
			return true; // JDK-8247209
		}
		if (isVersionOrGreater(javaVersion, 12, -1, -1))
		{
			return false; // unpatched
		}
		return isVersionOrGreater(javaVersion, 11, 0, 8); // JDK-8243374
	}

	@VisibleForTesting
	static boolean jdk8243925(String javaVersion)
	{
		if (isVersionOrGreater(javaVersion, 15, -1, -1))
		{
			return true; // JDK-8243925
		}
		if (isVersionOrGreater(javaVersion, 14, -1, -1))
		{
			return false; // unpatched
		}
		if (isVersionOrGreater(javaVersion, 13, 0, 7))
		{
			return true; // JDK-8261342
		}
		if (isVersionOrGreater(javaVersion, 12, -1, -1))
		{
			return false; // unpatched
		}
		return isVersionOrGreater(javaVersion, 11, 0, 9);  // JDK-8243374
	}

	private static boolean isVersionOrGreater(String javaVersion, int versionMajor, int versionMinor, int versionPatch)
	{
		int idx = javaVersion.indexOf('_');
		if (idx != -1)
		{
			javaVersion = javaVersion.substring(0, idx);
		}
		String[] s = javaVersion.split("\\.");
		int major, minor, patch;
		if (s.length >= 3)
		{
			major = Integer.parseInt(s[0]);
			minor = Integer.parseInt(s[1]);
			patch = Integer.parseInt(s[2]);
		}<commit_msg>containable frame: correct jdk bug number<commit_after>/*
 * Copyright (c) 2018, Woox <https://github.com/wooxsolo>
 * 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 com.google.common.annotations.VisibleForTesting;
import java.awt.Frame;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Insets;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.util.Arrays;
import java.util.Comparator;
import javax.swing.JFrame;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import net.runelite.client.config.ExpandResizeType;
import net.runelite.client.util.OSType;

@Slf4j
public class ContainableFrame extends JFrame
{
	public enum Mode
	{
		ALWAYS,
		RESIZING,
		NEVER;
	}

	private static final int SCREEN_EDGE_CLOSE_DISTANCE = 40;
	/**
	 * JDK-8231564 changes Frame#setMaximizedBounds() to apply ui scaling
	 */
	private static boolean jdk8231564;
	/**
	 * JDK-8243925 changes Toolkit#getScreenInsets() to apply ui scaling
	 */
	private static boolean jdk8243925;

	static
	{
		try
		{
			String javaVersion = System.getProperty("java.version");
			jdk8231564 = jdk8231564(javaVersion);
			jdk8243925 = jdk8243925(javaVersion);
		}
		catch (Exception ex)
		{
			log.error("error checking java version", ex);
		}
	}

	@VisibleForTesting
	static boolean jdk8231564(String javaVersion)
	{
		if (isVersionOrGreater(javaVersion, 15, -1, -1))
		{
			return true; // JDK-8231564
		}
		if (isVersionOrGreater(javaVersion, 14, -1, -1))
		{
			return false; // unpatched
		}
		if (isVersionOrGreater(javaVersion, 13, 0, 4))
		{
			return true; // JDK-8247209
		}
		if (isVersionOrGreater(javaVersion, 12, -1, -1))
		{
			return false; // unpatched
		}
		return isVersionOrGreater(javaVersion, 11, 0, 8); // JDK-8243374
	}

	@VisibleForTesting
	static boolean jdk8243925(String javaVersion)
	{
		if (isVersionOrGreater(javaVersion, 15, -1, -1))
		{
			return true; // JDK-8243925
		}
		if (isVersionOrGreater(javaVersion, 14, -1, -1))
		{
			return false; // unpatched
		}
		if (isVersionOrGreater(javaVersion, 13, 0, 7))
		{
			return true; // JDK-8261342
		}
		if (isVersionOrGreater(javaVersion, 12, -1, -1))
		{
			return false; // unpatched
		}
		return isVersionOrGreater(javaVersion, 11, 0, 9);  // JDK-8246659
	}

	private static boolean isVersionOrGreater(String javaVersion, int versionMajor, int versionMinor, int versionPatch)
	{
		int idx = javaVersion.indexOf('_');
		if (idx != -1)
		{
			javaVersion = javaVersion.substring(0, idx);
		}
		String[] s = javaVersion.split("\\.");
		int major, minor, patch;
		if (s.length >= 3)
		{
			major = Integer.parseInt(s[0]);
			minor = Integer.parseInt(s[1]);
			patch = Integer.parseInt(s[2]);
		}
{'fraction_non_alphanumeric': 0.09967805844477465, 'fraction_numerical': 0.04185240217929668, 'mean_word_length': 3.9981435643564356, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6348258', 'n_tokens_mistral': 3046, 'n_tokens_neox': 2585, 'n_words': 815}