⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 objectinputstream.java

📁 this gcc-g++-3.3.1.tar.gz is a source file of gcc, you can learn more about gcc through this codes f
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
	    }	  case TC_RESET:	    dumpElementln ("RESET");	    clearHandles ();	    ret_val = readObject ();	    break;	  case TC_EXCEPTION:	    {	      dumpElement ("EXCEPTION=");	      Exception e = (Exception)readObject ();	      dumpElementln (e.toString());	      clearHandles ();	      throw new WriteAbortedException ("Exception thrown during writing of stream", e);	    }	  default:	    throw new IOException ("Unknown marker on stream: " + marker);	  }      }    finally      {	setBlockDataMode (old_mode);		this.isDeserializing = was_deserializing;		if (! was_deserializing)	  {	    if (validators.size () > 0)	      invokeValidators ();	  }      }        return ret_val;  }  /**     Reads the current objects non-transient, non-static fields from     the current class from the underlying output stream.     This method is intended to be called from within a object's     <code>private void readObject (ObjectInputStream)</code>     method.     @exception ClassNotFoundException The class that an object being     read in belongs to cannot be found.     @exception NotActiveException This method was called from a     context other than from the current object's and current class's     <code>private void readObject (ObjectInputStream)</code>     method.     @exception IOException Exception from underlying     <code>OutputStream</code>.  */  public void defaultReadObject ()    throws ClassNotFoundException, IOException, NotActiveException  {    if (this.currentObject == null || this.currentObjectStreamClass == null)      throw new NotActiveException ("defaultReadObject called by non-active class and/or object");    if (fieldsAlreadyRead)      throw new NotActiveException ("defaultReadObject called but fields already read from stream (by defaultReadObject or readFields)");    boolean oldmode = setBlockDataMode(false);    readFields (this.currentObject, this.currentObjectStreamClass);    setBlockDataMode(oldmode);    fieldsAlreadyRead = true;  }  /**     Registers a <code>ObjectInputValidation</code> to be carried out     on the object graph currently being deserialized before it is     returned to the original caller of <code>readObject ()</code>.     The order of validation for multiple     <code>ObjectInputValidation</code>s can be controled using     <code>priority</code>.  Validators with higher priorities are     called first.     @see java.io.ObjectInputValidation     @exception InvalidObjectException <code>validator</code> is     <code>null</code>     @exception NotActiveException an attempt was made to add a     validator outside of the <code>readObject</code> method of the     object currently being deserialized  */  public void registerValidation (ObjectInputValidation validator,				  int priority)    throws InvalidObjectException, NotActiveException  {    if (this.currentObject == null || this.currentObjectStreamClass == null)      throw new NotActiveException ("registerValidation called by non-active class and/or object");    if (validator == null)      throw new InvalidObjectException ("attempt to add a null ObjectInputValidation object");    this.validators.addElement (new ValidatorAndPriority (validator,							  priority));  }  /**     Called when a class is being deserialized.  This is a hook to     allow subclasses to read in information written by the     <code>annotateClass (Class)</code> method of an     <code>ObjectOutputStream</code>.     This implementation looks up the active call stack for a     <code>ClassLoader</code>; if a <code>ClassLoader</code> is found,     it is used to load the class associated with <code>osc</code>,     otherwise, the default system <code>ClassLoader</code> is used.     @exception IOException Exception from underlying     <code>OutputStream</code>.     @see java.io.ObjectOutputStream#annotateClass (java.lang.Class)  */  protected Class resolveClass (ObjectStreamClass osc)    throws ClassNotFoundException, IOException  {    SecurityManager sm = System.getSecurityManager ();    if (sm == null)      sm = new SecurityManager () {};    // FIXME: currentClassLoader doesn't yet do anything useful. We need    // to call forName() with the classloader of the class which called     // readObject(). See SecurityManager.getClassContext().    ClassLoader cl = currentClassLoader (sm);    if (cl == null)      return Class.forName (osc.getName ());    else      return cl.loadClass (osc.getName ());  }  /**     Allows subclasses to resolve objects that are read from the     stream with other objects to be returned in their place.  This     method is called the first time each object is encountered.     This method must be enabled before it will be called in the     serialization process.     @exception IOException Exception from underlying     <code>OutputStream</code>.     @see enableResolveObject (boolean)  */  protected Object resolveObject (Object obj) throws IOException  {    return obj;  }  protected Class resolveProxyClass (String[] intfs)    throws IOException, ClassNotFoundException  {    SecurityManager sm = System.getSecurityManager ();        if (sm == null)      sm = new SecurityManager () {};        ClassLoader cl = currentClassLoader (sm);        Class[] clss = new Class[intfs.length];    if(cl == null){      for (int i = 0; i < intfs.length; i++)	clss[i] = Class.forName(intfs[i]);      cl = ClassLoader.getSystemClassLoader();    }    else      for (int i = 0; i < intfs.length; i++)	clss[i] = cl.loadClass(intfs[i]);    try {      return Proxy.getProxyClass(cl, clss);    } catch (IllegalArgumentException e) {      throw new ClassNotFoundException(null, e);    }  }    /**     If <code>enable</code> is <code>true</code> and this object is     trusted, then <code>resolveObject (Object)</code> will be called     in subsequent calls to <code>readObject (Object)</code>.     Otherwise, <code>resolveObject (Object)</code> will not be called.     @exception SecurityException This class is not trusted.  */  protected boolean enableResolveObject (boolean enable)    throws SecurityException  {    if (enable)      {	SecurityManager sm = System.getSecurityManager ();	if (sm != null)	  sm.checkPermission (new SerializablePermission ("enableSubstitution"));      }    boolean old_val = this.resolveEnabled;    this.resolveEnabled = enable;    return old_val;  }  /**     Reads stream magic and stream version information from the     underlying stream.     @exception IOException Exception from underlying stream.     @exception StreamCorruptedException An invalid stream magic     number or stream version was read from the stream.  */  protected void readStreamHeader ()    throws IOException, StreamCorruptedException  {    dumpElement ("STREAM MAGIC ");    if (this.realInputStream.readShort () != STREAM_MAGIC)      throw new StreamCorruptedException ("Invalid stream magic number");    dumpElementln ("STREAM VERSION ");    if (this.realInputStream.readShort () != STREAM_VERSION)      throw new StreamCorruptedException ("Invalid stream version number");  }  public int read () throws IOException  {    if (this.readDataFromBlock)      {	if (this.blockDataPosition >= this.blockDataBytes)	  readNextBlock ();	return (this.blockData[this.blockDataPosition++] & 0xff);      }    else      return this.realInputStream.read ();  }  public int read (byte[] data, int offset, int length) throws IOException  {    if (this.readDataFromBlock)      {	if (this.blockDataPosition + length > this.blockDataBytes)	  {	    int remain = this.blockDataBytes - this.blockDataPosition;	    if (remain != 0)	      {		System.arraycopy (this.blockData, this.blockDataPosition,				  data, offset, remain);		offset += remain;		length -= remain;	      }	    readNextBlock ();	  }	System.arraycopy (this.blockData, this.blockDataPosition,			  data, offset, length);	this.blockDataPosition += length;	return length;      }    else      return this.realInputStream.read (data, offset, length);  }  public int available () throws IOException  {    if (this.readDataFromBlock)      {	if (this.blockDataPosition >= this.blockDataBytes)	  readNextBlock ();	return this.blockDataBytes - this.blockDataPosition;      }    else      return this.realInputStream.available ();  }  public void close () throws IOException  {    this.realInputStream.close ();  }  public boolean readBoolean () throws IOException  {    return this.dataInputStream.readBoolean ();  }  public byte readByte () throws IOException  {    return this.dataInputStream.readByte ();  }  public int readUnsignedByte () throws IOException  {    return this.dataInputStream.readUnsignedByte ();  }  public short readShort () throws IOException  {    return this.dataInputStream.readShort ();  }  public int readUnsignedShort () throws IOException  {    return this.dataInputStream.readUnsignedShort ();  }  public char readChar () throws IOException  {    return this.dataInputStream.readChar ();  }  public int readInt () throws IOException  {    return this.dataInputStream.readInt ();  }  public long readLong () throws IOException  {    return this.dataInputStream.readLong ();  }  public float readFloat () throws IOException  {    return this.dataInputStream.readFloat ();  }  public double readDouble () throws IOException  {    return this.dataInputStream.readDouble ();  }  public void readFully (byte data[]) throws IOException  {    this.dataInputStream.readFully (data);  }  public void readFully (byte data[], int offset, int size)    throws IOException  {    this.dataInputStream.readFully (data, offset, size);  }  public int skipBytes (int len) throws IOException  {    return this.dataInputStream.skipBytes (len);  }  /**     @deprecated     @see java.io.DataInputStream#readLine ()  */  public String readLine () throws IOException  {    return this.dataInputStream.readLine ();  }  public String readUTF () throws IOException  {    return this.dataInputStream.readUTF ();  }  /**     This class allows a class to specify exactly which fields should     be read, and what values should be read for these fields.     XXX: finish up comments  */  public static abstract class GetField  {    public abstract ObjectStreamClass getObjectStreamClass ();    public abstract boolean defaulted (String name)      throws IOException, IllegalArgumentException;    public abstract boolean get (String name, boolean defvalue)      throws IOException, IllegalArgumentException;    public abstract char get (String name, char defvalue)      throws IOException, IllegalArgumentException;    public abstract byte get (String name, byte defvalue)      throws IOException, IllegalArgumentException;    public abstract short get (String name, short defvalue)      throws IOException, IllegalArgumentException;    public abstract int get (String name, int defvalue)      throws IOException, IllegalArgumentException;    public abstract long get (String name, long defvalue)      throws IOException, IllegalArgumentException;    public abstract float get (String name, float defvalue)      throws IOException, IllegalArgumentException;    public abstract double get (String name, double defvalue)      throws IOException, IllegalArgumentException;    public abstract Object get (String name, Object defvalue)      throws IOException, IllegalArgumentException;  }  public GetField readFields ()    throws IOException, ClassNotFoundException, NotActiveException  {    if (this.currentObject == null || this.currentObjectStreamClass == null)      throw new NotActiveException ("readFields called by non-active class and/or object");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -