How to call a method of sub class from super class in ICE using java?

raj0757raj0757 Rajkumar ChoudharyOrganization: Cranfield universityProject: IVHM architectureMember

ice file:

interface Latency
{
::osacbm::schema::DataEvent cbm1(::osacbm::schema::DataEvent x);
::osacbm::schema::DAWaveform cbm2(::osacbm::schema::DAWaveform x);
};

Class DataEvent()
{
Method A(){
System.out.println("Method A");
}
}

Class DAWaveform extends DataEvent()
{
Method B(){
System.out.println("Method B");
}
}

Client program 1:

base = ic.stringToProxy("LatencyImplAdapter:default -h localhost -p 10000");
Demo.LatencyPrx raj = Demo.LatencyPrxHelper.checkedCast(base);
DataEvent obj = new DataEvent():
obj = raj.A();

-----> No error

Client program 2:

base = ic.stringToProxy("LatencyImplAdapter:default -h localhost -p 10000");
Demo.LatencyPrx raj = Demo.LatencyPrxHelper.checkedCast(base);
DataEvent obj = new DAWaveform():
obj = raj.B();

-----> Error as shown below

Exception in thread "main" java.lang.NullPointerException
at osacbm.schema.DADataEvent.__writeImpl(DADataEvent.java:102)
at osacbm.schema.DAWaveform.__writeImpl(DAWaveform.java:108)
at Ice.ObjectImpl.__write(ObjectImpl.java:357)
at IceInternal.BasicStream$EncapsEncoder11.writeInstance(BasicStream.java:4445)
at IceInternal.BasicStream$EncapsEncoder11.writeObject(BasicStream.java:4198)
at IceInternal.BasicStream.writeObject(BasicStream.java:2023)
at Demo._LatencyDelM.cbm2(_LatencyDelM.java:421)
at Demo.LatencyPrxHelper.cbm2(LatencyPrxHelper.java:1129)
at Demo.LatencyPrxHelper.cbm2(LatencyPrxHelper.java:1103)
at C.main(C.java:40)

Answers

  • mesmes CaliforniaMark SpruiellOrganization: ZeroC, Inc.Project: Ice DeveloperAdministrators, ZeroC Staff ZeroC Staff

    Hi,

    It looks like there's a data member of the DADataEvent type that you did not initialize. We could provide more help if you can post the full Slice definitions. Please also specify your Ice version.

    Regards,
    Mark

Sign In or Register to comment.