import java.util.*;
import java.util.zip.*;
import java.util.List;
import java.util.regex.*;
import java.util.concurrent.*;
import java.util.concurrent.atomic.*;
import java.util.concurrent.locks.*;
import java.util.function.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.text.*;
import javax.swing.table.*;
import java.io.*;
import java.net.*;
import java.lang.reflect.*;
import java.lang.ref.*;
import java.lang.management.*;
import java.security.*;
import java.security.spec.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.awt.geom.*;
import javax.imageio.*;
import java.math.*;
import java.time.Duration;
import java.lang.invoke.VarHandle;
import java.lang.invoke.MethodHandles;
import java.nio.charset.Charset;
import java.text.SimpleDateFormat;
import javax.imageio.metadata.*;
import javax.imageio.stream.*;
import java.awt.geom.*;
import javax.swing.undo.UndoManager;
import static x30_pkg.x30_util.DynamicObject;
import java.awt.datatransfer.StringSelection;
import java.text.*;
import java.text.NumberFormat;
import java.util.TimeZone;
import javax.swing.Icon;
class main {
public static void main(final String[] args) throws Exception { pExperiment(); test_structure_Rectangle(); }
static void pExperiment() {
if (!isMain()) return;
//substance();
autoRestart(5);
experimentIcon();
centerHigherConsole();
tt();
}
static void test_structure_Rectangle() {
assertEqualsVerbose("java.awt.Rectangle(height=0, width=0, x=0, y=0)", struct(new Rectangle()));
}
static boolean isMain() {
return isMainProgram();
}
static double autoRestart_interval = 10;
static boolean autoRestart_on, autoRestart_debug, autoRestart_simulate;
static java.util.Timer autoRestart_timer;
static void autoRestart(double interval) {
autoRestart_interval = interval;
autoRestart();
}
static void autoRestart() {
if (!isMain() || autoRestart_on || vmHasResourceLoader()) return;
autoRestart_on = true;
autoRestart_schedule();
preloadProgramTitle();
}
static void autoRestart_off() {
if (!autoRestart_on) return;
stopTimer(autoRestart_timer);
autoRestart_timer = null;
}
static void autoRestart_schedule() {
autoRestart_timer = doLater_daemon(toMS(autoRestart_interval), new Runnable() { public void run() { try { autoRestart_check();
} catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "autoRestart_check();"; }});
}
static void autoRestart_check() {
try {
String newMD5;
try {
newMD5 = serverAutoRestartMD5(programID());
} catch (Throwable e) {
return;
}
if (!isMD5(newMD5)) { if (autoRestart_debug) print("autoRestart: no server transpilation"); return; }
if (autoRestart_localMD5 == null)
autoRestart_localMD5 = md5(loadCachedTranspilation(programID()));
String localMD5 = autoRestart_localMD5();
if (neq(localMD5, newMD5)) {
if (autoRestart_simulate)
print("Would upgrade now. " + localMD5 + " -> " + newMD5);
else {
infoBox("Upgrading " + programTitle());
restartWithDelay(500);
sleep();
}
}
} finally {
if (autoRestart_debug) print("autoRestart: Done");
autoRestart_schedule();
}
}
static void experimentIcon() {
consoleAndDefaultFrameIcon("#1101173" /*#1101171*/);
}
static void centerHigherConsole() {
if (headless()) return;
setConsoleHeight(600);
centerConsole();
}
static void tt() {
typeWriterConsole();
}
static String tt(Object contents, Object... params) {
return tag("tt", contents, params);
}
static A assertEqualsVerbose(Object x, A y) {
assertEqualsVerbose((String) null, x, y);
return y;
}
// x = expected, y = actual
static A assertEqualsVerbose(String msg, Object x, A y) {
if (!eq(x, y)) {
throw fail((nempty(msg) ? msg + ": " : "") + "expected: "+ x + ", got: " + y);
} else
print("OK" + (empty(msg) ? "" : " " + msg) + ": " + /*sfu*/(x));
return y;
}
static void assertEqualsVerbose(Scorer scorer, Object x, Object y) { assertEqualsVerbose(scorer, "", x, y); }
static void assertEqualsVerbose(Scorer scorer, String msg, Object x, Object y) {
if (scorer == null) { assertEqualsVerbose(x, y); return; }
if (!eq(x, y)) {
print(appendColonIfNempty(msg) + y + " != " + x);
scorer.add(false);
} else {
print("OK: " + appendColonIfNempty(msg) + x);
scorer.add(true);
}
}
static String struct(Object o) {
return structure(o);
}
static String struct(Object o, structure_Data data) {
return structure(o, data);
}
static boolean isMainProgram() {
return creator() == null;
}
static boolean vmHasResourceLoader() {
return vm_getResourceLoader() != null;
}
static void preloadProgramTitle() {
{ startThread(new Runnable() { public void run() { try { programTitle();
} catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "programTitle();"; }}); }
}
static void stopTimer(java.util.Timer timer) {
if (timer != null) timer.cancel();
}
static java.util.Timer doLater_daemon(long delay, final Object r) {
final java.util.Timer timer = new java.util.Timer(true);
timer.schedule(timerTask(r, timer), delay);
return timer;
}
static java.util.Timer doLater_daemon(double delaySeconds, final Object r) {
return doLater_daemon(toMS(delaySeconds), r);
}
static long toMS(double seconds) {
return (long) (seconds*1000);
}
static long toMS(Duration d) {
return d == null ? 0 : d.toMillis();
}
static RuntimeException rethrow(Throwable t) {
if (t instanceof Error)
_handleError((Error) t);
throw t instanceof RuntimeException ? (RuntimeException) t : new RuntimeException(t);
}
static RuntimeException rethrow(String msg, Throwable t) {
throw new RuntimeException(msg, t);
}
static int serverAutoRestartMD5_timeout = 10000;
static String serverAutoRestartMD5(String programID) {
return loadPageSilentlyWithTimeout("http://botcompany.de/1010693/raw?id=" + psI(programID), serverAutoRestartMD5_timeout);
}
static String serverAutoRestartMD5() {
return serverAutoRestartMD5(programID());
}
static String programID() {
return getProgramID();
}
static String programID(Object o) {
return getProgramID(o);
}
static boolean isMD5(String s) {
return l(s) == 32 && isLowerHexString(s);
}
static volatile StringBuffer local_log = new StringBuffer(); // not redirected
static boolean printAlsoToSystemOut = true;
static volatile Appendable print_log = local_log; // might be redirected, e.g. to main bot
// in bytes - will cut to half that
static volatile int print_log_max = 1024*1024;
static volatile int local_log_max = 100*1024;
static boolean print_silent = false; // total mute if set
static Object print_byThread_lock = new Object();
static volatile ThreadLocal