Closed kevincai closed 1 year ago
as jprotobuf will detects "java_package" option name, so while has this option package name reference will change to use this option. follow suggestion will show you how to fix it:
s1: message B { optional com.a.A column_name = 1; };
or s2: message B { optional A column_name = 1; };
s1:
if use com.a.A
, will protoc
recognize it as correct message type? After all, the .proto will be used for both java code and c++ code.
s2:
what if b.proto
has its own defined message A? how to distinguish b.A
and a.A
in that case?
Even with solution 2, putting aside name conflict in different protobuf packages, jprotobuf generates wrong java code
b.proto
syntax="proto2";
import public "a.proto";
package b;
option java_package = "com.b";
message B {
optional A column_name = 1;
};
generated code
package com.b;
import com.baidu.bjf.remoting.protobuf.FieldType;
import com.baidu.bjf.remoting.protobuf.EnumReadable;
import com.baidu.bjf.remoting.protobuf.annotation.Protobuf;
public class B {
/**
*
* optional A column_name=1
*/
@Protobuf(fieldType=FieldType.OBJECT, order=1, required=false)
public com.b.A columnName;
public void setColumnName(com.b.A columnName) {
this.columnName=columnName;
};
public com.b.A getColumnName() {
return this.columnName;
};
}
@jhunters not sure if more information is needed from me?
a.proto
b.proto
Error:
jprotobuf jar version: 2.4.14