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.*;
// https://bugs.openjdk.java.net/browse/JDK-8183385
class main {
static String s0 = "Hello World";
// (truncated) contents of jdk-headers-1.6.0/include/ibm/zos/jawt_md.h file encoding=IBM500/EBCDIC, read with UTF8
static String s1 = "a\\\u0015@\\@~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\u0015@\\@@\ufffd\ufffd\ufffd@\u00d6\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u0015@\\@@\ufffd\ufffd\ufffd@\u25a4\ufffd\ufffd\ufffd@\u0501\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u0015@\\\u0015@\\@@\ufffd\ufffd\ufffd@\ufffd\ufffd\ufffdk@\u0441\ufffd\ufffdM\ufffd\ufffd]@\u3143\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd@\u0144\ufffd\ufffd\ufffd\ufffd\ufffdk@\ufffd\ufffd\u0015@\\@@M\ufffd]@\u00d6\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd@\ufffd\ufffd\ufffd@\u00d6\ufffd\ufffdK@\ufffd\ufffd\ufffd\ufffdk@\ufffd\ufffd\ufffd\ufffdK@\ufffd\ufffd\ufffd@\u0649\ufffd\ufffd\ufffd\ufffd@\u0645\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u0015@\\\u0015@\\";
public static void main(final String[] args) throws Exception {
{ swing(new Runnable() { public void run() { try { new main().go();
} catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "new main().go();"; }}); }
}
void go() {
JFrame frame = new JFrame("BugRepro");
frame.setBounds(100, 100, 800, 600);
frame.setContentPane(foo());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
JCheckBox c;
JPanel foo() {
JPanel panel = new JPanel(new BorderLayout());
JButton b;
final JTextArea area = new JTextArea();
JPanel p = new JPanel(new FlowLayout());
panel.add(p, BorderLayout.NORTH);
p.add(b = new JButton("click me"));
p.add(c = new JCheckBox("include strange chars", true));
panel.add(new JLabel("Hello"), BorderLayout.SOUTH);
panel.add(new JScrollPane(area), BorderLayout.CENTER);
// need to set a new Document b/c setText() sets the text of the old document.
b.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent _evt) { try { area.setDocument(makeDoc()); } catch (Throwable __e) { messageBox(__e); }}});
return panel;
}
Document makeDoc() {
Document doc = new PlainDocument();
try {
doc.insertString(0, makeString(), new SimpleAttributeSet());
} catch (BadLocationException e) {
throw new Error(e);
}
return doc;
}
String makeString() {
int MAX = 1000;
StringBuilder buf = new StringBuilder();
extracted(MAX, buf);
System.out.println("Including strange chars: " + c.isSelected());
if (c.isSelected()) {
buf.append(s1); // XXX This line slows down the rendering noticeably since it contains strange chars
}
extracted(MAX, buf);
return buf.toString();
}
static void extracted(int MAX, StringBuilder buf) {
for (int i = 0; i < MAX; i++) {
buf.append(s0);
buf.append("\n");
}
}
static Object swing(Object f) {
return swingAndWait(f);
}
static A swing(F0 f) {
return (A) swingAndWait(f);
}
static RuntimeException rethrow(Throwable t) {
if (t instanceof Error)
_handleError((Error) t);
throw t instanceof RuntimeException ? (RuntimeException) t : new RuntimeException(t);
}
static void messageBox(final String msg) {
if (headless()) print(msg);
else { swing(new Runnable() { public void run() { try {
JOptionPane.showMessageDialog(null, msg, "JavaX", JOptionPane.INFORMATION_MESSAGE);
} catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "JOptionPane.showMessageDialog(null, msg, \"JavaX\", JOptionPane.INFORMATION_MES..."; }}); }
}
static void messageBox(Throwable e) {
//showConsole();
printStackTrace(e);
messageBox(hideCredentials(innerException(e)));
}
static void swingAndWait(Runnable r) { try {
if (isAWTThread())
r.run();
else
EventQueue.invokeAndWait(addThreadInfoToRunnable(r));
} catch (Exception __e) { throw rethrow(__e); } }
static Object swingAndWait(final Object f) {
if (isAWTThread())
return callF(f);
else {
final Var result = new Var();
swingAndWait(new Runnable() { public void run() { try {
result.set(callF(f));
} catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "result.set(callF(f));"; }});
return result.get();
}
}
static void _handleError(Error e) {
call(javax(), "_handleError", e);
}
static boolean headless() {
return isHeadless();
}
static volatile StringBuffer local_log = new StringBuffer(); // not redirected
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 int print_maxLineLength = 0; // 0 = unset
static boolean print_silent; // total mute if set
static Object print_byThread_lock = new Object();
static volatile ThreadLocal