class Trivial { // static // Works with this line present class DomainExcepiton extends RuntimeException { // nothing at all } static void doThings() { new Object() { void pony() { if (falseFunc()) throw new DomainExcepiton(); } }; } static boolean falseFunc() { return false; } }