Andrew Tobilko Andrew Tobilko - 1 year ago 98
Java Question

An equivalent for a Class.forName call without exception handling

I was wondering if there is "a method-wrapper" over the method

which throws an unchecked exception if the checked

My problem is to handle these types of exceptions inside a lambda body. It looks too scruffy:

definition -> {
new Thread(() -> {
try {
} catch (ClassNotFoundException e) {

Or do I have to write my own?

Thanks in advance.

Answer Source

Spring knows the org.springframework.util.ClassUtils.resolveClassName method which is an equivalent for Class.forName but throwing an IllegalArgumentException if the class cannot be found.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download