Its other way around. here is the java doc of isAssignableFrom(...)
method
Determines if the class or interface represented by this Class object is either the same as, or is a superclass or superinterface of, the class or interface represented by the specified Class parameter. It returns true if so; otherwise it returns false.
So when you do
if (toHandle.getClass().isAssignableFrom(Throwable.class))
Its actually checking whether RuntimeException
class object is either the same as, or is a superclass or superinterface of, the class or interface represented by Throwable
.