rovo89 / XposedBridge

The Java part of the Xposed framework.
3.89k stars 1.1k forks source link

Catch XposedHelpers.ClassNotFoundException #197

Closed daimoniuma closed 6 years ago

daimoniuma commented 6 years ago

How to catch it? AIDE writes error about unknown type. Is it same as system ClassNotFoundException?

try {
            Class<?> mClass = XposedHelpers.findClass(className, lpparam.classLoader);
        } catch (XposedHelpers.ClassNotFoundException e) {

        }
rovo89 commented 6 years ago

It's actually XposedHelpers.ClassNotFoundError, not XposedHelpers.ClassNotFoundException (which indeed doesn't exist). The difference is that Exceptions must be declared as throws in the method (and must be caught by the caller), whereas Errors and RuntimeExceptions don't need to be declared, but can still optionally be caught.

daimoniuma commented 6 years ago

Wow, it was autosuggestion from AIDE. Didn't notice that here is Exception instead of Error at the end. Sorry. And congrats with Nougat release. 🎉