/[classpath]/classpath/java/io/ObjectInputStream.java
ViewVC logotype

Diff of /classpath/java/io/ObjectInputStream.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.68 by tromey, Sat Sep 17 15:46:22 2005 UTC revision 1.69 by mark, Wed Oct 12 19:41:42 2005 UTC
# Line 52  import java.security.AccessController; Line 52  import java.security.AccessController;
52  import java.security.PrivilegedAction;  import java.security.PrivilegedAction;
53  import java.util.Arrays;  import java.util.Arrays;
54  import java.util.Hashtable;  import java.util.Hashtable;
55    import java.util.Iterator;
56    import java.util.TreeSet;
57  import java.util.Vector;  import java.util.Vector;
58    
59  public class ObjectInputStream extends InputStream  public class ObjectInputStream extends InputStream
# Line 90  public class ObjectInputStream extends I Line 92  public class ObjectInputStream extends I
92        }        }
93    
94      this.resolveEnabled = false;      this.resolveEnabled = false;
     this.isDeserializing = false;  
95      this.blockDataPosition = 0;      this.blockDataPosition = 0;
96      this.blockDataBytes = 0;      this.blockDataBytes = 0;
97      this.blockData = new byte[BUFFER_SIZE];      this.blockData = new byte[BUFFER_SIZE];
# Line 98  public class ObjectInputStream extends I Line 99  public class ObjectInputStream extends I
99      this.realInputStream = new DataInputStream(in);      this.realInputStream = new DataInputStream(in);
100      this.nextOID = baseWireHandle;      this.nextOID = baseWireHandle;
101      this.objectLookupTable = new Hashtable();      this.objectLookupTable = new Hashtable();
     this.validators = new Vector();  
102      this.classLookupTable = new Hashtable();      this.classLookupTable = new Hashtable();
103      setBlockDataMode(true);      setBlockDataMode(true);
104      readStreamHeader();      readStreamHeader();
# Line 126  public class ObjectInputStream extends I Line 126  public class ObjectInputStream extends I
126      if (this.useSubclassMethod)      if (this.useSubclassMethod)
127        return readObjectOverride();        return readObjectOverride();
128    
     boolean was_deserializing;  
   
129      Object ret_val;      Object ret_val;
     was_deserializing = this.isDeserializing;  
   
130      boolean old_mode = setBlockDataMode(false);      boolean old_mode = setBlockDataMode(false);
   
     this.isDeserializing = true;  
   
131      byte marker = this.realInputStream.readByte();      byte marker = this.realInputStream.readByte();
132    
133      depth += 2;      if (DEBUG)
134          depth += 2;
135    
136      if(dump) dumpElement("MARKER: 0x" + Integer.toHexString(marker) + " ");      if(dump) dumpElement("MARKER: 0x" + Integer.toHexString(marker) + " ");
137    
138      try      try
139        {        {
140          ret_val = parseContent(marker);          ret_val = parseContent(marker);
141         }        }
142       finally      finally
143         {        {
144          setBlockDataMode(old_mode);          setBlockDataMode(old_mode);
145                    if (DEBUG)
146          this.isDeserializing = was_deserializing;            depth -= 2;
147                  }
148          depth -= 2;      
149                return ret_val;
150          if (! was_deserializing)    }
           {  
             if (validators.size() > 0)  
               invokeValidators();  
           }  
        }  
       
      return ret_val;  
    }  
151    
152     /**     /**
153      * Handles a content block within the stream, which begins with a marker      * Handles a content block within the stream, which begins with a marker
# Line 347  public class ObjectInputStream extends I Line 333  public class ObjectInputStream extends I
333            int handle = assignNewHandle(obj);            int handle = assignNewHandle(obj);
334            Object prevObject = this.currentObject;            Object prevObject = this.currentObject;
335            ObjectStreamClass prevObjectStreamClass = this.currentObjectStreamClass;            ObjectStreamClass prevObjectStreamClass = this.currentObjectStreamClass;
336              TreeSet prevObjectValidators = this.currentObjectValidators;
337                        
338            this.currentObject = obj;            this.currentObject = obj;
339              this.currentObjectValidators = null;
340            ObjectStreamClass[] hierarchy =            ObjectStreamClass[] hierarchy =
341              inputGetObjectStreamClasses(clazz);              inputGetObjectStreamClasses(clazz);
342                        
# Line 400  public class ObjectInputStream extends I Line 388  public class ObjectInputStream extends I
388            this.currentObject = prevObject;            this.currentObject = prevObject;
389            this.currentObjectStreamClass = prevObjectStreamClass;            this.currentObjectStreamClass = prevObjectStreamClass;
390            ret_val = processResolution(osc, obj, handle);            ret_val = processResolution(osc, obj, handle);
391                        if (currentObjectValidators != null)
392                invokeValidators();
393              this.currentObjectValidators = prevObjectValidators;
394    
395            break;            break;
396          }          }
397                    
# Line 732  public class ObjectInputStream extends I Line 723  public class ObjectInputStream extends I
723        throw new InvalidObjectException("attempt to add a null "        throw new InvalidObjectException("attempt to add a null "
724                                         + "ObjectInputValidation object");                                         + "ObjectInputValidation object");
725    
726      this.validators.addElement(new ValidatorAndPriority (validator,      if (currentObjectValidators == null)
727                                                           priority));        currentObjectValidators = new TreeSet();
728        
729        currentObjectValidators.add(new ValidatorAndPriority(validator, priority));
730    }    }
731    
732    
# Line 1837  public class ObjectInputStream extends I Line 1830  public class ObjectInputStream extends I
1830    // on OBJ    // on OBJ
1831    private void invokeValidators() throws InvalidObjectException    private void invokeValidators() throws InvalidObjectException
1832    {    {
     Object[] validators = new Object[this.validators.size()];  
     this.validators.copyInto (validators);  
     Arrays.sort (validators);  
   
1833      try      try
1834        {        {
1835          for (int i=0; i < validators.length; i++)          Iterator it = currentObjectValidators.iterator();
1836            ((ObjectInputValidation)validators[i]).validateObject();          while(it.hasNext())
1837              {
1838                ValidatorAndPriority vap = (ValidatorAndPriority) it.next();
1839                ObjectInputValidation validator = vap.validator;
1840                validator.validateObject();
1841              }
1842        }        }
1843      finally      finally
1844        {        {
1845          this.validators.removeAllElements();          currentObjectValidators = null;
1846        }        }
1847    }    }
1848    
# Line 1897  public class ObjectInputStream extends I Line 1891  public class ObjectInputStream extends I
1891    private Hashtable objectLookupTable;    private Hashtable objectLookupTable;
1892    private Object currentObject;    private Object currentObject;
1893    private ObjectStreamClass currentObjectStreamClass;    private ObjectStreamClass currentObjectStreamClass;
1894      private TreeSet currentObjectValidators;
1895    private boolean readDataFromBlock;    private boolean readDataFromBlock;
   private boolean isDeserializing;  
1896    private boolean fieldsAlreadyRead;    private boolean fieldsAlreadyRead;
   private Vector validators;  
1897    private Hashtable classLookupTable;    private Hashtable classLookupTable;
1898    private GetField prereadFields;    private GetField prereadFields;
1899    

Legend:
Removed from v.1.68  
changed lines
  Added in v.1.69

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26