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)
我声明了如上一个字段。其中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>不起作用?