Now, I finally understood how to create it correctly. Enjoy :)
public class A {
public static final A INSTANCE = new A();
static {
throwError();
}
private static void throwError() {
throw new RuntimeException();
}
}
public static final A INSTANCE = new A();
static {
throwError();
}
private static void throwError() {
throw new RuntimeException();
}
}
static {
try {
A a = A.INSTANCE;
}
catch (Throwable t) {
// IGNORE
}
}
public static void main(String[] args) {
new A();
}
}