I made some tests using the demo (%JACORB_HOME%\demo\dynany) and found if put a complex data (e.g. a DynStruct) in an 'Any' object which be converted to a 'DynAny' object, then DynAnyFactoryImpl will can not extract the actual value correctly. The following is the sample code (refer to "%JACORB_HOME%\demo\dynany\Client.java"): ...... Any any = orb.create_any(); any.insert_any(dyn_struct.to_any()); // dyn_struct is a DynStruct instance, I omit how to create it, please see the demo... DynAny dynany = dynFactory.create_dyn_any(any); System.out.println("Passing a any..." + s.generic( dynany.to_any() ) ); ...... and Server can't display the actual value from the Any pass to it. (refer to "%JACORB_HOME%\demo\dynany\Server.java") As a workaround, I changed DynAnyFactoryImpl (create_dyn_any method) like: =================================================================== public org.omg.DynamicAny.DynAny create_dyn_any( org.omg.CORBA.Any value ) throws InconsistentTypeCode { try { // Correction: // In case of objects forwarded in value member of Any the TypeCode of inner object // has to be used for further processing (in other case it is treated as TCKind._tk_any) if (value instanceof org.jacorb.orb.Any) { java.lang.Object obj = ((org.jacorb.orb.Any)value).value(); if (obj instanceof org.jacorb.orb.Any) { org.jacorb.orb.Any anyValue = (org.jacorb.orb.Any)obj; org.omg.DynamicAny.DynAny dynAny = create_dyn_any_from_type_code(anyValue.type()); dynAny.from_any( anyValue ); return dynAny; } } // end of correction org.omg.DynamicAny.DynAny dynAny = create_dyn_any_from_type_code( value.type() ); dynAny.from_any( value ); return dynAny; } ....... ======================================================================== then the value can be extracted from Any and Server display the correct content within Any. I don't know whether it is a bug of JacORB2.3.0, if it is I wonder whether my doing above is correct, and if the change will cause any other side-effect? Could anybody look into this issue and give me some clarification? Thanks in advance, Shi Lei
Created attachment 313 [details] Demo code and patch which reproduce this case
I've tried different ORBs and all have the same behaviour as JacORB and have read the spec and can't see anything that implies this should be done. For now therefore I am closing this ticket - if you have another interpretation please reopen.