Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c74a113d authored by Ember Rose's avatar Ember Rose
Browse files

Re-throw reflective exceptions

Test: atest GeneratedInspectionCompanionProviderTest
Fixes: 125800739
Change-Id: Ifea2c3dc303e255bc704ee34168e250e649519b5
parent aa7b6826
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -40,8 +40,15 @@ public class GeneratedInspectionCompanionProvider implements InspectionCompanion
            final Class<InspectionCompanion<T>> companionClass =
                    (Class<InspectionCompanion<T>>) cls.getClassLoader().loadClass(companionName);
            return companionClass.newInstance();
        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
        } catch (ClassNotFoundException e) {
            return null;
        } catch (IllegalAccessException e) {
            throw new RuntimeException(e);
        } catch (InstantiationException e) {
            Throwable cause = e.getCause();
            if (cause instanceof RuntimeException) throw (RuntimeException) cause;
            if (cause instanceof Error) throw (Error) cause;
            throw new RuntimeException(cause);
        }
    }
}