Java Code Examples for com.sun.corba.se.impl.util.Utility#readAbstractAndNarrow()
The following examples show how to use
com.sun.corba.se.impl.util.Utility#readAbstractAndNarrow() .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: jdk1.8-source-analysis File: IIOPInputStream.java License: Apache License 2.0 | 4 votes |
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: if (type != null) objectValue = Utility.readAbstractAndNarrow(orbStream, type); else objectValue = orbStream.read_abstract_interface(); break; case ValueHandlerImpl.kValueType: if (type != null) objectValue = orbStream.read_value(type); else objectValue = orbStream.read_value(); break; default: // XXX I18N, logging needed. throw new StreamCorruptedException("Unknown callType: " + callType); } } return objectValue; }
Example 2
Source Project: jdk1.8-source-analysis File: IIOPInputStream.java License: Apache License 2.0 | 4 votes |
/** * Factored out of inputClassFields and reused in * inputCurrentClassFieldsForReadFields. * * Reads the field (which of an Object type as opposed to a primitive) * described by ObjectStreamField field and returns it. */ private Object inputObjectField(ObjectStreamField field) throws InvalidClassException, StreamCorruptedException, ClassNotFoundException, IndirectionException, IOException { if (ObjectStreamClassCorbaExt.isAny(field.getTypeString())) { return javax.rmi.CORBA.Util.readAny(orbStream); } Object objectValue = null; // fields have an API to provide the actual class // corresponding to the data type // Class type = osc.forClass(); Class fieldType = field.getType(); Class actualType = fieldType; // This may change if stub loaded. // Decide what method call to make based on the fieldType. If // it is a type for which we need to load a stub, convert // the type to the correct stub type. int callType = ValueHandlerImpl.kValueType; boolean narrow = false; if (fieldType.isInterface()) { boolean loadStubClass = false; if (java.rmi.Remote.class.isAssignableFrom(fieldType)) { // RMI Object reference... callType = ValueHandlerImpl.kRemoteType; } else if (org.omg.CORBA.Object.class.isAssignableFrom(fieldType)){ // IDL Object reference... callType = ValueHandlerImpl.kRemoteType; loadStubClass = true; } else if (vhandler.isAbstractBase(fieldType)) { // IDL Abstract Object reference... callType = ValueHandlerImpl.kAbstractType; loadStubClass = true; } else if (ObjectStreamClassCorbaExt.isAbstractInterface(fieldType)) { // RMI Abstract Object reference... callType = ValueHandlerImpl.kAbstractType; } if (loadStubClass) { try { String codebase = Util.getCodebase(fieldType); String repID = vhandler.createForAnyType(fieldType); Class stubType = Utility.loadStubClass(repID, codebase, fieldType); actualType = stubType; } catch (ClassNotFoundException e) { narrow = true; } } else { narrow = true; } } switch (callType) { case ValueHandlerImpl.kRemoteType: if (!narrow) objectValue = (Object)orbStream.read_Object(actualType); else objectValue = Utility.readObjectAndNarrow(orbStream, actualType); break; case ValueHandlerImpl.kAbstractType: if (!narrow) objectValue = (Object)orbStream.read_abstract_interface(actualType); else objectValue = Utility.readAbstractAndNarrow(orbStream, actualType); break; case ValueHandlerImpl.kValueType: objectValue = (Object)orbStream.read_value(actualType); break; default: // XXX I18N, logging needed. throw new StreamCorruptedException("Unknown callType: " + callType); } return objectValue; }
Example 3
Source Project: TencentKona-8 File: IIOPInputStream.java License: GNU General Public License v2.0 | 4 votes |
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: if (type != null) objectValue = Utility.readAbstractAndNarrow(orbStream, type); else objectValue = orbStream.read_abstract_interface(); break; case ValueHandlerImpl.kValueType: if (type != null) objectValue = orbStream.read_value(type); else objectValue = orbStream.read_value(); break; default: // XXX I18N, logging needed. throw new StreamCorruptedException("Unknown callType: " + callType); } } return objectValue; }
Example 4
Source Project: TencentKona-8 File: IIOPInputStream.java License: GNU General Public License v2.0 | 4 votes |
/** * Factored out of inputClassFields and reused in * inputCurrentClassFieldsForReadFields. * * Reads the field (which of an Object type as opposed to a primitive) * described by ObjectStreamField field and returns it. */ private Object inputObjectField(ObjectStreamField field) throws InvalidClassException, StreamCorruptedException, ClassNotFoundException, IndirectionException, IOException { if (ObjectStreamClassCorbaExt.isAny(field.getTypeString())) { return javax.rmi.CORBA.Util.readAny(orbStream); } Object objectValue = null; // fields have an API to provide the actual class // corresponding to the data type // Class type = osc.forClass(); Class fieldType = field.getType(); Class actualType = fieldType; // This may change if stub loaded. // Decide what method call to make based on the fieldType. If // it is a type for which we need to load a stub, convert // the type to the correct stub type. int callType = ValueHandlerImpl.kValueType; boolean narrow = false; if (fieldType.isInterface()) { boolean loadStubClass = false; if (java.rmi.Remote.class.isAssignableFrom(fieldType)) { // RMI Object reference... callType = ValueHandlerImpl.kRemoteType; } else if (org.omg.CORBA.Object.class.isAssignableFrom(fieldType)){ // IDL Object reference... callType = ValueHandlerImpl.kRemoteType; loadStubClass = true; } else if (vhandler.isAbstractBase(fieldType)) { // IDL Abstract Object reference... callType = ValueHandlerImpl.kAbstractType; loadStubClass = true; } else if (ObjectStreamClassCorbaExt.isAbstractInterface(fieldType)) { // RMI Abstract Object reference... callType = ValueHandlerImpl.kAbstractType; } if (loadStubClass) { try { String codebase = Util.getCodebase(fieldType); String repID = vhandler.createForAnyType(fieldType); Class stubType = Utility.loadStubClass(repID, codebase, fieldType); actualType = stubType; } catch (ClassNotFoundException e) { narrow = true; } } else { narrow = true; } } switch (callType) { case ValueHandlerImpl.kRemoteType: if (!narrow) objectValue = (Object)orbStream.read_Object(actualType); else objectValue = Utility.readObjectAndNarrow(orbStream, actualType); break; case ValueHandlerImpl.kAbstractType: if (!narrow) objectValue = (Object)orbStream.read_abstract_interface(actualType); else objectValue = Utility.readAbstractAndNarrow(orbStream, actualType); break; case ValueHandlerImpl.kValueType: objectValue = (Object)orbStream.read_value(actualType); break; default: // XXX I18N, logging needed. throw new StreamCorruptedException("Unknown callType: " + callType); } return objectValue; }
Example 5
Source Project: jdk8u60 File: IIOPInputStream.java License: GNU General Public License v2.0 | 4 votes |
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: if (type != null) objectValue = Utility.readAbstractAndNarrow(orbStream, type); else objectValue = orbStream.read_abstract_interface(); break; case ValueHandlerImpl.kValueType: if (type != null) objectValue = orbStream.read_value(type); else objectValue = orbStream.read_value(); break; default: // XXX I18N, logging needed. throw new StreamCorruptedException("Unknown callType: " + callType); } } return objectValue; }
Example 6
Source Project: jdk8u60 File: IIOPInputStream.java License: GNU General Public License v2.0 | 4 votes |
/** * Factored out of inputClassFields and reused in * inputCurrentClassFieldsForReadFields. * * Reads the field (which of an Object type as opposed to a primitive) * described by ObjectStreamField field and returns it. */ private Object inputObjectField(ObjectStreamField field) throws InvalidClassException, StreamCorruptedException, ClassNotFoundException, IndirectionException, IOException { if (ObjectStreamClassCorbaExt.isAny(field.getTypeString())) { return javax.rmi.CORBA.Util.readAny(orbStream); } Object objectValue = null; // fields have an API to provide the actual class // corresponding to the data type // Class type = osc.forClass(); Class fieldType = field.getType(); Class actualType = fieldType; // This may change if stub loaded. // Decide what method call to make based on the fieldType. If // it is a type for which we need to load a stub, convert // the type to the correct stub type. int callType = ValueHandlerImpl.kValueType; boolean narrow = false; if (fieldType.isInterface()) { boolean loadStubClass = false; if (java.rmi.Remote.class.isAssignableFrom(fieldType)) { // RMI Object reference... callType = ValueHandlerImpl.kRemoteType; } else if (org.omg.CORBA.Object.class.isAssignableFrom(fieldType)){ // IDL Object reference... callType = ValueHandlerImpl.kRemoteType; loadStubClass = true; } else if (vhandler.isAbstractBase(fieldType)) { // IDL Abstract Object reference... callType = ValueHandlerImpl.kAbstractType; loadStubClass = true; } else if (ObjectStreamClassCorbaExt.isAbstractInterface(fieldType)) { // RMI Abstract Object reference... callType = ValueHandlerImpl.kAbstractType; } if (loadStubClass) { try { String codebase = Util.getCodebase(fieldType); String repID = vhandler.createForAnyType(fieldType); Class stubType = Utility.loadStubClass(repID, codebase, fieldType); actualType = stubType; } catch (ClassNotFoundException e) { narrow = true; } } else { narrow = true; } } switch (callType) { case ValueHandlerImpl.kRemoteType: if (!narrow) objectValue = (Object)orbStream.read_Object(actualType); else objectValue = Utility.readObjectAndNarrow(orbStream, actualType); break; case ValueHandlerImpl.kAbstractType: if (!narrow) objectValue = (Object)orbStream.read_abstract_interface(actualType); else objectValue = Utility.readAbstractAndNarrow(orbStream, actualType); break; case ValueHandlerImpl.kValueType: objectValue = (Object)orbStream.read_value(actualType); break; default: // XXX I18N, logging needed. throw new StreamCorruptedException("Unknown callType: " + callType); } return objectValue; }
Example 7
Source Project: JDKSourceCode1.8 File: IIOPInputStream.java License: MIT License | 4 votes |
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: if (type != null) objectValue = Utility.readAbstractAndNarrow(orbStream, type); else objectValue = orbStream.read_abstract_interface(); break; case ValueHandlerImpl.kValueType: if (type != null) objectValue = orbStream.read_value(type); else objectValue = orbStream.read_value(); break; default: // XXX I18N, logging needed. throw new StreamCorruptedException("Unknown callType: " + callType); } } return objectValue; }
Example 8
Source Project: JDKSourceCode1.8 File: IIOPInputStream.java License: MIT License | 4 votes |
/** * Factored out of inputClassFields and reused in * inputCurrentClassFieldsForReadFields. * * Reads the field (which of an Object type as opposed to a primitive) * described by ObjectStreamField field and returns it. */ private Object inputObjectField(ObjectStreamField field) throws InvalidClassException, StreamCorruptedException, ClassNotFoundException, IndirectionException, IOException { if (ObjectStreamClassCorbaExt.isAny(field.getTypeString())) { return javax.rmi.CORBA.Util.readAny(orbStream); } Object objectValue = null; // fields have an API to provide the actual class // corresponding to the data type // Class type = osc.forClass(); Class fieldType = field.getType(); Class actualType = fieldType; // This may change if stub loaded. // Decide what method call to make based on the fieldType. If // it is a type for which we need to load a stub, convert // the type to the correct stub type. int callType = ValueHandlerImpl.kValueType; boolean narrow = false; if (fieldType.isInterface()) { boolean loadStubClass = false; if (java.rmi.Remote.class.isAssignableFrom(fieldType)) { // RMI Object reference... callType = ValueHandlerImpl.kRemoteType; } else if (org.omg.CORBA.Object.class.isAssignableFrom(fieldType)){ // IDL Object reference... callType = ValueHandlerImpl.kRemoteType; loadStubClass = true; } else if (vhandler.isAbstractBase(fieldType)) { // IDL Abstract Object reference... callType = ValueHandlerImpl.kAbstractType; loadStubClass = true; } else if (ObjectStreamClassCorbaExt.isAbstractInterface(fieldType)) { // RMI Abstract Object reference... callType = ValueHandlerImpl.kAbstractType; } if (loadStubClass) { try { String codebase = Util.getCodebase(fieldType); String repID = vhandler.createForAnyType(fieldType); Class stubType = Utility.loadStubClass(repID, codebase, fieldType); actualType = stubType; } catch (ClassNotFoundException e) { narrow = true; } } else { narrow = true; } } switch (callType) { case ValueHandlerImpl.kRemoteType: if (!narrow) objectValue = (Object)orbStream.read_Object(actualType); else objectValue = Utility.readObjectAndNarrow(orbStream, actualType); break; case ValueHandlerImpl.kAbstractType: if (!narrow) objectValue = (Object)orbStream.read_abstract_interface(actualType); else objectValue = Utility.readAbstractAndNarrow(orbStream, actualType); break; case ValueHandlerImpl.kValueType: objectValue = (Object)orbStream.read_value(actualType); break; default: // XXX I18N, logging needed. throw new StreamCorruptedException("Unknown callType: " + callType); } return objectValue; }
Example 9
Source Project: openjdk-jdk8u File: IIOPInputStream.java License: GNU General Public License v2.0 | 4 votes |
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: if (type != null) objectValue = Utility.readAbstractAndNarrow(orbStream, type); else objectValue = orbStream.read_abstract_interface(); break; case ValueHandlerImpl.kValueType: if (type != null) objectValue = orbStream.read_value(type); else objectValue = orbStream.read_value(); break; default: // XXX I18N, logging needed. throw new StreamCorruptedException("Unknown callType: " + callType); } } return objectValue; }
Example 10
Source Project: openjdk-jdk8u File: IIOPInputStream.java License: GNU General Public License v2.0 | 4 votes |
/** * Factored out of inputClassFields and reused in * inputCurrentClassFieldsForReadFields. * * Reads the field (which of an Object type as opposed to a primitive) * described by ObjectStreamField field and returns it. */ private Object inputObjectField(ObjectStreamField field) throws InvalidClassException, StreamCorruptedException, ClassNotFoundException, IndirectionException, IOException { if (ObjectStreamClassCorbaExt.isAny(field.getTypeString())) { return javax.rmi.CORBA.Util.readAny(orbStream); } Object objectValue = null; // fields have an API to provide the actual class // corresponding to the data type // Class type = osc.forClass(); Class fieldType = field.getType(); Class actualType = fieldType; // This may change if stub loaded. // Decide what method call to make based on the fieldType. If // it is a type for which we need to load a stub, convert // the type to the correct stub type. int callType = ValueHandlerImpl.kValueType; boolean narrow = false; if (fieldType.isInterface()) { boolean loadStubClass = false; if (java.rmi.Remote.class.isAssignableFrom(fieldType)) { // RMI Object reference... callType = ValueHandlerImpl.kRemoteType; } else if (org.omg.CORBA.Object.class.isAssignableFrom(fieldType)){ // IDL Object reference... callType = ValueHandlerImpl.kRemoteType; loadStubClass = true; } else if (vhandler.isAbstractBase(fieldType)) { // IDL Abstract Object reference... callType = ValueHandlerImpl.kAbstractType; loadStubClass = true; } else if (ObjectStreamClassCorbaExt.isAbstractInterface(fieldType)) { // RMI Abstract Object reference... callType = ValueHandlerImpl.kAbstractType; } if (loadStubClass) { try { String codebase = Util.getCodebase(fieldType); String repID = vhandler.createForAnyType(fieldType); Class stubType = Utility.loadStubClass(repID, codebase, fieldType); actualType = stubType; } catch (ClassNotFoundException e) { narrow = true; } } else { narrow = true; } } switch (callType) { case ValueHandlerImpl.kRemoteType: if (!narrow) objectValue = (Object)orbStream.read_Object(actualType); else objectValue = Utility.readObjectAndNarrow(orbStream, actualType); break; case ValueHandlerImpl.kAbstractType: if (!narrow) objectValue = (Object)orbStream.read_abstract_interface(actualType); else objectValue = Utility.readAbstractAndNarrow(orbStream, actualType); break; case ValueHandlerImpl.kValueType: objectValue = (Object)orbStream.read_value(actualType); break; default: // XXX I18N, logging needed. throw new StreamCorruptedException("Unknown callType: " + callType); } return objectValue; }
Example 11
Source Project: openjdk-jdk8u-backup File: IIOPInputStream.java License: GNU General Public License v2.0 | 4 votes |
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: if (type != null) objectValue = Utility.readAbstractAndNarrow(orbStream, type); else objectValue = orbStream.read_abstract_interface(); break; case ValueHandlerImpl.kValueType: if (type != null) objectValue = orbStream.read_value(type); else objectValue = orbStream.read_value(); break; default: // XXX I18N, logging needed. throw new StreamCorruptedException("Unknown callType: " + callType); } } return objectValue; }
Example 12
Source Project: openjdk-jdk8u-backup File: IIOPInputStream.java License: GNU General Public License v2.0 | 4 votes |
/** * Factored out of inputClassFields and reused in * inputCurrentClassFieldsForReadFields. * * Reads the field (which of an Object type as opposed to a primitive) * described by ObjectStreamField field and returns it. */ private Object inputObjectField(ObjectStreamField field) throws InvalidClassException, StreamCorruptedException, ClassNotFoundException, IndirectionException, IOException { if (ObjectStreamClassCorbaExt.isAny(field.getTypeString())) { return javax.rmi.CORBA.Util.readAny(orbStream); } Object objectValue = null; // fields have an API to provide the actual class // corresponding to the data type // Class type = osc.forClass(); Class fieldType = field.getType(); Class actualType = fieldType; // This may change if stub loaded. // Decide what method call to make based on the fieldType. If // it is a type for which we need to load a stub, convert // the type to the correct stub type. int callType = ValueHandlerImpl.kValueType; boolean narrow = false; if (fieldType.isInterface()) { boolean loadStubClass = false; if (java.rmi.Remote.class.isAssignableFrom(fieldType)) { // RMI Object reference... callType = ValueHandlerImpl.kRemoteType; } else if (org.omg.CORBA.Object.class.isAssignableFrom(fieldType)){ // IDL Object reference... callType = ValueHandlerImpl.kRemoteType; loadStubClass = true; } else if (vhandler.isAbstractBase(fieldType)) { // IDL Abstract Object reference... callType = ValueHandlerImpl.kAbstractType; loadStubClass = true; } else if (ObjectStreamClassCorbaExt.isAbstractInterface(fieldType)) { // RMI Abstract Object reference... callType = ValueHandlerImpl.kAbstractType; } if (loadStubClass) { try { String codebase = Util.getCodebase(fieldType); String repID = vhandler.createForAnyType(fieldType); Class stubType = Utility.loadStubClass(repID, codebase, fieldType); actualType = stubType; } catch (ClassNotFoundException e) { narrow = true; } } else { narrow = true; } } switch (callType) { case ValueHandlerImpl.kRemoteType: if (!narrow) objectValue = (Object)orbStream.read_Object(actualType); else objectValue = Utility.readObjectAndNarrow(orbStream, actualType); break; case ValueHandlerImpl.kAbstractType: if (!narrow) objectValue = (Object)orbStream.read_abstract_interface(actualType); else objectValue = Utility.readAbstractAndNarrow(orbStream, actualType); break; case ValueHandlerImpl.kValueType: objectValue = (Object)orbStream.read_value(actualType); break; default: // XXX I18N, logging needed. throw new StreamCorruptedException("Unknown callType: " + callType); } return objectValue; }
Example 13
Source Project: openjdk-jdk9 File: IIOPInputStream.java License: GNU General Public License v2.0 | 4 votes |
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: if (type != null) objectValue = Utility.readAbstractAndNarrow(orbStream, type); else objectValue = orbStream.read_abstract_interface(); break; case ValueHandlerImpl.kValueType: if (type != null) objectValue = orbStream.read_value(type); else objectValue = orbStream.read_value(); break; default: // XXX I18N, logging needed. throw new StreamCorruptedException("Unknown callType: " + callType); } } return objectValue; }
Example 14
Source Project: openjdk-jdk9 File: IIOPInputStream.java License: GNU General Public License v2.0 | 4 votes |
/** * Factored out of inputClassFields and reused in * inputCurrentClassFieldsForReadFields. * * Reads the field (which of an Object type as opposed to a primitive) * described by ObjectStreamField field and returns it. */ private Object inputObjectField(ObjectStreamField field) throws InvalidClassException, StreamCorruptedException, ClassNotFoundException, IndirectionException, IOException { if (ObjectStreamClassCorbaExt.isAny(field.getTypeString())) { return javax.rmi.CORBA.Util.readAny(orbStream); } Object objectValue = null; // fields have an API to provide the actual class // corresponding to the data type // Class type = osc.forClass(); Class fieldType = field.getType(); Class actualType = fieldType; // This may change if stub loaded. // Decide what method call to make based on the fieldType. If // it is a type for which we need to load a stub, convert // the type to the correct stub type. int callType = ValueHandlerImpl.kValueType; boolean narrow = false; if (fieldType.isInterface()) { boolean loadStubClass = false; if (java.rmi.Remote.class.isAssignableFrom(fieldType)) { // RMI Object reference... callType = ValueHandlerImpl.kRemoteType; } else if (org.omg.CORBA.Object.class.isAssignableFrom(fieldType)){ // IDL Object reference... callType = ValueHandlerImpl.kRemoteType; loadStubClass = true; } else if (vhandler.isAbstractBase(fieldType)) { // IDL Abstract Object reference... callType = ValueHandlerImpl.kAbstractType; loadStubClass = true; } else if (ObjectStreamClassCorbaExt.isAbstractInterface(fieldType)) { // RMI Abstract Object reference... callType = ValueHandlerImpl.kAbstractType; } if (loadStubClass) { try { String codebase = Util.getCodebase(fieldType); String repID = vhandler.createForAnyType(fieldType); Class stubType = Utility.loadStubClass(repID, codebase, fieldType); actualType = stubType; } catch (ClassNotFoundException e) { narrow = true; } } else { narrow = true; } } switch (callType) { case ValueHandlerImpl.kRemoteType: if (!narrow) objectValue = (Object)orbStream.read_Object(actualType); else objectValue = Utility.readObjectAndNarrow(orbStream, actualType); break; case ValueHandlerImpl.kAbstractType: if (!narrow) objectValue = (Object)orbStream.read_abstract_interface(actualType); else objectValue = Utility.readAbstractAndNarrow(orbStream, actualType); break; case ValueHandlerImpl.kValueType: objectValue = (Object)orbStream.read_value(actualType); break; default: // XXX I18N, logging needed. throw new StreamCorruptedException("Unknown callType: " + callType); } return objectValue; }
Example 15
Source Project: hottub File: IIOPInputStream.java License: GNU General Public License v2.0 | 4 votes |
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: if (type != null) objectValue = Utility.readAbstractAndNarrow(orbStream, type); else objectValue = orbStream.read_abstract_interface(); break; case ValueHandlerImpl.kValueType: if (type != null) objectValue = orbStream.read_value(type); else objectValue = orbStream.read_value(); break; default: // XXX I18N, logging needed. throw new StreamCorruptedException("Unknown callType: " + callType); } } return objectValue; }
Example 16
Source Project: hottub File: IIOPInputStream.java License: GNU General Public License v2.0 | 4 votes |
/** * Factored out of inputClassFields and reused in * inputCurrentClassFieldsForReadFields. * * Reads the field (which of an Object type as opposed to a primitive) * described by ObjectStreamField field and returns it. */ private Object inputObjectField(ObjectStreamField field) throws InvalidClassException, StreamCorruptedException, ClassNotFoundException, IndirectionException, IOException { if (ObjectStreamClassCorbaExt.isAny(field.getTypeString())) { return javax.rmi.CORBA.Util.readAny(orbStream); } Object objectValue = null; // fields have an API to provide the actual class // corresponding to the data type // Class type = osc.forClass(); Class fieldType = field.getType(); Class actualType = fieldType; // This may change if stub loaded. // Decide what method call to make based on the fieldType. If // it is a type for which we need to load a stub, convert // the type to the correct stub type. int callType = ValueHandlerImpl.kValueType; boolean narrow = false; if (fieldType.isInterface()) { boolean loadStubClass = false; if (java.rmi.Remote.class.isAssignableFrom(fieldType)) { // RMI Object reference... callType = ValueHandlerImpl.kRemoteType; } else if (org.omg.CORBA.Object.class.isAssignableFrom(fieldType)){ // IDL Object reference... callType = ValueHandlerImpl.kRemoteType; loadStubClass = true; } else if (vhandler.isAbstractBase(fieldType)) { // IDL Abstract Object reference... callType = ValueHandlerImpl.kAbstractType; loadStubClass = true; } else if (ObjectStreamClassCorbaExt.isAbstractInterface(fieldType)) { // RMI Abstract Object reference... callType = ValueHandlerImpl.kAbstractType; } if (loadStubClass) { try { String codebase = Util.getCodebase(fieldType); String repID = vhandler.createForAnyType(fieldType); Class stubType = Utility.loadStubClass(repID, codebase, fieldType); actualType = stubType; } catch (ClassNotFoundException e) { narrow = true; } } else { narrow = true; } } switch (callType) { case ValueHandlerImpl.kRemoteType: if (!narrow) objectValue = (Object)orbStream.read_Object(actualType); else objectValue = Utility.readObjectAndNarrow(orbStream, actualType); break; case ValueHandlerImpl.kAbstractType: if (!narrow) objectValue = (Object)orbStream.read_abstract_interface(actualType); else objectValue = Utility.readAbstractAndNarrow(orbStream, actualType); break; case ValueHandlerImpl.kValueType: objectValue = (Object)orbStream.read_value(actualType); break; default: // XXX I18N, logging needed. throw new StreamCorruptedException("Unknown callType: " + callType); } return objectValue; }
Example 17
Source Project: openjdk-8-source File: IIOPInputStream.java License: GNU General Public License v2.0 | 4 votes |
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: if (type != null) objectValue = Utility.readAbstractAndNarrow(orbStream, type); else objectValue = orbStream.read_abstract_interface(); break; case ValueHandlerImpl.kValueType: if (type != null) objectValue = orbStream.read_value(type); else objectValue = orbStream.read_value(); break; default: // XXX I18N, logging needed. throw new StreamCorruptedException("Unknown callType: " + callType); } } return objectValue; }
Example 18
Source Project: openjdk-8-source File: IIOPInputStream.java License: GNU General Public License v2.0 | 4 votes |
/** * Factored out of inputClassFields and reused in * inputCurrentClassFieldsForReadFields. * * Reads the field (which of an Object type as opposed to a primitive) * described by ObjectStreamField field and returns it. */ private Object inputObjectField(ObjectStreamField field) throws InvalidClassException, StreamCorruptedException, ClassNotFoundException, IndirectionException, IOException { if (ObjectStreamClassCorbaExt.isAny(field.getTypeString())) { return javax.rmi.CORBA.Util.readAny(orbStream); } Object objectValue = null; // fields have an API to provide the actual class // corresponding to the data type // Class type = osc.forClass(); Class fieldType = field.getType(); Class actualType = fieldType; // This may change if stub loaded. // Decide what method call to make based on the fieldType. If // it is a type for which we need to load a stub, convert // the type to the correct stub type. int callType = ValueHandlerImpl.kValueType; boolean narrow = false; if (fieldType.isInterface()) { boolean loadStubClass = false; if (java.rmi.Remote.class.isAssignableFrom(fieldType)) { // RMI Object reference... callType = ValueHandlerImpl.kRemoteType; } else if (org.omg.CORBA.Object.class.isAssignableFrom(fieldType)){ // IDL Object reference... callType = ValueHandlerImpl.kRemoteType; loadStubClass = true; } else if (vhandler.isAbstractBase(fieldType)) { // IDL Abstract Object reference... callType = ValueHandlerImpl.kAbstractType; loadStubClass = true; } else if (ObjectStreamClassCorbaExt.isAbstractInterface(fieldType)) { // RMI Abstract Object reference... callType = ValueHandlerImpl.kAbstractType; } if (loadStubClass) { try { String codebase = Util.getCodebase(fieldType); String repID = vhandler.createForAnyType(fieldType); Class stubType = Utility.loadStubClass(repID, codebase, fieldType); actualType = stubType; } catch (ClassNotFoundException e) { narrow = true; } } else { narrow = true; } } switch (callType) { case ValueHandlerImpl.kRemoteType: if (!narrow) objectValue = (Object)orbStream.read_Object(actualType); else objectValue = Utility.readObjectAndNarrow(orbStream, actualType); break; case ValueHandlerImpl.kAbstractType: if (!narrow) objectValue = (Object)orbStream.read_abstract_interface(actualType); else objectValue = Utility.readAbstractAndNarrow(orbStream, actualType); break; case ValueHandlerImpl.kValueType: objectValue = (Object)orbStream.read_value(actualType); break; default: // XXX I18N, logging needed. throw new StreamCorruptedException("Unknown callType: " + callType); } return objectValue; }
Example 19
Source Project: openjdk-8 File: IIOPInputStream.java License: GNU General Public License v2.0 | 4 votes |
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: if (type != null) objectValue = Utility.readAbstractAndNarrow(orbStream, type); else objectValue = orbStream.read_abstract_interface(); break; case ValueHandlerImpl.kValueType: if (type != null) objectValue = orbStream.read_value(type); else objectValue = orbStream.read_value(); break; default: // XXX I18N, logging needed. throw new StreamCorruptedException("Unknown callType: " + callType); } } return objectValue; }
Example 20
Source Project: openjdk-8 File: IIOPInputStream.java License: GNU General Public License v2.0 | 4 votes |
/** * Factored out of inputClassFields and reused in * inputCurrentClassFieldsForReadFields. * * Reads the field (which of an Object type as opposed to a primitive) * described by ObjectStreamField field and returns it. */ private Object inputObjectField(ObjectStreamField field) throws InvalidClassException, StreamCorruptedException, ClassNotFoundException, IndirectionException, IOException { if (ObjectStreamClassCorbaExt.isAny(field.getTypeString())) { return javax.rmi.CORBA.Util.readAny(orbStream); } Object objectValue = null; // fields have an API to provide the actual class // corresponding to the data type // Class type = osc.forClass(); Class fieldType = field.getType(); Class actualType = fieldType; // This may change if stub loaded. // Decide what method call to make based on the fieldType. If // it is a type for which we need to load a stub, convert // the type to the correct stub type. int callType = ValueHandlerImpl.kValueType; boolean narrow = false; if (fieldType.isInterface()) { boolean loadStubClass = false; if (java.rmi.Remote.class.isAssignableFrom(fieldType)) { // RMI Object reference... callType = ValueHandlerImpl.kRemoteType; } else if (org.omg.CORBA.Object.class.isAssignableFrom(fieldType)){ // IDL Object reference... callType = ValueHandlerImpl.kRemoteType; loadStubClass = true; } else if (vhandler.isAbstractBase(fieldType)) { // IDL Abstract Object reference... callType = ValueHandlerImpl.kAbstractType; loadStubClass = true; } else if (ObjectStreamClassCorbaExt.isAbstractInterface(fieldType)) { // RMI Abstract Object reference... callType = ValueHandlerImpl.kAbstractType; } if (loadStubClass) { try { String codebase = Util.getCodebase(fieldType); String repID = vhandler.createForAnyType(fieldType); Class stubType = Utility.loadStubClass(repID, codebase, fieldType); actualType = stubType; } catch (ClassNotFoundException e) { narrow = true; } } else { narrow = true; } } switch (callType) { case ValueHandlerImpl.kRemoteType: if (!narrow) objectValue = (Object)orbStream.read_Object(actualType); else objectValue = Utility.readObjectAndNarrow(orbStream, actualType); break; case ValueHandlerImpl.kAbstractType: if (!narrow) objectValue = (Object)orbStream.read_abstract_interface(actualType); else objectValue = Utility.readAbstractAndNarrow(orbStream, actualType); break; case ValueHandlerImpl.kValueType: objectValue = (Object)orbStream.read_value(actualType); break; default: // XXX I18N, logging needed. throw new StreamCorruptedException("Unknown callType: " + callType); } return objectValue; }