class Test { { bar(new ThrowableComputable() { @Override public String compute() throws Exception { return foo(); } }); } private void bar(ThrowableComputable throwableComputable) {} private K foo() throws Exception { return null; } interface ThrowableComputable { T compute() throws T1; } }