jhunters / jprotobuf

A useful utility library for java programmer using google protobuf
Apache License 2.0
879 stars 281 forks source link

ProtobufIDLProxy对proto中obj.obj的写法不支持 #165

Closed suiiceice closed 3 years ago

suiiceice commented 3 years ago
messageLine {
    string id = 1;
    Point start = 2;
    Point end = 3;
    enum CrossDirection {
        UNKNOWN = 0;  // Future-proof default
        LEFT = 1;
        RIGHT = 2;
    }
}
message LineCount {
    int32 count = 1;
    string line_id = 2;
    Line.CrossDirection cross_direction = 3;
}
java.lang.RuntimeException: Message 'LineCountJProtoBufProtoClass9f32064538414dc5b0fa338540443264' depend on message 'Linebb0441da2eab4f9b8bb013a457f4188d.CrossDirectionbde45f0147b64c99b4c415e84f32b69b' is missed
    at com.baidu.bjf.remoting.protobuf.ProtobufIDLProxy.hasDependency(ProtobufIDLProxy.java:1742)
    at com.baidu.bjf.remoting.protobuf.ProtobufIDLProxy.createMessageClass(ProtobufIDLProxy.java:1033)
    at com.baidu.bjf.remoting.protobuf.ProtobufIDLProxy.doCreatePro(ProtobufIDLProxy.java:1375)
    at com.baidu.bjf.remoting.protobuf.ProtobufIDLProxy.doCreatePro(ProtobufIDLProxy.java:1300)
    at com.baidu.bjf.remoting.protobuf.ProtobufIDLProxy.create(ProtobufIDLProxy.java:394)
    at com.baidu.bjf.remoting.protobuf.ProtobufIDLProxy.create(ProtobufIDLProxy.java:376)
    at com.baidu.bjf.remoting.protobuf.ProtobufIDLProxy.create(ProtobufIDLProxy.java:343)
    at io.jindong.pbtool.Test.main(Test.java:33)
jhunters commented 3 years ago

目前处理的一些问题, 可以通过以下方式先绕过,后面发布新版本解决。

syntax = "proto3";  

option java_package = "test";

message Line{
    string id = 1;
    string start = 2;
    string end = 3;
    enum CrossDirection {
        UNKNOWN = 0;  // Future-proof default
        LEFT = 1;
        RIGHT = 2;
    }
}
message LineCount{
    int32 count = 1;
    string line_id = 2;
    Line.CrossDirection cross_direction = 3;
}

java_package 目前要求加上,后续会修正该问题 在测试你的例子里,发现 Point 对象也没有定义,也会出错 对象引用的问题目前测试未发现有问题

suiiceice commented 3 years ago

谢谢。不过我调整之后发现,这个错误是在加入package之后出现的。

syntax = "proto3";

package acv.proto.vca;

option java_package = "test";

message Line{
    string id = 1;
    Point start = 2;
    Point end = 3;
    enum CrossDirection {
        UNKNOWN = 0;  // Future-proof default
        LEFT = 1;
        RIGHT = 2;
    }
}

message Point {
    float x = 1;
    float y = 2;
}

message LineCount{
    int32 count = 1;
    string line_id = 2;
    Line.CrossDirection cross_direction = 3;
}
jhunters commented 3 years ago

收到 package 处理对依赖识别有点问题,稍后版本修复