UnsuppotedOperationException.getCause returns itself

I have the following java code in android

Method getIfaceMethod =
            service.getClass().getDeclaredMethod("getIface", new Class<?>[0]);
getIfaceMethod.invoke(param1)));

Sometimes an exception occurs when he cannot call the method through reflection. The exception thrown is an UnspportedOperationException. The strange thing is that when I call getCause, it returns itself - take a look at the screenshot from the debugger: Debug Debug Screen

What the heck??

+4
source share
1 answer

If you look at the source code Throwable , you will see that the default value for the variable causeis equal this, that the reason for this exception has not yet been initialized.

getCause() Throwable, , null, cause . , (!) cause , .

+4

Source: https://habr.com/ru/post/1615204/


All Articles