binary compatibility between versions 2.x and 3.x

5,740 views
Skip to first unread message

Jeff Olson

unread,
Aug 12, 2016, 7:47:58 PM8/12/16
to Protocol Buffers
I've read through the release documents for Protocol Buffers v3.0.0 but I can't find any statements regrading binary compatibility with version 2.6.1 (or earlier). There are a couple of things I'd like to know:

  1. If I dump a 3.0.0 version of the com.google.protobuf/protobuf-java.jar in a project the depends on java classes generated by protoc v2.6.1 (or v2.5.0) will everything still work? That is, is the java runtime backwards compatible?
  2. Is the binary wire format the same for purely proto2 messages? If I serialize messages generated from proto2 sources using the 3.0.0 java runtime will clients using protobuf v2.6.1 be able to decode the messages correctly?
Thanks,
Jeff

Feng Xiao

unread,
Aug 12, 2016, 8:00:23 PM8/12/16
to Jeff Olson, Protocol Buffers
On Thu, Aug 11, 2016 at 12:21 PM, Jeff Olson <jeff.d...@gmail.com> wrote:
I've read through the release documents for Protocol Buffers v3.0.0 but I can't find any statements regrading binary compatibility with version 2.6.1 (or earlier). There are a couple of things I'd like to know:

  1. If I dump a 3.0.0 version of the com.google.protobuf/protobuf-java.jar in a project the depends on java classes generated by protoc v2.6.1 (or v2.5.0) will everything still work? That is, is the java runtime backwards compatible?
Unfortunately no. The 3.0.0 version protobuf-java.jar will not work with java classes generated by protoc v2.6.1 (or v2.5.0). For those who can not upgrade to 3.0 directly, we are considering releasing a 2.7 version which provides the following compatibility guarantees:
1. 2.7 protobuf-java.jar will be compatible with java classes generated by protoc 2.6.1 and protoc 2.5.0.
2. 3.0 protobuf-java.jar will be compatible with java classes generated by protoc 2.7

I.e., it allows you to upgrade to 3.0 in two steps: upgrade to 2.7, and after all your dependencies are upgraded to either 2.7 or 3.0, you can upgrade to 3.0 as well. It's not an ideal solution, but we hope it can help ease the migration pain for some users. I'm testing this 2.7 version in a github branch right now: https://github.com/google/protobuf/tree/2.7.0. If you are interested, feel free to test it and any feedback is welcome.
 
  1. Is the binary wire format the same for purely proto2 messages? If I serialize messages generated from proto2 sources using the 3.0.0 java runtime will clients using protobuf v2.6.1 be able to decode the messages correctly?
Yes. The wire format stays the same as long as you are using the proto2 syntax version.

Thanks,
Jeff

--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+unsubscribe@googlegroups.com.
To post to this group, send email to prot...@googlegroups.com.
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Scott Sue

unread,
Apr 20, 2017, 6:55:49 AM4/20/17
to Protocol Buffers, jeff.d...@gmail.com
Hi Feng,

Is this still the case considering that 3.2.0 is out that allows the version number to be used by protoc?

General
* Added protoc version number to protoc plugin protocol. It can be used by
protoc plugin to detect which version of protoc is used with the plugin and
mitigate known problems in certain version of protoc.

Regards,
Scott



On Saturday, August 13, 2016 at 8:00:23 AM UTC+8, Feng Xiao wrote:
On Thu, Aug 11, 2016 at 12:21 PM, Jeff Olson <jeff.d...@gmail.com> wrote:
I've read through the release documents for Protocol Buffers v3.0.0 but I can't find any statements regrading binary compatibility with version 2.6.1 (or earlier). There are a couple of things I'd like to know:

  1. If I dump a 3.0.0 version of the com.google.protobuf/protobuf-java.jar in a project the depends on java classes generated by protoc v2.6.1 (or v2.5.0) will everything still work? That is, is the java runtime backwards compatible?
Unfortunately no. The 3.0.0 version protobuf-java.jar will not work with java classes generated by protoc v2.6.1 (or v2.5.0). For those who can not upgrade to 3.0 directly, we are considering releasing a 2.7 version which provides the following compatibility guarantees:
1. 2.7 protobuf-java.jar will be compatible with java classes generated by protoc 2.6.1 and protoc 2.5.0.
2. 3.0 protobuf-java.jar will be compatible with java classes generated by protoc 2.7

I.e., it allows you to upgrade to 3.0 in two steps: upgrade to 2.7, and after all your dependencies are upgraded to either 2.7 or 3.0, you can upgrade to 3.0 as well. It's not an ideal solution, but we hope it can help ease the migration pain for some users. I'm testing this 2.7 version in a github branch right now: https://github.com/google/protobuf/tree/2.7.0. If you are interested, feel free to test it and any feedback is welcome.
 
  1. Is the binary wire format the same for purely proto2 messages? If I serialize messages generated from proto2 sources using the 3.0.0 java runtime will clients using protobuf v2.6.1 be able to decode the messages correctly?
Yes. The wire format stays the same as long as you are using the proto2 syntax version.

Thanks,
Jeff

--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+u...@googlegroups.com.

Feng Xiao

unread,
Apr 20, 2017, 2:08:59 PM4/20/17
to Scott Sue, Protocol Buffers, Jeff Olson
On Thu, Apr 20, 2017 at 3:55 AM, Scott Sue <scot...@celer-tech.com> wrote:
Hi Feng,

Is this still the case considering that 3.2.0 is out that allows the version number to be used by protoc?
Not sure what you are asking, but 3.0.0 generated code should work with 3.2.0 runtime and 3.2.0 protoc will work with any old version plugins.
 
This message, including any attachments, may include private, privileged and confidential information and is intended only for the personal and confidential use of the intended recipient(s). If the reader of this message is not an intended recipient, you are hereby notified that any review, use, dissemination, distribution, printing or copying of this message or its contents is strictly prohibited and may be unlawful. If you are not an intended recipient or have received this communication in error, please immediately notify the sender by telephone and/or a reply email and permanently delete the original message, including any attachments, without making a copy.

--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+unsubscribe@googlegroups.com.

Scott Sue

unread,
Apr 20, 2017, 9:02:01 PM4/20/17
to Feng Xiao, Protocol Buffers, Jeff Olson
Hi Feng,

Apologies, what I was meaning was that with the introduction of protobuf 3.2.0 now, is 3.2.0 binary compatible with protobuf 2.5.0?  Or does you original message reply still hold true?


Regards,
Scott

SCOTT SUE
CHIEF TECHNOLOGY OFFICER

Support Line : +44(0) 2031 371 603
Mobile : +852 9611 3969

9/F, 33 Lockhart Road, Wanchai, Hong Kong






Feng Xiao

unread,
Apr 20, 2017, 9:10:25 PM4/20/17
to Scott Sue, Protocol Buffers, Jeff Olson
On Thu, Apr 20, 2017 at 6:01 PM, Scott Sue <scot...@celer-tech.com> wrote:
Hi Feng,

Apologies, what I was meaning was that with the introduction of protobuf 3.2.0 now, is 3.2.0 binary compatible with protobuf 2.5.0?  Or does you original message reply still hold true?
No, 3.2.0 runtime is not binary compatible with 2.5.0 generated code. It is only binary compatible with older 3.x version generated code, such as 3.0, or 3.1.

madhav goyal

unread,
Jun 4, 2018, 8:44:02 PM6/4/18
to Protocol Buffers
Hey Feng, Can you please tell what's the incompatibility between protoc_linux.2.5 and protobuf-java_3.x? I upgraded protobuf-java to 3.5 and tried to use it with protoc_linux.2.5 and I was able to compile, read/write with no issues. 

$protoc_linux --version
libprotoc 2.5.0

<dependency>
                <groupId>com.google.protobuf</groupId>
                <artifactId>protobuf-java</artifactId>
                <version>3.5.0</version>
</dependency>

André Pinto

unread,
Oct 7, 2019, 6:36:19 AM10/7/19
to Protocol Buffers
I have the same question.

protobuf-java 3.7.1 seems to be compatible with Protobuf generated with protoc 2.5.0.

Is there any official statement about the compatibility of the protobuf-java library against different protobuf versions?

Adam Cozzette

unread,
Oct 7, 2019, 1:33:46 PM10/7/19
to André Pinto, Protocol Buffers
Any mixing of 2.x and 3.x is not supported; you might get lucky and have it work, but I wouldn't recommend doing that because no one has attempted to make that work safely. As long as all your code is at 3.0 or higher, you can freely mix 3.x versions as long as you follow the rule that the runtime library version is at least as high as the protoc version of the newest generated code (i.e. no generated code newer than the runtime library).

Xuelin Fan

unread,
Jun 24, 2020, 3:06:46 AM6/24/20
to Protocol Buffers
So there is no formal compatibility document between 2.6 and 3.x ?  Then how to upgrade? also seem 2.7 is not a stable version
Reply all
Reply to author
Forward
0 new messages