On 03/23/2015 04:45 PM, Chris Hegarty wrote:
Here is an updated version of the FieldSetter API, with all comments to date incorporated.


http://cr.openjdk.java.net/~chegar/8071472/02/specdiff/overview-summary.html

Final spec comments welcome, after which I intend to submit a CCC request.

-Chris.

Hi Chris,

Recent bug "JDK-8068721 - RMI-IIOP communication fails when ConcurrentHashMap is passed to remote method" made me thinking...

ObjectInputStream is an extensible API. There are subclasses of ObjectInputStream out there. For example, there is an abstract "com.sun.corba.se.impl.io.InputStreamHook" with concrete implementation "com.sun.corba.se.impl.io.IIOPInputStream". The InputStreamHook overrides ObjectInputStream.defaultReadObject() with it's own implementation which doesn call ObjectInputStream.defaultReadObject(), which means that FieldSetterContext.checkPersistentFinalsNotSet() and FieldSetterContext.markPersistentFinalsSet() is not called for InputStreamHook based subclasses when user's readObject() calls defaultReadObject(), which further means that FieldSetter.checkAllFinalsSet() that is eventually called as last thing in user's readObject() method might find any persistent finals as not set and throw InvalidObjectException.

I have been thinking about this and I see several solutions:

1. provide protected final methods ObjectInputStream.checkPersistentFinalsNotSet() and markPersistentFinalsSet() that just delegate to FieldSetterContext for ObjectInputStream classes to call as part of their own overriden defaultReadObject() method. We should make sure those methods are called in JDK's corba InputStreamHook and document they should be called in 3rd party subclasses.

2. in ObjectInputStream constructor, detect if defaultReadObject() is overridden and set a flag that makes FieldSetter.checkAllFinalsSet() effectively a no-op.

3. 1 + 2 + enable for ObjectInputStream subclasses to declare that they obey the contract and that they call markPersistentFinalsSet() from overridden defaultReadObject() so checkAllFinalsSet() can be enabled.


What do you think?

Regards, Peter

Reply via email to