Re: [protobuf] [Java] toString not longer supported?

1,496 views
Skip to first unread message

Feng Xiao

unread,
Apr 4, 2013, 1:20:03 PM4/4/13
to Stik kos, Protocol Buffers
On Thu, Apr 4, 2013 at 8:42 AM, Stik kos <sti...@gmail.com> wrote:
Hello,

I just upgraded 'protobuf-java' to 2.5.0 and noticed that this upgrade breaks the default toString implementation with error:

java.lang.UnsupportedOperationException: This is supposed to be overridden by subclasses.
at com.google.protobuf.GeneratedMessage.getUnknownFields(GeneratedMessage.java:180)
at com.google.protobuf.TextFormat$Printer.print(TextFormat.java:275)
at com.google.protobuf.TextFormat$Printer.access$400(TextFormat.java:248)
at com.google.protobuf.TextFormat.print(TextFormat.java:71)
at com.google.protobuf.TextFormat.printToString(TextFormat.java:118)
at com.google.protobuf.AbstractMessage.toString(AbstractMessage.java:106)
at java.lang.String.valueOf(String.java:2826)
at java.lang.StringBuilder.append(StringBuilder.java:115)


I can't find anything in the release notes about this and the docs (https://developers.google.com/protocol-buffers/docs/javatutorial) still state:

toString(): returns a human-readable representation of the message, particularly useful for debugging.

Is there any reason why no default toString is provided anymore?
The problem may be that you are compiling Java code generated from an old protocol compiler (< 2.5.0) with the new run-time library (2.5.0).
When you upgrade the run-time library, you are supposed to regenerate the code with new protocol compiler.
 

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+u...@googlegroups.com.
To post to this group, send email to prot...@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

jarl ostensen

unread,
Jan 8, 2015, 6:51:22 AM1/8/15
to prot...@googlegroups.com
I know this is a bit old but...I've just discovered that toString on any message class in Java throws an exception (java.lang.NoSuchMethodError: com.google.protobuf.DescriptorProtos$FileDescriptorProto.getPublicDependencyCount()) - this is with the version of the compiler and source being kept in sync so I must assume there's a bug somewhere in that code...?


On Thursday, April 4, 2013 4:42:14 PM UTC+1, Stik kos wrote:
Hello,

I just upgraded 'protobuf-java' to 2.5.0 and noticed that this upgrade breaks the default toString implementation with error:

java.lang.UnsupportedOperationException: This is supposed to be overridden by subclasses.
at com.google.protobuf.GeneratedMessage.getUnknownFields(GeneratedMessage.java:180)
at com.google.protobuf.TextFormat$Printer.print(TextFormat.java:275)
at com.google.protobuf.TextFormat$Printer.access$400(TextFormat.java:248)
at com.google.protobuf.TextFormat.print(TextFormat.java:71)
at com.google.protobuf.TextFormat.printToString(TextFormat.java:118)
at com.google.protobuf.AbstractMessage.toString(AbstractMessage.java:106)
at java.lang.String.valueOf(String.java:2826)
at java.lang.StringBuilder.append(StringBuilder.java:115)


I can't find anything in the release notes about this and the docs (https://developers.google.com/protocol-buffers/docs/javatutorial) still state:

toString(): returns a human-readable representation of the message, particularly useful for debugging.

Is there any reason why no default toString is provided anymore?

Thanks!
Reply all
Reply to author
Forward
0 new messages