try-catch syntactic sugar in java

You can't do something like your pseudocode suggests with annotations, but you can make the method(s) throw:

public void bar() throws Exception {}

And just let it bubble up all the way, catching it wherever you want to, higher up the call tree (or down the call stack, if you prefer).


Wrap up the try/catch in a class/method that accepts an interface. Pass an anonymous implementation to that class/method. Really only good when the exception handling is involved, otherwise similarly noisy.

You could also play AOP/bytecode games, depending on actual use case.