You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original issue 30 created by henri-tremblay on 2014-12-13T13:20:34.000Z:
just found while adapting fast serialization (github) to android.
What steps will reproduce the problem?
Create Externalizable ArrayList Subclass
use objenesis new instance
add an element to the arraylist subclass (=> exception)
What is the expected output? What do you see instead?
no excpetion
What version of the product are you using? On what operating system?
2.1
Please provide any additional information below.
the issue is, SunReflectionFactoryInstantiator always uses the "newConstructorForSerialization". However if there is public noarg constructor for an externalizable, this should be used instead (else initial state might be wrong).
The text was updated successfully, but these errors were encountered:
That is the expected behavior. The SunReflectionFactorySerializationInstantiator will behave as wanted since it mimics the serialization instantiation.
However, SunReflectionFactoryInstantiator bypasses all constructors.
There was indeed a bug related to SunReflectionFactorySerializationInstantiator. This instantiator should call the no-arg constructor of the first none-serializable parent class. If this constructor was not public, it would fail.
However, it is still normal that the constructor of the child class isn't called even though it implements Externalizable. Objenesis isn't following a full Java serialization process. It is only calling the no-arg constructor of the first none-serializable parent class. Nothing else. So if you want to detect Externalizable, you should do it in your own code.
henri-tremblay
changed the title
Invalid object state for classes defining public default constructor
SunReflectionFactoryInstantiator not working if parent class constructor isn't public
Jun 20, 2017
Original issue 30 created by henri-tremblay on 2014-12-13T13:20:34.000Z:
just found while adapting fast serialization (github) to android.
What steps will reproduce the problem?
What is the expected output? What do you see instead?
no excpetion
What version of the product are you using? On what operating system?
2.1
Please provide any additional information below.
the issue is, SunReflectionFactoryInstantiator always uses the "newConstructorForSerialization". However if there is public noarg constructor for an externalizable, this should be used instead (else initial state might be wrong).
The text was updated successfully, but these errors were encountered: