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

📄 iiopinputstream.java

📁 java jdk 1.4的源码
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
	    }	    catch (NoSuchMethodError e) {		throw new InvalidClassException(currentClass.getName(),						"NoSuchMethodError accessing no-arg constructor");    	    }    	    catch (IllegalAccessException e) {		throw new InvalidClassException(currentClass.getName(),						"IllegalAccessException");    	    }    	    catch (InstantiationException e) {		throw new InvalidClassException(currentClass.getName(),						"InstantiationException");    	    }    	} // end : if (currentClassDesc.isExternalizable())	else {    	    /* Count number of classes and descriptors we might have    	     * to work on.    	     */    	    ObjectStreamClass currdesc = currentClassDesc;    	    Class currclass = currentClass;    	    int spBase = spClass;	// current top of stack    	    /* The object's classes should be processed from supertype to subtype    	     * Push all the clases of the current object onto a stack.    	     * Note that only the serializable classes are represented    	     * in the descriptor list.    	     *    	     * Handle versioning where one or more supertypes of    	     * have been inserted or removed.  The stack will    	     * contain pairs of descriptors and the corresponding    	     * class.  If the object has a class that did not occur in    	     * the original the descriptor will be null.  If the    	     * original object had a descriptor for a class not    	     * present in the local hierarchy of the object the class will be    	     * null.    	     *    	     */    	    /*    	     * This is your basic diff pattern, made simpler    	     * because reordering is not allowed.    	     */            // sun.4296963 ibm.11861             // d11861 we should stop when we find the highest serializable class            // We need this so that when we allocate the new object below, we            // can call the constructor of the non-serializable superclass.            // Note that in the JRMP variant of this code the            // ObjectStreamClass.lookup() method handles this, but we've put            // this fix here rather than change lookup because the new behaviour            // is needed in other cases.    	    for (currdesc = currentClassDesc, currclass = currentClass;    		 currdesc != null && currdesc.isSerializable();   /*sun.4296963 ibm.11861*/    		 currdesc = currdesc.getSuperclass()) {    		/*    		 * Search the classes to see if the class of this    		 * descriptor appears further up the hierarchy. Until    		 * it's found assume its an inserted class.  If it's    		 * not found, its the descriptor's class that has been    		 * removed.    		 */    		Class cc = currdesc.forClass();    		Class cl;    		for (cl = currclass; cl != null; cl = cl.getSuperclass()) {    		    if (cc == cl) {    			// found a superclass that matches this descriptor    			break;    		    } else {    			/* Ignore a class that doesn't match.  No    			 * action is needed since it is already    			 * initialized.    			 */    		    }		} // end : for (cl = currclass; cl != null; cl = cl.getSuperclass())     		/* Test if there is room for this new entry.    		 * If not, double the size of the arrays and copy the contents.    		 */    		spClass++;    		if (spClass >= classes.length) {    		    int newlen = classes.length * 2;    		    Class[] newclasses = new Class[newlen];    		    ObjectStreamClass[] newclassdesc = new ObjectStreamClass[newlen];    		    System.arraycopy(classes, 0,				     newclasses, 0,				     classes.length);    		    System.arraycopy(classdesc, 0,    				     newclassdesc, 0,    				     classes.length);    		    classes = newclasses;    		    classdesc = newclassdesc;    		}    		if (cl == null) {    		    /* Class not found corresponding to this descriptor.    		     * Pop off all the extra classes pushed.    		     * Push the descriptor and a null class.    		     */    		    classdesc[spClass] = currdesc;    		    classes[spClass] = null;    		} else {		    /* Current class descriptor matches current class.    		     * Some classes may have been inserted.    		     * Record the match and advance the class, continue    		     * with the next descriptor.    		     */    		    classdesc[spClass] = currdesc;    		    classes[spClass] = cl;    		    currclass = cl.getSuperclass();    		}    	    } // end : for (currdesc = currentClassDesc, currclass = currentClass;    	    /* Allocate a new object.  The object is only constructed    	     * above the highest serializable class and is set to    	     * default values for all more specialized classes.    	     */    	    try {    		currentObject = (currentClass == null) ?		    null : allocateNewObject(currentClass, currclass);                // Store this object and its beginning position                // since there might be indirections to it while                // it's been unmarshalled.                activeRecursionMgr.addObject(offset, currentObject);    	    } catch (NoSuchMethodError e) {    		throw new InvalidClassException(currclass.getName(),    						"NoSuchMethodError accessing no-arg constructor");    	    } catch (IllegalAccessException e) {    		throw new InvalidClassException(currclass.getName(),    						"IllegalAccessException");    	    } catch (InstantiationException e) {		throw new InvalidClassException("UNKNOWN",//currclass.getName(),    						"InstantiationException");    	    }    	    /*    	     * For all the pushed descriptors and classes.    	     * 	if the class has its own writeObject and readObject methods    	     *	    call the readObject method    	     *	else    	     *	    invoke the defaultReadObject method    	     */    	    try {    		for (spClass = spClass; spClass > spBase; spClass--) {    		    /*    		     * Set current descriptor and corresponding class    		     */    		    currentClassDesc = classdesc[spClass];    		    currentClass = classes[spClass];    		    if (classes[spClass] != null) {    			/* Read the data from the stream described by the    			 * descriptor and store into the matching class.    			 */                        // Changed since invokeObjectReader no longer does this.                        if (currentClassDesc.hasWriteObject()) {			    // Read format version                            readByte();                            			    // Read defaultWriteObject indicator                            readBoolean();                        }                        if (!invokeObjectReader(currentClassDesc, currentObject, currentClass)) {				ObjectStreamField[] fields =				    currentClassDesc.getFieldsNoCopy();				if (fields.length > 0) {				    inputClassFields(currentObject, currentClass, fields, sender);				}			    }    		    } else {			// _REVISIT_ : Can we ever get here?			/* No local class for this descriptor,			 * Skip over the data for this class.			 * like defaultReadObject with a null currentObject.			 * The code will read the values but discard them.			 */			    ObjectStreamField[] fields =				currentClassDesc.getFieldsNoCopy();			    if (fields.length > 0) {				inputClassFields(null, currentClass, fields, sender);			    }									}							}    	    } finally {				// Make sure we exit at the same stack level as when we started.		spClass = spBase;    	    }    	}        } finally {            // We've completed deserializing this object.  Any            // future indirections will be handled correctly at the            // CDR level.  The ActiveRecursionManager only deals with            // objects currently being deserialized.            activeRecursionMgr.removeObject(offset);        }		    	return currentObject;    }    // This retrieves a vector of FVD's for the hierarchy of serializable classes stemming from     // repositoryID.  It is assumed that the sender will not provide base_value id's for non-serializable    // classes!    private Vector getOrderedDescriptions(String repositoryID,					  com.sun.org.omg.SendingContext.CodeBase sender) {	Vector descs = new Vector();	FullValueDescription aFVD = sender.meta(repositoryID);	while (aFVD != null) {	    descs.insertElementAt(aFVD, 0);	    if ((aFVD.base_value != null) && !kEmptyStr.equals(aFVD.base_value)) {		aFVD = sender.meta(aFVD.base_value);	    }	    else return descs;	}	return descs;    }    /**     * This input method uses FullValueDescriptions retrieved from the sender's runtime to      * read in the data.  This method is capable of throwing out data not applicable to client's fields.     * This method handles instances where the reader has a class not sent by the sender, the sender sent     * a class not present on the reader, and/or the reader's class does not match the sender's class.     *     * NOTE : If the local description indicates custom marshaling and the remote type's FVD also     * indicates custom marsahling than the local type is used to read the data off the wire.  However,     * if either says custom while the other does not, a MARSHAL error is thrown.  Externalizable is      * a form of custom marshaling.     *     */    private Object inputObjectUsingFVD(Class clz,				       String repositoryID,				       com.sun.org.omg.SendingContext.CodeBase sender,                                       int offset)	throws IOException, ClassNotFoundException    {			int spBase = spClass;	// current top of stack	try{				    /*	     * Get the descriptor and then class of the incoming object.	     */				    ObjectStreamClass currdesc = currentClassDesc = ObjectStreamClass.lookup(clz);	    Class currclass = currentClass = clz;				    /* If Externalizable,	     *  Create an instance and tell it to read its data.	     * else,	     *  Handle it as a serializable class.	     */	    if (currentClassDesc.isExternalizable()) {						try {		    currentObject = (currentClass == null) ?			null : allocateNewObject(currentClass, currentClass);		    if (currentObject != null) {                        // Store this object and its beginning position                        // since there might be indirections to it while                        // it's been unmarshalled.                        activeRecursionMgr.addObject(offset, currentObject);			// Read format version			readByte();									Externalizable ext = (Externalizable)currentObject;			ext.readExternal(this);		    }		}		catch (NoSuchMethodError e) {		    throw new InvalidClassException(currentClass.getName(),						    "NoSuchMethodError accessing no-arg constructor");		}		catch (IllegalAccessException e) {		    throw new InvalidClassException(currentClass.getName(),						    "IllegalAccessException");		}		catch (InstantiationException e) {		    throw new InvalidClassException(currentClass.getName(),						    "InstantiationException");		}	    } // end : if (currentClassDesc.isExternalizable())			else {								/*				 * This is your basic diff pattern, made simpler				 * because reordering is not allowed.				 */		for (currdesc = currentClassDesc, currclass = currentClass;		     currdesc != null && currdesc.isSerializable();   /*sun.4296963 ibm.11861*/		     currdesc = currdesc.getSuperclass()) {							    /*		     * Search the classes to see if the class of this		     * descriptor appears further up the hierarchy. Until		     * it's found assume its an inserted class.  If it's		     * not found, its the descriptor's class that has been		     * removed.		     */		    Class cc = currdesc.forClass();		    Class cl;		    for (cl = currclass; cl != null; cl = cl.getSuperclass()) {			if (cc == cl) {			    // found a superclass that matches this descriptor			    break;			} else {			    /* Ignore a class that doesn't match.  No			     * action is needed since it is already			     * initialized.			     */			}		    } // end : for (cl = currclass; cl != null; cl = cl.getSuperclass()) 		    /* Test if there is room for this new entry.		     * If not, double the size of the arrays and copy the contents.		     */		    spClass++;		    if (spClass >= classes.length) {			int newlen = classes.length * 2;			Class[] newclasses = new Class[newlen];			ObjectStreamClass[] newclassdesc = new ObjectStreamClass[newlen];							System.arraycopy(classes, 0,					 newclasses, 0,					 classes.length);			System.arraycopy(classdesc, 0,					 newclassdesc, 0,					 classes.length);									classes = newclasses;			classdesc = newclassdesc;    		    }		    if (cl == null) {			/* Class not found corresponding to this descriptor.			 * Pop off all the extra classes pushed.			 * Push the descriptor and a null class.			 */			classdesc[spClass] = currdesc;			classes[spClass] = null;		    } else {			/* Current class descriptor matches current class.			 * Some classes may have been inserted.			 * Record the match and advance the class, continue			 * with the next descriptor.			 */			classdesc[spClass] = currdesc;			classes[spClass] = cl;			currclass = cl.getSuperclass();    		}		} // end : for (currdesc = currentClassDesc, currclass = currentClass;								/* Allocate a new object.  				 */		try {		    currentObject = (currentClass == null) ?			null : allocateNewObject(currentClass, currclass);

⌨️ 快捷键说明

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