On 7/26/2012 8:21 AM, Valerie (Yu-Ching) Peng wrote: > Hi, Max or Xuelei, > > Either of you have cycles to review the following 3 perf related fixes? > 7107613: scalability bloker in javax.crypto.CryptoPermissions > 7107616: scalability bloker in javax.crypto.JceSecurityManager > 7185471: Avoid key expansion when AES cipher is re-init w/ the same key > > Webrevs are at: > http://cr.openjdk.java.net/~valeriep/7107613 In this update, the filed "perms" was declared as transient: ---------- - private Hashtable<String, PermissionCollection> perms; + private transient ConcurrentHashMap<String,PermissionCollection> perms; ----------
The ObjectOutputStream.PutField and ObjectInputStream.GetField will call: ---------- + Hashtable<String,PermissionCollection> permTable = + (Hashtable<String,PermissionCollection>) (fields.get("perms", null)); + Hashtable<String,PermissionCollection> permTable = + (Hashtable<String,PermissionCollection>) (fields.get("perms", null)); ---------- As will try to get the field offset of "perms" from the instance of this class, CryptoPermissions. Because "perms" has been declared as transient, a exception is properly thrown, java.lang.IllegalArgumentException: no such field perms with type class java.lang.Object I think we may need to override the "serialPersistentFields" of ObjectStreamField, as [1][2]: + private static final ObjectStreamField[] serialPersistentFields = { + new ObjectStreamField("perms", Hashtable.class), + }; + + private void readObject(ObjectInputStream s) + throws IOException, ClassNotFoundException { + ... Alternatively, I was wondering maybe we reserver the hashtable variable, "perms", and add a new transient ConcurrentHashMap variable, "transientPerms": ------------------ private Hashtable<String, PermissionCollection> perms; + private transient + ConcurrentHashMap<String,PermissionCollection> transientPerms; ------------------ Then we will not need to override the serialPersistentFields variable any more. The readObject and writeObject looks like: ------------------ + private void readObject(ObjectInputStream s) + throws IOException, ClassNotFoundException { + + s.defaultReadObject(); + transientPerms = new ConcurrentHashMap<>(perms); + perms = null; + } + + private void writeObject(ObjectOutputStream s) throws IOException { + perms = new Hashtable<>(transientPerms); + s.defaultWriteObject(); + perms = null; + } ------------------ Xuelei [1] http://docs.oracle.com/javase/6/docs/platform/serialization/spec/input.html#4936 [2] http://docs.oracle.com/javase/6/docs/platform/serialization/spec/class.html#3127 > http://cr.openjdk.java.net/~valeriep/7107616 > http://cr.openjdk.java.net/~valeriep/7185471 > > The changes are for JDK 8. May be backported to 7u later if necessary, > Thanks, > Valerie