Read only archive ; use https://github.com/JacORB/JacORB/issues for new issues

Bug 678

Summary: DynStruct with reference component
Product: JacORB Reporter: Michal Jelen <michal.jelen>
Component: DynAnyAssignee: Gerald Brose <gerald.brose>
Status: NEW ---    
Severity: normal    
Priority: P2    
Version: 2.2.3   
Hardware: PC   
OS: All   

Description Michal Jelen 2006-04-05 16:21:28 CEST
DynStruct.set_members() and DynStruct.set_members_as_dynany() do not work if
struct's member is an object reference of type narrower than generic
CORBA::Object. TypeMismatch exception is erroneously thrown.

---- IDL:
  interface Ifc{
  };

  struct Stc{
    Ifc ref; 
  };
----

---- Testcase:
  // ORB orb = ...;
  // POA poa = ...;
  // DynAnyFactory daf = ...;  

  DynStruct dstr = (DynStruct)
      daf.create_dyn_any_from_type_code(StcHelper.type());
      
  NameValuePair nvp[] = new NameValuePair[1];
  Any any = orb.create_any();
  IfcHelper.insert(any,IfcHelper.unchecked_narrow(
      poa.create_reference(StcHelper.id())
  ));
  nvp[0] = new NameValuePair("ref",any);
  dstr.set_members(nvp);
----

---- Exception :
org.omg.DynamicAny.DynAnyPackage.TypeMismatch:
IDL:omg.org/DynamicAny/DynAny/TypeMismatch:1.0
	at org.jacorb.orb.dynany.DynStruct.set_members(DynStruct.java:298)
	at Test.testDyns(Test.java:180)
	at Test.main(Test.java:109)
----

---- Analysis:
Exception is thrown from this test in DynStruct.java:

if( ! nvp[i].value.type().equivalent( members[i].value.type() ))
{
  throw new org.omg.DynamicAny.DynAnyPackage.TypeMismatch();
}

The expected type (members[0].value.type()) is omg.org/CORBA/Object, which is
NOT *equivalent* to any narrower type (such as Ifc in the example). 
----