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

📄 iiopinputstream.java

📁 java jdk 1.4的源码
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/* * @(#)IIOPInputStream.java	1.48 03/01/23 * * Copyright 2003 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. *//* * Licensed Materials - Property of IBM * RMI-IIOP v1.0 * Copyright IBM Corp. 1998 1999  All Rights Reserved * * US Government Users Restricted Rights - Use, duplication or * disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */package com.sun.corba.se.internal.io;import java.io.InputStream;import java.io.IOException;import java.io.StreamCorruptedException;import java.io.ObjectInputValidation;import java.io.NotActiveException;import java.io.InvalidObjectException;import java.io.InvalidClassException;import java.io.DataInputStream;import java.io.OptionalDataException;import java.io.WriteAbortedException;import java.io.Externalizable;import java.io.EOFException;import java.lang.reflect.InvocationTargetException;import java.util.Vector;import java.util.Stack;import java.util.Hashtable;import java.util.Enumeration;import com.sun.corba.se.internal.io.ObjectStreamClass;import com.sun.corba.se.internal.util.Utility;import com.sun.corba.se.internal.util.MinorCodes;import com.sun.corba.se.internal.util.Utility;import org.omg.CORBA.ValueMember;import org.omg.CORBA.TCKind;import org.omg.CORBA.ORB; //d11638import org.omg.CORBA.CompletionStatus;import org.omg.CORBA.portable.IndirectionException;import org.omg.CORBA.MARSHAL;import org.omg.CORBA.TypeCode;import com.sun.org.omg.CORBA.ValueDefPackage.FullValueDescription;import com.sun.org.omg.SendingContext.CodeBase;  // d11638import javax.rmi.PortableRemoteObject;import javax.rmi.CORBA.Util;import javax.rmi.CORBA.ValueHandler;import java.util.*;/** * IIOPInputStream is used by the ValueHandlerImpl to handle Java serialization * input semantics. * * @author  Stephen Lewallen * @since   JDK1.1.6 */public class IIOPInputStream    extends com.sun.corba.se.internal.io.InputStreamHook{    // Necessary to pass the appropriate fields into the    // defaultReadObjectDelegate method (which takes no    // parameters since it's called from     // java.io.ObjectInpuStream defaultReadObject()    // which we can't change).    //    // This is only used in the case where the fields had     // to be obtained remotely because of a serializable    // version difference.  Set in inputObjectUsingFVD.    // Part of serialization evolution fixes for Ladybird,    // bug 4365188.    private ValueMember defaultReadObjectFVDMembers[] = null;    private org.omg.CORBA_2_3.portable.InputStream orbStream;    private CodeBase cbSender;  //d11638    private ValueHandlerImpl vhandler;  //d4365188    private Object currentObject = null;    private ObjectStreamClass currentClassDesc = null;    private Class currentClass = null;    private int recursionDepth = 0;    private int simpleReadDepth = 0;    // The ActiveRecursionManager replaces the old RecursionManager which    // used to record how many recursions were made, and resolve them after    // an object was completely deserialized.    //    // That created problems (as in bug 4414154) because when custom    // unmarshaling in readObject, there can be recursive references    // to one of the objects currently being unmarshaled, and the    // passive recursion system failed.    ActiveRecursionManager activeRecursionMgr = new ActiveRecursionManager();    private IOException abortIOException = null;    /* Remember the first exception that stopped this stream. */    private ClassNotFoundException abortClassNotFoundException = null;    /* Vector of validation callback objects     * The vector is created as needed. The vector is maintained in     * order of highest (first) priority to lowest     */    private Vector callbacks;    // Serialization machinery fields    /* Arrays used to keep track of classes and ObjectStreamClasses     * as they are being merged; used in inputObject.     * spClass is the stack pointer for both.  */    ObjectStreamClass[] classdesc;    Class[] classes;    int spClass;    private static final String kEmptyStr = "";    // TCKind TypeCodes used in FVD inputClassFields    //public static final TypeCode kRemoteTypeCode = new TypeCodeImpl(TCKind._tk_objref);    //public static final TypeCode kValueTypeCode =  new TypeCodeImpl(TCKind._tk_value);    //d11638 removed TypeCodeImpl dependency    public static final TypeCode kRemoteTypeCode = ORB.init().get_primitive_tc(TCKind.tk_objref);    public static final TypeCode kValueTypeCode =  ORB.init().get_primitive_tc(TCKind.tk_value);    // TESTING CODE - useFVDOnly should be made final before FCS in order to    // optimize out the check.    private static final boolean useFVDOnly = false;	    public static void setTestFVDFlag(boolean val){	//  useFVDOnly = val;    }    /**     * Dummy constructor; passes upper stream a dummy stream;     **/    public IIOPInputStream()    	throws java.io.IOException {    	super();	resetStream();    }	    public final void setOrbStream(org.omg.CORBA_2_3.portable.InputStream os) {    	orbStream = os;    }    public final org.omg.CORBA_2_3.portable.InputStream getOrbStream() {    	return orbStream;    }    //d11638 added setSender and getSender    public final void setSender(CodeBase cb) {        cbSender = cb;    }    public final CodeBase getSender() {        return cbSender;    }    // 4365188 this is added to enable backward compatability w/ wrong    // rep-ids    public final void setValueHandler(ValueHandler vh) {        vhandler = (com.sun.corba.se.internal.io.ValueHandlerImpl) vh;    }    public final ValueHandler getValueHandler() {	return (javax.rmi.CORBA.ValueHandler) vhandler;    }	    public final void increaseRecursionDepth(){	recursionDepth++;    }    public final int decreaseRecursionDepth(){	return --recursionDepth;    }    /**     * Override the actions of the final method "readObject()"     * in ObjectInputStream.     * @since     JDK1.1.6     *     * Read an object from the ObjectInputStream.     * The class of the object, the signature of the class, and the values     * of the non-transient and non-static fields of the class and all     * of its supertypes are read.  Default deserializing for a class can be     * overriden using the writeObject and readObject methods.     * Objects referenced by this object are read transitively so     * that a complete equivalent graph of objects is reconstructed by readObject. <p>     *     * The root object is completly restored when all of its fields     * and the objects it references are completely restored.  At this     * point the object validation callbacks are executed in order     * based on their registered priorities. The callbacks are     * registered by objects (in the readObject special methods)     * as they are individually restored.     *     * Exceptions are thrown for problems with the InputStream and for classes     * that should not be deserialized.  All exceptions are fatal to the     * InputStream and leave it in an indeterminate state; it is up to the caller     * to ignore or recover the stream state.     * @exception java.lang.ClassNotFoundException Class of a serialized object     *      cannot be found.     * @exception InvalidClassException Something is wrong with a class used by     *     serialization.     * @exception StreamCorruptedException Control information in the     *     stream is inconsistent.     * @exception OptionalDataException Primitive data was found in the     * stream instead of objects.     * @exception IOException Any of the usual Input/Output related exceptions.     * @since     JDK1.1     */    public final Object readObjectDelegate() throws IOException    {	try	    {		return orbStream.read_abstract_interface();	    }	catch(IndirectionException cdrie)	    {                // The CDR stream had never seen the given offset before,                // so check the recursion manager (it will throw an                // IOException if it doesn't have a reference, either).                return activeRecursionMgr.getObject(cdrie.offset);	    }    }    final Object simpleReadObject(Class clz,                                  String repositoryID,                                  com.sun.org.omg.SendingContext.CodeBase sender,                                  int offset)					 /* throws OptionalDataException, ClassNotFoundException, IOException */    {    	/* Save the current state and get ready to read an object. */    	Object prevObject = currentObject;    	ObjectStreamClass prevClass = currentClassDesc;    	simpleReadDepth++;	// Entering    	Object obj = null;    	/*    	 * Check for reset, handle it before reading an object.    	 */    	try {	    // d4365188: backward compatability	    if (vhandler.useFullValueDescription(clz, repositoryID)) {		obj = inputObjectUsingFVD(clz, repositoryID, sender, offset);	    } else {                obj = inputObject(clz, repositoryID, sender, offset);	    }	    obj = currentClassDesc.readResolve(obj);    	}    	catch(ClassNotFoundException cnfe)	    {		throwExceptionType(ClassNotFoundException.class, cnfe.getMessage());		return null;	    }    	catch(IOException ioe)	    {		// System.out.println("CLZ = " + clz + "; " + ioe.toString());		throwExceptionType(IOException.class, ioe.getMessage());		return null;	    }    	finally {    	    simpleReadDepth --;    	    currentObject = prevObject;    	    currentClassDesc = prevClass;    	}    	/* Check for thrown exceptions and re-throw them, clearing them if    	 * this is the last recursive call .    	 */    	IOException exIOE = abortIOException;    	if (simpleReadDepth == 0)    	    abortIOException = null;    	if (exIOE != null){            throwExceptionType(IOException.class, exIOE.getMessage());            return null;    	}    	ClassNotFoundException exCNF = abortClassNotFoundException;    	if (simpleReadDepth == 0)    	    abortClassNotFoundException = null;    	if (exCNF != null) {            throwExceptionType(ClassNotFoundException.class, exCNF.getMessage());            return null;    	}    	return obj;    }    public final void simpleSkipObject(String repositoryID,				       com.sun.org.omg.SendingContext.CodeBase sender)				       /* throws OptionalDataException, ClassNotFoundException, IOException */    {				    	/* Save the current state and get ready to read an object. */    	Object prevObject = currentObject;    	ObjectStreamClass prevClass = currentClassDesc;    	simpleReadDepth++;	// Entering    	Object obj = null;    	/*    	 * Check for reset, handle it before reading an object.    	 */    	try {	    skipObjectUsingFVD(repositoryID, sender);    	}    	catch(ClassNotFoundException cnfe)	    {		throwExceptionType(ClassNotFoundException.class, cnfe.getMessage());		return;	    }    	catch(IOException ioe)	    {		throwExceptionType(IOException.class, ioe.getMessage());		return;	    }    	finally {    	    simpleReadDepth --;    	    currentObject = prevObject;    	    currentClassDesc = prevClass;    	}    	/* Check for thrown exceptions and re-throw them, clearing them if    	 * this is the last recursive call .    	 */    	IOException exIOE = abortIOException;    	if (simpleReadDepth == 0)    	    abortIOException = null;    	if (exIOE != null){            throwExceptionType(IOException.class, exIOE.getMessage());            return;    	}    	ClassNotFoundException exCNF = abortClassNotFoundException;    	if (simpleReadDepth == 0)    	    abortClassNotFoundException = null;    	if (exCNF != null) {            throwExceptionType(ClassNotFoundException.class, exCNF.getMessage());            return;    	}	return;    }    /////////////////    /**     * This method is called by trusted subclasses of ObjectOutputStream     * that constructed ObjectOutputStream using the     * protected no-arg constructor. The subclass is expected to provide

⌨️ 快捷键说明

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