package jetbrains.mps.baseLanguage.sandbox.internal;
/*Generated by MPS */
import java.io.Closeable;
import java.io.IOException;
import java.nio.CharBuffer;
public class InternalAnonymousClassUsage {
public InternalAnonymousClassUsage() {
}
public void safeRun(Runnable task) {
try {
task.run();
} catch (Exception x) {
System.out.println("exception: " + x.getMessage());
}
new Closeable() {
public void close() {
}
};
}
public void check1() {
// default anonymous class
safeRun(new Runnable() {
@Override
public void run() {
}
});
}
public void check2() {
safeRun(new Runnable() {
public void run() {
System.out.println("done");
}
});
}
public void check3() throws IOException {
(new Readable() {
public int read(CharBuffer cb) throws IOException {
if (cb == null) {
throw new IOException();
}
return 0;
}
}).read(CharBuffer.wrap("aa"));
}
public void check4() {
new Runnable() {
public void run() {
}
}.run();
}
public void check5() {
new ReadableImpl("wow, my title") {
{
System.out.println("initializer");
}
public int read(CharBuffer buffer) {
return 6;
}
};
}
public class ReadableImpl implements Readable {
public ReadableImpl(String title) {
}
@Override
public int read(CharBuffer buffer) throws IOException {
return 5;
}
}
}