changeset 118:a97c70f83ccb

8079323: Serialization compatibility for Templates: need to exclude Hashtable from serialization Reviewed-by: dfuchs, lancea, hawtin
author aefimov
date Fri, 15 May 2015 11:24:22 +0300
parents a109711b323a
children 6e513b74e14d
files drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/trax/TemplatesImpl.java
diffstat 1 files changed, 8 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/trax/TemplatesImpl.java	Tue Apr 28 16:07:40 2015 +0300
+++ b/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/trax/TemplatesImpl.java	Fri May 15 11:24:22 2015 +0300
@@ -24,6 +24,7 @@
 package com.sun.org.apache.xalan.internal.xsltc.trax;
 
 import java.io.IOException;
+import java.io.NotSerializableException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 import java.io.ObjectStreamField;
@@ -31,7 +32,6 @@
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.util.HashMap;
-import java.util.Hashtable;
 import java.util.Map;
 import java.util.Properties;
 
@@ -91,7 +91,7 @@
     /**
      * Contains the list of auxiliary class definitions.
      */
-    private Map<String, Class<?>> _auxClasses = null;
+    private transient Map<String, Class<?>> _auxClasses = null;
 
     /**
      * Output properties of this translet.
@@ -142,7 +142,6 @@
      * @serialField _bytecodes byte[][] Class definition
      * @serialField _class Class[] The translet class definition(s).
      * @serialField _transletIndex int The index of the main translet class
-     * @serialField _auxClasses Hashtable The list of auxiliary class definitions.
      * @serialField _outputProperties Properties Output properties of this translet.
      * @serialField _indentNumber int Number of spaces to add for output indentation.
      */
@@ -152,7 +151,6 @@
             new ObjectStreamField("_bytecodes", byte[][].class),
             new ObjectStreamField("_class", Class[].class),
             new ObjectStreamField("_transletIndex", int.class),
-            new ObjectStreamField("_auxClasses", Hashtable.class),
             new ObjectStreamField("_outputProperties", Properties.class),
             new ObjectStreamField("_indentNumber", int.class),
         };
@@ -203,6 +201,7 @@
      *  if yes then we need to deserialize the URIResolver
      *  Fix for bugzilla bug 22438
      */
+    @SuppressWarnings("unchecked")
     private void  readObject(ObjectInputStream is)
       throws IOException, ClassNotFoundException
     {
@@ -222,13 +221,9 @@
         _class = (Class[])gf.get("_class", null);
         _transletIndex = gf.get("_transletIndex", -1);
 
-        Hashtable<String, Class<?>> aux = (Hashtable<String, Class<?>>)gf.get("_auxClasses", null);
         _outputProperties = (Properties)gf.get("_outputProperties", null);
         _indentNumber = gf.get("_indentNumber", 0);
 
-        //convert Hashtable back to HashMap
-        if (aux != null) _auxClasses = new HashMap<String, Class<?>>(aux);
-
         if (is.readBoolean()) {
             _uriResolver = (URIResolver) is.readObject();
         }
@@ -244,8 +239,11 @@
      */
     private void writeObject(ObjectOutputStream os)
         throws IOException, ClassNotFoundException {
-        // Convert Maps to Hashtables
-        Hashtable<String, Class<?>> aux = (_auxClasses == null)? null : new Hashtable<String, Class<?>>(_auxClasses);
+        if (_auxClasses != null) {
+            //throw with the same message as when Hashtable was used for compatibility.
+            throw new NotSerializableException(
+                    "com.sun.org.apache.xalan.internal.xsltc.runtime.Hashtable");
+        }
 
         // Write serialized fields
         ObjectOutputStream.PutField pf = os.putFields();
@@ -253,7 +251,6 @@
         pf.put("_bytecodes", _bytecodes);
         pf.put("_class", _class);
         pf.put("_transletIndex", _transletIndex);
-        pf.put("_auxClasses", aux);
         pf.put("_outputProperties", _outputProperties);
         pf.put("_indentNumber", _indentNumber);
         os.writeFields();