Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map<String, Object> 字段无法成功编译 #173

Open
slovx2 opened this issue Sep 28, 2021 · 1 comment
Open

Map<String, Object> 字段无法成功编译 #173

slovx2 opened this issue Sep 28, 2021 · 1 comment

Comments

@slovx2
Copy link

slovx2 commented Sep 28, 2021

@Protobuf
private Map<String, Object> startVariable;

我声明了如上一个字段。其中value的类型有可能是List 和 String
但无法成功编译,报错如下:

Caused by: java.lang.IllegalArgumentException: Invalid class [java.lang.String] no field use annotation @com.baidu.bjf.remoting.protobuf.annotation.Protobuf at class java.lang.String
at com.baidu.bjf.remoting.protobuf.utils.ProtobufProxyUtils.fetchFieldInfos(ProtobufProxyUtils.java:107)
at com.baidu.bjf.remoting.protobuf.code.AbstractCodeGenerator.(AbstractCodeGenerator.java:72)
at com.baidu.bjf.remoting.protobuf.code.TemplateCodeGenerator.(TemplateCodeGenerator.java:66)
at com.baidu.bjf.remoting.protobuf.ProtobufProxy.getCodeGenerator(ProtobufProxy.java:195)
at com.baidu.bjf.remoting.protobuf.ProtobufProxy.create(ProtobufProxy.java:276)
at com.baidu.bjf.remoting.protobuf.ProtobufProxy.create(ProtobufProxy.java:249)
at com.baidu.bjf.remoting.protobuf.ProtobufProxy.create(ProtobufProxy.java:208)
at com.baidu.bjf.remoting.protobuf.code.CodedConstant.computeObjectSizeNoTag(CodedConstant.java:529)
at com.baidu.bjf.remoting.protobuf.code.CodedConstant.computeElementSizeNoTag(CodedConstant.java:1372)
at com.baidu.bjf.remoting.protobuf.code.CodedConstant.computeElementSize(CodedConstant.java:124)
at com.baidu.bjf.remoting.protobuf.MapEntryLite.computeSerializedSize(MapEntryLite.java:187)
at com.baidu.bjf.remoting.protobuf.MapEntry.getSerializedSize(MapEntry.java:196)
at com.google.protobuf.CodedOutputStream$OutputStreamEncoder.writeMessageNoTag(CodedOutputStream.java:2854)
at com.google.protobuf.CodedOutputStream$OutputStreamEncoder.writeMessage(CodedOutputStream.java:2824)
at com.baidu.bjf.remoting.protobuf.code.CodedConstant.writeToMap(CodedConstant.java:498)

请问是我用法不对吗?

我试了
@protobuf
private Map<String, String> startVariable;

没问题。

但我想让startVariable的类型更灵活一点,至少支持List,String和Map,但貌似Map<String, Object>不起作用?

@jhunters
Copy link
Owner

对使用上有问题, Map里不能用 Obejct,必须 是明确的对象类型

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants