Hi,

would like to propose a modification to Toms fix. It looks to me as if all fields of a deserialized object are accessible as well as the private readObject-Method. Or does the VM reset the Accessible flag?

I think we need to reset the accessible flag after we are done with the field or method:


private void callReadMethod (Object obj, ObjectStreamClass osc) throws IOException
{
...
boolean saved = setAccessible(m,true);
m.invoke (obj, args);
setAccessible(m,saved);
...
}


/**
* Sets the accessible flag of theAccessible in a privileged action.
* @param theAccessible
* @param isAccessible
* @return the previous value of theAccessible.isAccessible()
*/
private static boolean setAccessible(final AccessibleObject theAccessible, boolean isAccessible){
boolean oldValue = theAccessible.isAccessible();
AccessController.doPrivileged(new PrivilegedAction()
{
public Object run()
{
theAccessible.setAccessible(true);
return null;
}
});
return oldValue;
}


--ingo



_______________________________________________
Classpath mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/classpath

Reply via email to