我有以下 idl 结构。我想使用 opendds 发布它
#pragma DCPS_DATA_TYPE "B::CData"
#pragma DCPS_DATA_KEY "B::CData id"
module B {
struct Quote {
string skit_name;
string episode_name;
string line;
};
struct CData{
long id;
Quote payload;
};
};
我用java编写了发布者和订阅者。但是在发布和订阅上述主题时,JVM 崩溃了。
有人对此有想法吗?
以下是公共主题的java代码
public static void main(String[] args) {
DomainParticipantFactory dpf =
TheParticipantFactory.WithArgs(new StringSeqHolder(args));
if (dpf == null) {
System.err.println ("Domain Participant Factory not found");
return;
}
final int DOMAIN_ID = 42;
DomainParticipant dp = dpf.create_participant(DOMAIN_ID,
PARTICIPANT_QOS_DEFAULT.get(), null, DEFAULT_STATUS_MASK.value);
if (dp == null) {
System.err.println ("Domain Participant creation failed");
return;
}
CDataTypeSupportImpl servant = new CDataTypeSupportImpl();
if (servant.register_type(dp, "") != RETCODE_OK.value) {
System.err.println ("register_type failed");
return;
}
Topic top = dp.create_topic("data",
servant.get_type_name(),
TOPIC_QOS_DEFAULT.get(), null,
DEFAULT_STATUS_MASK.value);
Publisher pub = dp.create_publisher(
PUBLISHER_QOS_DEFAULT.get(),
null,
DEFAULT_STATUS_MASK.value);
DataWriter dw = pub.create_datawriter(
top, DATAWRITER_QOS_DEFAULT.get(), null, DEFAULT_STATUS_MASK.value);
CDataDataWriter mdw = CDataDataWriterHelper.narrow(dw);
CData cData=new CData();
int handle = mdw.register(cData);
// above statement crashes the jvm
int ret = mdw.write(msg, handle);
}