compile java class of protocol buffer has compile time error -


i'm using protocol buffer 2.6.1 java 1.7.0.71.

and compiled simple test protocol buffer file.

option java_package = "my.sample"; option java_outer_classname = "sum"; option java_generic_services = true; option java_generate_equals_and_hash = true; option optimize_for = speed; message sumrequest {     required string family = 1;     required string column = 2; }   message sumresponse {    required int64 sum = 1 [default = 0]; }  service sumservice {   rpc getsum(sumrequest)     returns (sumresponse); } 

but in code below, memoizedhashcode declared nowhere, throws compile error.

@java.lang.override public int hashcode() {   if (memoizedhashcode != 0) {     return memoizedhashcode;   }   int hash = 41;   hash = (19 * hash) + getdescriptorfortype().hashcode();   if (hasfamily()) {     hash = (37 * hash) + family_field_number;     hash = (53 * hash) + getfamily().hashcode();   }   if (hascolumn()) {     hash = (37 * hash) + column_field_number;     hash = (53 * hash) + getcolumn().hashcode();   }   hash = (29 * hash) + getunknownfields().hashcode();   memoizedhashcode = hash;   return hash; } 

i saw online adding

private int memoizedhashcode = 0 

solved problem, think workaround.

why happening?

memoizedhashcode defined in base class abstractmessagelite, part of protobuf library.

you need make sure version of protoc using generate code matches version of libprotobuf.jar bringing program. if versions not match, can see error describe, other errors.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -