Eyal leshem
Eyal leshem

Reputation: 1115

protobuf - Is it backward compatible to move message to imported file

Let's say i have the flowing message :

message Inner { 
   string value = 1; 
}

message Outer {
   Inner inner = 1; 
} 

and I want to move the inner to other "common" proto file:

common.proto 
------------ 
package common;
message Inner { 
  string value = 1;  
}

outer.proto 
----------- 
import "common.proto";
message Outer {
  Inner common.Inner = 1; 
} 

Can i count of that this change is backward compatible? Is the packet format of the message will be with same memory layout ? also is the string format of the PB will remain the same?

thanks :)

Upvotes: 2

Views: 843

Answers (1)

Andrew Cheong
Andrew Cheong

Reputation: 30273

Do you mean to have

common.Inner inner = 1;

But anyway, yes, it's backward compatible, same memory layout, and I'm not sure what you mean by the string format of the PB but at least in Java the naming of generated classes and methods is indeed the same, except that they have to be imported from new packages.

Upvotes: 1

Related Questions