Static Exceptions for Flow Control

1 points | by sea-gold 2 hours ago

1 comments

  • sea-gold 2 hours ago

    > TL;DR

    > To create high performance exceptions for flow control in the JVM, simply extend the following StaticException class. Then store the Exception instance in a static final field and throw it as needed. They're fast, because the call stack doesn't need to be traversed and since we're creating reusable objects, there's less for the garbage collector to do.