<commit_before>/*******************************************************************************
 * This file is part of TERMINAL RECALL
 * Copyright (c) 2015-2018 <NAME>
 * Part of the jTRFP.org project
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v3.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/gpl.html
 * 
 * Contributors:
 *     chuck - initial API and implementation
 ******************************************************************************/

package org.jtrfp.trcl.flow;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;

public class JVM {
    private String []args;
    private static final boolean runningFromJar = new File("RunMe.jar").exists();

    /**
     * @return the args
     */
    public String []getArgs() {
        return args;
    }

    /**
     * @param args the args to set
     */
    public JVM setArgs(String []args) {
        this.args = args;
        return this;
    }
    
    public JVM ensureProperlyConfigured() {//Skip if using 32-bit.
	final boolean is64Bit = System.getProperty("os.arch").contains("64");
	final boolean isServerVM = System.getProperty("java.vm.name").toLowerCase().contains("server");
	if (!isAlreadyConfigured()) {
	    //http://stackoverflow.com/questions/13029915/how-to-programmatically-test-if-assertions-are-enabled
	    //Seems to work better than the official way of querying assertion ability.
	    boolean useAssertions = false;
	    assert useAssertions = true;
	    System.out
		    .println("Overriding the default JVM settings. If you wish to manually set the JVM settings, include the `-Dorg.jtrfp.trcl.bypassConfigure=true` flag in the java command.");
	    String executable = isRunningFromJar() ? "-jar RunMe.jar"
		    : "-cp " + System.getProperty("java.class.path")
			    + " org.jtrfp.trcl.flow.RunMe";
	    String cmd = "";
	    
	    cmd+="java ";
	    
	    cmd+=isServerVM?"-server ":"-client ";
	    cmd+="-Dorg.jtrfp.trcl.bypassConfigure=true ";
	    cmd+="-Dcom.sun.management.jmxremote ";
	    
	    if( is64Bit && isServerVM) {
		cmd+="-XX:+UnlockExperimentalVMOptions ";
		cmd+="-XX:+DoEscapeAnalysis ";
		cmd+="-XX:+UseFastAccessorMethods ";
		cmd+="-XX:+UseParNewGC ";

		cmd+="-XX:+UseConcMarkSweepGC ";
		cmd+="-XX:MaxGCPauseMillis=5 ";
		cmd+="-XX:+AggressiveOpts ";

		cmd+="-XX:+UseBiasedLocking ";
		cmd+="-XX:+AlwaysPreTouch ";<commit_msg>✔Remove non-standard JVM args. Closes #243.<commit_after>/*******************************************************************************
 * This file is part of TERMINAL RECALL
 * Copyright (c) 2015-2018 <NAME>
 * Part of the jTRFP.org project
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v3.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/gpl.html
 * 
 * Contributors:
 *     chuck - initial API and implementation
 ******************************************************************************/

package org.jtrfp.trcl.flow;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;

public class JVM {
    private String []args;
    private static final boolean runningFromJar = new File("RunMe.jar").exists();

    /**
     * @return the args
     */
    public String []getArgs() {
        return args;
    }

    /**
     * @param args the args to set
     */
    public JVM setArgs(String []args) {
        this.args = args;
        return this;
    }
    
    public JVM ensureProperlyConfigured() {//Skip if using 32-bit.
	final boolean is64Bit = System.getProperty("os.arch").contains("64");
	final boolean isServerVM = System.getProperty("java.vm.name").toLowerCase().contains("server");
	if (!isAlreadyConfigured()) {
	    //http://stackoverflow.com/questions/13029915/how-to-programmatically-test-if-assertions-are-enabled
	    //Seems to work better than the official way of querying assertion ability.
	    boolean useAssertions = false;
	    assert useAssertions = true;
	    System.out
		    .println("Overriding the default JVM settings. If you wish to manually set the JVM settings, include the `-Dorg.jtrfp.trcl.bypassConfigure=true` flag in the java command.");
	    String executable = isRunningFromJar() ? "-jar RunMe.jar"
		    : "-cp " + System.getProperty("java.class.path")
			    + " org.jtrfp.trcl.flow.RunMe";
	    String cmd = "";
	    
	    cmd+="java ";
	    
	    cmd+=isServerVM?"-server ":"-client ";
	    cmd+="-Dorg.jtrfp.trcl.bypassConfigure=true ";
	    cmd+="-Dcom.sun.management.jmxremote ";
	    
	    if( is64Bit && isServerVM) {
		//Commented out because some VMs either don't support them or are implicit features today.
		
		//cmd+="-XX:+UnlockExperimentalVMOptions ";
		cmd+="-XX:+DoEscapeAnalysis ";
		//cmd+="-XX:+UseFastAccessorMethods ";
		//cmd+="-XX:+UseParNewGC ";

		cmd+="-XX:+UseConcMarkSweepGC ";
		cmd+="-XX:MaxGCPauseMillis=5 ";
		cmd+="-XX:+AggressiveOpts ";

		cmd+="-XX:+UseBiasedLocking ";
		cmd+="-XX:+AlwaysPreTouch ";
{'fraction_non_alphanumeric': 0.18411352746037596, 'fraction_numerical': 0.010504976041282713, 'mean_word_length': 3.5414225941422592, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2355699', 'n_tokens_mistral': 1742, 'n_tokens_neox': 1614, 'n_words': 403}