<commit_before>package lwjgl.standalone;

import hu.qgears.nativeloader.NativeLoadException;
import hu.qgears.nativeloader.UtilNativeLoader;
import hu.qgears.nativeloader.XmlNativeLoader;

import java.awt.Frame;
import java.io.File;

public class BaseAccessor extends XmlNativeLoader {
	private static boolean inited = false;

	@Override
	public void load(File nativeLibFile) throws Throwable {
		Runtime.getRuntime().load(nativeLibFile.getAbsolutePath());
	}

	@Override
	public String getNativesDeclarationResourceName() {
		return "natives-base-def.xml";
	}

	public static synchronized void initLwjglNatives()
			throws NativeLoadException {

		if (!inited) {
			if ("Linux".equals(System.getProperty("os.name"))) {
				// HACK - initialize AWT so it loads its native libs that lwjgl
				// depend on: libmawt.so, libjawt.so
				// A must on Linux but wine hangs on this call for some unknown
				// reason :-)
				{
					try
					{
						// mawt is not on classpath because it has two versions:
						// headless and x11. The correct version is selected dynamically 
						// lwjgl requires the X11 enabled one
						File mawt = findMawt(new File(System.getProperty("java.home")));
						Runtime.getRuntime().load(mawt.getAbsolutePath());
					}catch(Throwable t)
					{
						if(t.getMessage().indexOf("already loaded")<0)
						{
							// Do not log already loaded exception!
							t.printStackTrace();
						}
						// Try fallback mawt loading techniqe: create and dispose a frame:
						new Frame().dispose();
					}
				}
				// manually load libjawt.so into vm, needed since Java 7
				try {
					System.loadLibrary("jawt");					
				}catch(Throwable e)
				{
					System.err.println("Java version does not support jawt manual load");
				}
			}
			UtilNativeLoader.loadNatives(new BaseAccessor());
			inited = true;
		}
	}
	/**
	 * Find the X11 enabled libmawt.so file in the JRE folder.
	 * @param dir JRE folder (and subfolders on recursive calls)
	 * @return
	 */
	private static File findMawt(File dir) {
		if (dir.isDirectory()) {
			if ("xawt".equals(dir.getName())) {
				return new File(dir, "libmawt.so");
			}<commit_msg>Fix Java 8 compatibility issue of LWJGL bundle<commit_after>package lwjgl.standalone;

import hu.qgears.nativeloader.NativeLoadException;
import hu.qgears.nativeloader.UtilNativeLoader;
import hu.qgears.nativeloader.XmlNativeLoader;

import java.awt.Frame;
import java.io.File;

public class BaseAccessor extends XmlNativeLoader {
	private static boolean inited = false;

	@Override
	public void load(File nativeLibFile) throws Throwable {
		Runtime.getRuntime().load(nativeLibFile.getAbsolutePath());
	}

	@Override
	public String getNativesDeclarationResourceName() {
		return "natives-base-def.xml";
	}

	public static synchronized void initLwjglNatives()
			throws NativeLoadException {

		if (!inited) {
			if ("Linux".equals(System.getProperty("os.name"))) {
				// HACK - initialize AWT so it loads its native libs that lwjgl
				// depend on: libmawt.so, libjawt.so
				// A must on Linux but wine hangs on this call for some unknown
				// reason :-)
				{
					try
					{
						// mawt is not on classpath because it has two versions:
						// headless and x11. The correct version is selected dynamically 
						// lwjgl requires the X11 enabled one
						File mawt = findMawt(new File(System.getProperty("java.home")));
						Runtime.getRuntime().load(mawt.getAbsolutePath());
					}catch(Throwable t)
					{
						if((t.getMessage()!=null)&&t.getMessage().indexOf("already loaded")<0)
						{
							// Do not log already loaded exception!
							t.printStackTrace();
						}
						// Try fallback mawt loading techniqe: create and dispose a frame:
						new Frame().dispose();
					}
				}
				// manually load libjawt.so into vm, needed since Java 7
				try {
					System.loadLibrary("jawt");					
				}catch(Throwable e)
				{
					System.err.println("Java version does not support jawt manual load");
				}
			}
			UtilNativeLoader.loadNatives(new BaseAccessor());
			inited = true;
		}
	}
	/**
	 * Find the X11 enabled libmawt.so file in the JRE folder.
	 * @param dir JRE folder (and subfolders on recursive calls)
	 * @return
	 */
	private static File findMawt(File dir) {
		if (dir.isDirectory()) {
			if ("xawt".equals(dir.getName())) {
				return new File(dir, "libmawt.so");
			}
{'fraction_non_alphanumeric': 0.10922051046217521, 'fraction_numerical': 0.00390894458496206, 'mean_word_length': 3.131054131054131, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '676451', 'n_tokens_mistral': 1676, 'n_tokens_neox': 1337, 'n_words': 383}