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

📄 iiopinputstream.java

📁 java jdk 1.4的源码
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
                    // 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(currclass.getName(),						    "InstantiationException");		}						Enumeration fvdsList = getOrderedDescriptions(repositoryID, sender).elements();						while((fvdsList.hasMoreElements()) && (spClass > spBase)) {		    FullValueDescription fvd = (FullValueDescription)fvdsList.nextElement();	            // d4365188: backward compatability		    String repIDForFVD = vhandler.getClassName(fvd.id);		    String repIDForClass = vhandler.getClassName(vhandler.getRMIRepositoryID(currentClass));							    while ((spClass > spBase) &&			   (!repIDForFVD.equals(repIDForClass))) {			int pos = findNextClass(repIDForFVD, classes, spClass, spBase);			if (pos != -1){			    spClass = pos;			    currclass = currentClass = classes[spClass];			    repIDForClass = vhandler.getClassName(vhandler.getRMIRepositoryID(currentClass));			}			else { // Read and throw away one level of the fvdslist			    if (fvd.is_custom) {                                // Is this actually an error?  REVISIT				throw new IOException("Remote superclass is custom marshalled: "                                                      + fvd.id);			    } else {				inputClassFields(null, currentClass, null, fvd.members, sender);			    }			    if (fvdsList.hasMoreElements()){				fvd = (FullValueDescription)fvdsList.nextElement();				repIDForFVD = vhandler.getClassName(fvd.id);			    }			    else return currentObject;			}								    }							    currdesc = currentClassDesc = ObjectStreamClass.lookup(currentClass);							    if (!repIDForClass.equals("java.lang.Object")) {                        // If the sender used custom marshaling, then it should have put                        // these two bytes on the wire.  Currently, we don't do anything                        // with these, but that has to change at some point.                        if (fvd.is_custom) {			    // Read format version			    readByte();                            			    // Read defaultWriteObject indicator			    readBoolean();                        }                        // Always use readObject if it exists, and fall back to default                        // unmarshaling if it doesn't.                        boolean usedReadObject = false;                        try {                            // See the definition of defaultReadObjectFVDMembers                            // for more information.  This concerns making sure                            // we use the remote FVD's members in defaultReadObject.                            defaultReadObjectFVDMembers = fvd.members;                            usedReadObject = invokeObjectReader(currentClassDesc,                                                                currentObject,                                                                currentClass);                        } finally {                            defaultReadObjectFVDMembers = null;                        }                        if (!usedReadObject)                            inputClassFields(currentObject, currentClass, currdesc, fvd.members, sender);                                                   currclass = currentClass = classes[--spClass];		    } else { 			// The remaining hierarchy of the local class does not match the sender's FVD.			// So, use remaining FVDs to read data off wire.  If any remaining FVDs indicate			// custom marshaling, throw MARSHAL error.			inputClassFields(null, currentClass, null, fvd.members, sender);									while (fvdsList.hasMoreElements()){			    fvd = (FullValueDescription)fvdsList.nextElement();			    if (fvd.is_custom)				throw new IOException("Sender's custom marshaling class does not match local class: " + fvd.id);			    else inputClassFields(null, currentClass, null, fvd.members, sender);			}								    }							} // end : while(fvdsList.hasMoreElements()) 		while (fvdsList.hasMoreElements()){		    FullValueDescription fvd = (FullValueDescription)fvdsList.nextElement();		    if (fvd.is_custom)			throw new IOException("Sender's custom marshaling class does not match local class: " + fvd.id);		    else throwAwayData(fvd.members, sender);					}	    }				    return currentObject;	}	finally {    		// Make sure we exit at the same stack level as when we started.    		spClass = spBase;                // 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);    	    }		    	}    /**     * 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.     *     * 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 skipObjectUsingFVD(String repositoryID,				      com.sun.org.omg.SendingContext.CodeBase sender)	throws IOException, ClassNotFoundException    {	Enumeration fvdsList = getOrderedDescriptions(repositoryID, sender).elements();			while(fvdsList.hasMoreElements()) {	    FullValueDescription fvd = (FullValueDescription)fvdsList.nextElement();	    String repIDForFVD = vhandler.getClassName(fvd.id);				    if (!repIDForFVD.equals("java.lang.Object")) {		if (fvd.is_custom) {		    throw new IOException("Can't skip sender's custom marshaled class: "                                          + fvd.id);    }		else { 		    // Use default marshaling		    inputClassFields(null, null, null, fvd.members, sender);		}	    }	} // end : while(fvdsList.hasMoreElements()) 	return null;		    }    ///////////////////    private int findNextClass(String classname, Class classes[], int _spClass, int _spBase){	for (int i = _spClass; i > _spBase; i--){	    if (classname.equals(classes[i].getName())) {		return i;	    }	}	return -1;    }    /*     * Invoke the readObject method if present.  Assumes that in the case of custom     * marshaling, the format version and defaultWriteObject indicator were already     * removed.     */    private boolean invokeObjectReader(ObjectStreamClass osc, Object obj, Class aclass)	throws InvalidClassException, StreamCorruptedException,	       ClassNotFoundException, IOException    {	if (osc.readObjectMethod == null) {	    return false;	}			try {	    readObject(obj, aclass, this);	    return true;	} catch (InvocationTargetException e) {	    Throwable t = e.getTargetException();	    if (t instanceof ClassNotFoundException)		throw (ClassNotFoundException)t;	    else if (t instanceof IOException)		throw (IOException)t;	    else if (t instanceof RuntimeException)		throw (RuntimeException) t;	    else if (t instanceof Error)		throw (Error) t;	    else		throw new Error("interal error");	} catch (IllegalAccessException e) {	    return false;	}    }    /*     * Reset the stream to be just like it was after the constructor.     */    private void resetStream() throws IOException {	if (classes == null)	    classes = new Class[20];	else {	    for (int i = 0; i < classes.length; i++)		classes[i] = null;	}	if (classdesc == null)	    classdesc = new ObjectStreamClass[20];	else {	    for (int i = 0; i < classdesc.length; i++)		classdesc[i] = null;	}	spClass = 0;	if (callbacks != null)	    callbacks.setSize(0);	// discard any pending callbacks    }    /**     * Factored out of inputClassFields  This reads a primitive value and sets it      * (with a native call) in the field of o described by the ObjectStreamField     * field.     */    private void inputPrimitiveField(Object o, Class cl, ObjectStreamField field)        throws InvalidClassException, IOException {        try {                        switch (field.getTypeCode()) {                case 'B':                    byte byteValue = orbStream.read_octet();                    setByteFieldOpt(o, field.getFieldID(cl), byteValue);                    break;                case 'Z':                   boolean booleanValue = orbStream.read_boolean();                   setBooleanFieldOpt(o, field.getFieldID(cl), booleanValue);                   break;		case 'C':                    char charValue = orbStream.read_wchar();                    setCharFieldOpt(o, field.getFieldID(cl), charValue);                    break;		case 'S':                    short shortValue = orbStream.read_short();                    setShortFieldOpt(o, field.getFieldID(cl), shortValue);                    break;		case 'I':                    int intValue = orbStream.read_long();                    setIntFieldOpt(o, field.getFieldID(cl), intValue);                    break;		case 'J':                    long longValue = orbStream.read_longlong();                    setLongFieldOpt(o, field.getFieldID(cl), longValue);                    break;		case 'F' :                    float floatValue = orbStream.read_float();                    setFloatFieldOpt(o, field.getFieldID(cl), floatValue);                    break;		case 'D' :                    double doubleValue = orbStream.read_double();                    setDoubleFieldOpt(o, field.getFieldID(cl), doubleValue);                    break;		default:                    throw new InvalidClassException(cl.getName());            }        } catch (IllegalArgumentException e) {            /* This case should never happen. If the field types               are not the same, InvalidClassException is raised when               matching the local class to the serialized ObjectStreamClass. */            throw new ClassCastException("Assigning instance of class " +                                         field.getType().getName() +                                         " to field " +                                         currentClassDesc.getName() + '#' +                                         field.getField().getName());        }    }    private Object inputObjectField(org.omg.CORBA.ValueMember field,                                    com.sun.org.omg.SendingContext.CodeBase sender)        throws IndirectionException, ClassNotFoundException, IOException,               StreamCorruptedException {        Object objectValue = null;        Class type = null;        String id = field.id;							        try {            type = vhandler.getClassFromType(id);        } catch(ClassNotFoundException cnfe) {            // Make sure type = null            type = null;        }        String signature = null;        if (type != null)            signature = ValueUtility.getSignature(field);								        if (signature != null && (signature.equals("Ljava/lang/Object;") ||                                  signature.equals("Ljava/io/Serializable;") ||                                  signature.equals("Ljava/io/Externalizable;"))) {            objectValue = javax.rmi.CORBA.Util.readAny(orbStream);        } else {            // Decide what method call to make based on the type. If            // it is a type for which we need to load a stub, convert            // the type to the correct stub type.            //            // NOTE : Since FullValueDescription does not allow us            // to ask whether something is an interface we do not            // have the ability to optimize this check.                        int callType = ValueHandlerImpl.kValueType;                        if (!vhandler.isSequence(id)) {                if (field.type.kind().value() == kRemoteTypeCode.kind().value()) {                    // RMI Object reference...                    callType = ValueHandlerImpl.kRemoteType;                                    } else {                    // REVISIT.  If we don't have the local class,                    // we should probably verify that it's an RMI type,                     // query the remote FVD, and use is_abstract.                    // Our FVD seems to get NullPointerExceptions for any                    // non-RMI types.                    // This uses the local class in the same way as                    // inputObjectField(ObjectStreamField) does.  REVISIT                    // inputObjectField(ObjectStreamField)'s loadStubClass                    // logic.  Assumption is that the given type cannot                    // evolve to become a CORBA abstract interface or                    // a RMI abstract interface.                    if (type != null && type.isInterface() &&                        (vhandler.isAbstractBase(type) ||                         ObjectStreamClassCorbaExt.isAbstractInterface(type))) {                                        callType = ValueHandlerImpl.kAbstractType;                    }                }            }                            // Now that we have used the FVD of the field to determine the proper course            // of action, it is ok to use the type (Class) from this point forward since             // the rep. id for this read will also follow on the wire.            switch (callType) {                case ValueHandlerImpl.kRemoteType:                     if (type != null)                        objectValue = Utility.readObjectAndNarrow(orbStream, type);                    else                        objectValue = orbStream.read_Object();                    break;                case ValueHandlerImpl.kAbstractType: 

⌨️ 快捷键说明

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