Why AutoCloseable.use method is inlined?

The key reason why this is inline is to support non-local returns. In Java, if you put a return statement in a try-with-resources block, this will return out of the enclosing function. Since we offer use as a replacement for try-with-resources, it’s only natural to preserve this ability. And non-local returns are only supported for inline functions.

1 Like