|
|
|
I've implemented it as follows:
if there is a default constructor (may be private), it will be called to construct the object. If not, a warning is logged and the instance is created using objenesis without calling any constructor and initialization Initializing the class without calling a constructor seems to be a very difficult thing to do. In a future release we could add some code that uses ASM to add a constructor to the class and then call that one, but that is not something that is easy to write For now you will need to add a no-args (can be private) constructor. Of course this is not needed when there are no constructors. In that case java automatically creates a default constructor. |
|||||||||||||||||||||||||||||||||||||||
There are many different strategies that Objenesis uses for instantiating objects based on the JVM vendor, JVM version, SecurityManager and type of class being instantiated.
We have defined that two different kinds of instantiation are required:
* Stardard - No constructor will be called
* Serializable compliant - Acts like an object instantiated by java standard serialization. It means that the constructor of the first non-serializable parent class will be called. However, readResolve is not called and we never check if the object is serializable.
So, having an attribute that determines if it uses the standard or Serializable compliant might fix this.