Github user gzak commented on the pull request:
https://github.com/apache/commons-lang/pull/98#issuecomment-113777231
@netomi it is not flawed, but it is tricky to understand. There is no
ClassCastException, the original exception does indeed get thrown, even if it
is checked. Check out the unit test, it expects an Exception, not a
ClassCastException.
It exploits type erasure to trick the compiler into permitting a checked
exception to be thrown "as if" it were a RuntimeException. That cast operation
you see in the private method ultimately gets erased, because the generic type
argument itself gets erased. But it does the job of telling the compiler that
it will be a RuntimeException, even if it's not.
It's a very clever workaround (I cannot claim credit, so I'm not bragging,
I'm complimenting).
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---