After examining the Android source code, we found a way to achieve this using the static method ObjectInputStream # newInstance ().
private Object newInstanceSkippingConstructor(final Class clazz) throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { Method newInstance = ObjectInputStream.class.getDeclaredMethod("newInstance", Class.class, Class.class); newInstance.setAccessible(true); return newInstance.invoke(null, clazz, Object.class); }
Vagaus
source share