google / flatbuffers

FlatBuffers: Memory Efficient Serialization Library
https://flatbuffers.dev/
Apache License 2.0
23.28k stars 3.25k forks source link

Docs: Java example bug #190

Closed robfig closed 9 years ago

robfig commented 9 years ago

Cool project - I'm evaluating it for replacing some protobuf usage in some high performance corners of an existing system.

Tiny documentation bug on this page: https://google.github.io/flatbuffers/md__java_usage.html

It says

FlatBufferBuilder fbb = new FlatBufferBuilder();

but that constructor does not seem to exist -- I have to supply an initial size for the buffer.

Jiboo commented 9 years ago

The FlatBufferBuilder constructor in CPP also takes an initial size, but it defaults to 1024. As Java doesn't support default values for parameters, maybe it would be better to add a constructor with no parameters in the Java class instead of doing the fix in the docs. https://github.com/google/flatbuffers/blob/master/include/flatbuffers/flatbuffers.h#L486 https://github.com/google/flatbuffers/blob/master/java/com/google/flatbuffers/FlatBufferBuilder.java#L49