Re: [protobuf] Java classes generated from .proto file don't compile

2016-09-23 Thread 'Feng Xiao' via Protocol Buffers
On Fri, Sep 23, 2016 at 9:40 AM, Denis Vlah  wrote:

> Hello everyone.
>
> I have the following problem:
> The Java classes generated from .proto file doesn't compile.
>
> The original .proto file was generated from C# protobuf-net classes.
>
> There is a big switch in the generated javacode:
>
>
>  public  static final class Object extends
>   com.google.protobuf.GeneratedMessageV3 implements
>   // @@protoc_insertion_point(message_implements:Forcive.
> Dto.Objects.Object)
>   ObjectOrBuilder {
> // Use Object.newBuilder() to construct.
> private Object(com.google.protobuf.GeneratedMessageV3.Builder
> builder) {
>   super(builder);
> }
> private Object() {
> }
>
> @java.lang.Override
> public final com.google.protobuf.UnknownFieldSet
> getUnknownFields() {
>   return this.unknownFields;
> }
> private Object(
> com.google.protobuf.CodedInputStream input,
> com.google.protobuf.ExtensionRegistryLite extensionRegistry)
> throws com.google.protobuf.InvalidProtocolBufferException {
>   this();
>   int mutable_bitField0_ = 0;
>   int mutable_bitField1_ = 0;
>   int mutable_bitField2_ = 0;
>   int mutable_bitField3_ = 0;
>   com.google.protobuf.UnknownFieldSet.Builder unknownFields =
>   com.google.protobuf.UnknownFieldSet.newBuilder();
>   try {
> boolean done = false;
> while (!done) {
>   int tag = input.readTag();
>   switch (tag) {
>  case 2171691026: {
>   Forcive.Dto.Objects.AllMessages.UserDto.Builder subBuilder
> = null;
>   if (((bitField1_ & 0x8000) == 0x8000)) {
> subBuilder = userDto_.toBuilder();
>   }
>   userDto_ = input.readMessage(Forcive.Dto.
> Objects.AllMessages.UserDto.PARSER, extensionRegistry);
>   if (subBuilder != null) {
> subBuilder.mergeFrom(userDto_);
> userDto_ = subBuilder.buildPartial();
>   }
>   bitField1_ |= 0x8000;
>   break;
> }
>
> 
>
> The Java error is Error:(78413, 18) java: integer number too large:
> 2171691026
>
You are using a field with a too large field number. The generated Java
code should compile fine if the field number is smaller than 2<<28.


>
> The C++ generated classes from the same .proto file compiles fine.
>
> Any ideas how to fix this?
>

> Thanks
>
> --
> 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+unsubscr...@googlegroups.com.
> To post to this group, send email to protobuf@googlegroups.com.
> Visit this group at https://groups.google.com/group/protobuf.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.


[protobuf] Java classes generated from .proto file don't compile

2016-09-23 Thread Denis Vlah
Hello everyone.

I have the following problem:
The Java classes generated from .proto file doesn't compile.

The original .proto file was generated from C# protobuf-net classes.

There is a big switch in the generated javacode:


 public  static final class Object extends
  com.google.protobuf.GeneratedMessageV3 implements
  // 
@@protoc_insertion_point(message_implements:Forcive.Dto.Objects.Object)
  ObjectOrBuilder {
// Use Object.newBuilder() to construct.
private Object(com.google.protobuf.GeneratedMessageV3.Builder 
builder) {
  super(builder);
}
private Object() {
}

@java.lang.Override
public final com.google.protobuf.UnknownFieldSet
getUnknownFields() {
  return this.unknownFields;
}
private Object(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
  this();
  int mutable_bitField0_ = 0;
  int mutable_bitField1_ = 0;
  int mutable_bitField2_ = 0;
  int mutable_bitField3_ = 0;
  com.google.protobuf.UnknownFieldSet.Builder unknownFields =
  com.google.protobuf.UnknownFieldSet.newBuilder();
  try {
boolean done = false;
while (!done) {
  int tag = input.readTag();
  switch (tag) {
 case 2171691026: {
  Forcive.Dto.Objects.AllMessages.UserDto.Builder subBuilder = 
null;
  if (((bitField1_ & 0x8000) == 0x8000)) {
subBuilder = userDto_.toBuilder();
  }
  userDto_ = 
input.readMessage(Forcive.Dto.Objects.AllMessages.UserDto.PARSER, 
extensionRegistry);
  if (subBuilder != null) {
subBuilder.mergeFrom(userDto_);
userDto_ = subBuilder.buildPartial();
  }
  bitField1_ |= 0x8000;
  break;
}



The Java error is Error:(78413, 18) java: integer number too large: 
2171691026

The C++ generated classes from the same .proto file compiles fine.

Any ideas how to fix this?

Thanks

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.