Protobuf 2.5.0 bug?

◇◆丶佛笑我妖孽 提交于 2019-11-29 15:58:42

I would guess you did not upgrade / recompile something. In protobuf 2.4.1 version int the jars.

in the GeneratedMessage class, getUnknownFields was a final method in 2.4.1 but in 2.5.0 it becomes:

  //@Override (Java 1.6 override semantics, but we must support 1.5)
  public UnknownFieldSet getUnknownFields() {
    throw new UnsupportedOperationException(
        "This is supposed to be overridden by subclasses.");
  }

and is overridden in the generated class. You may need to recompile all your classes that use generated protocol buffer classes.

Given the messages

java.lang.VerifyError: class com.mta.pb.ACM$MyRequest overrides final method getUnknownFields.()Lcom/google/protobuf/UnknownFieldSet;

This tells you you are running code generated with Protocol-Buffers 2.5.0 with a protocol-fuffers-2.4.1 (or earlier) jar.

A similar thing happened to me when I was compiling an application after upgrading to 2.5. Eventually I realized that the old 2.4 jar was still in the same folder as the new 2.5 jar, and that the build system xml file was still referring to the old one. It was just a matter of being a little more careful - nothing mysterious was going on.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!