Fix a ClassCastException when looking at the internals of an InvocationTargetException

Managed to get a ClassCastException here in my CI environment, because an `java.lang.IllegalAccessError` was thrown during injection.