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 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 javax.imageio.*;
import java.math.*;
import org.pushingpixels.substance.api.*;
import org.pushingpixels.substance.api.skin.*;
import java.text.*;
import javax.net.ssl.*;
import java.security.SecureRandom;
import java.security.cert.X509Certificate;
import java.awt.geom.AffineTransform;
import java.text.SimpleDateFormat;
import java.awt.datatransfer.StringSelection;
class main {
static DynamicHStack buttons;
public static void main(final String[] args) throws Exception { substance(); autoUpdate();
buttons = renameFrame("Last changed snippets", showNiceButtons());
refresh();
addButtonsToWindow(buttons, "Refresh", dynamicCallableMC_thread("refresh"));
;
hideConsole(); }
static void refresh() {
replaceNiceButtons(buttons, recentlyChangedSnippetsForNiceButtons());
centerPackFrame(buttons);
}
// params = text, image, action, text, image, action, ...
// or TextImageAction...
// or a list of above stuff
static DynamicHStack showNiceButtons(Object... params) {
DynamicHStack stack = makeNiceButtons(params);
showCenterPackedFrame(withMargin(20, jHigherScrollPane(jfullcenter(stack))));
return stack;
}
static void autoUpdate(double interval) {
autoRestart(interval);
}
static void autoUpdate() {
autoRestart();
}
static A renameFrame(A c, String title) {
return setFrameTitle(c, title);
}
static A renameFrame(String title, A c) {
return setFrameTitle(c, title);
}
static DynamicCallable dynamicCallableMC_thread(final String methodName) {
return new DynamicCallable() {
public Object _dyn(final Object[] args) {
{ Thread _t_0 = new Thread() {
public void run() { try { callMC(methodName, args); } catch (Throwable __e) { printStackTrace2(__e); } }
};
startThread(_t_0); }
return null;
}
};
}
static List recentlyChangedSnippetsForNiceButtons() {
return map(recentlyChangedSnippets(), new F1() { TextImageAction get(Snippet s) { try { return
textImageActionToolTip(s.title, "#1101241", null, s.id)
; } catch (Exception __e) { throw rethrow(__e); } }
public String toString() { return "textImageActionToolTip(s.title, \"#1101241\", null, s.id)"; }});
}
static void centerPackFrame(Component c) {
centerPackedFrame(c);
}
static void substance() {
substanceLAF();
}
static void substance(String skinName) {
substanceLAF(skinName);
}
static Map _registerThread_threads = newWeakHashMap();
static Thread _registerThread(Thread t) {
_registerThread_threads.put(t, true);
return t;
}
static void _registerThread() { _registerThread(Thread.currentThread()); }
static void hideConsole() {
final JFrame frame = consoleFrame();
if (frame != null) {
autoVMExit();
swingLater(new Runnable() { public void run() { try {
frame.setVisible(false);
} catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "frame.setVisible(false);"; }});
}
}
static void addButtonsToWindow(Component c, Object... buttonParams) {
addToWindowWithMargin(c, jcenteredbuttons(buttonParams));
}
static void replaceNiceButtons(DynamicHStack stack, Object... params) {
stack.setComponents(makeNiceButtons(params).components());
}
static JPanel jfullcenter(Component c) { return jFullCenter(c); }
static JFrame consoleFrame() {
return (JFrame) getOpt(get(getJavaX(), "console"), "frame");
}
static A setFrameTitle(A c, String title) {
Frame f = getAWTFrame(c);
if (f == null)
showFrame(title, c);
else
f.setTitle(title);
return c;
}
static A setFrameTitle(String title, A c) {
return setFrameTitle(c, title);
}
// magically find a field called "frame" in main class :-)
static JFrame setFrameTitle(String title) {
Object f = getOpt(mc(), "frame");
if (f instanceof JFrame)
return setFrameTitle((JFrame) f, title);
return null;
}
static Map newWeakHashMap() {
return _registerWeakMap(synchroMap(new WeakHashMap()));
}
static String substanceLAF_defaultSkin = "Creme";
static void substanceLAF() {
substanceLAF(null);
}
static void substanceLAF(String skinName) {
try {
enableSubstance_impl(or2(skinName, substanceLAF_defaultSkin));
} catch (Throwable __e) { printStackTrace2(__e); }
}
static JScrollPane jHigherScrollPane(final JComponent c) {
return swing(new F0() { JScrollPane get() { try { return new JScrollPane(c) {
public Dimension getPreferredSize() {
Component view = getViewport().getView();
if (view == null) return super.getPreferredSize();
int pref_width = view.getPreferredSize().width;
setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
Dimension dim = new Dimension(pref_width, super.getPreferredSize().height + getHorizontalScrollBar().getSize().height);
setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
return dim;
}
}; } catch (Exception __e) { throw rethrow(__e); } }
public String toString() { return "ret new JScrollPane(c) {\r\n public Dimension getPreferredSize() {\r\n Co..."; }});
}
static HashMap> callMC_cache = new HashMap();
static String callMC_key;
static Method callMC_value;
// varargs assignment fixer for a single string array argument
static Object callMC(String method, String[] arg) {
return callMC(method, new Object[] {arg});
}
static Object callMC(String method, Object... args) { try {
Method me;
if (callMC_cache == null) callMC_cache = new HashMap(); // initializer time workaround
synchronized(callMC_cache) {
me = method == callMC_key ? callMC_value : null;
}
if (me != null) try {
return invokeMethod(me, null, args);
} catch (IllegalArgumentException e) {
throw new RuntimeException("Can't call " + me + " with arguments " + classNames(args), e);
}
List m;
synchronized(callMC_cache) {
m = callMC_cache.get(method);
}
if (m == null) {
if (callMC_cache.isEmpty()) {
callMC_makeCache();
m = callMC_cache.get(method);
}
if (m == null) throw fail("Method named " + method + " not found in main");
}
int n = m.size();
if (n == 1) {
me = m.get(0);
synchronized(callMC_cache) {
callMC_key = method;
callMC_value = me;
}
try {
return invokeMethod(me, null, args);
} catch (IllegalArgumentException e) {
throw new RuntimeException("Can't call " + me + " with arguments " + classNames(args), e);
}
}
for (int i = 0; i < n; i++) {
me = m.get(i);
if (call_checkArgs(me, args, false))
return invokeMethod(me, null, args);
}
throw fail("No method called " + method + " with matching arguments found in main");
} catch (Exception __e) { throw rethrow(__e); } }
static void callMC_makeCache() {
synchronized(callMC_cache) {
callMC_cache.clear();
Class _c = (Class) mc(), c = _c;
while (c != null) {
for (Method m : c.getDeclaredMethods())
if ((m.getModifiers() & java.lang.reflect.Modifier.STATIC) != 0) {
m.setAccessible(true);
multiMapPut(callMC_cache, m.getName(), m);
}
c = c.getSuperclass();
}
}
}
static int makeNiceButtons_maxImageSize = 128;
// params = text, image, action, text, image, action, ...
// or TextImageAction...
// or a list of above stuff
static DynamicHStack makeNiceButtons(Object... params) {
DynamicHStack stack = (DynamicHStack) dynamicHStack().spacing(20);
params = flattenArray2(params);
for (int i = 0; i < l(params); ) {
TextImageAction tia = null;
if (params[i] instanceof TextImageAction) {
tia = (TextImageAction) params[i];
i++;
} else {
tia = new TextImageAction(
str(get(params, i)),
str(get(params, i+1)),
get(params, i+2));
i += 3;
}
final Object _tia = tia;
Object action = tia.action;
if (action == null) action = new Runnable() { public void run() { try {
appendToMechQ_withDate("User actions", "User clicked on actionless button " + sfu(_tia));
} catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "appendToMechQ_withDate(\"User actions\", \"User clicked on actionless button \" +..."; }};
JButton b = jImageAndTextButton(tia.imageID, tia.text, action);
if (nempty(tia.toolTip)) setToolTip(b, tia.toolTip);
resizeImageButtonToMax(b, makeNiceButtons_maxImageSize);
setVerticalTextPosition(JButton.TOP, setFontSize(15, makeBold(b)));
setVerticalAlignment(JButton.TOP, b);
setMargin(10, b);
stack.addComponent(b);
}
return stack;
}
// get purpose 1: access a list/array/map (safer version of x.get(y))
static A get(List l, int idx) {
return l != null && idx >= 0 && idx < l(l) ? l.get(idx) : null;
}
// seems to conflict with other signatures
/*static B get(Map map, A key) {
ret map != null ? map.get(key) : null;
}*/
static A get(A[] l, int idx) {
return idx >= 0 && idx < l(l) ? l[idx] : null;
}
// default to false
static boolean get(boolean[] l, int idx) {
return idx >= 0 && idx < l(l) ? l[idx] : false;
}
// get purpose 2: access a field by reflection or a map
static Object get(Object o, String field) {
try {
if (o instanceof Class) return get((Class) o, field);
if (o instanceof Map)
return ((Map) o).get(field);
Field f = getOpt_findField(o.getClass(), field);
if (f != null) {
f.setAccessible(true);
return f.get(o);
}
if (o instanceof DynamicObject)
return ((DynamicObject) o).fieldValues.get(field);
} catch (Exception e) {
throw asRuntimeException(e);
}
throw new RuntimeException("Field '" + field + "' not found in " + o.getClass().getName());
}
static Object get_raw(Object o, String field) {
try {
Field f = get_findField(o.getClass(), field);
f.setAccessible(true);
return f.get(o);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
static Object get(Class c, String field) {
try {
Field f = get_findStaticField(c, field);
f.setAccessible(true);
return f.get(null);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
static Field get_findStaticField(Class> c, String field) {
Class _c = c;
do {
for (Field f : _c.getDeclaredFields())
if (f.getName().equals(field) && (f.getModifiers() & java.lang.reflect.Modifier.STATIC) != 0)
return f;
_c = _c.getSuperclass();
} while (_c != null);
throw new RuntimeException("Static field '" + field + "' not found in " + c.getName());
}
static Field get_findField(Class> c, String field) {
Class _c = c;
do {
for (Field f : _c.getDeclaredFields())
if (f.getName().equals(field))
return f;
_c = _c.getSuperclass();
} while (_c != null);
throw new RuntimeException("Field '" + field + "' not found in " + c.getName());
}
static void swingLater(long delay, final Object r) {
javax.swing.Timer timer = new javax.swing.Timer(toInt(delay), actionListener(wrapAsActivity(r)));
timer.setRepeats(false);
timer.start();
}
static void swingLater(Object r) {
SwingUtilities.invokeLater(toRunnable(r));
}
static TextImageAction textImageActionToolTip(String text, String image, String action, String toolTip) {
TextImageAction t = new TextImageAction(text, image, action);
t.toolTip = toolTip;
return t;
}
static Thread startThread(Object runnable) {
return startThread(defaultThreadName(), runnable);
}
static Thread startThread(String name, Object runnable) {
runnable = wrapAsActivity(runnable);
return startThread(newThread(toRunnable(runnable), name));
}
static Thread startThread(Thread t) {
_registerThread(t);
t.start();
return t;
}
static List map(Iterable l, Object f) {
return map(f, l);
}
static List map(Object f, Iterable l) {
List x = emptyList(l);
if (l != null) for (Object o : l)
x.add(callF(f, o));
return x;
}
static List map(F1 f, Iterable l) {
List x = emptyList(l);
if (l != null) for (Object o : l)
x.add(callF(f, o));
return x;
}
static List map(Object f, Object[] l) { return map(f, asList(l)); }
static List map(Object[] l, Object f) { return map(f, l); }
static List map(Object f, Map map) {
return map(map, f);
}
// map: func(key, value) -> list element
static List map(Map map, Object f) {
List x = new ArrayList();
if (map != null) for (Object _e : map.entrySet()) {
Map.Entry e = (Map.Entry) _e;
x.add(callF(f, e.getKey(), e.getValue()));
}
return x;
}
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) 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), "autoRestart_check");
}
static void autoRestart_check() {
try {
String newMD5 = loadPageSilently("http://botcompany.de/1010693/raw?id=" + psI(programID()));
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(1000);
sleep();
}
}
} finally {
if (autoRestart_debug) print("autoRestart: Done");
autoRestart_schedule();
}
}
static RuntimeException rethrow(Throwable t) {
if (t instanceof Error)
_handleError((Error) t);
throw t instanceof RuntimeException ? (RuntimeException) t : new RuntimeException(t);
}
static int withMargin_defaultWidth = 6;
static JPanel withMargin(Component c) {
return withMargin(withMargin_defaultWidth, c);
}
static JPanel withMargin(int w, Component c) {
return withMargin(w, w, c);
}
static JPanel withMargin(final int w, final int h, final Component c) { return swing(new F0() { JPanel get() { try {
JPanel p = new JPanel(new BorderLayout());
p.setBorder(BorderFactory.createEmptyBorder(h, w, h, w));
p.add(c);
return p;
} catch (Exception __e) { throw rethrow(__e); } }
public String toString() { return "JPanel p = new JPanel(new BorderLayout);\r\n p.setBorder(BorderFactory.creat..."; }});
}
static JFrame showCenterPackedFrame(String title, Component c) {
return setFrameTitle(title, showCenterPackedFrame(c));
}
static JFrame showCenterPackedFrame(Component c) {
return centerFrame(showPackedFrame(c));
}
static Component addToWindowWithMargin(final Component c, final Component toAdd) {
if (toAdd != null)
addToWindowAndGrow(c, withMargin(toAdd));
return c;
}
static JPanel jcenteredbuttons(Object... params) {
List l = new ArrayList();
for (int i = 0; i < l(params); i += 2)
if (params[i] != null)
l.add(jbutton((String) params[i], params[i+1]));
return jcenteredline(l);
}
static void autoVMExit() {
call(getJavaX(), "autoVMExit");
}
static Throwable printStackTrace2(Throwable e) {
// we go to system.out now - system.err is nonsense
print(getStackTrace2(e));
return e;
}
static void printStackTrace2() {
printStackTrace2(new Throwable());
}
static void printStackTrace2(String msg) {
printStackTrace2(new Throwable(msg));
}
/*static void printStackTrace2(S indent, Throwable e) {
if (endsWithLetter(indent)) indent += " ";
printIndent(indent, getStackTrace2(e));
}*/
static List recentlyChangedSnippets() {
return listRecentlyChangedSnippets();
}
static List recentlyChangedSnippets(int n) {
return listRecentlyChangedSnippets(n);
}
static JFrame centerPackedFrame(Component c) {
centerFrame(packFrame(c));
return getFrame(c);
}
static List listRecentlyChangedSnippets() {
return listRecentlyChangedSnippets(50);
}
static List listRecentlyChangedSnippets(int n) {
return snippetsFromHTML("http://tinybrain.de:8080/tb/snippets.php?reverse=1&withmd5=1&perpage=" + n + standardCredentials());
}
static WeakHashMap> callF_cache = new WeakHashMap();
static A callF(F0 f) {
return f == null ? null : f.get();
}
static B callF(F1 f, A a) {
return f == null ? null : f.get(a);
}
static Object callF(Object f, Object... args) { try {
if (f instanceof String)
return callMC((String) f, args);
if (f instanceof Runnable) {
((Runnable) f).run();
return null;
}
if (f == null) return null;
Class c = f.getClass();
ArrayList methods;
synchronized(callF_cache) {
methods = callF_cache.get(c);
if (methods == null)
methods = callF_makeCache(c);
}
int n = l(methods);
if (n == 0) {
if (f instanceof DynamicCallable)
return ((DynamicCallable) f)._dyn(args);
throw fail("No get method in " + getClassName(c));
}
if (n == 1) return invokeMethod(methods.get(0), f, args);
for (int i = 0; i < n; i++) {
Method m = methods.get(i);
if (call_checkArgs(m, args, false))
return invokeMethod(m, f, args);
}
throw fail("No matching get method in " + getClassName(c));
} catch (Exception __e) { throw rethrow(__e); } }
// used internally
static ArrayList callF_makeCache(Class c) {
ArrayList l = new ArrayList();
Class _c = c;
do {
for (Method m : _c.getDeclaredMethods())
if (m.getName().equals("get")) {
m.setAccessible(true);
l.add(m);
}
if (!l.isEmpty()) break;
_c = _c.getSuperclass();
} while (_c != null);
callF_cache.put(c, l);
return l;
}
static List classNames(Collection l) {
return getClassNames(l);
}
static List classNames(Object[] l) {
return getClassNames(Arrays.asList(l));
}
static ArrayList asList(A[] a) {
return a == null ? new ArrayList() : new ArrayList(Arrays.asList(a));
}
static ArrayList asList(int[] a) {
ArrayList l = new ArrayList();
for (int i : a) l.add(i);
return l;
}
static ArrayList asList(Iterable s) {
if (s instanceof ArrayList) return (ArrayList) s;
ArrayList l = new ArrayList();
if (s != null)
for (A a : s)
l.add(a);
return l;
}
static ArrayList asList(Enumeration e) {
ArrayList l = new ArrayList();
if (e != null)
while (e.hasMoreElements())
l.add(e.nextElement());
return l;
}
static class wrapAsActivity_R implements Runnable {
Object r;
wrapAsActivity_R() {}
wrapAsActivity_R(Object r) {
this.r = r;}
public void run() {
AutoCloseable __69 = tempActivity(r); try {
callF(r);
} finally { _close(__69); }}
}
static wrapAsActivity_R wrapAsActivity(final Object r) {
return r instanceof wrapAsActivity_R ? ((wrapAsActivity_R) r) : new wrapAsActivity_R(r);
}
static String getStackTrace2(Throwable throwable) {
return hideCredentials(getStackTrace(throwable) + replacePrefix("java.lang.RuntimeException: ", "FAIL: ",
hideCredentials(str(getInnerException(throwable)))) + "\n");
}
static int packFrame_minw = 150, packFrame_minh = 50;
static A packFrame(final A c) {
{ swing(new Runnable() { public void run() { try {
Window w = getWindow(c);
if (w != null) {
w.pack();
int maxW = getScreenWidth()-50, maxH = getScreenHeight()-50;
w.setSize(
min(maxW, max(w.getWidth(), packFrame_minw)),
min(maxH, max(w.getHeight(), packFrame_minh)));
}
} catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "Window w = getWindow(c);\r\n if (w != null) {\r\n w.pack();\r\n int ma..."; }}); }
return c;
}
static JFrame packFrame(ButtonGroup g) {
return packFrame(getFrame(g));
}
static void appendToMechQ_withDate(final String listName, final String text) {
mechAppend_noUniq_inQ(listName, "[" + localDateWithMilliseconds() + "] " + text);
}
static String defaultThreadName_name;
static String defaultThreadName() {
if (defaultThreadName_name == null)
defaultThreadName_name = "A thread by " + programID();
return defaultThreadName_name;
}
static JButton jbutton(String text, Object action) {
return newButton(text, action);
}
// button without action
static JButton jbutton(String text) {
return newButton(text, null);
}
static JButton jbutton(BufferedImage img, Object action) {
return setButtonImage(img, jbutton("", action));
}
static JButton jbutton(Action action) {
return swingNu(JButton.class, action);
}
static A setFontSize(final int size, final A a) {
if (a == null) return a;
{ swing(new Runnable() { public void run() { try {
Component _a = a;
if (a instanceof JComboBox)
_a = ((JComboBox) a).getEditor().getEditorComponent();
_a.setFont(_a.getFont().deriveFont((float) size));
} catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "Component _a = a;\r\n if (a instanceof JComboBox)\r\n _a = ((JComboBox) a..."; }}); }
return a;
}
static A setFontSize(A a, int size) {
return setFontSize(size, a);
}
static String str(Object o) {
return o == null ? "null" : o.toString();
}
static String str(char[] c) {
return new String(c);
}
static RuntimeException fail() { throw new RuntimeException("fail"); }
static RuntimeException fail(Throwable e) { throw asRuntimeException(e); }
static RuntimeException fail(Object msg) { throw new RuntimeException(String.valueOf(msg)); }
static RuntimeException fail(String msg) { throw new RuntimeException(msg == null ? "" : msg); }
static RuntimeException fail(String msg, Throwable innerException) { throw new RuntimeException(msg, innerException); }
// Substance
// Trident (required by Substance)
static void enableSubstance_impl(final String skinName) {
if (headless()) return;
{ swing(new Runnable() { public void run() { try {
if (!substanceLookAndFeelEnabled())
enableSubstance_impl_2(skinName);
} catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "if (!substanceLookAndFeelEnabled())\r\n enableSubstance_impl_2(skinName);"; }}); }
}
static void enableSubstance_impl_2(String skinName) { try {
boolean wasEnabled = substanceLookAndFeelEnabled();
ClassLoader cl = main.class.getClassLoader();
UIManager.getDefaults().put("ClassLoader", cl);
Thread.currentThread().setContextClassLoader(cl);
String skinClassName = "org.pushingpixels.substance.api.skin." + addSuffix(skinName, "Skin");
SubstanceSkin skin = (SubstanceSkin) nuObject(cl.loadClass(skinClassName));
SubstanceLookAndFeel.setSkin(skin);
JFrame.setDefaultLookAndFeelDecorated(true);
updateLookAndFeelOnAllWindows_noRenew();
if (!wasEnabled) renewConsoleFrame();
if (substanceLookAndFeelEnabled())
print("Substance L&F enabled.");
else
print("Could not enable Substance L&F?");
} catch (Exception __e) { throw rethrow(__e); } }
static List _registerWeakMap_preList;
static A _registerWeakMap(A map) {
if (javax() == null) {
// We're in class init
if (_registerWeakMap_preList == null) _registerWeakMap_preList = synchroList();
_registerWeakMap_preList.add(map);
return map;
}
try {
call(javax(), "_registerWeakMap", map);
} catch (Throwable e) {
printException(e);
print("Upgrade JavaX!!");
}
return map;
}
static void _onLoad_registerWeakMap() {
assertNotNull(javax());
if (_registerWeakMap_preList == null) return;
for (Object o : _registerWeakMap_preList)
_registerWeakMap(o);
_registerWeakMap_preList = null;
}
static JPanel jcenteredline(final Component... components) {
//ret new CenteredLine(components);
return swing(new F0() { JPanel get() { try { return jFullCenter(hstackWithSpacing(components)) ; } catch (Exception __e) { throw rethrow(__e); } }
public String toString() { return "jFullCenter(hstackWithSpacing(components))"; }});
}
static JPanel jcenteredline(List extends Component> components) {
return jcenteredline(asArray(Component.class, components));
}
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), delay);
return timer;
}
// runnable = Runnable or String (method name)
static Thread newThread(Object runnable) {
return new Thread(_topLevelErrorHandling(toRunnable(runnable)));
}
static Thread newThread(Object runnable, String name) {
if (name == null) name = defaultThreadName();
return new Thread(_topLevelErrorHandling(toRunnable(runnable)), name);
}
static Thread newThread(String name, Object runnable) {
return newThread(runnable, name);
}
static void restartWithDelay(int delay) {
Object j = getJavaX();
call(j, "preKill");
call(j, "nohupJavax", smartJoin((String[]) get(j, "fullArgs")), call(j, "fullVMArguments"));
sleep(delay);
System.exit(0);
sleep();
}
static int loadPage_defaultTimeout = 60000;
static ThreadLocal loadPage_charset = new ThreadLocal();
static boolean loadPage_allowGzip = true, loadPage_debug;
static boolean loadPage_anonymous; // don't send computer ID
static int loadPage_verboseness = 100000;
static int loadPage_retries = 1; //60; // seconds
static ThreadLocal loadPage_silent = new ThreadLocal();
static volatile int loadPage_forcedTimeout; // ms
static ThreadLocal loadPage_forcedTimeout_byThread = new ThreadLocal(); // ms
static ThreadLocal