Is it possible in java to create ‘blank’ instance of class without no-arg constructor using reflection?

With standard reflection, no, but there is a library that can do it for you: objenesis.

It’s specifically designed to instantiate classes without default constructors, and it’s used by other serialization libraries like xstream.

Note: the constructor might not be called in these cases (but that’s presumably what you want).

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)