Syncing from internal
This commit is contained in:
commit
b7fe12e367
73
CHANGES.txt
73
CHANGES.txt
@ -9,6 +9,79 @@ Unreleased Changes (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
|
||||
* Unknown enums for proto2 protos now properly implement proto2's behavior of
|
||||
putting such values in unknown fields.
|
||||
|
||||
Java
|
||||
* Don't support map fields in DynamicMessage.Builder.{getFieldBuilder,getRepeatedFieldBuilder}
|
||||
* Fix parseFrom to only throw InvalidProtocolBufferException
|
||||
* InvalidProtocolBufferException now allows arbitrary wrapped Exception types.
|
||||
* Fix bug in `FieldSet.Builder.mergeFrom`
|
||||
* Flush CodedOutputStream also flushes underlying OutputStream
|
||||
* When oneof case is the same and the field type is Message, merge the
|
||||
subfield. (previously it was replaced.)’
|
||||
* add @CheckReturnValue to some protobuf types
|
||||
* Report original exceptions when parsing JSON
|
||||
* Add more info to @deprecated javadoc for set/get/has methods
|
||||
* Fix initialization bug in doc comment line numbers
|
||||
|
||||
Kotlin
|
||||
* Enhancements to Kotlin support for Any protobuf.
|
||||
* Add orNull extensions for optional message fields in Kotlin.
|
||||
|
||||
Python
|
||||
* Fix type annotations of some Duration and Timestamp methods.
|
||||
* Repeated field containers are now generic in field types and could be used
|
||||
in type annotations.
|
||||
* Protobuf python generated codes are simplified. Descriptors and message
|
||||
classes' definitions are now dynamic created in internal/builder.py.
|
||||
Insertion Points for messages classes are discarded.
|
||||
* protoc is now able to generate python stub (.pyi) by --gen_pyi
|
||||
* has_presence is added for FieldDescriptor in python
|
||||
* Loosen indexing type requirements to allow valid __index__() implementations
|
||||
rather than only PyLongObjects.
|
||||
* Fix the deepcopy bug caused by not copying message_listener.
|
||||
* Added python JSON parse recursion limit (default 100)
|
||||
* path info is added for python JSON parse errors
|
||||
* Pure python repeated scalar fields will not able to pickle. Convert to list
|
||||
first.
|
||||
* Timestamp.ToDatetime() now accepts an optional tzinfo parameter. If
|
||||
specified, the function returns a timezone-aware datetime in the given time
|
||||
zone. If omitted or None, the function returns a timezone-naive UTC datetime
|
||||
(as previously).
|
||||
* Adds client_streaming and server_streaming fields to MethodDescriptor.
|
||||
|
||||
Compiler
|
||||
* Migrate IsDefault(const std::string*) and UnsafeSetDefault(const std::string*)
|
||||
* Implement strong qualified tags for TaggedPtr
|
||||
* Rework allocations to power-of-two byte sizes.
|
||||
* Migrate IsDefault(const std::string*) and UnsafeSetDefault(const std::string*)
|
||||
* Implement strong qualified tags for TaggedPtr
|
||||
* Make TaggedPtr Set...() calls explicitly spell out the content type.
|
||||
* Check for parsing error before verifying UTF8.
|
||||
* Enforce a maximum message nesting limit of 32 in the descriptor builder to
|
||||
guard against stack overflows
|
||||
* Fixed bugs in operators for RepeatedPtrIterator
|
||||
* Assert a maximum map alignment for allocated values
|
||||
* Fix proto1 group extension protodb parsing error
|
||||
* Do not log/report the same descriptor symbol multiple times if it contains
|
||||
more than one invalid character.
|
||||
* Add UnknownFieldSet::SerializeToString and SerializeToCodedStream.
|
||||
|
||||
Arenas
|
||||
* Change Repeated*Field to reuse memory when using arenas.
|
||||
* Implements pbarenaz for profiling proto arenas
|
||||
* Introduce CreateString() and CreateArenaString() for cleaner semantics
|
||||
* Fix unreferenced parameter for MSVC builds
|
||||
* Add UnsafeSetAllocated to be used for one-of string fields.
|
||||
* Make Arena::AllocateAligned() a public function.
|
||||
* Determine if ArenaDtor related code generation is necessary in one place.
|
||||
* Implement on demand register ArenaDtor for InlinedStringField
|
||||
|
||||
C++
|
||||
* manually *struct Cord fields to work better with arenas.
|
||||
* manually destruct map fields.
|
||||
* Generate narrower code
|
||||
* Fix https://github.com/protocolbuffers/protobuf/issues/9378 by removing
|
||||
shadowed _cached_size_ field
|
||||
|
||||
2022-01-28 version 3.19.4 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
|
||||
|
||||
Python
|
||||
|
@ -1019,6 +1019,7 @@ python_EXTRA_DIST= \
|
||||
python/google/protobuf/internal/any_test.proto \
|
||||
python/google/protobuf/internal/api_implementation.cc \
|
||||
python/google/protobuf/internal/api_implementation.py \
|
||||
python/google/protobuf/internal/builder.py \
|
||||
python/google/protobuf/internal/containers.py \
|
||||
python/google/protobuf/internal/decoder.py \
|
||||
python/google/protobuf/internal/descriptor_database_test.py \
|
||||
|
@ -4,8 +4,8 @@
|
||||
This directory contains benchmarking schemas and data sets that you
|
||||
can use to test a variety of performance scenarios against your
|
||||
protobuf language runtime. If you are looking for performance
|
||||
numbers of officially support languages, see [here](
|
||||
https://github.com/protocolbuffers/protobuf/blob/master/docs/performance.md)
|
||||
numbers of officially supported languages, see [Protobuf Performance](
|
||||
https://github.com/protocolbuffers/protobuf/blob/master/docs/performance.md).
|
||||
|
||||
## Prerequisite
|
||||
|
||||
|
@ -41,6 +41,8 @@ copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\php\php_gene
|
||||
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\plugin.h" include\google\protobuf\compiler\plugin.h
|
||||
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\plugin.pb.h" include\google\protobuf\compiler\plugin.pb.h
|
||||
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\python\python_generator.h" include\google\protobuf\compiler\python\python_generator.h
|
||||
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\python\python_pyi_generator.h" include\google\protobuf\compiler\python\python_pyi_generator.h
|
||||
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\python\python_helpers.h" include\google\protobuf\compiler\python\python_helpers.h
|
||||
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\ruby\ruby_generator.h" include\google\protobuf\compiler\ruby\ruby_generator.h
|
||||
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\descriptor.h" include\google\protobuf\descriptor.h
|
||||
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\descriptor.pb.h" include\google\protobuf\descriptor.pb.h
|
||||
|
@ -2,9 +2,9 @@ set(libprotobuf_lite_files
|
||||
${protobuf_source_dir}/src/google/protobuf/any_lite.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/arena.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/arenastring.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/arenaz_sampler.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/extension_set.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/generated_enum_util.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/generated_message_table_driven_lite.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/generated_message_tctable_lite.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/generated_message_util.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/implicit_weak_message.cc
|
||||
@ -38,15 +38,13 @@ set(libprotobuf_lite_includes
|
||||
${protobuf_source_dir}/src/google/protobuf/arena.h
|
||||
${protobuf_source_dir}/src/google/protobuf/arena_impl.h
|
||||
${protobuf_source_dir}/src/google/protobuf/arenastring.h
|
||||
${protobuf_source_dir}/src/google/protobuf/arenaz_sampler.h
|
||||
${protobuf_source_dir}/src/google/protobuf/explicitly_constructed.h
|
||||
${protobuf_source_dir}/src/google/protobuf/extension_set.h
|
||||
${protobuf_source_dir}/src/google/protobuf/extension_set_inl.h
|
||||
${protobuf_source_dir}/src/google/protobuf/generated_enum_util.h
|
||||
${protobuf_source_dir}/src/google/protobuf/generated_message_table_driven.h
|
||||
${protobuf_source_dir}/src/google/protobuf/generated_message_table_driven_lite.h
|
||||
${protobuf_source_dir}/src/google/protobuf/generated_message_tctable_decl.h
|
||||
${protobuf_source_dir}/src/google/protobuf/generated_message_tctable_impl.h
|
||||
${protobuf_source_dir}/src/google/protobuf/generated_message_tctable_impl.inc
|
||||
${protobuf_source_dir}/src/google/protobuf/generated_message_util.h
|
||||
${protobuf_source_dir}/src/google/protobuf/has_bits.h
|
||||
${protobuf_source_dir}/src/google/protobuf/implicit_weak_message.h
|
||||
|
@ -14,13 +14,13 @@ set(libprotobuf_files
|
||||
${protobuf_source_dir}/src/google/protobuf/field_mask.pb.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/generated_message_bases.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/generated_message_reflection.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/generated_message_table_driven.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/generated_message_tctable_full.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/io/gzip_stream.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/io/printer.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/io/tokenizer.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/map_field.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/message.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/reflection_internal.h
|
||||
${protobuf_source_dir}/src/google/protobuf/reflection_ops.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/service.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/source_context.pb.cc
|
||||
|
@ -36,6 +36,7 @@ set(libprotoc_files
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_doc_comment.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_enum.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_enum_field.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_enum_field.h
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_enum_field_lite.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_enum_lite.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_extension.cc
|
||||
@ -64,24 +65,38 @@ set(libprotoc_files
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/js/js_generator.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/js/well_known_types_embed.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_enum.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_enum.h
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_enum_field.h
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_extension.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_extension.h
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_field.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_field.h
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_file.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_file.h
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_generator.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_map_field.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_map_field.h
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_message.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_message.h
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_message_field.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_message_field.h
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_nsobject_methods.h
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_oneof.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_oneof.h
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.h
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/php/php_generator.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/plugin.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/plugin.pb.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/python/python_generator.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/python/python_helpers.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/python/python_pyi_generator.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/ruby/ruby_generator.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/subprocess.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/zip_writer.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/zip_writer.h
|
||||
)
|
||||
|
||||
set(libprotoc_headers
|
||||
@ -95,18 +110,16 @@ set(libprotoc_headers
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_generator.h
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_names.h
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_options.h
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/importer.h
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_generator.h
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_kotlin_generator.h
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_names.h
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/js/js_generator.h
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_generator.h
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_helpers.h
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/parser.h
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/php/php_generator.h
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/plugin.h
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/plugin.pb.h
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/python/python_generator.h
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/python/python_pyi_generator.h
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/ruby/ruby_generator.h
|
||||
)
|
||||
|
||||
|
@ -119,10 +119,10 @@ set(common_lite_test_files
|
||||
|
||||
set(common_test_files
|
||||
${common_lite_test_files}
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/mock_code_generator.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/map_test_util.inc
|
||||
${protobuf_source_dir}/src/google/protobuf/reflection_tester.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/test_util.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/test_util.inc
|
||||
${protobuf_source_dir}/src/google/protobuf/testing/file.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/testing/googletest.cc
|
||||
)
|
||||
@ -131,7 +131,9 @@ set(tests_files
|
||||
${protobuf_source_dir}/src/google/protobuf/any_test.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/arena_unittest.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/arenastring_unittest.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/arenaz_sampler_test.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/annotation_test_util.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/annotation_test_util.h
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/command_line_interface_unittest.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_move_unittest.cc
|
||||
@ -144,7 +146,6 @@ set(tests_files
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/importer_unittest.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_doc_comment_unittest.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_plugin_unittest.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/mock_code_generator.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/parser_unittest.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/compiler/python/python_plugin_unittest.cc
|
||||
@ -155,6 +156,7 @@ set(tests_files
|
||||
${protobuf_source_dir}/src/google/protobuf/dynamic_message_unittest.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/extension_set_unittest.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/generated_message_reflection_unittest.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/generated_message_tctable_lite_test.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/inlined_string_field_unittest.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/io/coded_stream_unittest.cc
|
||||
${protobuf_source_dir}/src/google/protobuf/io/io_win32_unittest.cc
|
||||
|
@ -361,7 +361,7 @@ class ConformanceJava {
|
||||
|
||||
case TEXT_FORMAT:
|
||||
return Conformance.ConformanceResponse.newBuilder()
|
||||
.setTextPayload(TextFormat.printToString(testMessage))
|
||||
.setTextPayload(TextFormat.printer().printToString(testMessage))
|
||||
.build();
|
||||
|
||||
default:
|
||||
|
@ -39,8 +39,8 @@ import sys
|
||||
import os
|
||||
from google.protobuf import json_format
|
||||
from google.protobuf import message
|
||||
from google.protobuf import test_messages_proto3_pb2
|
||||
from google.protobuf import test_messages_proto2_pb2
|
||||
from google3.third_party.protobuf import test_messages_proto3_pb2
|
||||
from google3.third_party.protobuf import test_messages_proto2_pb2
|
||||
from google.protobuf import text_format
|
||||
import conformance_pb2
|
||||
|
||||
|
@ -162,7 +162,7 @@ void ForkPipeRunner::RunTest(
|
||||
// We failed to read from the child, assume a crash and try to reap.
|
||||
GOOGLE_LOG(INFO) << "Trying to reap child, pid=" << child_pid_;
|
||||
|
||||
int status;
|
||||
int status = 0;
|
||||
waitpid(child_pid_, &status, WEXITED);
|
||||
|
||||
string error_msg;
|
||||
|
@ -25,7 +25,7 @@ namespace ProtobufTestMessages.Proto2 {
|
||||
byte[] descriptorData = global::System.Convert.FromBase64String(
|
||||
string.Concat(
|
||||
"Cipnb29nbGUvcHJvdG9idWYvdGVzdF9tZXNzYWdlc19wcm90bzIucHJvdG8S",
|
||||
"HXByb3RvYnVmX3Rlc3RfbWVzc2FnZXMucHJvdG8yIqQ+ChJUZXN0QWxsVHlw",
|
||||
"HXByb3RvYnVmX3Rlc3RfbWVzc2FnZXMucHJvdG8yIsQ+ChJUZXN0QWxsVHlw",
|
||||
"ZXNQcm90bzISFgoOb3B0aW9uYWxfaW50MzIYASABKAUSFgoOb3B0aW9uYWxf",
|
||||
"aW50NjQYAiABKAMSFwoPb3B0aW9uYWxfdWludDMyGAMgASgNEhcKD29wdGlv",
|
||||
"bmFsX3VpbnQ2NBgEIAEoBBIXCg9vcHRpb25hbF9zaW50MzIYBSABKBESFwoP",
|
||||
@ -148,79 +148,81 @@ namespace ProtobufTestMessages.Proto2 {
|
||||
"NTY3ODkxMjM0NTY3ODkSHQoNZGVmYXVsdF9mbG9hdBj7ASABKAI6BTllKzA5",
|
||||
"Eh4KDmRlZmF1bHRfZG91YmxlGPwBIAEoAToFN2UrMjISGwoMZGVmYXVsdF9i",
|
||||
"b29sGP0BIAEoCDoEdHJ1ZRIgCg5kZWZhdWx0X3N0cmluZxj+ASABKAk6B1Jv",
|
||||
"c2VidWQSEwoKZmllbGRuYW1lMRiRAyABKAUSFAoLZmllbGRfbmFtZTIYkgMg",
|
||||
"ASgFEhUKDF9maWVsZF9uYW1lMxiTAyABKAUSFgoNZmllbGRfX25hbWU0XxiU",
|
||||
"AyABKAUSFAoLZmllbGQwbmFtZTUYlQMgASgFEhYKDWZpZWxkXzBfbmFtZTYY",
|
||||
"lgMgASgFEhMKCmZpZWxkTmFtZTcYlwMgASgFEhMKCkZpZWxkTmFtZTgYmAMg",
|
||||
"ASgFEhQKC2ZpZWxkX05hbWU5GJkDIAEoBRIVCgxGaWVsZF9OYW1lMTAYmgMg",
|
||||
"ASgFEhUKDEZJRUxEX05BTUUxMRibAyABKAUSFQoMRklFTERfbmFtZTEyGJwD",
|
||||
"IAEoBRIXCg5fX2ZpZWxkX25hbWUxMxidAyABKAUSFwoOX19GaWVsZF9uYW1l",
|
||||
"MTQYngMgASgFEhYKDWZpZWxkX19uYW1lMTUYnwMgASgFEhYKDWZpZWxkX19O",
|
||||
"YW1lMTYYoAMgASgFEhcKDmZpZWxkX25hbWUxN19fGKEDIAEoBRIXCg5GaWVs",
|
||||
"ZF9uYW1lMThfXxiiAyABKAUaYgoNTmVzdGVkTWVzc2FnZRIJCgFhGAEgASgF",
|
||||
"EkYKC2NvcmVjdXJzaXZlGAIgASgLMjEucHJvdG9idWZfdGVzdF9tZXNzYWdl",
|
||||
"cy5wcm90bzIuVGVzdEFsbFR5cGVzUHJvdG8yGjQKEk1hcEludDMySW50MzJF",
|
||||
"bnRyeRILCgNrZXkYASABKAUSDQoFdmFsdWUYAiABKAU6AjgBGjQKEk1hcElu",
|
||||
"dDY0SW50NjRFbnRyeRILCgNrZXkYASABKAMSDQoFdmFsdWUYAiABKAM6AjgB",
|
||||
"GjYKFE1hcFVpbnQzMlVpbnQzMkVudHJ5EgsKA2tleRgBIAEoDRINCgV2YWx1",
|
||||
"ZRgCIAEoDToCOAEaNgoUTWFwVWludDY0VWludDY0RW50cnkSCwoDa2V5GAEg",
|
||||
"ASgEEg0KBXZhbHVlGAIgASgEOgI4ARo2ChRNYXBTaW50MzJTaW50MzJFbnRy",
|
||||
"eRILCgNrZXkYASABKBESDQoFdmFsdWUYAiABKBE6AjgBGjYKFE1hcFNpbnQ2",
|
||||
"NFNpbnQ2NEVudHJ5EgsKA2tleRgBIAEoEhINCgV2YWx1ZRgCIAEoEjoCOAEa",
|
||||
"OAoWTWFwRml4ZWQzMkZpeGVkMzJFbnRyeRILCgNrZXkYASABKAcSDQoFdmFs",
|
||||
"dWUYAiABKAc6AjgBGjgKFk1hcEZpeGVkNjRGaXhlZDY0RW50cnkSCwoDa2V5",
|
||||
"GAEgASgGEg0KBXZhbHVlGAIgASgGOgI4ARo6ChhNYXBTZml4ZWQzMlNmaXhl",
|
||||
"ZDMyRW50cnkSCwoDa2V5GAEgASgPEg0KBXZhbHVlGAIgASgPOgI4ARo6ChhN",
|
||||
"YXBTZml4ZWQ2NFNmaXhlZDY0RW50cnkSCwoDa2V5GAEgASgQEg0KBXZhbHVl",
|
||||
"GAIgASgQOgI4ARo0ChJNYXBJbnQzMkZsb2F0RW50cnkSCwoDa2V5GAEgASgF",
|
||||
"Eg0KBXZhbHVlGAIgASgCOgI4ARo1ChNNYXBJbnQzMkRvdWJsZUVudHJ5EgsK",
|
||||
"A2tleRgBIAEoBRINCgV2YWx1ZRgCIAEoAToCOAEaMgoQTWFwQm9vbEJvb2xF",
|
||||
"bnRyeRILCgNrZXkYASABKAgSDQoFdmFsdWUYAiABKAg6AjgBGjYKFE1hcFN0",
|
||||
"cmluZ1N0cmluZ0VudHJ5EgsKA2tleRgBIAEoCRINCgV2YWx1ZRgCIAEoCToC",
|
||||
"OAEaNQoTTWFwU3RyaW5nQnl0ZXNFbnRyeRILCgNrZXkYASABKAkSDQoFdmFs",
|
||||
"dWUYAiABKAw6AjgBGn4KG01hcFN0cmluZ05lc3RlZE1lc3NhZ2VFbnRyeRIL",
|
||||
"CgNrZXkYASABKAkSTgoFdmFsdWUYAiABKAsyPy5wcm90b2J1Zl90ZXN0X21l",
|
||||
"c3NhZ2VzLnByb3RvMi5UZXN0QWxsVHlwZXNQcm90bzIuTmVzdGVkTWVzc2Fn",
|
||||
"ZToCOAEacwocTWFwU3RyaW5nRm9yZWlnbk1lc3NhZ2VFbnRyeRILCgNrZXkY",
|
||||
"ASABKAkSQgoFdmFsdWUYAiABKAsyMy5wcm90b2J1Zl90ZXN0X21lc3NhZ2Vz",
|
||||
"LnByb3RvMi5Gb3JlaWduTWVzc2FnZVByb3RvMjoCOAEaeAoYTWFwU3RyaW5n",
|
||||
"TmVzdGVkRW51bUVudHJ5EgsKA2tleRgBIAEoCRJLCgV2YWx1ZRgCIAEoDjI8",
|
||||
"c2VidWQSHgoNZGVmYXVsdF9ieXRlcxj/ASABKAw6Bmpvc2h1YRITCgpmaWVs",
|
||||
"ZG5hbWUxGJEDIAEoBRIUCgtmaWVsZF9uYW1lMhiSAyABKAUSFQoMX2ZpZWxk",
|
||||
"X25hbWUzGJMDIAEoBRIWCg1maWVsZF9fbmFtZTRfGJQDIAEoBRIUCgtmaWVs",
|
||||
"ZDBuYW1lNRiVAyABKAUSFgoNZmllbGRfMF9uYW1lNhiWAyABKAUSEwoKZmll",
|
||||
"bGROYW1lNxiXAyABKAUSEwoKRmllbGROYW1lOBiYAyABKAUSFAoLZmllbGRf",
|
||||
"TmFtZTkYmQMgASgFEhUKDEZpZWxkX05hbWUxMBiaAyABKAUSFQoMRklFTERf",
|
||||
"TkFNRTExGJsDIAEoBRIVCgxGSUVMRF9uYW1lMTIYnAMgASgFEhcKDl9fZmll",
|
||||
"bGRfbmFtZTEzGJ0DIAEoBRIXCg5fX0ZpZWxkX25hbWUxNBieAyABKAUSFgoN",
|
||||
"ZmllbGRfX25hbWUxNRifAyABKAUSFgoNZmllbGRfX05hbWUxNhigAyABKAUS",
|
||||
"FwoOZmllbGRfbmFtZTE3X18YoQMgASgFEhcKDkZpZWxkX25hbWUxOF9fGKID",
|
||||
"IAEoBRpiCg1OZXN0ZWRNZXNzYWdlEgkKAWEYASABKAUSRgoLY29yZWN1cnNp",
|
||||
"dmUYAiABKAsyMS5wcm90b2J1Zl90ZXN0X21lc3NhZ2VzLnByb3RvMi5UZXN0",
|
||||
"QWxsVHlwZXNQcm90bzIaNAoSTWFwSW50MzJJbnQzMkVudHJ5EgsKA2tleRgB",
|
||||
"IAEoBRINCgV2YWx1ZRgCIAEoBToCOAEaNAoSTWFwSW50NjRJbnQ2NEVudHJ5",
|
||||
"EgsKA2tleRgBIAEoAxINCgV2YWx1ZRgCIAEoAzoCOAEaNgoUTWFwVWludDMy",
|
||||
"VWludDMyRW50cnkSCwoDa2V5GAEgASgNEg0KBXZhbHVlGAIgASgNOgI4ARo2",
|
||||
"ChRNYXBVaW50NjRVaW50NjRFbnRyeRILCgNrZXkYASABKAQSDQoFdmFsdWUY",
|
||||
"AiABKAQ6AjgBGjYKFE1hcFNpbnQzMlNpbnQzMkVudHJ5EgsKA2tleRgBIAEo",
|
||||
"ERINCgV2YWx1ZRgCIAEoEToCOAEaNgoUTWFwU2ludDY0U2ludDY0RW50cnkS",
|
||||
"CwoDa2V5GAEgASgSEg0KBXZhbHVlGAIgASgSOgI4ARo4ChZNYXBGaXhlZDMy",
|
||||
"Rml4ZWQzMkVudHJ5EgsKA2tleRgBIAEoBxINCgV2YWx1ZRgCIAEoBzoCOAEa",
|
||||
"OAoWTWFwRml4ZWQ2NEZpeGVkNjRFbnRyeRILCgNrZXkYASABKAYSDQoFdmFs",
|
||||
"dWUYAiABKAY6AjgBGjoKGE1hcFNmaXhlZDMyU2ZpeGVkMzJFbnRyeRILCgNr",
|
||||
"ZXkYASABKA8SDQoFdmFsdWUYAiABKA86AjgBGjoKGE1hcFNmaXhlZDY0U2Zp",
|
||||
"eGVkNjRFbnRyeRILCgNrZXkYASABKBASDQoFdmFsdWUYAiABKBA6AjgBGjQK",
|
||||
"Ek1hcEludDMyRmxvYXRFbnRyeRILCgNrZXkYASABKAUSDQoFdmFsdWUYAiAB",
|
||||
"KAI6AjgBGjUKE01hcEludDMyRG91YmxlRW50cnkSCwoDa2V5GAEgASgFEg0K",
|
||||
"BXZhbHVlGAIgASgBOgI4ARoyChBNYXBCb29sQm9vbEVudHJ5EgsKA2tleRgB",
|
||||
"IAEoCBINCgV2YWx1ZRgCIAEoCDoCOAEaNgoUTWFwU3RyaW5nU3RyaW5nRW50",
|
||||
"cnkSCwoDa2V5GAEgASgJEg0KBXZhbHVlGAIgASgJOgI4ARo1ChNNYXBTdHJp",
|
||||
"bmdCeXRlc0VudHJ5EgsKA2tleRgBIAEoCRINCgV2YWx1ZRgCIAEoDDoCOAEa",
|
||||
"fgobTWFwU3RyaW5nTmVzdGVkTWVzc2FnZUVudHJ5EgsKA2tleRgBIAEoCRJO",
|
||||
"CgV2YWx1ZRgCIAEoCzI/LnByb3RvYnVmX3Rlc3RfbWVzc2FnZXMucHJvdG8y",
|
||||
"LlRlc3RBbGxUeXBlc1Byb3RvMi5OZXN0ZWRNZXNzYWdlOgI4ARpzChxNYXBT",
|
||||
"dHJpbmdGb3JlaWduTWVzc2FnZUVudHJ5EgsKA2tleRgBIAEoCRJCCgV2YWx1",
|
||||
"ZRgCIAEoCzIzLnByb3RvYnVmX3Rlc3RfbWVzc2FnZXMucHJvdG8yLkZvcmVp",
|
||||
"Z25NZXNzYWdlUHJvdG8yOgI4ARp4ChhNYXBTdHJpbmdOZXN0ZWRFbnVtRW50",
|
||||
"cnkSCwoDa2V5GAEgASgJEksKBXZhbHVlGAIgASgOMjwucHJvdG9idWZfdGVz",
|
||||
"dF9tZXNzYWdlcy5wcm90bzIuVGVzdEFsbFR5cGVzUHJvdG8yLk5lc3RlZEVu",
|
||||
"dW06AjgBGm0KGU1hcFN0cmluZ0ZvcmVpZ25FbnVtRW50cnkSCwoDa2V5GAEg",
|
||||
"ASgJEj8KBXZhbHVlGAIgASgOMjAucHJvdG9idWZfdGVzdF9tZXNzYWdlcy5w",
|
||||
"cm90bzIuRm9yZWlnbkVudW1Qcm90bzI6AjgBGjMKBERhdGESFAoLZ3JvdXBf",
|
||||
"aW50MzIYygEgASgFEhUKDGdyb3VwX3VpbnQzMhjLASABKA0aIQoRTWVzc2Fn",
|
||||
"ZVNldENvcnJlY3QqCAgEEP////8HOgIIARrgAQobTWVzc2FnZVNldENvcnJl",
|
||||
"Y3RFeHRlbnNpb24xEgsKA3N0chgZIAEoCTKzAQoVbWVzc2FnZV9zZXRfZXh0",
|
||||
"ZW5zaW9uEkMucHJvdG9idWZfdGVzdF9tZXNzYWdlcy5wcm90bzIuVGVzdEFs",
|
||||
"bFR5cGVzUHJvdG8yLk1lc3NhZ2VTZXRDb3JyZWN0GPm7XiABKAsyTS5wcm90",
|
||||
"b2J1Zl90ZXN0X21lc3NhZ2VzLnByb3RvMi5UZXN0QWxsVHlwZXNQcm90bzIu",
|
||||
"TWVzc2FnZVNldENvcnJlY3RFeHRlbnNpb24xGt8BChtNZXNzYWdlU2V0Q29y",
|
||||
"cmVjdEV4dGVuc2lvbjISCQoBaRgJIAEoBTK0AQoVbWVzc2FnZV9zZXRfZXh0",
|
||||
"ZW5zaW9uEkMucHJvdG9idWZfdGVzdF9tZXNzYWdlcy5wcm90bzIuVGVzdEFs",
|
||||
"bFR5cGVzUHJvdG8yLk1lc3NhZ2VTZXRDb3JyZWN0GJCz/AEgASgLMk0ucHJv",
|
||||
"dG9idWZfdGVzdF9tZXNzYWdlcy5wcm90bzIuVGVzdEFsbFR5cGVzUHJvdG8y",
|
||||
"Lk1lc3NhZ2VTZXRDb3JyZWN0RXh0ZW5zaW9uMiI5CgpOZXN0ZWRFbnVtEgcK",
|
||||
"A0ZPTxAAEgcKA0JBUhABEgcKA0JBWhACEhAKA05FRxD///////////8BKgUI",
|
||||
"eBDJAUINCgtvbmVvZl9maWVsZEoGCOgHEJBOIiEKFEZvcmVpZ25NZXNzYWdl",
|
||||
"UHJvdG8yEgkKAWMYASABKAUiwQIKFVVua25vd25Ub1Rlc3RBbGxUeXBlcxIX",
|
||||
"Cg5vcHRpb25hbF9pbnQzMhjpByABKAUSGAoPb3B0aW9uYWxfc3RyaW5nGOoH",
|
||||
"IAEoCRJMCg5uZXN0ZWRfbWVzc2FnZRjrByABKAsyMy5wcm90b2J1Zl90ZXN0",
|
||||
"X21lc3NhZ2VzLnByb3RvMi5Gb3JlaWduTWVzc2FnZVByb3RvMhJaCg1vcHRp",
|
||||
"b25hbGdyb3VwGOwHIAEoCjJCLnByb3RvYnVmX3Rlc3RfbWVzc2FnZXMucHJv",
|
||||
"dG8yLlVua25vd25Ub1Rlc3RBbGxUeXBlcy5PcHRpb25hbEdyb3VwEhYKDW9w",
|
||||
"dGlvbmFsX2Jvb2wY7gcgASgIEhcKDnJlcGVhdGVkX2ludDMyGPMHIAMoBRoa",
|
||||
"Cg1PcHRpb25hbEdyb3VwEgkKAWEYASABKAUiFgoUTnVsbEh5cG90aGVzaXNQ",
|
||||
"cm90bzIiLwoORW51bU9ubHlQcm90bzIiHQoEQm9vbBIKCgZrRmFsc2UQABIJ",
|
||||
"CgVrVHJ1ZRABIh8KD09uZVN0cmluZ1Byb3RvMhIMCgRkYXRhGAEgASgJKkYK",
|
||||
"EUZvcmVpZ25FbnVtUHJvdG8yEg8KC0ZPUkVJR05fRk9PEAASDwoLRk9SRUlH",
|
||||
"Tl9CQVIQARIPCgtGT1JFSUdOX0JBWhACOkoKD2V4dGVuc2lvbl9pbnQzMhIx",
|
||||
"LnByb3RvYnVmX3Rlc3RfbWVzc2FnZXMucHJvdG8yLlRlc3RBbGxUeXBlc1By",
|
||||
"b3RvMi5OZXN0ZWRFbnVtOgI4ARptChlNYXBTdHJpbmdGb3JlaWduRW51bUVu",
|
||||
"dHJ5EgsKA2tleRgBIAEoCRI/CgV2YWx1ZRgCIAEoDjIwLnByb3RvYnVmX3Rl",
|
||||
"c3RfbWVzc2FnZXMucHJvdG8yLkZvcmVpZ25FbnVtUHJvdG8yOgI4ARozCgRE",
|
||||
"YXRhEhQKC2dyb3VwX2ludDMyGMoBIAEoBRIVCgxncm91cF91aW50MzIYywEg",
|
||||
"ASgNGiEKEU1lc3NhZ2VTZXRDb3JyZWN0KggIBBD/////BzoCCAEa4AEKG01l",
|
||||
"c3NhZ2VTZXRDb3JyZWN0RXh0ZW5zaW9uMRILCgNzdHIYGSABKAkyswEKFW1l",
|
||||
"c3NhZ2Vfc2V0X2V4dGVuc2lvbhJDLnByb3RvYnVmX3Rlc3RfbWVzc2FnZXMu",
|
||||
"cHJvdG8yLlRlc3RBbGxUeXBlc1Byb3RvMi5NZXNzYWdlU2V0Q29ycmVjdBj5",
|
||||
"u14gASgLMk0ucHJvdG9idWZfdGVzdF9tZXNzYWdlcy5wcm90bzIuVGVzdEFs",
|
||||
"bFR5cGVzUHJvdG8yLk1lc3NhZ2VTZXRDb3JyZWN0RXh0ZW5zaW9uMRrfAQob",
|
||||
"TWVzc2FnZVNldENvcnJlY3RFeHRlbnNpb24yEgkKAWkYCSABKAUytAEKFW1l",
|
||||
"c3NhZ2Vfc2V0X2V4dGVuc2lvbhJDLnByb3RvYnVmX3Rlc3RfbWVzc2FnZXMu",
|
||||
"cHJvdG8yLlRlc3RBbGxUeXBlc1Byb3RvMi5NZXNzYWdlU2V0Q29ycmVjdBiQ",
|
||||
"s/wBIAEoCzJNLnByb3RvYnVmX3Rlc3RfbWVzc2FnZXMucHJvdG8yLlRlc3RB",
|
||||
"bGxUeXBlc1Byb3RvMi5NZXNzYWdlU2V0Q29ycmVjdEV4dGVuc2lvbjIiOQoK",
|
||||
"TmVzdGVkRW51bRIHCgNGT08QABIHCgNCQVIQARIHCgNCQVoQAhIQCgNORUcQ",
|
||||
"////////////ASoFCHgQyQFCDQoLb25lb2ZfZmllbGRKBgjoBxCQTiIhChRG",
|
||||
"b3JlaWduTWVzc2FnZVByb3RvMhIJCgFjGAEgASgFIsECChVVbmtub3duVG9U",
|
||||
"ZXN0QWxsVHlwZXMSFwoOb3B0aW9uYWxfaW50MzIY6QcgASgFEhgKD29wdGlv",
|
||||
"bmFsX3N0cmluZxjqByABKAkSTAoObmVzdGVkX21lc3NhZ2UY6wcgASgLMjMu",
|
||||
"cHJvdG9idWZfdGVzdF9tZXNzYWdlcy5wcm90bzIuRm9yZWlnbk1lc3NhZ2VQ",
|
||||
"cm90bzISWgoNb3B0aW9uYWxncm91cBjsByABKAoyQi5wcm90b2J1Zl90ZXN0",
|
||||
"X21lc3NhZ2VzLnByb3RvMi5Vbmtub3duVG9UZXN0QWxsVHlwZXMuT3B0aW9u",
|
||||
"YWxHcm91cBIWCg1vcHRpb25hbF9ib29sGO4HIAEoCBIXCg5yZXBlYXRlZF9p",
|
||||
"bnQzMhjzByADKAUaGgoNT3B0aW9uYWxHcm91cBIJCgFhGAEgASgFIhYKFE51",
|
||||
"bGxIeXBvdGhlc2lzUHJvdG8yIi8KDkVudW1Pbmx5UHJvdG8yIh0KBEJvb2wS",
|
||||
"CgoGa0ZhbHNlEAASCQoFa1RydWUQASpGChFGb3JlaWduRW51bVByb3RvMhIP",
|
||||
"CgtGT1JFSUdOX0ZPTxAAEg8KC0ZPUkVJR05fQkFSEAESDwoLRk9SRUlHTl9C",
|
||||
"QVoQAjpKCg9leHRlbnNpb25faW50MzISMS5wcm90b2J1Zl90ZXN0X21lc3Nh",
|
||||
"Z2VzLnByb3RvMi5UZXN0QWxsVHlwZXNQcm90bzIYeCABKAVCLwooY29tLmdv",
|
||||
"b2dsZS5wcm90b2J1Zl90ZXN0X21lc3NhZ2VzLnByb3RvMkgB+AEB"));
|
||||
"b3RvMhh4IAEoBUIvCihjb20uZ29vZ2xlLnByb3RvYnVmX3Rlc3RfbWVzc2Fn",
|
||||
"ZXMucHJvdG8ySAH4AQE="));
|
||||
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
|
||||
new pbr::FileDescriptor[] { },
|
||||
new pbr::GeneratedClrTypeInfo(new[] {typeof(global::ProtobufTestMessages.Proto2.ForeignEnumProto2), }, new pb::Extension[] { TestMessagesProto2Extensions.ExtensionInt32 }, new pbr::GeneratedClrTypeInfo[] {
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::ProtobufTestMessages.Proto2.TestAllTypesProto2), global::ProtobufTestMessages.Proto2.TestAllTypesProto2.Parser, new[]{ "OptionalInt32", "OptionalInt64", "OptionalUint32", "OptionalUint64", "OptionalSint32", "OptionalSint64", "OptionalFixed32", "OptionalFixed64", "OptionalSfixed32", "OptionalSfixed64", "OptionalFloat", "OptionalDouble", "OptionalBool", "OptionalString", "OptionalBytes", "OptionalNestedMessage", "OptionalForeignMessage", "OptionalNestedEnum", "OptionalForeignEnum", "OptionalStringPiece", "OptionalCord", "RecursiveMessage", "RepeatedInt32", "RepeatedInt64", "RepeatedUint32", "RepeatedUint64", "RepeatedSint32", "RepeatedSint64", "RepeatedFixed32", "RepeatedFixed64", "RepeatedSfixed32", "RepeatedSfixed64", "RepeatedFloat", "RepeatedDouble", "RepeatedBool", "RepeatedString", "RepeatedBytes", "RepeatedNestedMessage", "RepeatedForeignMessage", "RepeatedNestedEnum", "RepeatedForeignEnum", "RepeatedStringPiece", "RepeatedCord", "PackedInt32", "PackedInt64", "PackedUint32", "PackedUint64", "PackedSint32", "PackedSint64", "PackedFixed32", "PackedFixed64", "PackedSfixed32", "PackedSfixed64", "PackedFloat", "PackedDouble", "PackedBool", "PackedNestedEnum", "UnpackedInt32", "UnpackedInt64", "UnpackedUint32", "UnpackedUint64", "UnpackedSint32", "UnpackedSint64", "UnpackedFixed32", "UnpackedFixed64", "UnpackedSfixed32", "UnpackedSfixed64", "UnpackedFloat", "UnpackedDouble", "UnpackedBool", "UnpackedNestedEnum", "MapInt32Int32", "MapInt64Int64", "MapUint32Uint32", "MapUint64Uint64", "MapSint32Sint32", "MapSint64Sint64", "MapFixed32Fixed32", "MapFixed64Fixed64", "MapSfixed32Sfixed32", "MapSfixed64Sfixed64", "MapInt32Float", "MapInt32Double", "MapBoolBool", "MapStringString", "MapStringBytes", "MapStringNestedMessage", "MapStringForeignMessage", "MapStringNestedEnum", "MapStringForeignEnum", "OneofUint32", "OneofNestedMessage", "OneofString", "OneofBytes", "OneofBool", "OneofUint64", "OneofFloat", "OneofDouble", "OneofEnum", "Data", "DefaultInt32", "DefaultInt64", "DefaultUint32", "DefaultUint64", "DefaultSint32", "DefaultSint64", "DefaultFixed32", "DefaultFixed64", "DefaultSfixed32", "DefaultSfixed64", "DefaultFloat", "DefaultDouble", "DefaultBool", "DefaultString", "Fieldname1", "FieldName2", "FieldName3", "FieldName4", "Field0Name5", "Field0Name6", "FieldName7", "FieldName8", "FieldName9", "FieldName10", "FIELDNAME11", "FIELDName12", "FieldName13", "FieldName14", "FieldName15", "FieldName16", "FieldName17", "FieldName18" }, new[]{ "OneofField" }, new[]{ typeof(global::ProtobufTestMessages.Proto2.TestAllTypesProto2.Types.NestedEnum) }, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::ProtobufTestMessages.Proto2.TestAllTypesProto2.Types.NestedMessage), global::ProtobufTestMessages.Proto2.TestAllTypesProto2.Types.NestedMessage.Parser, new[]{ "A", "Corecursive" }, null, null, null, null),
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::ProtobufTestMessages.Proto2.TestAllTypesProto2), global::ProtobufTestMessages.Proto2.TestAllTypesProto2.Parser, new[]{ "OptionalInt32", "OptionalInt64", "OptionalUint32", "OptionalUint64", "OptionalSint32", "OptionalSint64", "OptionalFixed32", "OptionalFixed64", "OptionalSfixed32", "OptionalSfixed64", "OptionalFloat", "OptionalDouble", "OptionalBool", "OptionalString", "OptionalBytes", "OptionalNestedMessage", "OptionalForeignMessage", "OptionalNestedEnum", "OptionalForeignEnum", "OptionalStringPiece", "OptionalCord", "RecursiveMessage", "RepeatedInt32", "RepeatedInt64", "RepeatedUint32", "RepeatedUint64", "RepeatedSint32", "RepeatedSint64", "RepeatedFixed32", "RepeatedFixed64", "RepeatedSfixed32", "RepeatedSfixed64", "RepeatedFloat", "RepeatedDouble", "RepeatedBool", "RepeatedString", "RepeatedBytes", "RepeatedNestedMessage", "RepeatedForeignMessage", "RepeatedNestedEnum", "RepeatedForeignEnum", "RepeatedStringPiece", "RepeatedCord", "PackedInt32", "PackedInt64", "PackedUint32", "PackedUint64", "PackedSint32", "PackedSint64", "PackedFixed32", "PackedFixed64", "PackedSfixed32", "PackedSfixed64", "PackedFloat", "PackedDouble", "PackedBool", "PackedNestedEnum", "UnpackedInt32", "UnpackedInt64", "UnpackedUint32", "UnpackedUint64", "UnpackedSint32", "UnpackedSint64", "UnpackedFixed32", "UnpackedFixed64", "UnpackedSfixed32", "UnpackedSfixed64", "UnpackedFloat", "UnpackedDouble", "UnpackedBool", "UnpackedNestedEnum", "MapInt32Int32", "MapInt64Int64", "MapUint32Uint32", "MapUint64Uint64", "MapSint32Sint32", "MapSint64Sint64", "MapFixed32Fixed32", "MapFixed64Fixed64", "MapSfixed32Sfixed32", "MapSfixed64Sfixed64", "MapInt32Float", "MapInt32Double", "MapBoolBool", "MapStringString", "MapStringBytes", "MapStringNestedMessage", "MapStringForeignMessage", "MapStringNestedEnum", "MapStringForeignEnum", "OneofUint32", "OneofNestedMessage", "OneofString", "OneofBytes", "OneofBool", "OneofUint64", "OneofFloat", "OneofDouble", "OneofEnum", "Data", "DefaultInt32", "DefaultInt64", "DefaultUint32", "DefaultUint64", "DefaultSint32", "DefaultSint64", "DefaultFixed32", "DefaultFixed64", "DefaultSfixed32", "DefaultSfixed64", "DefaultFloat", "DefaultDouble", "DefaultBool", "DefaultString", "DefaultBytes", "Fieldname1", "FieldName2", "FieldName3", "FieldName4", "Field0Name5", "Field0Name6", "FieldName7", "FieldName8", "FieldName9", "FieldName10", "FIELDNAME11", "FIELDName12", "FieldName13", "FieldName14", "FieldName15", "FieldName16", "FieldName17", "FieldName18" }, new[]{ "OneofField" }, new[]{ typeof(global::ProtobufTestMessages.Proto2.TestAllTypesProto2.Types.NestedEnum) }, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::ProtobufTestMessages.Proto2.TestAllTypesProto2.Types.NestedMessage), global::ProtobufTestMessages.Proto2.TestAllTypesProto2.Types.NestedMessage.Parser, new[]{ "A", "Corecursive" }, null, null, null, null),
|
||||
null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, new pbr::GeneratedClrTypeInfo(typeof(global::ProtobufTestMessages.Proto2.TestAllTypesProto2.Types.Data), global::ProtobufTestMessages.Proto2.TestAllTypesProto2.Types.Data.Parser, new[]{ "GroupInt32", "GroupUint32" }, null, null, null, null),
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::ProtobufTestMessages.Proto2.TestAllTypesProto2.Types.MessageSetCorrect), global::ProtobufTestMessages.Proto2.TestAllTypesProto2.Types.MessageSetCorrect.Parser, null, null, null, null, null),
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::ProtobufTestMessages.Proto2.TestAllTypesProto2.Types.MessageSetCorrectExtension1), global::ProtobufTestMessages.Proto2.TestAllTypesProto2.Types.MessageSetCorrectExtension1.Parser, new[]{ "Str" }, null, null, new pb::Extension[] { global::ProtobufTestMessages.Proto2.TestAllTypesProto2.Types.MessageSetCorrectExtension1.Extensions.MessageSetExtension }, null),
|
||||
@ -228,7 +230,8 @@ namespace ProtobufTestMessages.Proto2 {
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::ProtobufTestMessages.Proto2.ForeignMessageProto2), global::ProtobufTestMessages.Proto2.ForeignMessageProto2.Parser, new[]{ "C" }, null, null, null, null),
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::ProtobufTestMessages.Proto2.UnknownToTestAllTypes), global::ProtobufTestMessages.Proto2.UnknownToTestAllTypes.Parser, new[]{ "OptionalInt32", "OptionalString", "NestedMessage", "OptionalGroup", "OptionalBool", "RepeatedInt32" }, null, null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::ProtobufTestMessages.Proto2.UnknownToTestAllTypes.Types.OptionalGroup), global::ProtobufTestMessages.Proto2.UnknownToTestAllTypes.Types.OptionalGroup.Parser, new[]{ "A" }, null, null, null, null)}),
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::ProtobufTestMessages.Proto2.NullHypothesisProto2), global::ProtobufTestMessages.Proto2.NullHypothesisProto2.Parser, null, null, null, null, null),
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::ProtobufTestMessages.Proto2.EnumOnlyProto2), global::ProtobufTestMessages.Proto2.EnumOnlyProto2.Parser, null, null, new[]{ typeof(global::ProtobufTestMessages.Proto2.EnumOnlyProto2.Types.Bool) }, null, null)
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::ProtobufTestMessages.Proto2.EnumOnlyProto2), global::ProtobufTestMessages.Proto2.EnumOnlyProto2.Parser, null, null, new[]{ typeof(global::ProtobufTestMessages.Proto2.EnumOnlyProto2.Types.Bool) }, null, null),
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::ProtobufTestMessages.Proto2.OneStringProto2), global::ProtobufTestMessages.Proto2.OneStringProto2.Parser, new[]{ "Data" }, null, null, null, null)
|
||||
}));
|
||||
}
|
||||
#endregion
|
||||
@ -404,6 +407,7 @@ namespace ProtobufTestMessages.Proto2 {
|
||||
defaultDouble_ = other.defaultDouble_;
|
||||
defaultBool_ = other.defaultBool_;
|
||||
defaultString_ = other.defaultString_;
|
||||
defaultBytes_ = other.defaultBytes_;
|
||||
fieldname1_ = other.fieldname1_;
|
||||
fieldName2_ = other.fieldName2_;
|
||||
FieldName3_ = other.FieldName3_;
|
||||
@ -2394,6 +2398,32 @@ namespace ProtobufTestMessages.Proto2 {
|
||||
defaultString_ = null;
|
||||
}
|
||||
|
||||
/// <summary>Field number for the "default_bytes" field.</summary>
|
||||
public const int DefaultBytesFieldNumber = 255;
|
||||
private readonly static pb::ByteString DefaultBytesDefaultValue = pb::ByteString.FromBase64("am9zaHVh");
|
||||
|
||||
private pb::ByteString defaultBytes_;
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public pb::ByteString DefaultBytes {
|
||||
get { return defaultBytes_ ?? DefaultBytesDefaultValue; }
|
||||
set {
|
||||
defaultBytes_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
|
||||
}
|
||||
}
|
||||
/// <summary>Gets whether the "default_bytes" field is set</summary>
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public bool HasDefaultBytes {
|
||||
get { return defaultBytes_ != null; }
|
||||
}
|
||||
/// <summary>Clears the value of the "default_bytes" field</summary>
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public void ClearDefaultBytes() {
|
||||
defaultBytes_ = null;
|
||||
}
|
||||
|
||||
/// <summary>Field number for the "fieldname1" field.</summary>
|
||||
public const int Fieldname1FieldNumber = 401;
|
||||
private readonly static int Fieldname1DefaultValue = 0;
|
||||
@ -3041,6 +3071,7 @@ namespace ProtobufTestMessages.Proto2 {
|
||||
if (!pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.Equals(DefaultDouble, other.DefaultDouble)) return false;
|
||||
if (DefaultBool != other.DefaultBool) return false;
|
||||
if (DefaultString != other.DefaultString) return false;
|
||||
if (DefaultBytes != other.DefaultBytes) return false;
|
||||
if (Fieldname1 != other.Fieldname1) return false;
|
||||
if (FieldName2 != other.FieldName2) return false;
|
||||
if (FieldName3 != other.FieldName3) return false;
|
||||
@ -3184,6 +3215,7 @@ namespace ProtobufTestMessages.Proto2 {
|
||||
if (HasDefaultDouble) hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(DefaultDouble);
|
||||
if (HasDefaultBool) hash ^= DefaultBool.GetHashCode();
|
||||
if (HasDefaultString) hash ^= DefaultString.GetHashCode();
|
||||
if (HasDefaultBytes) hash ^= DefaultBytes.GetHashCode();
|
||||
if (HasFieldname1) hash ^= Fieldname1.GetHashCode();
|
||||
if (HasFieldName2) hash ^= FieldName2.GetHashCode();
|
||||
if (HasFieldName3) hash ^= FieldName3.GetHashCode();
|
||||
@ -3477,6 +3509,10 @@ namespace ProtobufTestMessages.Proto2 {
|
||||
output.WriteRawTag(242, 15);
|
||||
output.WriteString(DefaultString);
|
||||
}
|
||||
if (HasDefaultBytes) {
|
||||
output.WriteRawTag(250, 15);
|
||||
output.WriteBytes(DefaultBytes);
|
||||
}
|
||||
if (HasFieldname1) {
|
||||
output.WriteRawTag(136, 25);
|
||||
output.WriteInt32(Fieldname1);
|
||||
@ -3815,6 +3851,10 @@ namespace ProtobufTestMessages.Proto2 {
|
||||
output.WriteRawTag(242, 15);
|
||||
output.WriteString(DefaultString);
|
||||
}
|
||||
if (HasDefaultBytes) {
|
||||
output.WriteRawTag(250, 15);
|
||||
output.WriteBytes(DefaultBytes);
|
||||
}
|
||||
if (HasFieldname1) {
|
||||
output.WriteRawTag(136, 25);
|
||||
output.WriteInt32(Fieldname1);
|
||||
@ -4106,6 +4146,9 @@ namespace ProtobufTestMessages.Proto2 {
|
||||
if (HasDefaultString) {
|
||||
size += 2 + pb::CodedOutputStream.ComputeStringSize(DefaultString);
|
||||
}
|
||||
if (HasDefaultBytes) {
|
||||
size += 2 + pb::CodedOutputStream.ComputeBytesSize(DefaultBytes);
|
||||
}
|
||||
if (HasFieldname1) {
|
||||
size += 2 + pb::CodedOutputStream.ComputeInt32Size(Fieldname1);
|
||||
}
|
||||
@ -4366,6 +4409,9 @@ namespace ProtobufTestMessages.Proto2 {
|
||||
if (other.HasDefaultString) {
|
||||
DefaultString = other.DefaultString;
|
||||
}
|
||||
if (other.HasDefaultBytes) {
|
||||
DefaultBytes = other.DefaultBytes;
|
||||
}
|
||||
if (other.HasFieldname1) {
|
||||
Fieldname1 = other.Fieldname1;
|
||||
}
|
||||
@ -4988,6 +5034,10 @@ namespace ProtobufTestMessages.Proto2 {
|
||||
DefaultString = input.ReadString();
|
||||
break;
|
||||
}
|
||||
case 2042: {
|
||||
DefaultBytes = input.ReadBytes();
|
||||
break;
|
||||
}
|
||||
case 3208: {
|
||||
Fieldname1 = input.ReadInt32();
|
||||
break;
|
||||
@ -5594,6 +5644,10 @@ namespace ProtobufTestMessages.Proto2 {
|
||||
DefaultString = input.ReadString();
|
||||
break;
|
||||
}
|
||||
case 2042: {
|
||||
DefaultBytes = input.ReadBytes();
|
||||
break;
|
||||
}
|
||||
case 3208: {
|
||||
Fieldname1 = input.ReadInt32();
|
||||
break;
|
||||
@ -8043,6 +8097,209 @@ namespace ProtobufTestMessages.Proto2 {
|
||||
|
||||
}
|
||||
|
||||
public sealed partial class OneStringProto2 : pb::IMessage<OneStringProto2>
|
||||
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
||||
, pb::IBufferMessage
|
||||
#endif
|
||||
{
|
||||
private static readonly pb::MessageParser<OneStringProto2> _parser = new pb::MessageParser<OneStringProto2>(() => new OneStringProto2());
|
||||
private pb::UnknownFieldSet _unknownFields;
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public static pb::MessageParser<OneStringProto2> Parser { get { return _parser; } }
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public static pbr::MessageDescriptor Descriptor {
|
||||
get { return global::ProtobufTestMessages.Proto2.TestMessagesProto2Reflection.Descriptor.MessageTypes[5]; }
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
pbr::MessageDescriptor pb::IMessage.Descriptor {
|
||||
get { return Descriptor; }
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public OneStringProto2() {
|
||||
OnConstruction();
|
||||
}
|
||||
|
||||
partial void OnConstruction();
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public OneStringProto2(OneStringProto2 other) : this() {
|
||||
data_ = other.data_;
|
||||
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public OneStringProto2 Clone() {
|
||||
return new OneStringProto2(this);
|
||||
}
|
||||
|
||||
/// <summary>Field number for the "data" field.</summary>
|
||||
public const int DataFieldNumber = 1;
|
||||
private readonly static string DataDefaultValue = "";
|
||||
|
||||
private string data_;
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public string Data {
|
||||
get { return data_ ?? DataDefaultValue; }
|
||||
set {
|
||||
data_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
|
||||
}
|
||||
}
|
||||
/// <summary>Gets whether the "data" field is set</summary>
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public bool HasData {
|
||||
get { return data_ != null; }
|
||||
}
|
||||
/// <summary>Clears the value of the "data" field</summary>
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public void ClearData() {
|
||||
data_ = null;
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public override bool Equals(object other) {
|
||||
return Equals(other as OneStringProto2);
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public bool Equals(OneStringProto2 other) {
|
||||
if (ReferenceEquals(other, null)) {
|
||||
return false;
|
||||
}
|
||||
if (ReferenceEquals(other, this)) {
|
||||
return true;
|
||||
}
|
||||
if (Data != other.Data) return false;
|
||||
return Equals(_unknownFields, other._unknownFields);
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public override int GetHashCode() {
|
||||
int hash = 1;
|
||||
if (HasData) hash ^= Data.GetHashCode();
|
||||
if (_unknownFields != null) {
|
||||
hash ^= _unknownFields.GetHashCode();
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public override string ToString() {
|
||||
return pb::JsonFormatter.ToDiagnosticString(this);
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public void WriteTo(pb::CodedOutputStream output) {
|
||||
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
||||
output.WriteRawMessage(this);
|
||||
#else
|
||||
if (HasData) {
|
||||
output.WriteRawTag(10);
|
||||
output.WriteString(Data);
|
||||
}
|
||||
if (_unknownFields != null) {
|
||||
_unknownFields.WriteTo(output);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) {
|
||||
if (HasData) {
|
||||
output.WriteRawTag(10);
|
||||
output.WriteString(Data);
|
||||
}
|
||||
if (_unknownFields != null) {
|
||||
_unknownFields.WriteTo(ref output);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public int CalculateSize() {
|
||||
int size = 0;
|
||||
if (HasData) {
|
||||
size += 1 + pb::CodedOutputStream.ComputeStringSize(Data);
|
||||
}
|
||||
if (_unknownFields != null) {
|
||||
size += _unknownFields.CalculateSize();
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public void MergeFrom(OneStringProto2 other) {
|
||||
if (other == null) {
|
||||
return;
|
||||
}
|
||||
if (other.HasData) {
|
||||
Data = other.Data;
|
||||
}
|
||||
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public void MergeFrom(pb::CodedInputStream input) {
|
||||
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
||||
input.ReadRawMessage(this);
|
||||
#else
|
||||
uint tag;
|
||||
while ((tag = input.ReadTag()) != 0) {
|
||||
switch(tag) {
|
||||
default:
|
||||
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
|
||||
break;
|
||||
case 10: {
|
||||
Data = input.ReadString();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) {
|
||||
uint tag;
|
||||
while ((tag = input.ReadTag()) != 0) {
|
||||
switch(tag) {
|
||||
default:
|
||||
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input);
|
||||
break;
|
||||
case 10: {
|
||||
Data = input.ReadString();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
@ -113,52 +113,53 @@ namespace Google.Protobuf.Reflection {
|
||||
"CgpkZXByZWNhdGVkGAMgASgIOgVmYWxzZRIRCgltYXBfZW50cnkYByABKAgS",
|
||||
"QwoUdW5pbnRlcnByZXRlZF9vcHRpb24Y5wcgAygLMiQuZ29vZ2xlLnByb3Rv",
|
||||
"YnVmLlVuaW50ZXJwcmV0ZWRPcHRpb24qCQjoBxCAgICAAkoECAQQBUoECAUQ",
|
||||
"BkoECAYQB0oECAgQCUoECAkQCiKeAwoMRmllbGRPcHRpb25zEjoKBWN0eXBl",
|
||||
"BkoECAYQB0oECAgQCUoECAkQCiK+AwoMRmllbGRPcHRpb25zEjoKBWN0eXBl",
|
||||
"GAEgASgOMiMuZ29vZ2xlLnByb3RvYnVmLkZpZWxkT3B0aW9ucy5DVHlwZToG",
|
||||
"U1RSSU5HEg4KBnBhY2tlZBgCIAEoCBI/CgZqc3R5cGUYBiABKA4yJC5nb29n",
|
||||
"bGUucHJvdG9idWYuRmllbGRPcHRpb25zLkpTVHlwZToJSlNfTk9STUFMEhMK",
|
||||
"BGxhenkYBSABKAg6BWZhbHNlEhkKCmRlcHJlY2F0ZWQYAyABKAg6BWZhbHNl",
|
||||
"EhMKBHdlYWsYCiABKAg6BWZhbHNlEkMKFHVuaW50ZXJwcmV0ZWRfb3B0aW9u",
|
||||
"GOcHIAMoCzIkLmdvb2dsZS5wcm90b2J1Zi5VbmludGVycHJldGVkT3B0aW9u",
|
||||
"Ii8KBUNUeXBlEgoKBlNUUklORxAAEggKBENPUkQQARIQCgxTVFJJTkdfUElF",
|
||||
"Q0UQAiI1CgZKU1R5cGUSDQoJSlNfTk9STUFMEAASDQoJSlNfU1RSSU5HEAES",
|
||||
"DQoJSlNfTlVNQkVSEAIqCQjoBxCAgICAAkoECAQQBSJeCgxPbmVvZk9wdGlv",
|
||||
"bnMSQwoUdW5pbnRlcnByZXRlZF9vcHRpb24Y5wcgAygLMiQuZ29vZ2xlLnBy",
|
||||
"b3RvYnVmLlVuaW50ZXJwcmV0ZWRPcHRpb24qCQjoBxCAgICAAiKTAQoLRW51",
|
||||
"bU9wdGlvbnMSEwoLYWxsb3dfYWxpYXMYAiABKAgSGQoKZGVwcmVjYXRlZBgD",
|
||||
"IAEoCDoFZmFsc2USQwoUdW5pbnRlcnByZXRlZF9vcHRpb24Y5wcgAygLMiQu",
|
||||
"Z29vZ2xlLnByb3RvYnVmLlVuaW50ZXJwcmV0ZWRPcHRpb24qCQjoBxCAgICA",
|
||||
"AkoECAUQBiJ9ChBFbnVtVmFsdWVPcHRpb25zEhkKCmRlcHJlY2F0ZWQYASAB",
|
||||
"KAg6BWZhbHNlEkMKFHVuaW50ZXJwcmV0ZWRfb3B0aW9uGOcHIAMoCzIkLmdv",
|
||||
"b2dsZS5wcm90b2J1Zi5VbmludGVycHJldGVkT3B0aW9uKgkI6AcQgICAgAIi",
|
||||
"ewoOU2VydmljZU9wdGlvbnMSGQoKZGVwcmVjYXRlZBghIAEoCDoFZmFsc2US",
|
||||
"QwoUdW5pbnRlcnByZXRlZF9vcHRpb24Y5wcgAygLMiQuZ29vZ2xlLnByb3Rv",
|
||||
"YnVmLlVuaW50ZXJwcmV0ZWRPcHRpb24qCQjoBxCAgICAAiKtAgoNTWV0aG9k",
|
||||
"T3B0aW9ucxIZCgpkZXByZWNhdGVkGCEgASgIOgVmYWxzZRJfChFpZGVtcG90",
|
||||
"ZW5jeV9sZXZlbBgiIAEoDjIvLmdvb2dsZS5wcm90b2J1Zi5NZXRob2RPcHRp",
|
||||
"b25zLklkZW1wb3RlbmN5TGV2ZWw6E0lERU1QT1RFTkNZX1VOS05PV04SQwoU",
|
||||
"BGxhenkYBSABKAg6BWZhbHNlEh4KD3VudmVyaWZpZWRfbGF6eRgPIAEoCDoF",
|
||||
"ZmFsc2USGQoKZGVwcmVjYXRlZBgDIAEoCDoFZmFsc2USEwoEd2VhaxgKIAEo",
|
||||
"CDoFZmFsc2USQwoUdW5pbnRlcnByZXRlZF9vcHRpb24Y5wcgAygLMiQuZ29v",
|
||||
"Z2xlLnByb3RvYnVmLlVuaW50ZXJwcmV0ZWRPcHRpb24iLwoFQ1R5cGUSCgoG",
|
||||
"U1RSSU5HEAASCAoEQ09SRBABEhAKDFNUUklOR19QSUVDRRACIjUKBkpTVHlw",
|
||||
"ZRINCglKU19OT1JNQUwQABINCglKU19TVFJJTkcQARINCglKU19OVU1CRVIQ",
|
||||
"AioJCOgHEICAgIACSgQIBBAFIl4KDE9uZW9mT3B0aW9ucxJDChR1bmludGVy",
|
||||
"cHJldGVkX29wdGlvbhjnByADKAsyJC5nb29nbGUucHJvdG9idWYuVW5pbnRl",
|
||||
"cnByZXRlZE9wdGlvbioJCOgHEICAgIACIpMBCgtFbnVtT3B0aW9ucxITCgth",
|
||||
"bGxvd19hbGlhcxgCIAEoCBIZCgpkZXByZWNhdGVkGAMgASgIOgVmYWxzZRJD",
|
||||
"ChR1bmludGVycHJldGVkX29wdGlvbhjnByADKAsyJC5nb29nbGUucHJvdG9i",
|
||||
"dWYuVW5pbnRlcnByZXRlZE9wdGlvbioJCOgHEICAgIACSgQIBRAGIn0KEEVu",
|
||||
"dW1WYWx1ZU9wdGlvbnMSGQoKZGVwcmVjYXRlZBgBIAEoCDoFZmFsc2USQwoU",
|
||||
"dW5pbnRlcnByZXRlZF9vcHRpb24Y5wcgAygLMiQuZ29vZ2xlLnByb3RvYnVm",
|
||||
"LlVuaW50ZXJwcmV0ZWRPcHRpb24iUAoQSWRlbXBvdGVuY3lMZXZlbBIXChNJ",
|
||||
"REVNUE9URU5DWV9VTktOT1dOEAASEwoPTk9fU0lERV9FRkZFQ1RTEAESDgoK",
|
||||
"SURFTVBPVEVOVBACKgkI6AcQgICAgAIingIKE1VuaW50ZXJwcmV0ZWRPcHRp",
|
||||
"b24SOwoEbmFtZRgCIAMoCzItLmdvb2dsZS5wcm90b2J1Zi5VbmludGVycHJl",
|
||||
"dGVkT3B0aW9uLk5hbWVQYXJ0EhgKEGlkZW50aWZpZXJfdmFsdWUYAyABKAkS",
|
||||
"GgoScG9zaXRpdmVfaW50X3ZhbHVlGAQgASgEEhoKEm5lZ2F0aXZlX2ludF92",
|
||||
"YWx1ZRgFIAEoAxIUCgxkb3VibGVfdmFsdWUYBiABKAESFAoMc3RyaW5nX3Zh",
|
||||
"bHVlGAcgASgMEhcKD2FnZ3JlZ2F0ZV92YWx1ZRgIIAEoCRozCghOYW1lUGFy",
|
||||
"dBIRCgluYW1lX3BhcnQYASACKAkSFAoMaXNfZXh0ZW5zaW9uGAIgAigIItUB",
|
||||
"Cg5Tb3VyY2VDb2RlSW5mbxI6Cghsb2NhdGlvbhgBIAMoCzIoLmdvb2dsZS5w",
|
||||
"cm90b2J1Zi5Tb3VyY2VDb2RlSW5mby5Mb2NhdGlvbhqGAQoITG9jYXRpb24S",
|
||||
"EAoEcGF0aBgBIAMoBUICEAESEAoEc3BhbhgCIAMoBUICEAESGAoQbGVhZGlu",
|
||||
"Z19jb21tZW50cxgDIAEoCRIZChF0cmFpbGluZ19jb21tZW50cxgEIAEoCRIh",
|
||||
"ChlsZWFkaW5nX2RldGFjaGVkX2NvbW1lbnRzGAYgAygJIqcBChFHZW5lcmF0",
|
||||
"ZWRDb2RlSW5mbxJBCgphbm5vdGF0aW9uGAEgAygLMi0uZ29vZ2xlLnByb3Rv",
|
||||
"YnVmLkdlbmVyYXRlZENvZGVJbmZvLkFubm90YXRpb24aTwoKQW5ub3RhdGlv",
|
||||
"bhIQCgRwYXRoGAEgAygFQgIQARITCgtzb3VyY2VfZmlsZRgCIAEoCRINCgVi",
|
||||
"ZWdpbhgDIAEoBRILCgNlbmQYBCABKAVCfgoTY29tLmdvb2dsZS5wcm90b2J1",
|
||||
"ZkIQRGVzY3JpcHRvclByb3Rvc0gBWi1nb29nbGUuZ29sYW5nLm9yZy9wcm90",
|
||||
"b2J1Zi90eXBlcy9kZXNjcmlwdG9ycGL4AQGiAgNHUEKqAhpHb29nbGUuUHJv",
|
||||
"dG9idWYuUmVmbGVjdGlvbg=="));
|
||||
"LlVuaW50ZXJwcmV0ZWRPcHRpb24qCQjoBxCAgICAAiJ7Cg5TZXJ2aWNlT3B0",
|
||||
"aW9ucxIZCgpkZXByZWNhdGVkGCEgASgIOgVmYWxzZRJDChR1bmludGVycHJl",
|
||||
"dGVkX29wdGlvbhjnByADKAsyJC5nb29nbGUucHJvdG9idWYuVW5pbnRlcnBy",
|
||||
"ZXRlZE9wdGlvbioJCOgHEICAgIACIq0CCg1NZXRob2RPcHRpb25zEhkKCmRl",
|
||||
"cHJlY2F0ZWQYISABKAg6BWZhbHNlEl8KEWlkZW1wb3RlbmN5X2xldmVsGCIg",
|
||||
"ASgOMi8uZ29vZ2xlLnByb3RvYnVmLk1ldGhvZE9wdGlvbnMuSWRlbXBvdGVu",
|
||||
"Y3lMZXZlbDoTSURFTVBPVEVOQ1lfVU5LTk9XThJDChR1bmludGVycHJldGVk",
|
||||
"X29wdGlvbhjnByADKAsyJC5nb29nbGUucHJvdG9idWYuVW5pbnRlcnByZXRl",
|
||||
"ZE9wdGlvbiJQChBJZGVtcG90ZW5jeUxldmVsEhcKE0lERU1QT1RFTkNZX1VO",
|
||||
"S05PV04QABITCg9OT19TSURFX0VGRkVDVFMQARIOCgpJREVNUE9URU5UEAIq",
|
||||
"CQjoBxCAgICAAiKeAgoTVW5pbnRlcnByZXRlZE9wdGlvbhI7CgRuYW1lGAIg",
|
||||
"AygLMi0uZ29vZ2xlLnByb3RvYnVmLlVuaW50ZXJwcmV0ZWRPcHRpb24uTmFt",
|
||||
"ZVBhcnQSGAoQaWRlbnRpZmllcl92YWx1ZRgDIAEoCRIaChJwb3NpdGl2ZV9p",
|
||||
"bnRfdmFsdWUYBCABKAQSGgoSbmVnYXRpdmVfaW50X3ZhbHVlGAUgASgDEhQK",
|
||||
"DGRvdWJsZV92YWx1ZRgGIAEoARIUCgxzdHJpbmdfdmFsdWUYByABKAwSFwoP",
|
||||
"YWdncmVnYXRlX3ZhbHVlGAggASgJGjMKCE5hbWVQYXJ0EhEKCW5hbWVfcGFy",
|
||||
"dBgBIAIoCRIUCgxpc19leHRlbnNpb24YAiACKAgi1QEKDlNvdXJjZUNvZGVJ",
|
||||
"bmZvEjoKCGxvY2F0aW9uGAEgAygLMiguZ29vZ2xlLnByb3RvYnVmLlNvdXJj",
|
||||
"ZUNvZGVJbmZvLkxvY2F0aW9uGoYBCghMb2NhdGlvbhIQCgRwYXRoGAEgAygF",
|
||||
"QgIQARIQCgRzcGFuGAIgAygFQgIQARIYChBsZWFkaW5nX2NvbW1lbnRzGAMg",
|
||||
"ASgJEhkKEXRyYWlsaW5nX2NvbW1lbnRzGAQgASgJEiEKGWxlYWRpbmdfZGV0",
|
||||
"YWNoZWRfY29tbWVudHMYBiADKAkipwEKEUdlbmVyYXRlZENvZGVJbmZvEkEK",
|
||||
"CmFubm90YXRpb24YASADKAsyLS5nb29nbGUucHJvdG9idWYuR2VuZXJhdGVk",
|
||||
"Q29kZUluZm8uQW5ub3RhdGlvbhpPCgpBbm5vdGF0aW9uEhAKBHBhdGgYASAD",
|
||||
"KAVCAhABEhMKC3NvdXJjZV9maWxlGAIgASgJEg0KBWJlZ2luGAMgASgFEgsK",
|
||||
"A2VuZBgEIAEoBUJ+ChNjb20uZ29vZ2xlLnByb3RvYnVmQhBEZXNjcmlwdG9y",
|
||||
"UHJvdG9zSAFaLWdvb2dsZS5nb2xhbmcub3JnL3Byb3RvYnVmL3R5cGVzL2Rl",
|
||||
"c2NyaXB0b3JwYvgBAaICA0dQQqoCGkdvb2dsZS5Qcm90b2J1Zi5SZWZsZWN0",
|
||||
"aW9u"));
|
||||
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
|
||||
new pbr::FileDescriptor[] { },
|
||||
new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] {
|
||||
@ -175,7 +176,7 @@ namespace Google.Protobuf.Reflection {
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.MethodDescriptorProto), global::Google.Protobuf.Reflection.MethodDescriptorProto.Parser, new[]{ "Name", "InputType", "OutputType", "Options", "ClientStreaming", "ServerStreaming" }, null, null, null, null),
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.FileOptions), global::Google.Protobuf.Reflection.FileOptions.Parser, new[]{ "JavaPackage", "JavaOuterClassname", "JavaMultipleFiles", "JavaGenerateEqualsAndHash", "JavaStringCheckUtf8", "OptimizeFor", "GoPackage", "CcGenericServices", "JavaGenericServices", "PyGenericServices", "PhpGenericServices", "Deprecated", "CcEnableArenas", "ObjcClassPrefix", "CsharpNamespace", "SwiftPrefix", "PhpClassPrefix", "PhpNamespace", "PhpMetadataNamespace", "RubyPackage", "UninterpretedOption" }, null, new[]{ typeof(global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode) }, null, null),
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.MessageOptions), global::Google.Protobuf.Reflection.MessageOptions.Parser, new[]{ "MessageSetWireFormat", "NoStandardDescriptorAccessor", "Deprecated", "MapEntry", "UninterpretedOption" }, null, null, null, null),
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.FieldOptions), global::Google.Protobuf.Reflection.FieldOptions.Parser, new[]{ "Ctype", "Packed", "Jstype", "Lazy", "Deprecated", "Weak", "UninterpretedOption" }, null, new[]{ typeof(global::Google.Protobuf.Reflection.FieldOptions.Types.CType), typeof(global::Google.Protobuf.Reflection.FieldOptions.Types.JSType) }, null, null),
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.FieldOptions), global::Google.Protobuf.Reflection.FieldOptions.Parser, new[]{ "Ctype", "Packed", "Jstype", "Lazy", "UnverifiedLazy", "Deprecated", "Weak", "UninterpretedOption" }, null, new[]{ typeof(global::Google.Protobuf.Reflection.FieldOptions.Types.CType), typeof(global::Google.Protobuf.Reflection.FieldOptions.Types.JSType) }, null, null),
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.OneofOptions), global::Google.Protobuf.Reflection.OneofOptions.Parser, new[]{ "UninterpretedOption" }, null, null, null, null),
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.EnumOptions), global::Google.Protobuf.Reflection.EnumOptions.Parser, new[]{ "AllowAlias", "Deprecated", "UninterpretedOption" }, null, null, null, null),
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.EnumValueOptions), global::Google.Protobuf.Reflection.EnumValueOptions.Parser, new[]{ "Deprecated", "UninterpretedOption" }, null, null, null, null),
|
||||
@ -2507,7 +2508,6 @@ namespace Google.Protobuf.Reflection {
|
||||
/// For booleans, "true" or "false".
|
||||
/// For strings, contains the default text contents (not escaped in any way).
|
||||
/// For bytes, contains the C escaped value. All bytes >= 128 are escaped.
|
||||
/// TODO(kenton): Base-64 encode?
|
||||
/// </summary>
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
@ -6943,6 +6943,7 @@ namespace Google.Protobuf.Reflection {
|
||||
packed_ = other.packed_;
|
||||
jstype_ = other.jstype_;
|
||||
lazy_ = other.lazy_;
|
||||
unverifiedLazy_ = other.unverifiedLazy_;
|
||||
deprecated_ = other.deprecated_;
|
||||
weak_ = other.weak_;
|
||||
uninterpretedOption_ = other.uninterpretedOption_.Clone();
|
||||
@ -7096,6 +7097,12 @@ namespace Google.Protobuf.Reflection {
|
||||
/// implementation must either *always* check its required fields, or *never*
|
||||
/// check its required fields, regardless of whether or not the message has
|
||||
/// been parsed.
|
||||
///
|
||||
/// As of 2021, lazy does no correctness checks on the byte stream during
|
||||
/// parsing. This may lead to crashes if and when an invalid byte stream is
|
||||
/// finally parsed upon access.
|
||||
///
|
||||
/// TODO(b/211906113): Enable validation on lazy fields.
|
||||
/// </summary>
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
@ -7119,6 +7126,38 @@ namespace Google.Protobuf.Reflection {
|
||||
_hasBits0 &= ~8;
|
||||
}
|
||||
|
||||
/// <summary>Field number for the "unverified_lazy" field.</summary>
|
||||
public const int UnverifiedLazyFieldNumber = 15;
|
||||
private readonly static bool UnverifiedLazyDefaultValue = false;
|
||||
|
||||
private bool unverifiedLazy_;
|
||||
/// <summary>
|
||||
/// unverified_lazy does no correctness checks on the byte stream. This should
|
||||
/// only be used where lazy with verification is prohibitive for performance
|
||||
/// reasons.
|
||||
/// </summary>
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public bool UnverifiedLazy {
|
||||
get { if ((_hasBits0 & 64) != 0) { return unverifiedLazy_; } else { return UnverifiedLazyDefaultValue; } }
|
||||
set {
|
||||
_hasBits0 |= 64;
|
||||
unverifiedLazy_ = value;
|
||||
}
|
||||
}
|
||||
/// <summary>Gets whether the "unverified_lazy" field is set</summary>
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public bool HasUnverifiedLazy {
|
||||
get { return (_hasBits0 & 64) != 0; }
|
||||
}
|
||||
/// <summary>Clears the value of the "unverified_lazy" field</summary>
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public void ClearUnverifiedLazy() {
|
||||
_hasBits0 &= ~64;
|
||||
}
|
||||
|
||||
/// <summary>Field number for the "deprecated" field.</summary>
|
||||
public const int DeprecatedFieldNumber = 3;
|
||||
private readonly static bool DeprecatedDefaultValue = false;
|
||||
@ -7215,6 +7254,7 @@ namespace Google.Protobuf.Reflection {
|
||||
if (Packed != other.Packed) return false;
|
||||
if (Jstype != other.Jstype) return false;
|
||||
if (Lazy != other.Lazy) return false;
|
||||
if (UnverifiedLazy != other.UnverifiedLazy) return false;
|
||||
if (Deprecated != other.Deprecated) return false;
|
||||
if (Weak != other.Weak) return false;
|
||||
if(!uninterpretedOption_.Equals(other.uninterpretedOption_)) return false;
|
||||
@ -7232,6 +7272,7 @@ namespace Google.Protobuf.Reflection {
|
||||
if (HasPacked) hash ^= Packed.GetHashCode();
|
||||
if (HasJstype) hash ^= Jstype.GetHashCode();
|
||||
if (HasLazy) hash ^= Lazy.GetHashCode();
|
||||
if (HasUnverifiedLazy) hash ^= UnverifiedLazy.GetHashCode();
|
||||
if (HasDeprecated) hash ^= Deprecated.GetHashCode();
|
||||
if (HasWeak) hash ^= Weak.GetHashCode();
|
||||
hash ^= uninterpretedOption_.GetHashCode();
|
||||
@ -7280,6 +7321,10 @@ namespace Google.Protobuf.Reflection {
|
||||
output.WriteRawTag(80);
|
||||
output.WriteBool(Weak);
|
||||
}
|
||||
if (HasUnverifiedLazy) {
|
||||
output.WriteRawTag(120);
|
||||
output.WriteBool(UnverifiedLazy);
|
||||
}
|
||||
uninterpretedOption_.WriteTo(output, _repeated_uninterpretedOption_codec);
|
||||
if (_extensions != null) {
|
||||
_extensions.WriteTo(output);
|
||||
@ -7318,6 +7363,10 @@ namespace Google.Protobuf.Reflection {
|
||||
output.WriteRawTag(80);
|
||||
output.WriteBool(Weak);
|
||||
}
|
||||
if (HasUnverifiedLazy) {
|
||||
output.WriteRawTag(120);
|
||||
output.WriteBool(UnverifiedLazy);
|
||||
}
|
||||
uninterpretedOption_.WriteTo(ref output, _repeated_uninterpretedOption_codec);
|
||||
if (_extensions != null) {
|
||||
_extensions.WriteTo(ref output);
|
||||
@ -7344,6 +7393,9 @@ namespace Google.Protobuf.Reflection {
|
||||
if (HasLazy) {
|
||||
size += 1 + 1;
|
||||
}
|
||||
if (HasUnverifiedLazy) {
|
||||
size += 1 + 1;
|
||||
}
|
||||
if (HasDeprecated) {
|
||||
size += 1 + 1;
|
||||
}
|
||||
@ -7378,6 +7430,9 @@ namespace Google.Protobuf.Reflection {
|
||||
if (other.HasLazy) {
|
||||
Lazy = other.Lazy;
|
||||
}
|
||||
if (other.HasUnverifiedLazy) {
|
||||
UnverifiedLazy = other.UnverifiedLazy;
|
||||
}
|
||||
if (other.HasDeprecated) {
|
||||
Deprecated = other.Deprecated;
|
||||
}
|
||||
@ -7427,6 +7482,10 @@ namespace Google.Protobuf.Reflection {
|
||||
Weak = input.ReadBool();
|
||||
break;
|
||||
}
|
||||
case 120: {
|
||||
UnverifiedLazy = input.ReadBool();
|
||||
break;
|
||||
}
|
||||
case 7994: {
|
||||
uninterpretedOption_.AddEntriesFrom(input, _repeated_uninterpretedOption_codec);
|
||||
break;
|
||||
@ -7472,6 +7531,10 @@ namespace Google.Protobuf.Reflection {
|
||||
Weak = input.ReadBool();
|
||||
break;
|
||||
}
|
||||
case 120: {
|
||||
UnverifiedLazy = input.ReadBool();
|
||||
break;
|
||||
}
|
||||
case 7994: {
|
||||
uninterpretedOption_.AddEntriesFrom(ref input, _repeated_uninterpretedOption_codec);
|
||||
break;
|
||||
|
@ -224,7 +224,7 @@ public abstract class AbstractMessage
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares two set of fields. This method is used to implement {@link
|
||||
* Compares two sets of fields. This method is used to implement {@link
|
||||
* AbstractMessage#equals(Object)} and {@link AbstractMutableMessage#equals(Object)}. It takes
|
||||
* special care of bytes fields because immutable messages and mutable messages use different Java
|
||||
* type to represent a bytes field and this method should be able to compare immutable messages,
|
||||
@ -242,8 +242,8 @@ public abstract class AbstractMessage
|
||||
Object value2 = b.get(descriptor);
|
||||
if (descriptor.getType() == FieldDescriptor.Type.BYTES) {
|
||||
if (descriptor.isRepeated()) {
|
||||
List list1 = (List) value1;
|
||||
List list2 = (List) value2;
|
||||
List<?> list1 = (List) value1;
|
||||
List<?> list2 = (List) value2;
|
||||
if (list1.size() != list2.size()) {
|
||||
return false;
|
||||
}
|
||||
@ -383,8 +383,6 @@ public abstract class AbstractMessage
|
||||
// them to insure that they don't change after verification (since
|
||||
// the Message interface itself cannot enforce immutability of
|
||||
// implementations).
|
||||
// TODO(kenton): Provide a function somewhere called makeDeepCopy()
|
||||
// which allows people to make secure deep copies of messages.
|
||||
|
||||
for (final Map.Entry<FieldDescriptor, Object> entry : allFields.entrySet()) {
|
||||
final FieldDescriptor field = entry.getKey();
|
||||
@ -568,17 +566,6 @@ public abstract class AbstractMessage
|
||||
final InputStream input, final ExtensionRegistryLite extensionRegistry) throws IOException {
|
||||
return (BuilderType) super.mergeFrom(input, extensionRegistry);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mergeDelimitedFrom(final InputStream input) throws IOException {
|
||||
return super.mergeDelimitedFrom(input);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mergeDelimitedFrom(
|
||||
final InputStream input, final ExtensionRegistryLite extensionRegistry) throws IOException {
|
||||
return super.mergeDelimitedFrom(input, extensionRegistry);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -89,9 +89,9 @@ public abstract class AbstractMessageLite<
|
||||
final int serialized = getSerializedSize();
|
||||
final int bufferSize =
|
||||
CodedOutputStream.computePreferredBufferSize(
|
||||
CodedOutputStream.computeRawVarint32Size(serialized) + serialized);
|
||||
CodedOutputStream.computeUInt32SizeNoTag(serialized) + serialized);
|
||||
final CodedOutputStream codedOutput = CodedOutputStream.newInstance(output, bufferSize);
|
||||
codedOutput.writeRawVarint32(serialized);
|
||||
codedOutput.writeUInt32NoTag(serialized);
|
||||
writeTo(codedOutput);
|
||||
codedOutput.flush();
|
||||
}
|
||||
@ -316,8 +316,11 @@ public abstract class AbstractMessageLite<
|
||||
|
||||
@Override
|
||||
public long skip(final long n) throws IOException {
|
||||
final long result = super.skip(Math.min(n, limit));
|
||||
// because we take the minimum of an int and a long, result is guaranteed to be
|
||||
// less than or equal to Integer.MAX_INT so this cast is safe
|
||||
int result = (int) super.skip(Math.min(n, limit));
|
||||
if (result >= 0) {
|
||||
// if the superclass adheres to the contract for skip, this condition is always true
|
||||
limit -= result;
|
||||
}
|
||||
return result;
|
||||
|
@ -38,6 +38,7 @@ import java.nio.ByteBuffer;
|
||||
* A buffer that was allocated by a {@link BufferAllocator}. For every buffer, it is guaranteed that
|
||||
* at least one of {@link #hasArray()} or {@link #hasNioBuffer()} will be {@code true}.
|
||||
*/
|
||||
@CheckReturnValue
|
||||
@ExperimentalApi
|
||||
abstract class AllocatedBuffer {
|
||||
/**
|
||||
@ -106,6 +107,7 @@ abstract class AllocatedBuffer {
|
||||
* @return This buffer
|
||||
* @throws IllegalArgumentException If the preconditions on {@code position} do not hold
|
||||
*/
|
||||
@CanIgnoreReturnValue
|
||||
public abstract AllocatedBuffer position(int position);
|
||||
|
||||
/**
|
||||
|
@ -43,6 +43,7 @@ import java.io.IOException;
|
||||
* IndexOutOfBoundsException and convert it to protobuf's InvalidProtocolBufferException when
|
||||
* crossing protobuf public API boundaries.
|
||||
*/
|
||||
@CheckReturnValue
|
||||
final class ArrayDecoders {
|
||||
/**
|
||||
* A helper used to return multiple values in a Java function. Java doesn't natively support
|
||||
@ -548,7 +549,6 @@ final class ArrayDecoders {
|
||||
}
|
||||
|
||||
/** Decodes a packed sint64 field. Returns the position after all read values. */
|
||||
@SuppressWarnings("unchecked")
|
||||
static int decodePackedSInt64List(
|
||||
byte[] data, int position, ProtobufList<?> list, Registers registers) throws IOException {
|
||||
final LongArrayList output = (LongArrayList) list;
|
||||
|
@ -48,6 +48,7 @@ import java.util.Map;
|
||||
* A {@link Reader} that reads from a buffer containing a message serialized with the binary
|
||||
* protocol.
|
||||
*/
|
||||
@CheckReturnValue
|
||||
@ExperimentalApi
|
||||
abstract class BinaryReader implements Reader {
|
||||
private static final int FIXED32_MULTIPLE_MASK = FIXED32_SIZE - 1;
|
||||
@ -271,6 +272,7 @@ abstract class BinaryReader implements Reader {
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public <T> T readGroup(Class<T> clazz, ExtensionRegistryLite extensionRegistry)
|
||||
throws IOException {
|
||||
@ -278,6 +280,7 @@ abstract class BinaryReader implements Reader {
|
||||
return readGroup(Protobuf.getInstance().schemaFor(clazz), extensionRegistry);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public <T> T readGroupBySchemaWithCheck(
|
||||
Schema<T> schema, ExtensionRegistryLite extensionRegistry) throws IOException {
|
||||
@ -956,6 +959,7 @@ abstract class BinaryReader implements Reader {
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public <T> void readGroupList(
|
||||
List<T> target, Class<T> targetType, ExtensionRegistryLite extensionRegistry)
|
||||
@ -964,6 +968,7 @@ abstract class BinaryReader implements Reader {
|
||||
readGroupList(target, schema, extensionRegistry);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public <T> void readGroupList(
|
||||
List<T> target, Schema<T> schema, ExtensionRegistryLite extensionRegistry)
|
||||
|
@ -65,6 +65,7 @@ import java.util.Queue;
|
||||
* The {@link #getTotalBytesWritten()} will continue to reflect the total of the write and will not
|
||||
* be reset.
|
||||
*/
|
||||
@CheckReturnValue
|
||||
@ExperimentalApi
|
||||
abstract class BinaryWriter extends ByteOutput implements Writer {
|
||||
public static final int DEFAULT_CHUNK_SIZE = 4096;
|
||||
@ -162,6 +163,7 @@ abstract class BinaryWriter extends ByteOutput implements Writer {
|
||||
* <p>After calling this method, the writer can not be reused. Create a new writer for future
|
||||
* writes.
|
||||
*/
|
||||
@CanIgnoreReturnValue
|
||||
public final Queue<AllocatedBuffer> complete() {
|
||||
finishCurrentBuffer();
|
||||
return buffers;
|
||||
@ -808,6 +810,7 @@ abstract class BinaryWriter extends ByteOutput implements Writer {
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public final void writeGroupList(int fieldNumber, List<?> list) throws IOException {
|
||||
for (int i = list.size() - 1; i >= 0; i--) {
|
||||
@ -815,6 +818,7 @@ abstract class BinaryWriter extends ByteOutput implements Writer {
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public final void writeGroupList(int fieldNumber, List<?> list, Schema schema)
|
||||
throws IOException {
|
||||
@ -1080,6 +1084,7 @@ abstract class BinaryWriter extends ByteOutput implements Writer {
|
||||
writeTag(fieldNumber, WIRETYPE_LENGTH_DELIMITED);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public void writeGroup(int fieldNumber, Object value) throws IOException {
|
||||
writeTag(fieldNumber, WIRETYPE_END_GROUP);
|
||||
@ -1497,8 +1502,8 @@ abstract class BinaryWriter extends ByteOutput implements Writer {
|
||||
this.allocatedBuffer = allocatedBuffer;
|
||||
this.buffer = allocatedBuffer.array();
|
||||
int arrayOffset = allocatedBuffer.arrayOffset();
|
||||
this.limit = arrayOffset + allocatedBuffer.limit();
|
||||
this.offset = arrayOffset + allocatedBuffer.position();
|
||||
this.limit = (long) arrayOffset + allocatedBuffer.limit();
|
||||
this.offset = (long) arrayOffset + allocatedBuffer.position();
|
||||
this.offsetMinusOne = offset - 1;
|
||||
this.limitMinusOne = limit - 1;
|
||||
this.pos = limitMinusOne;
|
||||
@ -2148,6 +2153,7 @@ abstract class BinaryWriter extends ByteOutput implements Writer {
|
||||
writeTag(fieldNumber, WIRETYPE_LENGTH_DELIMITED);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public void writeGroup(int fieldNumber, Object value) throws IOException {
|
||||
writeTag(fieldNumber, WIRETYPE_END_GROUP);
|
||||
@ -2162,11 +2168,13 @@ abstract class BinaryWriter extends ByteOutput implements Writer {
|
||||
writeTag(fieldNumber, WIRETYPE_START_GROUP);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public void writeStartGroup(int fieldNumber) {
|
||||
writeTag(fieldNumber, WIRETYPE_START_GROUP);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public void writeEndGroup(int fieldNumber) {
|
||||
writeTag(fieldNumber, WIRETYPE_END_GROUP);
|
||||
@ -2719,11 +2727,13 @@ abstract class BinaryWriter extends ByteOutput implements Writer {
|
||||
writeTag(fieldNumber, WIRETYPE_START_GROUP);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public void writeStartGroup(int fieldNumber) {
|
||||
writeTag(fieldNumber, WIRETYPE_START_GROUP);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public void writeEndGroup(int fieldNumber) {
|
||||
writeTag(fieldNumber, WIRETYPE_END_GROUP);
|
||||
|
@ -36,6 +36,7 @@ import java.nio.ByteBuffer;
|
||||
* An object responsible for allocation of buffers. This is an extension point to enable buffer
|
||||
* pooling within an application.
|
||||
*/
|
||||
@CheckReturnValue
|
||||
@ExperimentalApi
|
||||
abstract class BufferAllocator {
|
||||
private static final BufferAllocator UNPOOLED =
|
||||
|
@ -236,6 +236,11 @@ public abstract class ByteString implements Iterable<Byte>, Serializable {
|
||||
return size() == 0;
|
||||
}
|
||||
|
||||
/** Returns an empty {@code ByteString} of size {@code 0}. */
|
||||
public static final ByteString empty() {
|
||||
return EMPTY;
|
||||
}
|
||||
|
||||
// =================================================================
|
||||
// Comparison
|
||||
|
||||
@ -253,6 +258,38 @@ public abstract class ByteString implements Iterable<Byte>, Serializable {
|
||||
return value & UNSIGNED_BYTE_MASK;
|
||||
}
|
||||
|
||||
/** Returns the numeric value of the given character in hex, or -1 if invalid. */
|
||||
private static int hexDigit(char c) {
|
||||
if (c >= '0' && c <= '9') {
|
||||
return c - '0';
|
||||
} else if (c >= 'A' && c <= 'F') {
|
||||
return c - 'A' + 10;
|
||||
} else if (c >= 'a' && c <= 'f') {
|
||||
return c - 'a' + 10;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the numeric value of the given character at index in hexString.
|
||||
*
|
||||
* @throws NumberFormatException if the hexString character is invalid.
|
||||
*/
|
||||
private static int extractHexDigit(String hexString, int index) {
|
||||
int digit = hexDigit(hexString.charAt(index));
|
||||
if (digit == -1) {
|
||||
throw new NumberFormatException(
|
||||
"Invalid hexString "
|
||||
+ hexString
|
||||
+ " must only contain [0-9a-fA-F] but contained "
|
||||
+ hexString.charAt(index)
|
||||
+ " at index "
|
||||
+ index);
|
||||
}
|
||||
return digit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares two {@link ByteString}s lexicographically, treating their contents as unsigned byte
|
||||
* values between 0 and 255 (inclusive).
|
||||
@ -279,8 +316,13 @@ public abstract class ByteString implements Iterable<Byte>, Serializable {
|
||||
};
|
||||
|
||||
/**
|
||||
<<<<<<< HEAD
|
||||
* Returns a {@link Comparator} which compares {@link ByteString}-s lexicographically
|
||||
* as sequences of unsigned byte values between 0 and 255, inclusive.
|
||||
=======
|
||||
* Returns a {@link Comparator} which compares {@link ByteString}-s lexicographically as sequences
|
||||
* of unsigned bytes (i.e. values between 0 and 255, inclusive).
|
||||
>>>>>>> refs/tags/sync-piper
|
||||
*
|
||||
* <p>For example, {@code (byte) -1} is considered to be greater than {@code (byte) 1} because it
|
||||
* is interpreted as an unsigned value, {@code 255}:
|
||||
@ -343,6 +385,30 @@ public abstract class ByteString implements Iterable<Byte>, Serializable {
|
||||
return size() >= suffix.size() && substring(size() - suffix.size()).equals(suffix);
|
||||
}
|
||||
|
||||
// =================================================================
|
||||
// String -> ByteString
|
||||
|
||||
/**
|
||||
* Returns a {@code ByteString} from a hexadecimal String. Alternative CharSequences should use
|
||||
* {@link ByteStrings#decode(CharSequence, BaseEncoding)}
|
||||
*
|
||||
* @param hexString String of hexadecimal digits to create {@code ByteString} from.
|
||||
* @throws NumberFormatException if the hexString does not contain a parsable hex String.
|
||||
*/
|
||||
public static ByteString fromHex(@CompileTimeConstant String hexString) {
|
||||
if (hexString.length() % 2 != 0) {
|
||||
throw new NumberFormatException(
|
||||
"Invalid hexString " + hexString + " of length " + hexString.length() + " must be even.");
|
||||
}
|
||||
byte[] bytes = new byte[hexString.length() / 2];
|
||||
for (int i = 0; i < bytes.length; i++) {
|
||||
int d1 = extractHexDigit(hexString, 2 * i);
|
||||
int d2 = extractHexDigit(hexString, 2 * i + 1);
|
||||
bytes[i] = (byte) (d1 << 4 | d2);
|
||||
}
|
||||
return new LiteralByteString(bytes);
|
||||
}
|
||||
|
||||
// =================================================================
|
||||
// byte[] -> ByteString
|
||||
|
||||
|
@ -680,33 +680,33 @@ public abstract class CodedInputStream {
|
||||
case WireFormat.WIRETYPE_VARINT:
|
||||
{
|
||||
long value = readInt64();
|
||||
output.writeRawVarint32(tag);
|
||||
output.writeUInt32NoTag(tag);
|
||||
output.writeUInt64NoTag(value);
|
||||
return true;
|
||||
}
|
||||
case WireFormat.WIRETYPE_FIXED64:
|
||||
{
|
||||
long value = readRawLittleEndian64();
|
||||
output.writeRawVarint32(tag);
|
||||
output.writeUInt32NoTag(tag);
|
||||
output.writeFixed64NoTag(value);
|
||||
return true;
|
||||
}
|
||||
case WireFormat.WIRETYPE_LENGTH_DELIMITED:
|
||||
{
|
||||
ByteString value = readBytes();
|
||||
output.writeRawVarint32(tag);
|
||||
output.writeUInt32NoTag(tag);
|
||||
output.writeBytesNoTag(value);
|
||||
return true;
|
||||
}
|
||||
case WireFormat.WIRETYPE_START_GROUP:
|
||||
{
|
||||
output.writeRawVarint32(tag);
|
||||
output.writeUInt32NoTag(tag);
|
||||
skipMessage(output);
|
||||
int endtag =
|
||||
WireFormat.makeTag(
|
||||
WireFormat.getTagFieldNumber(tag), WireFormat.WIRETYPE_END_GROUP);
|
||||
checkLastTagWas(endtag);
|
||||
output.writeRawVarint32(endtag);
|
||||
output.writeUInt32NoTag(endtag);
|
||||
return true;
|
||||
}
|
||||
case WireFormat.WIRETYPE_END_GROUP:
|
||||
@ -716,7 +716,7 @@ public abstract class CodedInputStream {
|
||||
case WireFormat.WIRETYPE_FIXED32:
|
||||
{
|
||||
int value = readRawLittleEndian32();
|
||||
output.writeRawVarint32(tag);
|
||||
output.writeUInt32NoTag(tag);
|
||||
output.writeFixed32NoTag(value);
|
||||
return true;
|
||||
}
|
||||
@ -1395,33 +1395,33 @@ public abstract class CodedInputStream {
|
||||
case WireFormat.WIRETYPE_VARINT:
|
||||
{
|
||||
long value = readInt64();
|
||||
output.writeRawVarint32(tag);
|
||||
output.writeUInt32NoTag(tag);
|
||||
output.writeUInt64NoTag(value);
|
||||
return true;
|
||||
}
|
||||
case WireFormat.WIRETYPE_FIXED64:
|
||||
{
|
||||
long value = readRawLittleEndian64();
|
||||
output.writeRawVarint32(tag);
|
||||
output.writeUInt32NoTag(tag);
|
||||
output.writeFixed64NoTag(value);
|
||||
return true;
|
||||
}
|
||||
case WireFormat.WIRETYPE_LENGTH_DELIMITED:
|
||||
{
|
||||
ByteString value = readBytes();
|
||||
output.writeRawVarint32(tag);
|
||||
output.writeUInt32NoTag(tag);
|
||||
output.writeBytesNoTag(value);
|
||||
return true;
|
||||
}
|
||||
case WireFormat.WIRETYPE_START_GROUP:
|
||||
{
|
||||
output.writeRawVarint32(tag);
|
||||
output.writeUInt32NoTag(tag);
|
||||
skipMessage(output);
|
||||
int endtag =
|
||||
WireFormat.makeTag(
|
||||
WireFormat.getTagFieldNumber(tag), WireFormat.WIRETYPE_END_GROUP);
|
||||
checkLastTagWas(endtag);
|
||||
output.writeRawVarint32(endtag);
|
||||
output.writeUInt32NoTag(endtag);
|
||||
return true;
|
||||
}
|
||||
case WireFormat.WIRETYPE_END_GROUP:
|
||||
@ -1431,7 +1431,7 @@ public abstract class CodedInputStream {
|
||||
case WireFormat.WIRETYPE_FIXED32:
|
||||
{
|
||||
int value = readRawLittleEndian32();
|
||||
output.writeRawVarint32(tag);
|
||||
output.writeUInt32NoTag(tag);
|
||||
output.writeFixed32NoTag(value);
|
||||
return true;
|
||||
}
|
||||
@ -2163,33 +2163,33 @@ public abstract class CodedInputStream {
|
||||
case WireFormat.WIRETYPE_VARINT:
|
||||
{
|
||||
long value = readInt64();
|
||||
output.writeRawVarint32(tag);
|
||||
output.writeUInt32NoTag(tag);
|
||||
output.writeUInt64NoTag(value);
|
||||
return true;
|
||||
}
|
||||
case WireFormat.WIRETYPE_FIXED64:
|
||||
{
|
||||
long value = readRawLittleEndian64();
|
||||
output.writeRawVarint32(tag);
|
||||
output.writeUInt32NoTag(tag);
|
||||
output.writeFixed64NoTag(value);
|
||||
return true;
|
||||
}
|
||||
case WireFormat.WIRETYPE_LENGTH_DELIMITED:
|
||||
{
|
||||
ByteString value = readBytes();
|
||||
output.writeRawVarint32(tag);
|
||||
output.writeUInt32NoTag(tag);
|
||||
output.writeBytesNoTag(value);
|
||||
return true;
|
||||
}
|
||||
case WireFormat.WIRETYPE_START_GROUP:
|
||||
{
|
||||
output.writeRawVarint32(tag);
|
||||
output.writeUInt32NoTag(tag);
|
||||
skipMessage(output);
|
||||
int endtag =
|
||||
WireFormat.makeTag(
|
||||
WireFormat.getTagFieldNumber(tag), WireFormat.WIRETYPE_END_GROUP);
|
||||
checkLastTagWas(endtag);
|
||||
output.writeRawVarint32(endtag);
|
||||
output.writeUInt32NoTag(endtag);
|
||||
return true;
|
||||
}
|
||||
case WireFormat.WIRETYPE_END_GROUP:
|
||||
@ -2199,7 +2199,7 @@ public abstract class CodedInputStream {
|
||||
case WireFormat.WIRETYPE_FIXED32:
|
||||
{
|
||||
int value = readRawLittleEndian32();
|
||||
output.writeRawVarint32(tag);
|
||||
output.writeUInt32NoTag(tag);
|
||||
output.writeFixed32NoTag(value);
|
||||
return true;
|
||||
}
|
||||
@ -3284,33 +3284,33 @@ public abstract class CodedInputStream {
|
||||
case WireFormat.WIRETYPE_VARINT:
|
||||
{
|
||||
long value = readInt64();
|
||||
output.writeRawVarint32(tag);
|
||||
output.writeUInt32NoTag(tag);
|
||||
output.writeUInt64NoTag(value);
|
||||
return true;
|
||||
}
|
||||
case WireFormat.WIRETYPE_FIXED64:
|
||||
{
|
||||
long value = readRawLittleEndian64();
|
||||
output.writeRawVarint32(tag);
|
||||
output.writeUInt32NoTag(tag);
|
||||
output.writeFixed64NoTag(value);
|
||||
return true;
|
||||
}
|
||||
case WireFormat.WIRETYPE_LENGTH_DELIMITED:
|
||||
{
|
||||
ByteString value = readBytes();
|
||||
output.writeRawVarint32(tag);
|
||||
output.writeUInt32NoTag(tag);
|
||||
output.writeBytesNoTag(value);
|
||||
return true;
|
||||
}
|
||||
case WireFormat.WIRETYPE_START_GROUP:
|
||||
{
|
||||
output.writeRawVarint32(tag);
|
||||
output.writeUInt32NoTag(tag);
|
||||
skipMessage(output);
|
||||
int endtag =
|
||||
WireFormat.makeTag(
|
||||
WireFormat.getTagFieldNumber(tag), WireFormat.WIRETYPE_END_GROUP);
|
||||
checkLastTagWas(endtag);
|
||||
output.writeRawVarint32(endtag);
|
||||
output.writeUInt32NoTag(endtag);
|
||||
return true;
|
||||
}
|
||||
case WireFormat.WIRETYPE_END_GROUP:
|
||||
@ -3320,7 +3320,7 @@ public abstract class CodedInputStream {
|
||||
case WireFormat.WIRETYPE_FIXED32:
|
||||
{
|
||||
int value = readRawLittleEndian32();
|
||||
output.writeRawVarint32(tag);
|
||||
output.writeUInt32NoTag(tag);
|
||||
output.writeFixed32NoTag(value);
|
||||
return true;
|
||||
}
|
||||
|
@ -44,6 +44,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/** An adapter between the {@link Reader} interface and {@link CodedInputStream}. */
|
||||
@CheckReturnValue
|
||||
@ExperimentalApi
|
||||
final class CodedInputStreamReader implements Reader {
|
||||
private static final int FIXED32_MULTIPLE_MASK = FIXED32_SIZE - 1;
|
||||
@ -165,7 +166,6 @@ final class CodedInputStreamReader implements Reader {
|
||||
return input.readStringRequireUtf8();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> T readMessage(Class<T> clazz, ExtensionRegistryLite extensionRegistry)
|
||||
throws IOException {
|
||||
@ -181,7 +181,7 @@ final class CodedInputStreamReader implements Reader {
|
||||
return readMessage(schema, extensionRegistry);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Deprecated
|
||||
@Override
|
||||
public <T> T readGroup(Class<T> clazz, ExtensionRegistryLite extensionRegistry)
|
||||
throws IOException {
|
||||
@ -189,7 +189,7 @@ final class CodedInputStreamReader implements Reader {
|
||||
return readGroup(Protobuf.getInstance().schemaFor(clazz), extensionRegistry);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Deprecated
|
||||
@Override
|
||||
public <T> T readGroupBySchemaWithCheck(Schema<T> schema, ExtensionRegistryLite extensionRegistry)
|
||||
throws IOException {
|
||||
@ -821,6 +821,7 @@ final class CodedInputStreamReader implements Reader {
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public <T> void readGroupList(
|
||||
List<T> target, Class<T> targetType, ExtensionRegistryLite extensionRegistry)
|
||||
@ -829,6 +830,7 @@ final class CodedInputStreamReader implements Reader {
|
||||
readGroupList(target, schema, extensionRegistry);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public <T> void readGroupList(
|
||||
List<T> target, Schema<T> schema, ExtensionRegistryLite extensionRegistry)
|
||||
@ -1314,7 +1316,7 @@ final class CodedInputStreamReader implements Reader {
|
||||
case UINT64:
|
||||
return readUInt64();
|
||||
default:
|
||||
throw new RuntimeException("unsupported field type.");
|
||||
throw new IllegalArgumentException("unsupported field type.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1056,7 +1056,7 @@ public abstract class CodedOutputStream extends ByteOutput {
|
||||
*/
|
||||
@Deprecated
|
||||
public static int computeGroupSize(final int fieldNumber, final MessageLite value) {
|
||||
return computeTagSize(fieldNumber) * 2 + computeGroupSizeNoTag(value);
|
||||
return computeTagSize(fieldNumber) * 2 + value.getSerializedSize();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1072,6 +1072,7 @@ public abstract class CodedOutputStream extends ByteOutput {
|
||||
|
||||
/** Compute the number of bytes that would be needed to encode a {@code group} field. */
|
||||
@Deprecated
|
||||
@InlineMe(replacement = "value.getSerializedSize()")
|
||||
public static int computeGroupSizeNoTag(final MessageLite value) {
|
||||
return value.getSerializedSize();
|
||||
}
|
||||
@ -1089,6 +1090,7 @@ public abstract class CodedOutputStream extends ByteOutput {
|
||||
* @deprecated use {@link #writeUInt32NoTag} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@InlineMe(replacement = "this.writeUInt32NoTag(value)")
|
||||
public final void writeRawVarint32(int value) throws IOException {
|
||||
writeUInt32NoTag(value);
|
||||
}
|
||||
@ -1099,6 +1101,7 @@ public abstract class CodedOutputStream extends ByteOutput {
|
||||
* @deprecated use {@link #writeUInt64NoTag} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@InlineMe(replacement = "this.writeUInt64NoTag(value)")
|
||||
public final void writeRawVarint64(long value) throws IOException {
|
||||
writeUInt64NoTag(value);
|
||||
}
|
||||
@ -1110,6 +1113,9 @@ public abstract class CodedOutputStream extends ByteOutput {
|
||||
* @deprecated use {@link #computeUInt32SizeNoTag(int)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@InlineMe(
|
||||
replacement = "CodedOutputStream.computeUInt32SizeNoTag(value)",
|
||||
imports = "com.google.protobuf.CodedOutputStream")
|
||||
public static int computeRawVarint32Size(final int value) {
|
||||
return computeUInt32SizeNoTag(value);
|
||||
}
|
||||
@ -1120,6 +1126,9 @@ public abstract class CodedOutputStream extends ByteOutput {
|
||||
* @deprecated use {@link #computeUInt64SizeNoTag(long)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@InlineMe(
|
||||
replacement = "CodedOutputStream.computeUInt64SizeNoTag(value)",
|
||||
imports = "com.google.protobuf.CodedOutputStream")
|
||||
public static int computeRawVarint64Size(long value) {
|
||||
return computeUInt64SizeNoTag(value);
|
||||
}
|
||||
@ -1130,6 +1139,7 @@ public abstract class CodedOutputStream extends ByteOutput {
|
||||
* @deprecated Use {@link #writeFixed32NoTag} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@InlineMe(replacement = "this.writeFixed32NoTag(value)")
|
||||
public final void writeRawLittleEndian32(final int value) throws IOException {
|
||||
writeFixed32NoTag(value);
|
||||
}
|
||||
@ -1140,6 +1150,7 @@ public abstract class CodedOutputStream extends ByteOutput {
|
||||
* @deprecated Use {@link #writeFixed64NoTag} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@InlineMe(replacement = "this.writeFixed64NoTag(value)")
|
||||
public final void writeRawLittleEndian64(final long value) throws IOException {
|
||||
writeFixed64NoTag(value);
|
||||
}
|
||||
|
@ -39,6 +39,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/** An adapter between the {@link Writer} interface and {@link CodedOutputStream}. */
|
||||
@CheckReturnValue
|
||||
@ExperimentalApi
|
||||
final class CodedOutputStreamWriter implements Writer {
|
||||
private final CodedOutputStream output;
|
||||
@ -154,6 +155,7 @@ final class CodedOutputStreamWriter implements Writer {
|
||||
output.writeMessage(fieldNumber, (MessageLite) value, schema);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public void writeGroup(int fieldNumber, Object value) throws IOException {
|
||||
output.writeGroup(fieldNumber, (MessageLite) value);
|
||||
@ -164,11 +166,13 @@ final class CodedOutputStreamWriter implements Writer {
|
||||
output.writeGroup(fieldNumber, (MessageLite) value, schema);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public void writeStartGroup(int fieldNumber) throws IOException {
|
||||
output.writeTag(fieldNumber, WireFormat.WIRETYPE_START_GROUP);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public void writeEndGroup(int fieldNumber) throws IOException {
|
||||
output.writeTag(fieldNumber, WireFormat.WIRETYPE_END_GROUP);
|
||||
@ -561,6 +565,7 @@ final class CodedOutputStreamWriter implements Writer {
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public void writeGroupList(int fieldNumber, List<?> value) throws IOException {
|
||||
for (int i = 0; i < value.size(); ++i) {
|
||||
|
@ -30,18 +30,18 @@
|
||||
|
||||
package com.google.protobuf;
|
||||
|
||||
/**
|
||||
* A prerun for a test suite that allows running the full protocol buffer tests in a mode that
|
||||
* disables the optimization for not using {@link RepeatedFieldBuilder} and {@link
|
||||
* SingleFieldBuilder} until they are requested. This allows us to run all the tests through both
|
||||
* code paths and ensures that both code paths produce identical results.
|
||||
*
|
||||
* @author jonp@google.com (Jon Perlow)
|
||||
*/
|
||||
public class ForceFieldBuildersPreRun implements Runnable {
|
||||
import static java.lang.annotation.RetentionPolicy.CLASS;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
GeneratedMessage.enableAlwaysUseFieldBuildersForTesting();
|
||||
}
|
||||
}
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Annotation for method parameter and class field declarations, which denotes that corresponding
|
||||
* actual values must be compile-time constant expressions.
|
||||
*/
|
||||
@Documented
|
||||
@Retention(CLASS)
|
||||
@Target({ElementType.PARAMETER, ElementType.FIELD})
|
||||
@interface CompileTimeConstant {}
|
@ -278,14 +278,13 @@ public final class Descriptors {
|
||||
/**
|
||||
* Construct a {@code FileDescriptor}.
|
||||
*
|
||||
* @param proto The protocol message form of the FileDescriptor.
|
||||
* @param dependencies {@code FileDescriptor}s corresponding to all of the file's dependencies.
|
||||
* @param proto the protocol message form of the FileDescriptort
|
||||
* @param dependencies {@code FileDescriptor}s corresponding to all of the file's dependencies
|
||||
* @throws DescriptorValidationException {@code proto} is not a valid descriptor. This can occur
|
||||
* for a number of reasons, e.g. because a field has an undefined type or because two
|
||||
* messages were defined with the same name.
|
||||
* for a number of reasons; for instance, because a field has an undefined type or because
|
||||
* two messages were defined with the same name.
|
||||
*/
|
||||
public static FileDescriptor buildFrom(
|
||||
final FileDescriptorProto proto, final FileDescriptor[] dependencies)
|
||||
public static FileDescriptor buildFrom(FileDescriptorProto proto, FileDescriptor[] dependencies)
|
||||
throws DescriptorValidationException {
|
||||
return buildFrom(proto, dependencies, false);
|
||||
}
|
||||
@ -293,18 +292,19 @@ public final class Descriptors {
|
||||
/**
|
||||
* Construct a {@code FileDescriptor}.
|
||||
*
|
||||
* @param proto The protocol message form of the FileDescriptor.
|
||||
* @param dependencies {@code FileDescriptor}s corresponding to all of the file's dependencies.
|
||||
* @param allowUnknownDependencies If true, non-exist dependenncies will be ignored and
|
||||
* undefined message types will be replaced with a placeholder type.
|
||||
* @param proto the protocol message form of the FileDescriptor
|
||||
* @param dependencies {@code FileDescriptor}s corresponding to all of the file's dependencies
|
||||
* @param allowUnknownDependencies if true, non-existing dependencies will be ignored and
|
||||
* undefined message types will be replaced with a placeholder type. Undefined enum types
|
||||
* still cause a DescriptorValidationException.
|
||||
* @throws DescriptorValidationException {@code proto} is not a valid descriptor. This can occur
|
||||
* for a number of reasons, e.g. because a field has an undefined type or because two
|
||||
* messages were defined with the same name.
|
||||
* for a number of reasons; for instance, because a field has an undefined type or because
|
||||
* two messages were defined with the same name.
|
||||
*/
|
||||
public static FileDescriptor buildFrom(
|
||||
final FileDescriptorProto proto,
|
||||
final FileDescriptor[] dependencies,
|
||||
final boolean allowUnknownDependencies)
|
||||
FileDescriptorProto proto,
|
||||
FileDescriptor[] dependencies,
|
||||
boolean allowUnknownDependencies)
|
||||
throws DescriptorValidationException {
|
||||
// Building descriptors involves two steps: translating and linking.
|
||||
// In the translation step (implemented by FileDescriptor's
|
||||
@ -315,8 +315,8 @@ public final class Descriptors {
|
||||
// FieldDescriptor for an embedded message contains a pointer directly
|
||||
// to the Descriptor for that message's type. We also detect undefined
|
||||
// types in the linking step.
|
||||
final DescriptorPool pool = new DescriptorPool(dependencies, allowUnknownDependencies);
|
||||
final FileDescriptor result =
|
||||
DescriptorPool pool = new DescriptorPool(dependencies, allowUnknownDependencies);
|
||||
FileDescriptor result =
|
||||
new FileDescriptor(proto, dependencies, pool, allowUnknownDependencies);
|
||||
result.crossLink();
|
||||
return result;
|
||||
@ -1837,8 +1837,8 @@ public final class Descriptors {
|
||||
// The number represents an unknown enum value.
|
||||
synchronized (this) {
|
||||
if (cleanupQueue == null) {
|
||||
cleanupQueue = new ReferenceQueue<EnumValueDescriptor>();
|
||||
unknownValues = new HashMap<Integer, WeakReference<EnumValueDescriptor>>();
|
||||
cleanupQueue = new ReferenceQueue<>();
|
||||
unknownValues = new HashMap<>();
|
||||
} else {
|
||||
while (true) {
|
||||
UnknownEnumValueReference toClean = (UnknownEnumValueReference) cleanupQueue.poll();
|
||||
@ -2415,7 +2415,7 @@ public final class Descriptors {
|
||||
}
|
||||
|
||||
private final Set<FileDescriptor> dependencies;
|
||||
private boolean allowUnknownDependencies;
|
||||
private final boolean allowUnknownDependencies;
|
||||
|
||||
private final Map<String, GenericDescriptor> descriptorsByName = new HashMap<>();
|
||||
|
||||
@ -2475,7 +2475,6 @@ public final class Descriptors {
|
||||
final GenericDescriptor relativeTo,
|
||||
final DescriptorPool.SearchFilter filter)
|
||||
throws DescriptorValidationException {
|
||||
// TODO(kenton): This could be optimized in a number of ways.
|
||||
|
||||
GenericDescriptor result;
|
||||
String fullname;
|
||||
@ -2547,11 +2546,11 @@ public final class Descriptors {
|
||||
logger.warning(
|
||||
"The descriptor for message type \""
|
||||
+ name
|
||||
+ "\" can not be found and a placeholder is created for it");
|
||||
+ "\" cannot be found and a placeholder is created for it");
|
||||
// We create a dummy message descriptor here regardless of the
|
||||
// expected type. If the type should be message, this dummy
|
||||
// descriptor will work well and if the type should be enum, a
|
||||
// DescriptorValidationException will be thrown latter. In either
|
||||
// DescriptorValidationException will be thrown later. In either
|
||||
// case, the code works as expected: we allow unknown message types
|
||||
// but not unknown enum types.
|
||||
result = new Descriptor(fullname);
|
||||
@ -2766,8 +2765,7 @@ public final class Descriptors {
|
||||
final OneofDescriptorProto proto,
|
||||
final FileDescriptor file,
|
||||
final Descriptor parent,
|
||||
final int index)
|
||||
throws DescriptorValidationException {
|
||||
final int index) {
|
||||
this.proto = proto;
|
||||
fullName = computeFullName(file, parent, proto.getName());
|
||||
this.file = file;
|
||||
|
@ -38,6 +38,7 @@ import com.google.protobuf.Descriptors.FieldDescriptor;
|
||||
import com.google.protobuf.Descriptors.OneofDescriptor;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -318,14 +319,14 @@ public final class DynamicMessage extends AbstractMessage {
|
||||
/** Builder for {@link DynamicMessage}s. */
|
||||
public static final class Builder extends AbstractMessage.Builder<Builder> {
|
||||
private final Descriptor type;
|
||||
private FieldSet<FieldDescriptor> fields;
|
||||
private FieldSet.Builder<FieldDescriptor> fields;
|
||||
private final FieldDescriptor[] oneofCases;
|
||||
private UnknownFieldSet unknownFields;
|
||||
|
||||
/** Construct a {@code Builder} for the given type. */
|
||||
private Builder(Descriptor type) {
|
||||
this.type = type;
|
||||
this.fields = FieldSet.newFieldSet();
|
||||
this.fields = FieldSet.newBuilder();
|
||||
this.unknownFields = UnknownFieldSet.getDefaultInstance();
|
||||
this.oneofCases = new FieldDescriptor[type.toProto().getOneofDeclCount()];
|
||||
}
|
||||
@ -335,11 +336,7 @@ public final class DynamicMessage extends AbstractMessage {
|
||||
|
||||
@Override
|
||||
public Builder clear() {
|
||||
if (fields.isImmutable()) {
|
||||
fields = FieldSet.newFieldSet();
|
||||
} else {
|
||||
fields.clear();
|
||||
}
|
||||
fields = FieldSet.newBuilder();
|
||||
unknownFields = UnknownFieldSet.getDefaultInstance();
|
||||
return this;
|
||||
}
|
||||
@ -353,7 +350,6 @@ public final class DynamicMessage extends AbstractMessage {
|
||||
throw new IllegalArgumentException(
|
||||
"mergeFrom(Message) can only merge messages of the same type.");
|
||||
}
|
||||
ensureIsMutable();
|
||||
fields.mergeFrom(otherDynamicMessage.fields);
|
||||
mergeUnknownFields(otherDynamicMessage.unknownFields);
|
||||
for (int i = 0; i < oneofCases.length; i++) {
|
||||
@ -378,10 +374,7 @@ public final class DynamicMessage extends AbstractMessage {
|
||||
if (!isInitialized()) {
|
||||
throw newUninitializedMessageException(
|
||||
new DynamicMessage(
|
||||
type,
|
||||
fields,
|
||||
java.util.Arrays.copyOf(oneofCases, oneofCases.length),
|
||||
unknownFields));
|
||||
type, fields.build(), Arrays.copyOf(oneofCases, oneofCases.length), unknownFields));
|
||||
}
|
||||
return buildPartial();
|
||||
}
|
||||
@ -395,8 +388,8 @@ public final class DynamicMessage extends AbstractMessage {
|
||||
throw newUninitializedMessageException(
|
||||
new DynamicMessage(
|
||||
type,
|
||||
fields,
|
||||
java.util.Arrays.copyOf(oneofCases, oneofCases.length),
|
||||
fields.build(),
|
||||
Arrays.copyOf(oneofCases, oneofCases.length),
|
||||
unknownFields))
|
||||
.asInvalidProtocolBufferException();
|
||||
}
|
||||
@ -418,17 +411,16 @@ public final class DynamicMessage extends AbstractMessage {
|
||||
}
|
||||
}
|
||||
|
||||
fields.makeImmutable();
|
||||
DynamicMessage result =
|
||||
new DynamicMessage(
|
||||
type, fields, java.util.Arrays.copyOf(oneofCases, oneofCases.length), unknownFields);
|
||||
type, fields.build(), Arrays.copyOf(oneofCases, oneofCases.length), unknownFields);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder clone() {
|
||||
Builder result = new Builder(type);
|
||||
result.fields.mergeFrom(fields);
|
||||
result.fields.mergeFrom(fields.build());
|
||||
result.mergeUnknownFields(unknownFields);
|
||||
System.arraycopy(oneofCases, 0, result.oneofCases, 0, oneofCases.length);
|
||||
return result;
|
||||
@ -436,7 +428,17 @@ public final class DynamicMessage extends AbstractMessage {
|
||||
|
||||
@Override
|
||||
public boolean isInitialized() {
|
||||
return DynamicMessage.isInitialized(type, fields);
|
||||
// Check that all required fields are present.
|
||||
for (FieldDescriptor field : type.getFields()) {
|
||||
if (field.isRequired()) {
|
||||
if (!fields.hasField(field)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check that embedded messages are initialized.
|
||||
return fields.isInitialized();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -517,15 +519,12 @@ public final class DynamicMessage extends AbstractMessage {
|
||||
@Override
|
||||
public Builder setField(FieldDescriptor field, Object value) {
|
||||
verifyContainingType(field);
|
||||
ensureIsMutable();
|
||||
// TODO(xiaofeng): This check should really be put in FieldSet.setField()
|
||||
// where all other such checks are done. However, currently
|
||||
// FieldSet.setField() permits Integer value for enum fields probably
|
||||
// because of some internal features we support. Should figure it out
|
||||
// and move this check to a more appropriate place.
|
||||
if (field.getType() == FieldDescriptor.Type.ENUM) {
|
||||
ensureEnumValueDescriptor(field, value);
|
||||
}
|
||||
verifyType(field, value);
|
||||
OneofDescriptor oneofDescriptor = field.getContainingOneof();
|
||||
if (oneofDescriptor != null) {
|
||||
int index = oneofDescriptor.getIndex();
|
||||
@ -550,7 +549,6 @@ public final class DynamicMessage extends AbstractMessage {
|
||||
@Override
|
||||
public Builder clearField(FieldDescriptor field) {
|
||||
verifyContainingType(field);
|
||||
ensureIsMutable();
|
||||
OneofDescriptor oneofDescriptor = field.getContainingOneof();
|
||||
if (oneofDescriptor != null) {
|
||||
int index = oneofDescriptor.getIndex();
|
||||
@ -577,7 +575,7 @@ public final class DynamicMessage extends AbstractMessage {
|
||||
@Override
|
||||
public Builder setRepeatedField(FieldDescriptor field, int index, Object value) {
|
||||
verifyContainingType(field);
|
||||
ensureIsMutable();
|
||||
verifySingularValueType(field, value);
|
||||
fields.setRepeatedField(field, index, value);
|
||||
return this;
|
||||
}
|
||||
@ -585,7 +583,7 @@ public final class DynamicMessage extends AbstractMessage {
|
||||
@Override
|
||||
public Builder addRepeatedField(FieldDescriptor field, Object value) {
|
||||
verifyContainingType(field);
|
||||
ensureIsMutable();
|
||||
verifySingularValueType(field, value);
|
||||
fields.addRepeatedField(field, value);
|
||||
return this;
|
||||
}
|
||||
@ -622,53 +620,116 @@ public final class DynamicMessage extends AbstractMessage {
|
||||
}
|
||||
}
|
||||
|
||||
/** Verifies that the value is EnumValueDescriptor and matches Enum Type. */
|
||||
private void ensureSingularEnumValueDescriptor(FieldDescriptor field, Object value) {
|
||||
checkNotNull(value);
|
||||
if (!(value instanceof EnumValueDescriptor)) {
|
||||
throw new IllegalArgumentException(
|
||||
"DynamicMessage should use EnumValueDescriptor to set Enum Value.");
|
||||
/**
|
||||
* Verifies that {@code value} is of the appropriate type, in addition to the checks already
|
||||
* performed by {@link FieldSet.Builder}.
|
||||
*/
|
||||
private void verifySingularValueType(FieldDescriptor field, Object value) {
|
||||
// Most type checks are performed by FieldSet.Builder, but FieldSet.Builder is more permissive
|
||||
// than generated Message.Builder subclasses, so we perform extra checks in this class so that
|
||||
// DynamicMessage.Builder's semantics more closely match the semantics of generated builders.
|
||||
switch (field.getType()) {
|
||||
case ENUM:
|
||||
checkNotNull(value);
|
||||
// FieldSet.Builder accepts Integer values for enum fields.
|
||||
if (!(value instanceof EnumValueDescriptor)) {
|
||||
throw new IllegalArgumentException(
|
||||
"DynamicMessage should use EnumValueDescriptor to set Enum Value.");
|
||||
}
|
||||
// TODO(xiaofeng): Re-enable this check after Orgstore is fixed to not
|
||||
// set incorrect EnumValueDescriptors.
|
||||
// EnumDescriptor fieldType = field.getEnumType();
|
||||
// EnumDescriptor fieldValueType = ((EnumValueDescriptor) value).getType();
|
||||
// if (fieldType != fieldValueType) {
|
||||
// throw new IllegalArgumentException(String.format(
|
||||
// "EnumDescriptor %s of field doesn't match EnumDescriptor %s of field value",
|
||||
// fieldType.getFullName(), fieldValueType.getFullName()));
|
||||
// }
|
||||
break;
|
||||
case MESSAGE:
|
||||
// FieldSet.Builder accepts Message.Builder values for message fields.
|
||||
if (value instanceof Message.Builder) {
|
||||
throw new IllegalArgumentException(
|
||||
String.format(
|
||||
"Wrong object type used with protocol message reflection.\n"
|
||||
+ "Field number: %d, field java type: %s, value type: %s\n",
|
||||
field.getNumber(),
|
||||
field.getLiteType().getJavaType(),
|
||||
value.getClass().getName()));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// TODO(xiaofeng): Re-enable this check after Orgstore is fixed to not
|
||||
// set incorrect EnumValueDescriptors.
|
||||
// EnumDescriptor fieldType = field.getEnumType();
|
||||
// EnumDescriptor fieldValueType = ((EnumValueDescriptor) value).getType();
|
||||
// if (fieldType != fieldValueType) {
|
||||
// throw new IllegalArgumentException(String.format(
|
||||
// "EnumDescriptor %s of field doesn't match EnumDescriptor %s of field value",
|
||||
// fieldType.getFullName(), fieldValueType.getFullName()));
|
||||
// }
|
||||
}
|
||||
|
||||
/** Verifies the value for an enum field. */
|
||||
private void ensureEnumValueDescriptor(FieldDescriptor field, Object value) {
|
||||
/**
|
||||
* Verifies that {@code value} is of the appropriate type, in addition to the checks already
|
||||
* performed by {@link FieldSet.Builder}.
|
||||
*/
|
||||
private void verifyType(FieldDescriptor field, Object value) {
|
||||
if (field.isRepeated()) {
|
||||
for (Object item : (List) value) {
|
||||
ensureSingularEnumValueDescriptor(field, item);
|
||||
for (Object item : (List<?>) value) {
|
||||
verifySingularValueType(field, item);
|
||||
}
|
||||
} else {
|
||||
ensureSingularEnumValueDescriptor(field, value);
|
||||
}
|
||||
}
|
||||
|
||||
private void ensureIsMutable() {
|
||||
if (fields.isImmutable()) {
|
||||
fields = fields.clone();
|
||||
verifySingularValueType(field, value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public com.google.protobuf.Message.Builder getFieldBuilder(FieldDescriptor field) {
|
||||
// TODO(xiangl): need implementation for dynamic message
|
||||
throw new UnsupportedOperationException(
|
||||
"getFieldBuilder() called on a dynamic message type.");
|
||||
verifyContainingType(field);
|
||||
// Error messages chosen for parity with GeneratedMessage.getFieldBuilder.
|
||||
if (field.isMapField()) {
|
||||
throw new UnsupportedOperationException("Nested builder not supported for map fields.");
|
||||
}
|
||||
if (field.getJavaType() != FieldDescriptor.JavaType.MESSAGE) {
|
||||
throw new UnsupportedOperationException("getFieldBuilder() called on a non-Message type.");
|
||||
}
|
||||
|
||||
Object existingValue = fields.getFieldAllowBuilders(field);
|
||||
Message.Builder builder =
|
||||
existingValue == null
|
||||
? new Builder(field.getMessageType())
|
||||
: toMessageBuilder(existingValue);
|
||||
fields.setField(field, builder);
|
||||
return builder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public com.google.protobuf.Message.Builder getRepeatedFieldBuilder(
|
||||
FieldDescriptor field, int index) {
|
||||
throw new UnsupportedOperationException(
|
||||
"getRepeatedFieldBuilder() called on a dynamic message type.");
|
||||
verifyContainingType(field);
|
||||
// Error messages chosen for parity with GeneratedMessage.getRepeatedFieldBuilder.
|
||||
if (field.isMapField()) {
|
||||
throw new UnsupportedOperationException("Map fields cannot be repeated");
|
||||
}
|
||||
if (field.getJavaType() != FieldDescriptor.JavaType.MESSAGE) {
|
||||
throw new UnsupportedOperationException(
|
||||
"getRepeatedFieldBuilder() called on a non-Message type.");
|
||||
}
|
||||
|
||||
Message.Builder builder =
|
||||
toMessageBuilder(fields.getRepeatedFieldAllowBuilders(field, index));
|
||||
fields.setRepeatedField(field, index, builder);
|
||||
return builder;
|
||||
}
|
||||
|
||||
private static Message.Builder toMessageBuilder(Object o) {
|
||||
if (o instanceof Message.Builder) {
|
||||
return (Message.Builder) o;
|
||||
}
|
||||
|
||||
if (o instanceof LazyField) {
|
||||
o = ((LazyField) o).getValue();
|
||||
}
|
||||
if (o instanceof Message) {
|
||||
return ((Message) o).toBuilder();
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException(
|
||||
String.format("Cannot convert %s to Message.Builder", o.getClass()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ public class ExtensionRegistry extends ExtensionRegistryLite {
|
||||
return mutableExtensionsByName.get(fullName);
|
||||
}
|
||||
|
||||
/** Deprecated. Use {@link #findImmutableExtensionByNumber( Descriptors.Descriptor, int)} */
|
||||
/** Deprecated. Use {@link #findImmutableExtensionByNumber(Descriptors.Descriptor, int)} */
|
||||
@Deprecated
|
||||
public ExtensionInfo findExtensionByNumber(
|
||||
final Descriptor containingType, final int fieldNumber) {
|
||||
|
@ -33,6 +33,7 @@ package com.google.protobuf;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
@CheckReturnValue
|
||||
abstract class ExtensionSchema<T extends FieldSet.FieldDescriptorLite<T>> {
|
||||
|
||||
/** Returns true for messages that support extensions. */
|
||||
|
@ -497,7 +497,7 @@ final class ExtensionSchemaFull extends ExtensionSchema<FieldDescriptor> {
|
||||
Object findExtensionByNumber(
|
||||
ExtensionRegistryLite extensionRegistry, MessageLite defaultInstance, int number) {
|
||||
return ((ExtensionRegistry) extensionRegistry)
|
||||
.findExtensionByNumber(((Message) defaultInstance).getDescriptorForType(), number);
|
||||
.findImmutableExtensionByNumber(((Message) defaultInstance).getDescriptorForType(), number);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -37,6 +37,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@CheckReturnValue
|
||||
@SuppressWarnings("unchecked")
|
||||
final class ExtensionSchemaLite extends ExtensionSchema<ExtensionDescriptor> {
|
||||
|
||||
|
@ -30,6 +30,7 @@
|
||||
|
||||
package com.google.protobuf;
|
||||
|
||||
@CheckReturnValue
|
||||
final class ExtensionSchemas {
|
||||
private static final ExtensionSchema<?> LITE_SCHEMA = new ExtensionSchemaLite();
|
||||
private static final ExtensionSchema<?> FULL_SCHEMA = loadSchemaForFullRuntime();
|
||||
|
@ -36,6 +36,7 @@ import com.google.protobuf.Internal.EnumVerifier;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
/** Information for a single field in a protobuf message class. */
|
||||
@CheckReturnValue
|
||||
@ExperimentalApi
|
||||
final class FieldInfo implements Comparable<FieldInfo> {
|
||||
private final Field field;
|
||||
|
@ -387,17 +387,10 @@ final class FieldSet<T extends FieldSet.FieldDescriptorLite<T>> {
|
||||
* (For repeated fields, this checks if the object is the right type to be one element of the
|
||||
* field.)
|
||||
*
|
||||
* @throws IllegalArgumentException The value is not of the right type.
|
||||
* @throws IllegalArgumentException the value is not of the right type
|
||||
*/
|
||||
private void verifyType(final T descriptor, final Object value) {
|
||||
if (!isValidType(descriptor.getLiteType(), value)) {
|
||||
// TODO(kenton): When chaining calls to setField(), it can be hard to
|
||||
// tell from the stack trace which exact call failed, since the whole
|
||||
// chain is considered one line of code. It would be nice to print
|
||||
// more information here, e.g. naming the field. We used to do that.
|
||||
// But we can't now that FieldSet doesn't use descriptors. Maybe this
|
||||
// isn't a big deal, though, since it would only really apply when using
|
||||
// reflection and generally people don't chain reflection setters.
|
||||
throw new IllegalArgumentException(
|
||||
String.format(
|
||||
"Wrong object type used with protocol message reflection.\n"
|
||||
@ -427,10 +420,8 @@ final class FieldSet<T extends FieldSet.FieldDescriptorLite<T>> {
|
||||
case BYTE_STRING:
|
||||
return value instanceof ByteString || value instanceof byte[];
|
||||
case ENUM:
|
||||
// TODO(kenton): Caller must do type checking here, I guess.
|
||||
return (value instanceof Integer || value instanceof Internal.EnumLite);
|
||||
case MESSAGE:
|
||||
// TODO(kenton): Caller must do type checking here, I guess.
|
||||
return (value instanceof MessageLite) || (value instanceof LazyField);
|
||||
}
|
||||
return false;
|
||||
@ -458,34 +449,36 @@ final class FieldSet<T extends FieldSet.FieldDescriptorLite<T>> {
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static <T extends FieldDescriptorLite<T>> boolean isInitialized(
|
||||
final Map.Entry<T, Object> entry) {
|
||||
final T descriptor = entry.getKey();
|
||||
if (descriptor.getLiteJavaType() == WireFormat.JavaType.MESSAGE) {
|
||||
if (descriptor.isRepeated()) {
|
||||
for (final MessageLite element : (List<MessageLite>) entry.getValue()) {
|
||||
if (!element.isInitialized()) {
|
||||
for (final Object element : (List<?>) entry.getValue()) {
|
||||
if (!isMessageFieldValueInitialized(element)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Object value = entry.getValue();
|
||||
if (value instanceof MessageLite) {
|
||||
if (!((MessageLite) value).isInitialized()) {
|
||||
return false;
|
||||
}
|
||||
} else if (value instanceof LazyField) {
|
||||
return true;
|
||||
} else {
|
||||
throw new IllegalArgumentException(
|
||||
"Wrong object type used with protocol message reflection.");
|
||||
}
|
||||
return isMessageFieldValueInitialized(entry.getValue());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean isMessageFieldValueInitialized(Object value) {
|
||||
if (value instanceof MessageLiteOrBuilder) {
|
||||
// Message fields cannot have builder values in FieldSet, but can in FieldSet.Builder, and
|
||||
// this method is used by FieldSet.Builder.isInitialized.
|
||||
return ((MessageLiteOrBuilder) value).isInitialized();
|
||||
} else if (value instanceof LazyField) {
|
||||
return true;
|
||||
} else {
|
||||
throw new IllegalArgumentException(
|
||||
"Wrong object type used with protocol message reflection.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a field type, return the wire type.
|
||||
*
|
||||
@ -554,18 +547,15 @@ final class FieldSet<T extends FieldSet.FieldDescriptorLite<T>> {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO(kenton): Move static parsing and serialization methods into some
|
||||
// other class. Probably WireFormat.
|
||||
|
||||
/**
|
||||
* Read a field of any primitive type for immutable messages from a CodedInputStream. Enums,
|
||||
* groups, and embedded messages are not handled by this method.
|
||||
*
|
||||
* @param input The stream from which to read.
|
||||
* @param type Declared type of the field.
|
||||
* @param checkUtf8 When true, check that the input is valid utf8.
|
||||
* @return An object representing the field's value, of the exact type which would be returned by
|
||||
* {@link Message#getField(Descriptors.FieldDescriptor)} for this field.
|
||||
* @param input the stream from which to read
|
||||
* @param type declared type of the field
|
||||
* @param checkUtf8 When true, check that the input is valid UTF-8
|
||||
* @return an object representing the field's value, of the exact type which would be returned by
|
||||
* {@link Message#getField(Descriptors.FieldDescriptor)} for this field
|
||||
*/
|
||||
public static Object readPrimitiveField(
|
||||
CodedInputStream input, final WireFormat.FieldType type, boolean checkUtf8)
|
||||
@ -737,7 +727,7 @@ final class FieldSet<T extends FieldSet.FieldDescriptorLite<T>> {
|
||||
for (final Object element : valueList) {
|
||||
dataSize += computeElementSizeNoTag(type, element);
|
||||
}
|
||||
output.writeRawVarint32(dataSize);
|
||||
output.writeUInt32NoTag(dataSize);
|
||||
// Write the data itself, without any tags.
|
||||
for (final Object element : valueList) {
|
||||
writeElementNoTag(output, type, element);
|
||||
@ -903,7 +893,7 @@ final class FieldSet<T extends FieldSet.FieldDescriptorLite<T>> {
|
||||
}
|
||||
return dataSize
|
||||
+ CodedOutputStream.computeTagSize(number)
|
||||
+ CodedOutputStream.computeRawVarint32Size(dataSize);
|
||||
+ CodedOutputStream.computeUInt32SizeNoTag(dataSize);
|
||||
} else {
|
||||
int size = 0;
|
||||
for (final Object element : (List<?>) value) {
|
||||
@ -1114,10 +1104,10 @@ final class FieldSet<T extends FieldSet.FieldDescriptorLite<T>> {
|
||||
public int getRepeatedFieldCount(final T descriptor) {
|
||||
if (!descriptor.isRepeated()) {
|
||||
throw new IllegalArgumentException(
|
||||
"getRepeatedField() can only be called on repeated fields.");
|
||||
"getRepeatedFieldCount() can only be called on repeated fields.");
|
||||
}
|
||||
|
||||
final Object value = getField(descriptor);
|
||||
final Object value = getFieldAllowBuilders(descriptor);
|
||||
if (value == null) {
|
||||
return 0;
|
||||
} else {
|
||||
@ -1169,7 +1159,7 @@ final class FieldSet<T extends FieldSet.FieldDescriptorLite<T>> {
|
||||
|
||||
hasNestedBuilders = hasNestedBuilders || value instanceof MessageLite.Builder;
|
||||
|
||||
final Object list = getField(descriptor);
|
||||
final Object list = getFieldAllowBuilders(descriptor);
|
||||
if (list == null) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
@ -1194,7 +1184,7 @@ final class FieldSet<T extends FieldSet.FieldDescriptorLite<T>> {
|
||||
|
||||
verifyType(descriptor, value);
|
||||
|
||||
final Object existingValue = getField(descriptor);
|
||||
final Object existingValue = getFieldAllowBuilders(descriptor);
|
||||
List<Object> list;
|
||||
if (existingValue == null) {
|
||||
list = new ArrayList<>();
|
||||
@ -1262,7 +1252,7 @@ final class FieldSet<T extends FieldSet.FieldDescriptorLite<T>> {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
@SuppressWarnings("unchecked")
|
||||
private void mergeFromField(final Map.Entry<T, Object> entry) {
|
||||
final T descriptor = entry.getKey();
|
||||
Object otherValue = entry.getValue();
|
||||
@ -1271,16 +1261,16 @@ final class FieldSet<T extends FieldSet.FieldDescriptorLite<T>> {
|
||||
}
|
||||
|
||||
if (descriptor.isRepeated()) {
|
||||
Object value = getField(descriptor);
|
||||
List<Object> value = (List<Object>) getFieldAllowBuilders(descriptor);
|
||||
if (value == null) {
|
||||
value = new ArrayList<>();
|
||||
fields.put(descriptor, value);
|
||||
}
|
||||
for (Object element : (List) otherValue) {
|
||||
((List) value).add(FieldSet.cloneIfMutable(element));
|
||||
for (Object element : (List<?>) otherValue) {
|
||||
value.add(FieldSet.cloneIfMutable(element));
|
||||
}
|
||||
fields.put(descriptor, value);
|
||||
} else if (descriptor.getLiteJavaType() == WireFormat.JavaType.MESSAGE) {
|
||||
Object value = getField(descriptor);
|
||||
Object value = getFieldAllowBuilders(descriptor);
|
||||
if (value == null) {
|
||||
fields.put(descriptor, FieldSet.cloneIfMutable(otherValue));
|
||||
} else {
|
||||
|
@ -985,7 +985,6 @@ public abstract class GeneratedMessageLite<
|
||||
|
||||
/** Get one element of a repeated extension. */
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public final <Type> Type getExtension(
|
||||
final ExtensionLite<MessageType, List<Type>> extension, final int index) {
|
||||
return instance.getExtension(extension, index);
|
||||
@ -1342,7 +1341,6 @@ public abstract class GeneratedMessageLite<
|
||||
*
|
||||
* @return a GeneratedMessage of the type that was serialized
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
protected Object readResolve() throws ObjectStreamException {
|
||||
try {
|
||||
Class<?> messageClass = resolveMessageClass();
|
||||
@ -1542,6 +1540,8 @@ public abstract class GeneratedMessageLite<
|
||||
e = new InvalidProtocolBufferException(e);
|
||||
}
|
||||
throw e.setUnfinishedMessage(result);
|
||||
} catch (UninitializedMessageException e) {
|
||||
throw e.asInvalidProtocolBufferException().setUnfinishedMessage(result);
|
||||
} catch (IOException e) {
|
||||
if (e.getCause() instanceof InvalidProtocolBufferException) {
|
||||
throw (InvalidProtocolBufferException) e.getCause();
|
||||
@ -1557,7 +1557,7 @@ public abstract class GeneratedMessageLite<
|
||||
}
|
||||
|
||||
/** A static helper method for parsing a partial from byte array. */
|
||||
static <T extends GeneratedMessageLite<T, ?>> T parsePartialFrom(
|
||||
private static <T extends GeneratedMessageLite<T, ?>> T parsePartialFrom(
|
||||
T instance, byte[] input, int offset, int length, ExtensionRegistryLite extensionRegistry)
|
||||
throws InvalidProtocolBufferException {
|
||||
@SuppressWarnings("unchecked") // Guaranteed by protoc
|
||||
@ -1575,6 +1575,8 @@ public abstract class GeneratedMessageLite<
|
||||
e = new InvalidProtocolBufferException(e);
|
||||
}
|
||||
throw e.setUnfinishedMessage(result);
|
||||
} catch (UninitializedMessageException e) {
|
||||
throw e.asInvalidProtocolBufferException().setUnfinishedMessage(result);
|
||||
} catch (IOException e) {
|
||||
if (e.getCause() instanceof InvalidProtocolBufferException) {
|
||||
throw (InvalidProtocolBufferException) e.getCause();
|
||||
@ -1641,28 +1643,14 @@ public abstract class GeneratedMessageLite<
|
||||
private static <T extends GeneratedMessageLite<T, ?>> T parsePartialFrom(
|
||||
T defaultInstance, ByteString data, ExtensionRegistryLite extensionRegistry)
|
||||
throws InvalidProtocolBufferException {
|
||||
T message;
|
||||
CodedInputStream input = data.newCodedInput();
|
||||
T message = parsePartialFrom(defaultInstance, input, extensionRegistry);
|
||||
try {
|
||||
CodedInputStream input = data.newCodedInput();
|
||||
message = parsePartialFrom(defaultInstance, input, extensionRegistry);
|
||||
try {
|
||||
input.checkLastTagWas(0);
|
||||
} catch (InvalidProtocolBufferException e) {
|
||||
throw e.setUnfinishedMessage(message);
|
||||
}
|
||||
return message;
|
||||
input.checkLastTagWas(0);
|
||||
} catch (InvalidProtocolBufferException e) {
|
||||
throw e;
|
||||
throw e.setUnfinishedMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
// This is a special case since we want to verify that the last tag is 0. We assume we exhaust the
|
||||
// ByteString.
|
||||
private static <T extends GeneratedMessageLite<T, ?>> T parsePartialFrom(
|
||||
T defaultInstance, byte[] data, ExtensionRegistryLite extensionRegistry)
|
||||
throws InvalidProtocolBufferException {
|
||||
return checkMessageInitialized(
|
||||
parsePartialFrom(defaultInstance, data, 0, data.length, extensionRegistry));
|
||||
return message;
|
||||
}
|
||||
|
||||
// Validates last tag.
|
||||
|
@ -2726,8 +2726,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage
|
||||
|
||||
@Override
|
||||
public com.google.protobuf.Message.Builder getRepeatedBuilder(Builder builder, int index) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Nested builder not supported for map fields.");
|
||||
throw new UnsupportedOperationException("Map fields cannot be repeated");
|
||||
}
|
||||
}
|
||||
|
||||
|
59
java/core/src/main/java/com/google/protobuf/InlineMe.java
Normal file
59
java/core/src/main/java/com/google/protobuf/InlineMe.java
Normal file
@ -0,0 +1,59 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
package com.google.protobuf;
|
||||
|
||||
import static java.lang.annotation.ElementType.CONSTRUCTOR;
|
||||
import static java.lang.annotation.ElementType.METHOD;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Indicates that callers of this API should be inlined. That is, this API is trivially expressible
|
||||
* in terms of another API, for example a method that just calls another method.
|
||||
*/
|
||||
@Documented
|
||||
@Target({METHOD, CONSTRUCTOR})
|
||||
@interface InlineMe {
|
||||
/**
|
||||
* What the caller should be replaced with. Local parameter names can be used in the replacement
|
||||
* string. If you are invoking an instance method or constructor, you must include the implicit
|
||||
* {@code this} in the replacement body. If you are invoking a static method, you must include the
|
||||
* implicit {@code ClassName} in the replacement body.
|
||||
*/
|
||||
String replacement();
|
||||
|
||||
/** The new imports to (optionally) add to the caller. */
|
||||
String[] imports() default {};
|
||||
|
||||
/** The new static imports to (optionally) add to the caller. */
|
||||
String[] staticImports() default {};
|
||||
}
|
@ -31,6 +31,7 @@
|
||||
package com.google.protobuf;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.nio.Buffer;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.AbstractList;
|
||||
@ -139,10 +140,12 @@ public final class Internal {
|
||||
ByteBuffer temp = source.duplicate();
|
||||
// We want to copy all the data in the source ByteBuffer, not just the
|
||||
// remaining bytes.
|
||||
temp.clear();
|
||||
// View ByteBuffer as Buffer to avoid issue with covariant return types
|
||||
// See https://issues.apache.org/jira/browse/MRESOLVER-85
|
||||
((Buffer) temp).clear();
|
||||
ByteBuffer result = ByteBuffer.allocate(temp.capacity());
|
||||
result.put(temp);
|
||||
result.clear();
|
||||
((Buffer) result).clear();
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -450,7 +453,6 @@ public final class Internal {
|
||||
this.valueConverter = valueConverter;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public V get(Object key) {
|
||||
RealValue result = realMap.get(key);
|
||||
@ -549,7 +551,6 @@ public final class Internal {
|
||||
if (!(o instanceof Map.Entry)) {
|
||||
return false;
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
Map.Entry<?, ?> other = (Map.Entry<?, ?>) o;
|
||||
return getKey().equals(other.getKey()) && getValue().equals(getValue());
|
||||
}
|
||||
|
@ -33,8 +33,8 @@ package com.google.protobuf;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Thrown when a protocol message being parsed is invalid in some way, e.g. it contains a malformed
|
||||
* varint or a negative byte length.
|
||||
* Thrown when a protocol message being parsed is invalid in some way. For instance,
|
||||
* it contains a malformed varint or a negative byte length.
|
||||
*
|
||||
* @author kenton@google.com Kenton Varda
|
||||
*/
|
||||
@ -43,15 +43,15 @@ public class InvalidProtocolBufferException extends IOException {
|
||||
private MessageLite unfinishedMessage = null;
|
||||
private boolean wasThrownFromInputStream;
|
||||
|
||||
public InvalidProtocolBufferException(final String description) {
|
||||
public InvalidProtocolBufferException(String description) {
|
||||
super(description);
|
||||
}
|
||||
|
||||
public InvalidProtocolBufferException(IOException e) {
|
||||
public InvalidProtocolBufferException(Exception e) {
|
||||
super(e.getMessage(), e);
|
||||
}
|
||||
|
||||
public InvalidProtocolBufferException(final String description, IOException e) {
|
||||
public InvalidProtocolBufferException(String description, Exception e) {
|
||||
super(description, e);
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,7 @@ import java.util.List;
|
||||
/**
|
||||
* Utility class that aids in properly manipulating list fields for either the lite or full runtime.
|
||||
*/
|
||||
@CheckReturnValue
|
||||
abstract class ListFieldSchema {
|
||||
// Disallow construction.
|
||||
private ListFieldSchema() {}
|
||||
|
@ -35,6 +35,7 @@ import static com.google.protobuf.Internal.checkNotNull;
|
||||
/**
|
||||
* Dynamically generates a manifest-based (i.e. table-based) schema for a given protobuf message.
|
||||
*/
|
||||
@CheckReturnValue
|
||||
@ExperimentalApi
|
||||
final class ManifestSchemaFactory implements SchemaFactory {
|
||||
|
||||
|
@ -437,7 +437,6 @@ public final class MapEntry<K, V> extends AbstractMessage {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Builder<K, V> clone() {
|
||||
return new Builder<>(metadata, key, value, hasKey, hasValue);
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ public class MapField<K, V> implements MutabilityOracle {
|
||||
|
||||
private volatile boolean isMutable;
|
||||
private volatile StorageMode mode;
|
||||
private MutatabilityAwareMap<K, V> mapData;
|
||||
private MutabilityAwareMap<K, V> mapData;
|
||||
private List<Message> listData;
|
||||
|
||||
// Convert between a map entry Message and a key-value pair.
|
||||
@ -129,7 +129,7 @@ public class MapField<K, V> implements MutabilityOracle {
|
||||
this.converter = converter;
|
||||
this.isMutable = true;
|
||||
this.mode = mode;
|
||||
this.mapData = new MutatabilityAwareMap<K, V>(this, mapData);
|
||||
this.mapData = new MutabilityAwareMap<K, V>(this, mapData);
|
||||
this.listData = null;
|
||||
}
|
||||
|
||||
@ -154,12 +154,11 @@ public class MapField<K, V> implements MutabilityOracle {
|
||||
return converter.convertKeyAndValueToMessage(key, value);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void convertMessageToKeyAndValue(Message message, Map<K, V> map) {
|
||||
converter.convertMessageToKeyAndValue(message, map);
|
||||
}
|
||||
|
||||
private List<Message> convertMapToList(MutatabilityAwareMap<K, V> mapData) {
|
||||
private List<Message> convertMapToList(MutabilityAwareMap<K, V> mapData) {
|
||||
List<Message> listData = new ArrayList<Message>();
|
||||
for (Map.Entry<K, V> entry : mapData.entrySet()) {
|
||||
listData.add(convertKeyAndValueToMessage(entry.getKey(), entry.getValue()));
|
||||
@ -167,12 +166,12 @@ public class MapField<K, V> implements MutabilityOracle {
|
||||
return listData;
|
||||
}
|
||||
|
||||
private MutatabilityAwareMap<K, V> convertListToMap(List<Message> listData) {
|
||||
private MutabilityAwareMap<K, V> convertListToMap(List<Message> listData) {
|
||||
Map<K, V> mapData = new LinkedHashMap<K, V>();
|
||||
for (Message item : listData) {
|
||||
convertMessageToKeyAndValue(item, mapData);
|
||||
}
|
||||
return new MutatabilityAwareMap<K, V>(this, mapData);
|
||||
return new MutabilityAwareMap<K, V>(this, mapData);
|
||||
}
|
||||
|
||||
/** Returns the content of this MapField as a read-only Map. */
|
||||
@ -205,7 +204,7 @@ public class MapField<K, V> implements MutabilityOracle {
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
mapData = new MutatabilityAwareMap<K, V>(this, new LinkedHashMap<K, V>());
|
||||
mapData = new MutabilityAwareMap<K, V>(this, new LinkedHashMap<K, V>());
|
||||
mode = StorageMode.MAP;
|
||||
}
|
||||
|
||||
@ -283,11 +282,11 @@ public class MapField<K, V> implements MutabilityOracle {
|
||||
}
|
||||
|
||||
/** An internal map that checks for mutability before delegating. */
|
||||
private static class MutatabilityAwareMap<K, V> implements Map<K, V> {
|
||||
private static class MutabilityAwareMap<K, V> implements Map<K, V> {
|
||||
private final MutabilityOracle mutabilityOracle;
|
||||
private final Map<K, V> delegate;
|
||||
|
||||
MutatabilityAwareMap(MutabilityOracle mutabilityOracle, Map<K, V> delegate) {
|
||||
MutabilityAwareMap(MutabilityOracle mutabilityOracle, Map<K, V> delegate) {
|
||||
this.mutabilityOracle = mutabilityOracle;
|
||||
this.delegate = delegate;
|
||||
}
|
||||
@ -349,17 +348,17 @@ public class MapField<K, V> implements MutabilityOracle {
|
||||
|
||||
@Override
|
||||
public Set<K> keySet() {
|
||||
return new MutatabilityAwareSet<K>(mutabilityOracle, delegate.keySet());
|
||||
return new MutabilityAwareSet<K>(mutabilityOracle, delegate.keySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<V> values() {
|
||||
return new MutatabilityAwareCollection<V>(mutabilityOracle, delegate.values());
|
||||
return new MutabilityAwareCollection<V>(mutabilityOracle, delegate.values());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<java.util.Map.Entry<K, V>> entrySet() {
|
||||
return new MutatabilityAwareSet<Entry<K, V>>(mutabilityOracle, delegate.entrySet());
|
||||
return new MutabilityAwareSet<Entry<K, V>>(mutabilityOracle, delegate.entrySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -378,11 +377,11 @@ public class MapField<K, V> implements MutabilityOracle {
|
||||
}
|
||||
|
||||
/** An internal collection that checks for mutability before delegating. */
|
||||
private static class MutatabilityAwareCollection<E> implements Collection<E> {
|
||||
private static class MutabilityAwareCollection<E> implements Collection<E> {
|
||||
private final MutabilityOracle mutabilityOracle;
|
||||
private final Collection<E> delegate;
|
||||
|
||||
MutatabilityAwareCollection(MutabilityOracle mutabilityOracle, Collection<E> delegate) {
|
||||
MutabilityAwareCollection(MutabilityOracle mutabilityOracle, Collection<E> delegate) {
|
||||
this.mutabilityOracle = mutabilityOracle;
|
||||
this.delegate = delegate;
|
||||
}
|
||||
@ -404,7 +403,7 @@ public class MapField<K, V> implements MutabilityOracle {
|
||||
|
||||
@Override
|
||||
public Iterator<E> iterator() {
|
||||
return new MutatabilityAwareIterator<E>(mutabilityOracle, delegate.iterator());
|
||||
return new MutabilityAwareIterator<E>(mutabilityOracle, delegate.iterator());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -475,11 +474,11 @@ public class MapField<K, V> implements MutabilityOracle {
|
||||
}
|
||||
|
||||
/** An internal set that checks for mutability before delegating. */
|
||||
private static class MutatabilityAwareSet<E> implements Set<E> {
|
||||
private static class MutabilityAwareSet<E> implements Set<E> {
|
||||
private final MutabilityOracle mutabilityOracle;
|
||||
private final Set<E> delegate;
|
||||
|
||||
MutatabilityAwareSet(MutabilityOracle mutabilityOracle, Set<E> delegate) {
|
||||
MutabilityAwareSet(MutabilityOracle mutabilityOracle, Set<E> delegate) {
|
||||
this.mutabilityOracle = mutabilityOracle;
|
||||
this.delegate = delegate;
|
||||
}
|
||||
@ -501,7 +500,7 @@ public class MapField<K, V> implements MutabilityOracle {
|
||||
|
||||
@Override
|
||||
public Iterator<E> iterator() {
|
||||
return new MutatabilityAwareIterator<E>(mutabilityOracle, delegate.iterator());
|
||||
return new MutabilityAwareIterator<E>(mutabilityOracle, delegate.iterator());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -572,11 +571,11 @@ public class MapField<K, V> implements MutabilityOracle {
|
||||
}
|
||||
|
||||
/** An internal iterator that checks for mutability before delegating. */
|
||||
private static class MutatabilityAwareIterator<E> implements Iterator<E> {
|
||||
private static class MutabilityAwareIterator<E> implements Iterator<E> {
|
||||
private final MutabilityOracle mutabilityOracle;
|
||||
private final Iterator<E> delegate;
|
||||
|
||||
MutatabilityAwareIterator(MutabilityOracle mutabilityOracle, Iterator<E> delegate) {
|
||||
MutabilityAwareIterator(MutabilityOracle mutabilityOracle, Iterator<E> delegate) {
|
||||
this.mutabilityOracle = mutabilityOracle;
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
@ -57,15 +57,14 @@ public final class MapFieldLite<K, V> extends LinkedHashMap<K, V> {
|
||||
this.isMutable = true;
|
||||
}
|
||||
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
private static final MapFieldLite EMPTY_MAP_FIELD = new MapFieldLite<>();
|
||||
private static final MapFieldLite<?, ?> EMPTY_MAP_FIELD = new MapFieldLite<>();
|
||||
|
||||
static {
|
||||
EMPTY_MAP_FIELD.makeImmutable();
|
||||
}
|
||||
|
||||
/** Returns a singleton immutable empty MapFieldLite instance. */
|
||||
@SuppressWarnings({"unchecked", "cast"})
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <K, V> MapFieldLite<K, V> emptyMapField() {
|
||||
return (MapFieldLite<K, V>) EMPTY_MAP_FIELD;
|
||||
}
|
||||
@ -77,7 +76,6 @@ public final class MapFieldLite<K, V> extends LinkedHashMap<K, V> {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked", "cast"})
|
||||
@Override
|
||||
public Set<Map.Entry<K, V>> entrySet() {
|
||||
return isEmpty() ? Collections.<Map.Entry<K, V>>emptySet() : super.entrySet();
|
||||
|
@ -32,6 +32,7 @@ package com.google.protobuf;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@CheckReturnValue
|
||||
interface MapFieldSchema {
|
||||
/** Returns the map data for mutation. */
|
||||
Map<?, ?> forMutableMapData(Object mapField);
|
||||
@ -56,6 +57,7 @@ interface MapFieldSchema {
|
||||
MapEntryLite.Metadata<?, ?> forMapMetadata(Object mapDefaultEntry);
|
||||
|
||||
/** Merges {@code srcMapField} into {@code destMapField}, and returns the merged instance. */
|
||||
@CanIgnoreReturnValue
|
||||
Object mergeFrom(Object destMapField, Object srcMapField);
|
||||
|
||||
/** Compute the serialized size for the map with a given field number. */
|
||||
|
@ -33,6 +33,7 @@ package com.google.protobuf;
|
||||
import com.google.protobuf.MapEntryLite.Metadata;
|
||||
import java.util.Map;
|
||||
|
||||
@CheckReturnValue
|
||||
class MapFieldSchemaLite implements MapFieldSchema {
|
||||
|
||||
@Override
|
||||
|
@ -30,6 +30,7 @@
|
||||
|
||||
package com.google.protobuf;
|
||||
|
||||
@CheckReturnValue
|
||||
final class MapFieldSchemas {
|
||||
private static final MapFieldSchema FULL_SCHEMA = loadSchemaForFullRuntime();
|
||||
private static final MapFieldSchema LITE_SCHEMA = new MapFieldSchemaLite();
|
||||
|
@ -28,9 +28,6 @@
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// TODO(kenton): Use generics? E.g. Builder<BuilderType extends Builder>, then
|
||||
// mergeFrom*() could return BuilderType for better type-safety.
|
||||
|
||||
package com.google.protobuf;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -41,8 +38,8 @@ import java.util.Map;
|
||||
* Abstract interface implemented by Protocol Message objects.
|
||||
*
|
||||
* <p>See also {@link MessageLite}, which defines most of the methods that typical users care about.
|
||||
* {@link Message} adds to it methods that are not available in the "lite" runtime. The biggest
|
||||
* added features are introspection and reflection -- i.e., getting descriptors for the message type
|
||||
* {@link Message} adds methods that are not available in the "lite" runtime. The biggest added
|
||||
* features are introspection and reflection; that is, getting descriptors for the message type
|
||||
* and accessing the field values dynamically.
|
||||
*
|
||||
* @author kenton@google.com Kenton Varda
|
||||
@ -165,16 +162,13 @@ public interface Message extends MessageLite, MessageOrBuilder {
|
||||
* Get a nested builder instance for the given field.
|
||||
*
|
||||
* <p>Normally, we hold a reference to the immutable message object for the message type field.
|
||||
* Some implementations(the generated message builders), however, can also hold a reference to
|
||||
* Some implementations (the generated message builders) can also hold a reference to
|
||||
* the builder object (a nested builder) for the field.
|
||||
*
|
||||
* <p>If the field is already backed up by a nested builder, the nested builder will be
|
||||
* returned. Otherwise, a new field builder will be created and returned. The original message
|
||||
* field (if exist) will be merged into the field builder, which will then be nested into its
|
||||
* <p>If the field is already backed up by a nested builder, the nested builder is
|
||||
* returned. Otherwise, a new field builder is created and returned. The original message
|
||||
* field (if one exists) is merged into the field builder, which is then nested into its
|
||||
* parent builder.
|
||||
*
|
||||
* <p>NOTE: implementations that do not support nested builders will throw <code>
|
||||
* UnsupportedOperationException</code>.
|
||||
*/
|
||||
Builder getFieldBuilder(Descriptors.FieldDescriptor field);
|
||||
|
||||
@ -182,22 +176,19 @@ public interface Message extends MessageLite, MessageOrBuilder {
|
||||
* Get a nested builder instance for the given repeated field instance.
|
||||
*
|
||||
* <p>Normally, we hold a reference to the immutable message object for the message type field.
|
||||
* Some implementations(the generated message builders), however, can also hold a reference to
|
||||
* Some implementations (the generated message builders) can also hold a reference to
|
||||
* the builder object (a nested builder) for the field.
|
||||
*
|
||||
* <p>If the field is already backed up by a nested builder, the nested builder will be
|
||||
* returned. Otherwise, a new field builder will be created and returned. The original message
|
||||
* field (if exist) will be merged into the field builder, which will then be nested into its
|
||||
* <p>If the field is already backed up by a nested builder, the nested builder is
|
||||
* returned. Otherwise, a new field builder is created and returned. The original message
|
||||
* field (if one exists) is merged into the field builder, which is then nested into its
|
||||
* parent builder.
|
||||
*
|
||||
* <p>NOTE: implementations that do not support nested builders will throw <code>
|
||||
* UnsupportedOperationException</code>.
|
||||
*/
|
||||
Builder getRepeatedFieldBuilder(Descriptors.FieldDescriptor field, int index);
|
||||
|
||||
/**
|
||||
* Sets a field to the given value. The value must be of the correct type for this field, i.e.
|
||||
* the same type that {@link Message#getField(Descriptors.FieldDescriptor)} would return.
|
||||
* Sets a field to the given value. The value must be of the correct type for this field, that
|
||||
* is, the same type that {@link Message#getField(Descriptors.FieldDescriptor)} returns.
|
||||
*/
|
||||
Builder setField(Descriptors.FieldDescriptor field, Object value);
|
||||
|
||||
@ -215,10 +206,10 @@ public interface Message extends MessageLite, MessageOrBuilder {
|
||||
|
||||
/**
|
||||
* Sets an element of a repeated field to the given value. The value must be of the correct type
|
||||
* for this field, i.e. the same type that {@link
|
||||
* Message#getRepeatedField(Descriptors.FieldDescriptor,int)} would return.
|
||||
* for this field; that is, the same type that {@link
|
||||
* Message#getRepeatedField(Descriptors.FieldDescriptor,int)} returns.
|
||||
*
|
||||
* @throws IllegalArgumentException The field is not a repeated field, or {@code
|
||||
* @throws IllegalArgumentException if the field is not a repeated field, or {@code
|
||||
* field.getContainingType() != getDescriptorForType()}.
|
||||
*/
|
||||
Builder setRepeatedField(Descriptors.FieldDescriptor field, int index, Object value);
|
||||
@ -226,8 +217,8 @@ public interface Message extends MessageLite, MessageOrBuilder {
|
||||
/**
|
||||
* Like {@code setRepeatedField}, but appends the value as a new element.
|
||||
*
|
||||
* @throws IllegalArgumentException The field is not a repeated field, or {@code
|
||||
* field.getContainingType() != getDescriptorForType()}.
|
||||
* @throws IllegalArgumentException if the field is not a repeated field, or {@code
|
||||
* field.getContainingType() != getDescriptorForType()}
|
||||
*/
|
||||
Builder addRepeatedField(Descriptors.FieldDescriptor field, Object value);
|
||||
|
||||
|
@ -30,7 +30,8 @@
|
||||
|
||||
package com.google.protobuf;
|
||||
|
||||
/** A MesageInfo object describes a proto message type. */
|
||||
/** A MessageInfo object describes a proto message type. */
|
||||
@CheckReturnValue
|
||||
interface MessageInfo {
|
||||
/** Gets syntax for this type. */
|
||||
ProtoSyntax getSyntax();
|
||||
|
@ -32,6 +32,7 @@ package com.google.protobuf;
|
||||
|
||||
/** A factory that creates {@link MessageInfo} instances for message types. */
|
||||
@ExperimentalApi
|
||||
@CheckReturnValue
|
||||
interface MessageInfoFactory {
|
||||
/** Whether the message class is supported by this factory. */
|
||||
boolean isSupported(Class<?> clazz);
|
||||
|
@ -28,9 +28,6 @@
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// TODO(kenton): Use generics? E.g. Builder<BuilderType extends Builder>, then
|
||||
// mergeFrom*() could return BuilderType for better type-safety.
|
||||
|
||||
package com.google.protobuf;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -109,10 +106,10 @@ public interface MessageLite extends MessageLiteOrBuilder {
|
||||
*
|
||||
* <p>NOTE: Protocol Buffers are not self-delimiting. Therefore, if you write any more data to the
|
||||
* stream after the message, you must somehow ensure that the parser on the receiving end does not
|
||||
* interpret this as being part of the protocol message. This can be done e.g. by writing the size
|
||||
* of the message before the data, then making sure to limit the input to that size on the
|
||||
* receiving end (e.g. by wrapping the InputStream in one which limits the input). Alternatively,
|
||||
* just use {@link #writeDelimitedTo(OutputStream)}.
|
||||
* interpret this as being part of the protocol message. This can be done, for instance, by
|
||||
* writing the size of the message before the data, then making sure to limit the input to that
|
||||
* size on the receiving end by wrapping the InputStream in one which limits the input.
|
||||
* Alternatively, just use {@link #writeDelimitedTo(OutputStream)}.
|
||||
*/
|
||||
void writeTo(OutputStream output) throws IOException;
|
||||
|
||||
@ -183,6 +180,11 @@ public interface MessageLite extends MessageLiteOrBuilder {
|
||||
*
|
||||
* <p>Note: The caller should call {@link CodedInputStream#checkLastTagWas(int)} after calling
|
||||
* this to verify that the last tag seen was the appropriate end-group tag, or zero for EOF.
|
||||
*
|
||||
* @throws InvalidProtocolBufferException the bytes read are not syntactically correct
|
||||
* according to the protobuf wire format specification. The data is corrupt, incomplete,
|
||||
* or was never a protobuf in the first place.
|
||||
* @throws IOException an I/O error reading from the stream
|
||||
*/
|
||||
Builder mergeFrom(CodedInputStream input) throws IOException;
|
||||
|
||||
@ -190,6 +192,11 @@ public interface MessageLite extends MessageLiteOrBuilder {
|
||||
* Like {@link Builder#mergeFrom(CodedInputStream)}, but also parses extensions. The extensions
|
||||
* that you want to be able to parse must be registered in {@code extensionRegistry}. Extensions
|
||||
* not in the registry will be treated as unknown fields.
|
||||
*
|
||||
* @throws InvalidProtocolBufferException the bytes read are not syntactically correct
|
||||
* according to the protobuf wire format specification. The data is corrupt, incomplete,
|
||||
* or was never a protobuf in the first place.
|
||||
* @throws IOException an I/O error reading from the stream
|
||||
*/
|
||||
Builder mergeFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)
|
||||
throws IOException;
|
||||
@ -201,6 +208,9 @@ public interface MessageLite extends MessageLiteOrBuilder {
|
||||
* Parse {@code data} as a message of this type and merge it with the message being built. This
|
||||
* is just a small wrapper around {@link #mergeFrom(CodedInputStream)}.
|
||||
*
|
||||
* @throws InvalidProtocolBufferException the bytes in data are not syntactically correct
|
||||
* according to the protobuf wire format specification. The data is corrupt, incomplete,
|
||||
* or was never a protobuf in the first place.
|
||||
* @return this
|
||||
*/
|
||||
Builder mergeFrom(ByteString data) throws InvalidProtocolBufferException;
|
||||
@ -209,6 +219,9 @@ public interface MessageLite extends MessageLiteOrBuilder {
|
||||
* Parse {@code data} as a message of this type and merge it with the message being built. This
|
||||
* is just a small wrapper around {@link #mergeFrom(CodedInputStream,ExtensionRegistryLite)}.
|
||||
*
|
||||
* @throws InvalidProtocolBufferException the bytes in data are not syntactically correct
|
||||
* according to the protobuf wire format specification. The data is corrupt, incomplete,
|
||||
* or was never a protobuf in the first place.
|
||||
* @return this
|
||||
*/
|
||||
Builder mergeFrom(ByteString data, ExtensionRegistryLite extensionRegistry)
|
||||
@ -218,6 +231,9 @@ public interface MessageLite extends MessageLiteOrBuilder {
|
||||
* Parse {@code data} as a message of this type and merge it with the message being built. This
|
||||
* is just a small wrapper around {@link #mergeFrom(CodedInputStream)}.
|
||||
*
|
||||
* @throws InvalidProtocolBufferException the bytes in data are not syntactically correct
|
||||
* according to the protobuf wire format specification. The data is corrupt, incomplete,
|
||||
* or was never a protobuf in the first place.
|
||||
* @return this
|
||||
*/
|
||||
Builder mergeFrom(byte[] data) throws InvalidProtocolBufferException;
|
||||
@ -226,6 +242,9 @@ public interface MessageLite extends MessageLiteOrBuilder {
|
||||
* Parse {@code data} as a message of this type and merge it with the message being built. This
|
||||
* is just a small wrapper around {@link #mergeFrom(CodedInputStream)}.
|
||||
*
|
||||
* @throws InvalidProtocolBufferException the bytes in data are not syntactically correct
|
||||
* according to the protobuf wire format specification. The data is corrupt, incomplete,
|
||||
* or was never a protobuf in the first place.
|
||||
* @return this
|
||||
*/
|
||||
Builder mergeFrom(byte[] data, int off, int len) throws InvalidProtocolBufferException;
|
||||
@ -234,6 +253,9 @@ public interface MessageLite extends MessageLiteOrBuilder {
|
||||
* Parse {@code data} as a message of this type and merge it with the message being built. This
|
||||
* is just a small wrapper around {@link #mergeFrom(CodedInputStream,ExtensionRegistryLite)}.
|
||||
*
|
||||
* @throws InvalidProtocolBufferException the bytes in data are not syntactically correct
|
||||
* according to the protobuf wire format specification. The data is corrupt, incomplete,
|
||||
* or was never a protobuf in the first place.
|
||||
* @return this
|
||||
*/
|
||||
Builder mergeFrom(byte[] data, ExtensionRegistryLite extensionRegistry)
|
||||
@ -243,6 +265,9 @@ public interface MessageLite extends MessageLiteOrBuilder {
|
||||
* Parse {@code data} as a message of this type and merge it with the message being built. This
|
||||
* is just a small wrapper around {@link #mergeFrom(CodedInputStream,ExtensionRegistryLite)}.
|
||||
*
|
||||
* @throws InvalidProtocolBufferException the bytes in data are not syntactically correct
|
||||
* according to the protobuf wire format specification. The data is corrupt, incomplete,
|
||||
* or was never a protobuf in the first place.
|
||||
* @return this
|
||||
*/
|
||||
Builder mergeFrom(byte[] data, int off, int len, ExtensionRegistryLite extensionRegistry)
|
||||
@ -258,6 +283,10 @@ public interface MessageLite extends MessageLiteOrBuilder {
|
||||
*
|
||||
* <p>Despite usually reading the entire input, this does not close the stream.
|
||||
*
|
||||
* @throws InvalidProtocolBufferException the bytes read are not syntactically correct
|
||||
* according to the protobuf wire format specification. The data is corrupt, incomplete,
|
||||
* or was never a protobuf in the first place.
|
||||
* @throws IOException an I/O error reading from the stream
|
||||
* @return this
|
||||
*/
|
||||
Builder mergeFrom(InputStream input) throws IOException;
|
||||
@ -295,12 +324,25 @@ public interface MessageLite extends MessageLiteOrBuilder {
|
||||
* message (encoded as a varint) is read first, then the message data. Use {@link
|
||||
* MessageLite#writeDelimitedTo(OutputStream)} to write messages in this format.
|
||||
*
|
||||
* @return True if successful, or false if the stream is at EOF when the method starts. Any
|
||||
* other error (including reaching EOF during parsing) will cause an exception to be thrown.
|
||||
* @return true if successful, or false if the stream is at EOF when the method starts. Any
|
||||
* other error (including reaching EOF during parsing) causes an exception to be thrown.
|
||||
* @throws InvalidProtocolBufferException the bytes read are not syntactically correct
|
||||
* according to the protobuf wire format specification. The data is corrupt, incomplete,
|
||||
* or was never a protobuf in the first place.
|
||||
* @throws IOException an I/O error reading from the stream
|
||||
*/
|
||||
boolean mergeDelimitedFrom(InputStream input) throws IOException;
|
||||
|
||||
/** Like {@link #mergeDelimitedFrom(InputStream)} but supporting extensions. */
|
||||
/**
|
||||
* Like {@link #mergeDelimitedFrom(InputStream)} but supporting extensions.
|
||||
*
|
||||
* @return true if successful, or false if the stream is at EOF when the method starts. Any
|
||||
* other error (including reaching EOF during parsing) causes an exception to be thrown.
|
||||
* @throws InvalidProtocolBufferException the bytes read are not syntactically correct
|
||||
* according to the protobuf wire format specification. The data is corrupt, incomplete,
|
||||
* or was never a protobuf in the first place.
|
||||
* @throws IOException an I/O error reading from the stream
|
||||
*/
|
||||
boolean mergeDelimitedFrom(InputStream input, ExtensionRegistryLite extensionRegistry)
|
||||
throws IOException;
|
||||
}
|
||||
|
@ -47,13 +47,16 @@ final class MessageLiteToString {
|
||||
private static final String MAP_SUFFIX = "Map";
|
||||
private static final String BYTES_SUFFIX = "Bytes";
|
||||
|
||||
private MessageLiteToString() {
|
||||
// Classes which are not intended to be instantiated should be made non-instantiable with a
|
||||
// private constructor. This includes utility classes (classes with only static members).
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a {@link String} representation of the {@link MessageLite} object. The first line of
|
||||
* the {@code String} representation representation includes a comment string to uniquely identify
|
||||
* the {@code String} representation includes a comment string to uniquely identify
|
||||
* the object instance. This acts as an indicator that this should not be relied on for
|
||||
* comparisons.
|
||||
*
|
||||
* <p>For use by generated code only.
|
||||
*/
|
||||
static String toString(MessageLite messageLite, String commentString) {
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
@ -73,9 +76,9 @@ final class MessageLiteToString {
|
||||
// Build a map of method name to method. We're looking for methods like getFoo(), hasFoo(),
|
||||
// getFooList() and getFooMap() which might be useful for building an object's string
|
||||
// representation.
|
||||
Map<String, Method> nameToNoArgMethod = new HashMap<String, Method>();
|
||||
Map<String, Method> nameToMethod = new HashMap<String, Method>();
|
||||
Set<String> getters = new TreeSet<String>();
|
||||
Map<String, Method> nameToNoArgMethod = new HashMap<>();
|
||||
Map<String, Method> nameToMethod = new HashMap<>();
|
||||
Set<String> getters = new TreeSet<>();
|
||||
for (Method method : messageLite.getClass().getDeclaredMethods()) {
|
||||
nameToMethod.put(method.getName(), method);
|
||||
if (method.getParameterTypes().length == 0) {
|
||||
@ -263,7 +266,7 @@ final class MessageLiteToString {
|
||||
}
|
||||
buffer.append("}");
|
||||
} else {
|
||||
buffer.append(": ").append(object.toString());
|
||||
buffer.append(": ").append(object);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -82,6 +82,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/** Schema used for standard messages. */
|
||||
@CheckReturnValue
|
||||
final class MessageSchema<T> implements Schema<T> {
|
||||
private static final int INTS_PER_FIELD = 3;
|
||||
private static final int OFFSET_BITS = 20;
|
||||
@ -2533,7 +2534,6 @@ final class MessageSchema<T> implements Schema<T> {
|
||||
return (List<?>) UnsafeUtil.getObject(message, offset);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
// TODO(nathanmittler): Consider serializing oneof fields last so that only one entry per
|
||||
// oneof is actually serialized. This would mean that we would violate the serialization order
|
||||
@ -4875,6 +4875,7 @@ final class MessageSchema<T> implements Schema<T> {
|
||||
* group (endGroup != 0), parsing ends when a tag == endGroup is encountered and the position
|
||||
* after that tag is returned.
|
||||
*/
|
||||
@CanIgnoreReturnValue
|
||||
int parseProto2Message(
|
||||
T message, byte[] data, int position, int limit, int endGroup, Registers registers)
|
||||
throws IOException {
|
||||
@ -5184,6 +5185,7 @@ final class MessageSchema<T> implements Schema<T> {
|
||||
}
|
||||
|
||||
/** Parses a proto3 message and returns the limit if parsing is successful. */
|
||||
@CanIgnoreReturnValue
|
||||
private int parseProto3Message(
|
||||
T message, byte[] data, int position, int limit, Registers registers) throws IOException {
|
||||
final sun.misc.Unsafe unsafe = UNSAFE;
|
||||
|
@ -35,6 +35,7 @@ import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
/** Schema used for proto2 messages using message_set_wireformat. */
|
||||
@CheckReturnValue
|
||||
final class MessageSetSchema<T> implements Schema<T> {
|
||||
private final MessageLite defaultInstance;
|
||||
private final UnknownFieldSchema<?, ?> unknownFieldSchema;
|
||||
@ -231,7 +232,6 @@ final class MessageSetSchema<T> implements Schema<T> {
|
||||
* A helper method for wildcard capture of {@code unknownFieldSchema}. See:
|
||||
* https://docs.oracle.com/javase/tutorial/java/generics/capture.html
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private <UT, UB, ET extends FieldSet.FieldDescriptorLite<ET>> void mergeFromHelper(
|
||||
UnknownFieldSchema<UT, UB> unknownFieldSchema,
|
||||
ExtensionSchema<ET> extensionSchema,
|
||||
|
@ -30,6 +30,7 @@
|
||||
|
||||
package com.google.protobuf;
|
||||
|
||||
@CheckReturnValue
|
||||
interface NewInstanceSchema {
|
||||
/** Create a new message instance given the default instance of the message type. */
|
||||
Object newInstance(Object defaultInstance);
|
||||
|
@ -30,6 +30,7 @@
|
||||
|
||||
package com.google.protobuf;
|
||||
|
||||
@CheckReturnValue
|
||||
final class NewInstanceSchemaLite implements NewInstanceSchema {
|
||||
@Override
|
||||
public Object newInstance(Object defaultInstance) {
|
||||
|
@ -30,6 +30,7 @@
|
||||
|
||||
package com.google.protobuf;
|
||||
|
||||
@CheckReturnValue
|
||||
final class NewInstanceSchemas {
|
||||
private static final NewInstanceSchema FULL_SCHEMA = loadSchemaForFullRuntime();
|
||||
private static final NewInstanceSchema LITE_SCHEMA = new NewInstanceSchemaLite();
|
||||
|
@ -35,6 +35,7 @@ import java.lang.reflect.Field;
|
||||
/** Information for a oneof within a protobuf message. */
|
||||
// TODO(nathanmittler): make this private once all of experimental code is migrated to protobuf.
|
||||
@ExperimentalApi
|
||||
@CheckReturnValue
|
||||
final class OneofInfo {
|
||||
private final int id;
|
||||
private final Field caseField;
|
||||
|
@ -41,6 +41,7 @@ import java.util.concurrent.ConcurrentMap;
|
||||
* than directly accessing internal APIs) in order to perform operations on protobuf messages.
|
||||
*/
|
||||
@ExperimentalApi
|
||||
@CheckReturnValue
|
||||
final class Protobuf {
|
||||
private static final Protobuf INSTANCE = new Protobuf();
|
||||
|
||||
@ -127,6 +128,7 @@ final class Protobuf {
|
||||
* @return the previously registered schema, or {@code null} if no schema was registered
|
||||
* previously.
|
||||
*/
|
||||
@CanIgnoreReturnValue
|
||||
public Schema<?> registerSchemaOverride(Class<?> messageType, Schema<?> schema) {
|
||||
checkNotNull(messageType, "messageType");
|
||||
checkNotNull(schema, "schema");
|
||||
|
@ -39,6 +39,7 @@ import com.google.protobuf.Internal.ProtobufList;
|
||||
|
||||
/** Utility class for construction of lists that extend {@link ProtobufList}. */
|
||||
@ExperimentalApi
|
||||
@CheckReturnValue
|
||||
final class ProtobufLists {
|
||||
private ProtobufLists() {}
|
||||
|
||||
|
@ -34,6 +34,7 @@ package com.google.protobuf;
|
||||
* RawMessageInfo stores the same amount of information as {@link MessageInfo} but in a more compact
|
||||
* format.
|
||||
*/
|
||||
@CheckReturnValue
|
||||
final class RawMessageInfo implements MessageInfo {
|
||||
|
||||
private final MessageLite defaultInstance;
|
||||
|
@ -37,6 +37,7 @@ import java.util.Map;
|
||||
/** A reader of fields from a serialized protobuf message. */
|
||||
// TODO(nathanmittler): Refactor to allow the reader to allocate properly sized lists.
|
||||
@ExperimentalApi
|
||||
@CheckReturnValue
|
||||
interface Reader {
|
||||
/** Value used to indicate that the end of input has been reached. */
|
||||
int READ_DONE = Integer.MAX_VALUE;
|
||||
|
@ -38,6 +38,7 @@ import java.io.IOException;
|
||||
* such as serialization/deserialization.
|
||||
*/
|
||||
@ExperimentalApi
|
||||
@CheckReturnValue
|
||||
interface Schema<T> {
|
||||
/** Writes the given message to the target {@link Writer}. */
|
||||
void writeTo(T message, Writer writer) throws IOException;
|
||||
|
@ -32,6 +32,7 @@ package com.google.protobuf;
|
||||
|
||||
/** A factory that manufactures {@link Schema} instances for protobuf messages. */
|
||||
@ExperimentalApi
|
||||
@CheckReturnValue
|
||||
interface SchemaFactory {
|
||||
/** Creates a schema instance for the given protobuf message type. */
|
||||
<T> Schema<T> createSchema(Class<T> messageType);
|
||||
|
@ -41,6 +41,7 @@ import java.util.RandomAccess;
|
||||
|
||||
/** Helper methods used by schemas. */
|
||||
@ExperimentalApi
|
||||
@CheckReturnValue
|
||||
final class SchemaUtil {
|
||||
private static final Class<?> GENERATED_MESSAGE_CLASS = getGeneratedMessageClass();
|
||||
private static final UnknownFieldSchema<?, ?> PROTO2_UNKNOWN_FIELD_SET_SCHEMA =
|
||||
@ -980,6 +981,7 @@ final class SchemaUtil {
|
||||
}
|
||||
|
||||
/** Stores an unrecognized enum value as an unknown value. */
|
||||
@CanIgnoreReturnValue
|
||||
static <UT, UB> UB storeUnknownEnum(
|
||||
int number, int enumValue, UB unknownFields, UnknownFieldSchema<UT, UB> unknownFieldSchema) {
|
||||
if (unknownFields == null) {
|
||||
|
@ -374,7 +374,6 @@ class SmallSortedMap<K extends Comparable<K>, V> extends AbstractMap<K, V> {
|
||||
* @return a {@link SortedMap} to which overflow entries mappings can be added or removed.
|
||||
* @throws UnsupportedOperationException if {@link #makeImmutable()} has been called.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private SortedMap<K, V> getOverflowEntriesMutable() {
|
||||
checkMutable();
|
||||
if (overflowEntries.isEmpty() && !(overflowEntries instanceof TreeMap)) {
|
||||
@ -441,7 +440,6 @@ class SmallSortedMap<K extends Comparable<K>, V> extends AbstractMap<K, V> {
|
||||
if (!(o instanceof Map.Entry)) {
|
||||
return false;
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
Map.Entry<?, ?> other = (Map.Entry<?, ?>) o;
|
||||
return equals(key, other.getKey()) && equals(value, other.getValue());
|
||||
}
|
||||
|
@ -41,6 +41,7 @@ import java.util.List;
|
||||
* contained within a message.
|
||||
*/
|
||||
@ExperimentalApi
|
||||
@CheckReturnValue
|
||||
final class StructuralMessageInfo implements MessageInfo {
|
||||
private final ProtoSyntax syntax;
|
||||
private final boolean messageSetWireFormat;
|
||||
|
@ -68,6 +68,9 @@ public final class TextFormat {
|
||||
* @deprecated Use {@code printer().print(MessageOrBuilder, Appendable)}
|
||||
*/
|
||||
@Deprecated
|
||||
@InlineMe(
|
||||
replacement = "TextFormat.printer().print(message, output)",
|
||||
imports = "com.google.protobuf.TextFormat")
|
||||
public static void print(final MessageOrBuilder message, final Appendable output)
|
||||
throws IOException {
|
||||
printer().print(message, output);
|
||||
@ -90,6 +93,9 @@ public final class TextFormat {
|
||||
* @deprecated Use {@code printer().escapingNonAscii(false).print(MessageOrBuilder, Appendable)}
|
||||
*/
|
||||
@Deprecated
|
||||
@InlineMe(
|
||||
replacement = "TextFormat.printer().escapingNonAscii(false).print(message, output)",
|
||||
imports = "com.google.protobuf.TextFormat")
|
||||
public static void printUnicode(final MessageOrBuilder message, final Appendable output)
|
||||
throws IOException {
|
||||
printer().escapingNonAscii(false).print(message, output);
|
||||
@ -143,6 +149,9 @@ public final class TextFormat {
|
||||
* @deprecated Use {@code message.toString()}
|
||||
*/
|
||||
@Deprecated
|
||||
@InlineMe(
|
||||
replacement = "TextFormat.printer().printToString(message)",
|
||||
imports = "com.google.protobuf.TextFormat")
|
||||
public static String printToString(final MessageOrBuilder message) {
|
||||
return printer().printToString(message);
|
||||
}
|
||||
@ -164,6 +173,9 @@ public final class TextFormat {
|
||||
* @deprecated Use {@code printer().escapingNonAscii(false).printToString(MessageOrBuilder)}
|
||||
*/
|
||||
@Deprecated
|
||||
@InlineMe(
|
||||
replacement = "TextFormat.printer().escapingNonAscii(false).printToString(message)",
|
||||
imports = "com.google.protobuf.TextFormat")
|
||||
public static String printToUnicodeString(final MessageOrBuilder message) {
|
||||
return printer().escapingNonAscii(false).printToString(message);
|
||||
}
|
||||
@ -225,6 +237,9 @@ public final class TextFormat {
|
||||
* @throws IOException if there is an exception writing to the output
|
||||
*/
|
||||
@Deprecated
|
||||
@InlineMe(
|
||||
replacement = "TextFormat.printer().printFieldValue(field, value, output)",
|
||||
imports = "com.google.protobuf.TextFormat")
|
||||
public static void printFieldValue(
|
||||
final FieldDescriptor field, final Object value, final Appendable output) throws IOException {
|
||||
printer().printFieldValue(field, value, output);
|
||||
|
@ -33,6 +33,7 @@ package com.google.protobuf;
|
||||
import java.io.IOException;
|
||||
|
||||
@ExperimentalApi
|
||||
@CheckReturnValue
|
||||
abstract class UnknownFieldSchema<T, B> {
|
||||
|
||||
/** Whether unknown fields should be dropped. */
|
||||
|
@ -32,6 +32,7 @@ package com.google.protobuf;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@CheckReturnValue
|
||||
class UnknownFieldSetLiteSchema
|
||||
extends UnknownFieldSchema<UnknownFieldSetLite, UnknownFieldSetLite> {
|
||||
|
||||
|
@ -35,7 +35,7 @@ import java.nio.ByteBuffer;
|
||||
|
||||
/**
|
||||
* Provides a number of unsafe byte operations to be used by advanced applications with high
|
||||
* performance requirements. These methods are referred to as "unsafe" due to the fact that they
|
||||
* performance requirements. These methods are referred to as "unsafe" because they
|
||||
* potentially expose the backing buffer of a {@link ByteString} to the application.
|
||||
*
|
||||
* <p><strong>DISCLAIMER:</strong> The methods in this class should only be called if it is
|
||||
|
@ -102,10 +102,10 @@ final class Utf8 {
|
||||
* State value indicating that the byte sequence is well-formed and complete (no further bytes are
|
||||
* needed to complete a character).
|
||||
*/
|
||||
public static final int COMPLETE = 0;
|
||||
static final int COMPLETE = 0;
|
||||
|
||||
/** State value indicating that the byte sequence is definitely not well-formed. */
|
||||
public static final int MALFORMED = -1;
|
||||
static final int MALFORMED = -1;
|
||||
|
||||
/**
|
||||
* Used by {@code Unsafe} UTF-8 string validation logic to determine the minimum string length
|
||||
@ -143,7 +143,7 @@ final class Utf8 {
|
||||
* <p>This is a convenience method, equivalent to a call to {@code isValidUtf8(bytes, 0,
|
||||
* bytes.length)}.
|
||||
*/
|
||||
public static boolean isValidUtf8(byte[] bytes) {
|
||||
static boolean isValidUtf8(byte[] bytes) {
|
||||
return processor.isValidUtf8(bytes, 0, bytes.length);
|
||||
}
|
||||
|
||||
@ -155,7 +155,7 @@ final class Utf8 {
|
||||
* <p>This is a convenience method, equivalent to {@code partialIsValidUtf8(bytes, index, limit)
|
||||
* == Utf8.COMPLETE}.
|
||||
*/
|
||||
public static boolean isValidUtf8(byte[] bytes, int index, int limit) {
|
||||
static boolean isValidUtf8(byte[] bytes, int index, int limit) {
|
||||
return processor.isValidUtf8(bytes, index, limit);
|
||||
}
|
||||
|
||||
@ -172,7 +172,7 @@ final class Utf8 {
|
||||
* "state" value containing enough information to decode the character when passed to a
|
||||
* subsequent invocation of a partial decoding method.
|
||||
*/
|
||||
public static int partialIsValidUtf8(int state, byte[] bytes, int index, int limit) {
|
||||
static int partialIsValidUtf8(int state, byte[] bytes, int index, int limit) {
|
||||
return processor.partialIsValidUtf8(state, bytes, index, limit);
|
||||
}
|
||||
|
||||
@ -572,7 +572,7 @@ final class Utf8 {
|
||||
return incompleteStateFor(buffer, byte1, index, limit - index);
|
||||
}
|
||||
|
||||
final byte byte2 = buffer.get(index++);
|
||||
byte byte2 = buffer.get(index++);
|
||||
if (byte2 > (byte) 0xBF
|
||||
// overlong? 5 most significant bits must not all be zero
|
||||
|| (byte1 == (byte) 0xE0 && byte2 < (byte) 0xA0)
|
||||
@ -591,7 +591,7 @@ final class Utf8 {
|
||||
}
|
||||
|
||||
// TODO(nathanmittler): Consider using getInt() to improve performance.
|
||||
final int byte2 = buffer.get(index++);
|
||||
int byte2 = buffer.get(index++);
|
||||
if (byte2 > (byte) 0xBF
|
||||
// Check that 1 <= plane <= 16. Tricky optimized form of:
|
||||
// if (byte1 > (byte) 0xF4 ||
|
||||
@ -611,7 +611,7 @@ final class Utf8 {
|
||||
/**
|
||||
* Decodes the given byte array slice into a {@link String}.
|
||||
*
|
||||
* @throws InvalidProtocolBufferException if the byte array slice is not valid UTF-8.
|
||||
* @throws InvalidProtocolBufferException if the byte array slice is not valid UTF-8
|
||||
*/
|
||||
abstract String decodeUtf8(byte[] bytes, int index, int size)
|
||||
throws InvalidProtocolBufferException;
|
||||
@ -619,7 +619,7 @@ final class Utf8 {
|
||||
/**
|
||||
* Decodes the given portion of the {@link ByteBuffer} into a {@link String}.
|
||||
*
|
||||
* @throws InvalidProtocolBufferException if the portion of the buffer is not valid UTF-8.
|
||||
* @throws InvalidProtocolBufferException if the portion of the buffer is not valid UTF-8
|
||||
*/
|
||||
final String decodeUtf8(ByteBuffer buffer, int index, int size)
|
||||
throws InvalidProtocolBufferException {
|
||||
@ -649,7 +649,7 @@ final class Utf8 {
|
||||
}
|
||||
|
||||
int offset = index;
|
||||
final int limit = offset + size;
|
||||
int limit = offset + size;
|
||||
|
||||
// The longest possible resulting String is the same as the number of input bytes, when it is
|
||||
// all ASCII. For other cases, this over-allocates and we will truncate in the end.
|
||||
@ -1907,12 +1907,24 @@ final class Utf8 {
|
||||
return b >= 0;
|
||||
}
|
||||
|
||||
/** Returns whether this is a two-byte codepoint with the form '10XXXXXX'. */
|
||||
/**
|
||||
* Returns whether this is a two-byte codepoint with the form '10XXXXXX' iff
|
||||
* {@link #isOneByte(byte)} is false. This private method works in the limited use in
|
||||
* this class where this method is only called when {@link #isOneByte(byte)} has already
|
||||
* returned false. It is not suitable for general or public use.
|
||||
*/
|
||||
private static boolean isTwoBytes(byte b) {
|
||||
return b < (byte) 0xE0;
|
||||
}
|
||||
|
||||
/** Returns whether this is a three-byte codepoint with the form '110XXXXX'. */
|
||||
/**
|
||||
* Returns whether this is a three-byte codepoint with the form '110XXXXX' iff
|
||||
* {@link #isOneByte(byte)} and {@link #isTwoBytes(byte)} are false.
|
||||
* This private method works in the limited use in
|
||||
* this class where this method is only called when {@link #isOneByte(byte)} an
|
||||
* {@link #isTwoBytes(byte)} have already returned false. It is not suitable for general
|
||||
* or public use.
|
||||
*/
|
||||
private static boolean isThreeBytes(byte b) {
|
||||
return b < (byte) 0xF0;
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ import java.util.Map;
|
||||
|
||||
/** A writer that performs serialization of protobuf message fields. */
|
||||
@ExperimentalApi
|
||||
@CheckReturnValue
|
||||
interface Writer {
|
||||
|
||||
/** The order in which the fields are written by a {@link Writer}. */
|
||||
|
@ -69,16 +69,16 @@ public class ByteStringTest {
|
||||
return result;
|
||||
}
|
||||
|
||||
private byte[] getTestBytes(int size) {
|
||||
private static byte[] getTestBytes(int size) {
|
||||
return getTestBytes(size, 445566L);
|
||||
}
|
||||
|
||||
private byte[] getTestBytes() {
|
||||
private static byte[] getTestBytes() {
|
||||
return getTestBytes(1000);
|
||||
}
|
||||
|
||||
// Compare the entire left array with a subset of the right array.
|
||||
private boolean isArrayRange(byte[] left, byte[] right, int rightOffset, int length) {
|
||||
private static boolean isArrayRange(byte[] left, byte[] right, int rightOffset, int length) {
|
||||
boolean stillEqual = (left.length == length);
|
||||
for (int i = 0; (stillEqual && i < length); ++i) {
|
||||
stillEqual = (left[i] == right[rightOffset + i]);
|
||||
@ -87,7 +87,7 @@ public class ByteStringTest {
|
||||
}
|
||||
|
||||
// Returns true only if the given two arrays have identical contents.
|
||||
private boolean isArray(byte[] left, byte[] right) {
|
||||
private static boolean isArray(byte[] left, byte[] right) {
|
||||
return left.length == right.length && isArrayRange(left, right, 0, left.length);
|
||||
}
|
||||
|
||||
@ -134,7 +134,7 @@ public class ByteStringTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSubstring_BeginIndex() {
|
||||
public void testSubstring_beginIndex() {
|
||||
byte[] bytes = getTestBytes();
|
||||
ByteString substring = ByteString.copyFrom(bytes).substring(500);
|
||||
assertWithMessage("substring must contain the tail of the string")
|
||||
@ -143,7 +143,66 @@ public class ByteStringTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCopyFrom_BytesOffsetSize() {
|
||||
public void testEmpty_isEmpty() {
|
||||
ByteString byteString = ByteString.empty();
|
||||
assertThat(byteString.isEmpty()).isTrue();
|
||||
assertWithMessage("ByteString.empty() must return empty byte array")
|
||||
.that(isArray(byteString.toByteArray(), new byte[] {}))
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEmpty_referenceEquality() {
|
||||
assertThat(ByteString.empty()).isSameInstanceAs(ByteString.EMPTY);
|
||||
assertThat(ByteString.empty()).isSameInstanceAs(ByteString.empty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFromHex_hexString() {
|
||||
ByteString byteString;
|
||||
byteString = ByteString.fromHex("0a0b0c");
|
||||
assertWithMessage("fromHex must contain the expected bytes")
|
||||
.that(isArray(byteString.toByteArray(), new byte[] {0x0a, 0x0b, 0x0c}))
|
||||
.isTrue();
|
||||
|
||||
byteString = ByteString.fromHex("0A0B0C");
|
||||
assertWithMessage("fromHex must contain the expected bytes")
|
||||
.that(isArray(byteString.toByteArray(), new byte[] {0x0a, 0x0b, 0x0c}))
|
||||
.isTrue();
|
||||
|
||||
byteString = ByteString.fromHex("0a0b0c0d0e0f");
|
||||
assertWithMessage("fromHex must contain the expected bytes")
|
||||
.that(isArray(byteString.toByteArray(), new byte[] {0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f}))
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("AlwaysThrows") // Verifying that indeed these calls do throw.
|
||||
public void testFromHex_invalidHexString() {
|
||||
try {
|
||||
ByteString.fromHex("a0b0c");
|
||||
assertWithMessage("Should throw").fail();
|
||||
} catch (NumberFormatException expected) {
|
||||
assertThat(expected).hasMessageThat().contains("even");
|
||||
}
|
||||
|
||||
try {
|
||||
ByteString.fromHex("0x0y0z");
|
||||
assertWithMessage("Should throw").fail();
|
||||
} catch (NumberFormatException expected) {
|
||||
assertThat(expected).hasMessageThat().contains("[0-9a-fA-F]");
|
||||
}
|
||||
|
||||
try {
|
||||
ByteString.fromHex("0૫");
|
||||
assertWithMessage("Should throw").fail();
|
||||
} catch (NumberFormatException expected) {
|
||||
assertThat(expected).hasMessageThat().contains("[0-9a-fA-F]");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCopyFrom_bytesOffsetSize() {
|
||||
byte[] bytes = getTestBytes();
|
||||
ByteString byteString = ByteString.copyFrom(bytes, 500, 200);
|
||||
assertWithMessage("copyFrom sub-range must contain the expected bytes")
|
||||
@ -152,7 +211,7 @@ public class ByteStringTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCopyFrom_Bytes() {
|
||||
public void testCopyFrom_bytes() {
|
||||
byte[] bytes = getTestBytes();
|
||||
ByteString byteString = ByteString.copyFrom(bytes);
|
||||
assertWithMessage("copyFrom must contain the expected bytes")
|
||||
@ -161,7 +220,7 @@ public class ByteStringTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCopyFrom_ByteBufferSize() {
|
||||
public void testCopyFrom_byteBufferSize() {
|
||||
byte[] bytes = getTestBytes();
|
||||
ByteBuffer byteBuffer = ByteBuffer.allocate(bytes.length);
|
||||
byteBuffer.put(bytes);
|
||||
@ -173,7 +232,7 @@ public class ByteStringTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCopyFrom_ByteBuffer() {
|
||||
public void testCopyFrom_byteBuffer() {
|
||||
byte[] bytes = getTestBytes();
|
||||
ByteBuffer byteBuffer = ByteBuffer.allocate(bytes.length);
|
||||
byteBuffer.put(bytes);
|
||||
@ -185,7 +244,7 @@ public class ByteStringTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCopyFrom_StringEncoding() {
|
||||
public void testCopyFrom_stringEncoding() {
|
||||
String testString = "I love unicode \u1234\u5678 characters";
|
||||
ByteString byteString = ByteString.copyFrom(testString, UTF_16);
|
||||
byte[] testBytes = testString.getBytes(UTF_16);
|
||||
@ -195,7 +254,7 @@ public class ByteStringTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCopyFrom_Utf8() {
|
||||
public void testCopyFrom_utf8() {
|
||||
String testString = "I love unicode \u1234\u5678 characters";
|
||||
ByteString byteString = ByteString.copyFromUtf8(testString);
|
||||
byte[] testBytes = testString.getBytes(Internal.UTF_8);
|
||||
@ -205,7 +264,7 @@ public class ByteStringTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCopyFrom_Iterable() {
|
||||
public void testCopyFrom_iterable() {
|
||||
byte[] testBytes = getTestBytes(77777, 113344L);
|
||||
final List<ByteString> pieces = makeConcretePieces(testBytes);
|
||||
// Call copyFrom() on a Collection
|
||||
@ -228,7 +287,7 @@ public class ByteStringTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCopyFrom_LengthTooBig() {
|
||||
public void testCopyFrom_lengthTooBig() {
|
||||
byte[] testBytes = getTestBytes(100);
|
||||
try {
|
||||
ByteString.copyFrom(testBytes, 0, 200);
|
||||
@ -257,7 +316,7 @@ public class ByteStringTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCopyTo_TargetOffset() {
|
||||
public void testCopyTo_targetOffset() {
|
||||
byte[] bytes = getTestBytes();
|
||||
ByteString byteString = ByteString.copyFrom(bytes);
|
||||
byte[] target = new byte[bytes.length + 1000];
|
||||
@ -353,7 +412,7 @@ public class ByteStringTest {
|
||||
|
||||
// Tests that IOExceptions propagate through ByteString.readFrom().
|
||||
@Test
|
||||
public void testReadFrom_IOExceptions() {
|
||||
public void testReadFrom_iOExceptions() {
|
||||
try {
|
||||
ByteString.readFrom(new FailStream());
|
||||
assertWithMessage("readFrom must throw the underlying IOException").fail();
|
||||
@ -547,7 +606,7 @@ public class ByteStringTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNewOutput_InitialCapacity() throws IOException {
|
||||
public void testNewOutput_initialCapacity() throws IOException {
|
||||
byte[] bytes = getTestBytes();
|
||||
ByteString.Output output = ByteString.newOutput(bytes.length + 100);
|
||||
output.write(bytes);
|
||||
@ -560,7 +619,7 @@ public class ByteStringTest {
|
||||
// Test newOutput() using a variety of buffer sizes and a variety of (fixed)
|
||||
// write sizes
|
||||
@Test
|
||||
public void testNewOutput_ArrayWrite() {
|
||||
public void testNewOutput_arrayWrite() {
|
||||
byte[] bytes = getTestBytes();
|
||||
int length = bytes.length;
|
||||
int[] bufferSizes = {
|
||||
@ -586,7 +645,7 @@ public class ByteStringTest {
|
||||
// Test newOutput() using a variety of buffer sizes, but writing all the
|
||||
// characters using write(byte);
|
||||
@Test
|
||||
public void testNewOutput_WriteChar() {
|
||||
public void testNewOutput_writeChar() {
|
||||
byte[] bytes = getTestBytes();
|
||||
int length = bytes.length;
|
||||
int[] bufferSizes = {
|
||||
@ -607,7 +666,7 @@ public class ByteStringTest {
|
||||
// Test newOutput() in which we write the bytes using a variety of methods
|
||||
// and sizes, and in which we repeatedly call toByteString() in the middle.
|
||||
@Test
|
||||
public void testNewOutput_Mixed() {
|
||||
public void testNewOutput_mixed() {
|
||||
Random rng = new Random(1);
|
||||
byte[] bytes = getTestBytes();
|
||||
int length = bytes.length;
|
||||
@ -649,7 +708,7 @@ public class ByteStringTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNewOutput_Mutating() throws IOException {
|
||||
public void testNewOutput_mutating() throws IOException {
|
||||
Output os = ByteString.newOutput(5);
|
||||
os.write(new byte[] {1, 2, 3, 4, 5});
|
||||
EvilOutputStream eos = new EvilOutputStream();
|
||||
|
@ -540,8 +540,8 @@ public class CodedInputStreamTest {
|
||||
CodedOutputStream output = CodedOutputStream.newInstance(rawOutput);
|
||||
|
||||
int tag = WireFormat.makeTag(1, WireFormat.WIRETYPE_LENGTH_DELIMITED);
|
||||
output.writeRawVarint32(tag);
|
||||
output.writeRawVarint32(0x7FFFFFFF);
|
||||
output.writeUInt32NoTag(tag);
|
||||
output.writeUInt32NoTag(0x7FFFFFFF);
|
||||
output.writeRawBytes(new byte[32]); // Pad with a few random bytes.
|
||||
output.flush();
|
||||
|
||||
@ -747,11 +747,11 @@ public class CodedInputStreamTest {
|
||||
CodedOutputStream output = CodedOutputStream.newInstance(rawOutput, bytes.length);
|
||||
|
||||
int tag = WireFormat.makeTag(1, WireFormat.WIRETYPE_LENGTH_DELIMITED);
|
||||
output.writeRawVarint32(tag);
|
||||
output.writeRawVarint32(bytes.length);
|
||||
output.writeUInt32NoTag(tag);
|
||||
output.writeUInt32NoTag(bytes.length);
|
||||
output.writeRawBytes(bytes);
|
||||
output.writeRawVarint32(tag);
|
||||
output.writeRawVarint32(bytes.length);
|
||||
output.writeUInt32NoTag(tag);
|
||||
output.writeUInt32NoTag(bytes.length);
|
||||
output.writeRawBytes(bytes);
|
||||
output.writeRawByte(4);
|
||||
output.flush();
|
||||
@ -796,8 +796,8 @@ public class CodedInputStreamTest {
|
||||
CodedOutputStream output = CodedOutputStream.newInstance(rawOutput, bytes.length);
|
||||
|
||||
int tag = WireFormat.makeTag(1, WireFormat.WIRETYPE_LENGTH_DELIMITED);
|
||||
output.writeRawVarint32(tag);
|
||||
output.writeRawVarint32(bytes.length);
|
||||
output.writeUInt32NoTag(tag);
|
||||
output.writeUInt32NoTag(bytes.length);
|
||||
output.writeRawBytes(bytes);
|
||||
output.flush();
|
||||
|
||||
@ -851,8 +851,8 @@ public class CodedInputStreamTest {
|
||||
CodedOutputStream output = CodedOutputStream.newInstance(rawOutput, bytes.length);
|
||||
|
||||
int tag = WireFormat.makeTag(1, WireFormat.WIRETYPE_LENGTH_DELIMITED);
|
||||
output.writeRawVarint32(tag);
|
||||
output.writeRawVarint32(bytes.length);
|
||||
output.writeUInt32NoTag(tag);
|
||||
output.writeUInt32NoTag(bytes.length);
|
||||
output.writeRawBytes(bytes);
|
||||
output.flush();
|
||||
|
||||
@ -878,8 +878,8 @@ public class CodedInputStreamTest {
|
||||
CodedOutputStream output = CodedOutputStream.newInstance(rawOutput, bytes.length);
|
||||
|
||||
int tag = WireFormat.makeTag(1, WireFormat.WIRETYPE_LENGTH_DELIMITED);
|
||||
output.writeRawVarint32(tag);
|
||||
output.writeRawVarint32(bytes.length);
|
||||
output.writeUInt32NoTag(tag);
|
||||
output.writeUInt32NoTag(bytes.length);
|
||||
output.writeRawBytes(bytes);
|
||||
output.flush();
|
||||
|
||||
@ -902,8 +902,8 @@ public class CodedInputStreamTest {
|
||||
CodedOutputStream output = CodedOutputStream.newInstance(rawOutput);
|
||||
|
||||
int tag = WireFormat.makeTag(1, WireFormat.WIRETYPE_LENGTH_DELIMITED);
|
||||
output.writeRawVarint32(tag);
|
||||
output.writeRawVarint32(1);
|
||||
output.writeUInt32NoTag(tag);
|
||||
output.writeUInt32NoTag(1);
|
||||
output.writeRawBytes(new byte[] {(byte) 0x80});
|
||||
output.flush();
|
||||
|
||||
@ -926,8 +926,8 @@ public class CodedInputStreamTest {
|
||||
CodedOutputStream output = CodedOutputStream.newInstance(rawOutput);
|
||||
|
||||
int tag = WireFormat.makeTag(1, WireFormat.WIRETYPE_LENGTH_DELIMITED);
|
||||
output.writeRawVarint32(tag);
|
||||
output.writeRawVarint32(1);
|
||||
output.writeUInt32NoTag(tag);
|
||||
output.writeUInt32NoTag(1);
|
||||
output.writeRawBytes(new byte[] {(byte) 0x80});
|
||||
output.flush();
|
||||
|
||||
@ -985,19 +985,19 @@ public class CodedInputStreamTest {
|
||||
ByteString.Output rawOutput = ByteString.newOutput();
|
||||
CodedOutputStream output = CodedOutputStream.newInstance(rawOutput);
|
||||
// Zero-sized bytes field.
|
||||
output.writeRawVarint32(0);
|
||||
output.writeUInt32NoTag(0);
|
||||
// One one-byte bytes field
|
||||
output.writeRawVarint32(1);
|
||||
output.writeUInt32NoTag(1);
|
||||
output.writeRawBytes(new byte[] {(byte) 23});
|
||||
// Another one-byte bytes field
|
||||
output.writeRawVarint32(1);
|
||||
output.writeUInt32NoTag(1);
|
||||
output.writeRawBytes(new byte[] {(byte) 45});
|
||||
// A bytes field large enough that won't fit into the 4K buffer.
|
||||
final int bytesLength = 16 * 1024;
|
||||
byte[] bytes = new byte[bytesLength];
|
||||
bytes[0] = (byte) 67;
|
||||
bytes[bytesLength - 1] = (byte) 89;
|
||||
output.writeRawVarint32(bytesLength);
|
||||
output.writeUInt32NoTag(bytesLength);
|
||||
output.writeRawBytes(bytes);
|
||||
|
||||
output.flush();
|
||||
@ -1029,7 +1029,7 @@ public class CodedInputStreamTest {
|
||||
}
|
||||
ByteString.Output rawOutput = ByteString.newOutput();
|
||||
CodedOutputStream output = CodedOutputStream.newInstance(rawOutput);
|
||||
output.writeRawVarint32(bytes.length);
|
||||
output.writeUInt32NoTag(bytes.length);
|
||||
output.writeRawBytes(bytes);
|
||||
output.flush();
|
||||
byte[] data = rawOutput.toByteString().toByteArray();
|
||||
@ -1054,7 +1054,7 @@ public class CodedInputStreamTest {
|
||||
}
|
||||
ByteString.Output rawOutput = ByteString.newOutput();
|
||||
CodedOutputStream output = CodedOutputStream.newInstance(rawOutput);
|
||||
output.writeRawVarint32(bytes.length);
|
||||
output.writeUInt32NoTag(bytes.length);
|
||||
output.writeRawBytes(bytes);
|
||||
output.flush();
|
||||
byte[] data = rawOutput.toByteString().toByteArray();
|
||||
@ -1076,19 +1076,19 @@ public class CodedInputStreamTest {
|
||||
ByteString.Output rawOutput = ByteString.newOutput();
|
||||
CodedOutputStream output = CodedOutputStream.newInstance(rawOutput);
|
||||
// Zero-sized bytes field.
|
||||
output.writeRawVarint32(0);
|
||||
output.writeUInt32NoTag(0);
|
||||
// One one-byte bytes field
|
||||
output.writeRawVarint32(1);
|
||||
output.writeUInt32NoTag(1);
|
||||
output.writeRawBytes(new byte[] {(byte) 23});
|
||||
// Another one-byte bytes field
|
||||
output.writeRawVarint32(1);
|
||||
output.writeUInt32NoTag(1);
|
||||
output.writeRawBytes(new byte[] {(byte) 45});
|
||||
// A bytes field large enough that won't fit into the 4K buffer.
|
||||
final int bytesLength = 16 * 1024;
|
||||
byte[] bytes = new byte[bytesLength];
|
||||
bytes[0] = (byte) 67;
|
||||
bytes[bytesLength - 1] = (byte) 89;
|
||||
output.writeRawVarint32(bytesLength);
|
||||
output.writeUInt32NoTag(bytesLength);
|
||||
output.writeRawBytes(bytes);
|
||||
|
||||
output.flush();
|
||||
@ -1118,19 +1118,19 @@ public class CodedInputStreamTest {
|
||||
ByteArrayOutputStream byteArrayStream = new ByteArrayOutputStream();
|
||||
CodedOutputStream output = CodedOutputStream.newInstance(byteArrayStream);
|
||||
// Zero-sized bytes field.
|
||||
output.writeRawVarint32(0);
|
||||
output.writeUInt32NoTag(0);
|
||||
// One one-byte bytes field
|
||||
output.writeRawVarint32(1);
|
||||
output.writeUInt32NoTag(1);
|
||||
output.writeRawBytes(new byte[] {(byte) 23});
|
||||
// Another one-byte bytes field
|
||||
output.writeRawVarint32(1);
|
||||
output.writeUInt32NoTag(1);
|
||||
output.writeRawBytes(new byte[] {(byte) 45});
|
||||
// A bytes field large enough that won't fit into the 4K buffer.
|
||||
final int bytesLength = 16 * 1024;
|
||||
byte[] bytes = new byte[bytesLength];
|
||||
bytes[0] = (byte) 67;
|
||||
bytes[bytesLength - 1] = (byte) 89;
|
||||
output.writeRawVarint32(bytesLength);
|
||||
output.writeUInt32NoTag(bytesLength);
|
||||
output.writeRawBytes(bytes);
|
||||
output.flush();
|
||||
|
||||
|
@ -399,7 +399,7 @@ public class CodedOutputStreamTest {
|
||||
public void testWriteMessageWithNegativeEnumValue() throws Exception {
|
||||
SparseEnumMessage message =
|
||||
SparseEnumMessage.newBuilder().setSparseEnum(TestSparseEnum.SPARSE_E).build();
|
||||
assertThat(message.getSparseEnum().getNumber() < 0).isTrue();
|
||||
assertThat(message.getSparseEnum().getNumber()).isLessThan(0);
|
||||
for (OutputType outputType : OutputType.values()) {
|
||||
Coder coder = outputType.newCoder(message.getSerializedSize());
|
||||
message.writeTo(coder.stream());
|
||||
@ -427,11 +427,9 @@ public class CodedOutputStreamTest {
|
||||
String string =
|
||||
"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz";
|
||||
// Ensure we take the slower fast path.
|
||||
assertThat(
|
||||
CodedOutputStream.computeUInt32SizeNoTag(string.length())
|
||||
!= CodedOutputStream.computeUInt32SizeNoTag(
|
||||
string.length() * Utf8.MAX_BYTES_PER_CHAR))
|
||||
.isTrue();
|
||||
assertThat(CodedOutputStream.computeUInt32SizeNoTag(string.length()))
|
||||
.isNotEqualTo(
|
||||
CodedOutputStream.computeUInt32SizeNoTag(string.length() * Utf8.MAX_BYTES_PER_CHAR));
|
||||
|
||||
coder.stream().writeStringNoTag(string);
|
||||
coder.stream().flush();
|
||||
|
@ -460,6 +460,33 @@ public class DescriptorsTest {
|
||||
}
|
||||
}
|
||||
|
||||
/** Tests that parsing an unknown enum throws an exception */
|
||||
@Test
|
||||
public void testParseUnknownEnum() {
|
||||
FieldDescriptorProto.Builder field = FieldDescriptorProto.newBuilder()
|
||||
.setLabel(FieldDescriptorProto.Label.LABEL_OPTIONAL)
|
||||
.setTypeName("UnknownEnum")
|
||||
.setType(FieldDescriptorProto.Type.TYPE_ENUM)
|
||||
.setName("bar")
|
||||
.setNumber(1);
|
||||
DescriptorProto.Builder messageType = DescriptorProto.newBuilder()
|
||||
.setName("Foo")
|
||||
.addField(field);
|
||||
FileDescriptorProto fooProto =
|
||||
FileDescriptorProto.newBuilder()
|
||||
.setName("foo.proto")
|
||||
.addDependency("bar.proto")
|
||||
.addMessageType(messageType)
|
||||
.build();
|
||||
try {
|
||||
Descriptors.FileDescriptor.buildFrom(fooProto, new FileDescriptor[0], true);
|
||||
assertWithMessage("DescriptorValidationException expected").fail();
|
||||
} catch (DescriptorValidationException expected) {
|
||||
assertThat(expected.getMessage()).contains("\"UnknownEnum\" is not an enum type.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests the translate/crosslink for an example where a message field's name and type name are the
|
||||
* same.
|
||||
|
@ -31,10 +31,13 @@
|
||||
package com.google.protobuf;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.junit.Assert.assertThrows;
|
||||
|
||||
import com.google.protobuf.Descriptors.EnumDescriptor;
|
||||
import com.google.protobuf.Descriptors.FieldDescriptor;
|
||||
import com.google.protobuf.Descriptors.OneofDescriptor;
|
||||
import dynamicmessagetest.DynamicMessageTestProto.EmptyMessage;
|
||||
import dynamicmessagetest.DynamicMessageTestProto.MessageWithMapFields;
|
||||
import protobuf_unittest.UnittestProto;
|
||||
import protobuf_unittest.UnittestProto.TestAllExtensions;
|
||||
import protobuf_unittest.UnittestProto.TestAllTypes;
|
||||
@ -42,6 +45,7 @@ import protobuf_unittest.UnittestProto.TestAllTypes.NestedMessage;
|
||||
import protobuf_unittest.UnittestProto.TestEmptyMessage;
|
||||
import protobuf_unittest.UnittestProto.TestPackedTypes;
|
||||
import org.junit.Test;
|
||||
import org.junit.function.ThrowingRunnable;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
|
||||
@ -335,4 +339,52 @@ public class DynamicMessageTest {
|
||||
DynamicMessage message = builder.build();
|
||||
assertThat(message.getField(repeatedEnumField)).isEqualTo(enumDescriptor.getValues());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBuilderGetFieldBuilder_mapField_throwsUnsupportedOperationException() {
|
||||
final DynamicMessage.Builder builder =
|
||||
DynamicMessage.newBuilder(MessageWithMapFields.getDescriptor());
|
||||
final FieldDescriptor mapField =
|
||||
MessageWithMapFields.getDescriptor().findFieldByName("string_message_map");
|
||||
|
||||
Message.Builder entryBuilder = builder.newBuilderForField(mapField);
|
||||
entryBuilder.setField(entryBuilder.getDescriptorForType().findFieldByNumber(1), "foo");
|
||||
entryBuilder.setField(
|
||||
entryBuilder.getDescriptorForType().findFieldByNumber(2),
|
||||
EmptyMessage.getDefaultInstance());
|
||||
builder.addRepeatedField(mapField, entryBuilder.build());
|
||||
|
||||
assertThrows(
|
||||
UnsupportedOperationException.class,
|
||||
new ThrowingRunnable() {
|
||||
@Override
|
||||
public void run() throws Throwable {
|
||||
builder.getFieldBuilder(mapField);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBuilderGetRepeatedFieldBuilder_mapField_throwsUnsupportedOperationException() {
|
||||
final DynamicMessage.Builder builder =
|
||||
DynamicMessage.newBuilder(MessageWithMapFields.getDescriptor());
|
||||
final FieldDescriptor mapField =
|
||||
MessageWithMapFields.getDescriptor().findFieldByName("string_message_map");
|
||||
|
||||
Message.Builder entryBuilder = builder.newBuilderForField(mapField);
|
||||
entryBuilder.setField(entryBuilder.getDescriptorForType().findFieldByNumber(1), "foo");
|
||||
entryBuilder.setField(
|
||||
entryBuilder.getDescriptorForType().findFieldByNumber(2),
|
||||
EmptyMessage.getDefaultInstance());
|
||||
builder.addRepeatedField(mapField, entryBuilder.build());
|
||||
|
||||
assertThrows(
|
||||
UnsupportedOperationException.class,
|
||||
new ThrowingRunnable() {
|
||||
@Override
|
||||
public void run() throws Throwable {
|
||||
builder.getFieldBuilder(mapField);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -85,6 +85,20 @@ import org.junit.runners.JUnit4;
|
||||
@SuppressWarnings({"ProtoBuilderReturnValueIgnored", "ReturnValueIgnored"})
|
||||
@RunWith(JUnit4.class)
|
||||
public class GeneratedMessageTest {
|
||||
|
||||
private static final TestOneof2 EXPECTED_MERGED_MESSAGE =
|
||||
TestOneof2.newBuilder()
|
||||
.setFooMessage(TestOneof2.NestedMessage.newBuilder().addCorgeInt(1).addCorgeInt(2))
|
||||
.build();
|
||||
|
||||
private static final TestOneof2 MESSAGE_TO_MERGE_FROM =
|
||||
TestOneof2.newBuilder()
|
||||
.setFooMessage(TestOneof2.NestedMessage.newBuilder().addCorgeInt(2))
|
||||
.build();
|
||||
|
||||
private static final FieldDescriptor NESTED_MESSAGE_BB_FIELD =
|
||||
UnittestProto.TestAllTypes.NestedMessage.getDescriptor().findFieldByName("bb");
|
||||
|
||||
TestUtil.ReflectionTester reflectionTester =
|
||||
new TestUtil.ReflectionTester(TestAllTypes.getDescriptor(), null);
|
||||
|
||||
@ -1036,9 +1050,8 @@ public class GeneratedMessageTest {
|
||||
public void testRecursiveMessageDefaultInstance() throws Exception {
|
||||
UnittestProto.TestRecursiveMessage message =
|
||||
UnittestProto.TestRecursiveMessage.getDefaultInstance();
|
||||
assertThat(message != null).isTrue();
|
||||
assertThat(message.getA()).isNotNull();
|
||||
assertThat(message.getA().equals(message)).isTrue();
|
||||
assertThat(message).isNotNull();
|
||||
assertThat(message.getA()).isEqualTo(message);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -1047,11 +1060,8 @@ public class GeneratedMessageTest {
|
||||
TestAllTypes.Builder builder = TestAllTypes.newBuilder();
|
||||
TestUtil.setAllFields(builder);
|
||||
TestAllTypes expected = builder.build();
|
||||
ObjectOutputStream out = new ObjectOutputStream(baos);
|
||||
try {
|
||||
try (ObjectOutputStream out = new ObjectOutputStream(baos)) {
|
||||
out.writeObject(expected);
|
||||
} finally {
|
||||
out.close();
|
||||
}
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
|
||||
ObjectInputStream in = new ObjectInputStream(bais);
|
||||
@ -1317,9 +1327,7 @@ public class GeneratedMessageTest {
|
||||
builder1
|
||||
.newBuilderForField(fieldDescriptor)
|
||||
.mergeFrom((Message) builder1.getField(fieldDescriptor));
|
||||
FieldDescriptor subFieldDescriptor1 =
|
||||
fieldBuilder1.getDescriptorForType().findFieldByName("bb");
|
||||
fieldBuilder1.setField(subFieldDescriptor1, 1);
|
||||
fieldBuilder1.setField(NESTED_MESSAGE_BB_FIELD, 1);
|
||||
builder1.setField(fieldDescriptor, fieldBuilder1.build());
|
||||
|
||||
// Mutate foreign message
|
||||
@ -1348,9 +1356,7 @@ public class GeneratedMessageTest {
|
||||
// Mutate nested message
|
||||
TestAllTypes.Builder builder2 = TestAllTypes.newBuilder();
|
||||
Message.Builder fieldBuilder2 = builder2.getFieldBuilder(fieldDescriptor);
|
||||
FieldDescriptor subFieldDescriptor2 =
|
||||
fieldBuilder2.getDescriptorForType().findFieldByName("bb");
|
||||
fieldBuilder2.setField(subFieldDescriptor2, 1);
|
||||
fieldBuilder2.setField(NESTED_MESSAGE_BB_FIELD, 1);
|
||||
builder2.setField(fieldDescriptor, fieldBuilder2.build());
|
||||
|
||||
// Mutate foreign message
|
||||
@ -1650,7 +1656,7 @@ public class GeneratedMessageTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOneofMerge() throws Exception {
|
||||
public void testOneofMergeNonMessage() throws Exception {
|
||||
// Primitive Type
|
||||
{
|
||||
TestOneof2.Builder builder = TestOneof2.newBuilder();
|
||||
@ -1677,18 +1683,39 @@ public class GeneratedMessageTest {
|
||||
assertThat(message2.hasFooEnum()).isTrue();
|
||||
assertThat(message2.getFooEnum()).isEqualTo(TestOneof2.NestedEnum.BAR);
|
||||
}
|
||||
}
|
||||
|
||||
// Message
|
||||
{
|
||||
TestOneof2.Builder builder = TestOneof2.newBuilder();
|
||||
TestOneof2 message =
|
||||
builder
|
||||
.setFooMessage(TestOneof2.NestedMessage.newBuilder().setQuxInt(234).build())
|
||||
.build();
|
||||
TestOneof2 message2 = TestOneof2.newBuilder().mergeFrom(message).build();
|
||||
assertThat(message2.hasFooMessage()).isTrue();
|
||||
assertThat(message2.getFooMessage().getQuxInt()).isEqualTo(234);
|
||||
}
|
||||
@Test
|
||||
public void testOneofMergeMessage_mergeIntoNewBuilder() {
|
||||
TestOneof2.Builder builder = TestOneof2.newBuilder();
|
||||
TestOneof2 message =
|
||||
builder.setFooMessage(TestOneof2.NestedMessage.newBuilder().setQuxInt(234).build()).build();
|
||||
TestOneof2 message2 = TestOneof2.newBuilder().mergeFrom(message).build();
|
||||
assertThat(message2.hasFooMessage()).isTrue();
|
||||
assertThat(message2.getFooMessage().getQuxInt()).isEqualTo(234);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOneofMergeMessage_mergeWithGetMessageBuilder() {
|
||||
TestOneof2.Builder builder = TestOneof2.newBuilder();
|
||||
builder.getFooMessageBuilder().addCorgeInt(1);
|
||||
assertThat(builder.mergeFrom(MESSAGE_TO_MERGE_FROM).build()).isEqualTo(EXPECTED_MERGED_MESSAGE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOneofMergeMessage_mergeIntoMessageBuiltWithGetMessageBuilder() {
|
||||
TestOneof2.Builder builder = TestOneof2.newBuilder();
|
||||
builder.getFooMessageBuilder().addCorgeInt(1);
|
||||
TestOneof2 message = builder.build();
|
||||
assertThat(message.toBuilder().mergeFrom(MESSAGE_TO_MERGE_FROM).build())
|
||||
.isEqualTo(EXPECTED_MERGED_MESSAGE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOneofMergeMessage_mergeWithoutGetMessageBuilder() {
|
||||
TestOneof2.Builder builder =
|
||||
TestOneof2.newBuilder().setFooMessage(TestOneof2.NestedMessage.newBuilder().addCorgeInt(1));
|
||||
assertThat(builder.mergeFrom(MESSAGE_TO_MERGE_FROM).build()).isEqualTo(EXPECTED_MERGED_MESSAGE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -1796,9 +1823,7 @@ public class GeneratedMessageTest {
|
||||
// Mutate nested message
|
||||
TestAllTypes.Builder builder1 = TestAllTypes.newBuilder();
|
||||
Message.Builder fieldBuilder1 = builder1.newBuilderForField(fieldDescriptor);
|
||||
FieldDescriptor subFieldDescriptor1 =
|
||||
fieldBuilder1.getDescriptorForType().findFieldByName("bb");
|
||||
fieldBuilder1.setField(subFieldDescriptor1, 1);
|
||||
fieldBuilder1.setField(NESTED_MESSAGE_BB_FIELD, 1);
|
||||
builder1.addRepeatedField(fieldDescriptor, fieldBuilder1.build());
|
||||
|
||||
// Mutate foreign message
|
||||
@ -1822,9 +1847,7 @@ public class GeneratedMessageTest {
|
||||
TestAllTypes.Builder builder2 = TestAllTypes.newBuilder();
|
||||
builder2.addRepeatedNestedMessageBuilder();
|
||||
Message.Builder fieldBuilder2 = builder2.getRepeatedFieldBuilder(fieldDescriptor, 0);
|
||||
FieldDescriptor subFieldDescriptor2 =
|
||||
fieldBuilder2.getDescriptorForType().findFieldByName("bb");
|
||||
fieldBuilder2.setField(subFieldDescriptor2, 1);
|
||||
fieldBuilder2.setField(NESTED_MESSAGE_BB_FIELD, 1);
|
||||
|
||||
// Mutate foreign message
|
||||
Message.Builder foreignFieldBuilder2 = builder2.newBuilderForField(foreignFieldDescriptor);
|
||||
@ -1905,4 +1928,99 @@ public class GeneratedMessageTest {
|
||||
// We expect this exception.
|
||||
}
|
||||
}
|
||||
|
||||
private static final FieldDescriptor OPTIONAL_NESTED_MESSAGE_EXTENSION =
|
||||
UnittestProto.getDescriptor().findExtensionByName("optional_nested_message_extension");
|
||||
private static final FieldDescriptor REPEATED_NESTED_MESSAGE_EXTENSION =
|
||||
UnittestProto.getDescriptor().findExtensionByName("repeated_nested_message_extension");
|
||||
// A compile-time check that TestAllExtensions.Builder does in fact extend
|
||||
// GeneratedMessageV3.ExtendableBuilder. The tests below assume that it does.
|
||||
static {
|
||||
@SuppressWarnings("unused")
|
||||
Class<? extends GeneratedMessageV3.ExtendableBuilder<?, ?>> ignored =
|
||||
TestAllExtensions.Builder.class;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void
|
||||
extendableBuilder_extensionFieldContainingBuilder_setRepeatedFieldOverwritesElement() {
|
||||
TestAllExtensions.Builder builder = TestAllExtensions.newBuilder();
|
||||
builder.addRepeatedField(REPEATED_NESTED_MESSAGE_EXTENSION, NestedMessage.getDefaultInstance());
|
||||
// Calling getRepeatedFieldBuilder and ignoring the returned Builder should have no
|
||||
// externally-visible effect, but internally it sets the stored field element to a builder.
|
||||
builder.getRepeatedFieldBuilder(REPEATED_NESTED_MESSAGE_EXTENSION, 0);
|
||||
|
||||
NestedMessage setNestedMessage = NestedMessage.newBuilder().setBb(100).build();
|
||||
builder.setRepeatedField(REPEATED_NESTED_MESSAGE_EXTENSION, 0, setNestedMessage);
|
||||
|
||||
assertThat(builder.getRepeatedField(REPEATED_NESTED_MESSAGE_EXTENSION, 0))
|
||||
.isEqualTo(setNestedMessage);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void extendableBuilder_extensionFieldContainingBuilder_addRepeatedFieldAppendsToField() {
|
||||
TestAllExtensions.Builder builder = TestAllExtensions.newBuilder();
|
||||
builder.addRepeatedField(REPEATED_NESTED_MESSAGE_EXTENSION, NestedMessage.getDefaultInstance());
|
||||
// Calling getRepeatedFieldBuilder and ignoring the returned Builder should have no
|
||||
// externally-visible effect, but internally it sets the stored field element to a builder.
|
||||
builder.getRepeatedFieldBuilder(REPEATED_NESTED_MESSAGE_EXTENSION, 0);
|
||||
|
||||
builder.addRepeatedField(REPEATED_NESTED_MESSAGE_EXTENSION, NestedMessage.getDefaultInstance());
|
||||
|
||||
assertThat((List<?>) builder.getField(REPEATED_NESTED_MESSAGE_EXTENSION)).hasSize(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void extendableBuilder_mergeFrom_optionalField_changesReflectedInExistingBuilder() {
|
||||
TestAllExtensions.Builder builder = TestAllExtensions.newBuilder();
|
||||
Message.Builder nestedMessageBuilder =
|
||||
builder.getFieldBuilder(OPTIONAL_NESTED_MESSAGE_EXTENSION);
|
||||
|
||||
builder.mergeFrom(
|
||||
TestAllExtensions.newBuilder()
|
||||
.setField(OPTIONAL_NESTED_MESSAGE_EXTENSION, NestedMessage.newBuilder().setBb(100))
|
||||
.build());
|
||||
|
||||
assertThat(nestedMessageBuilder.getField(NESTED_MESSAGE_BB_FIELD)).isEqualTo(100);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void extendableBuilder_mergeFrom_optionalField_doesNotInvalidateExistingBuilder() {
|
||||
TestAllExtensions.Builder builder = TestAllExtensions.newBuilder();
|
||||
Message.Builder nestedMessageBuilder =
|
||||
builder.getFieldBuilder(OPTIONAL_NESTED_MESSAGE_EXTENSION);
|
||||
|
||||
builder.mergeFrom(
|
||||
TestAllExtensions.newBuilder()
|
||||
.setField(OPTIONAL_NESTED_MESSAGE_EXTENSION, NestedMessage.newBuilder().setBb(100))
|
||||
.build());
|
||||
|
||||
// Changes to nestedMessageBuilder should still be reflected in the parent builder.
|
||||
nestedMessageBuilder.setField(NESTED_MESSAGE_BB_FIELD, 200);
|
||||
|
||||
assertThat(builder.build())
|
||||
.isEqualTo(
|
||||
TestAllExtensions.newBuilder()
|
||||
.setField(OPTIONAL_NESTED_MESSAGE_EXTENSION, NestedMessage.newBuilder().setBb(200))
|
||||
.build());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void extendableBuilder_mergeFrom_repeatedField_doesNotInvalidateExistingBuilder() {
|
||||
TestAllExtensions.Builder builder = TestAllExtensions.newBuilder();
|
||||
builder.addRepeatedField(REPEATED_NESTED_MESSAGE_EXTENSION, NestedMessage.getDefaultInstance());
|
||||
Message.Builder nestedMessageBuilder =
|
||||
builder.getRepeatedFieldBuilder(REPEATED_NESTED_MESSAGE_EXTENSION, 0);
|
||||
|
||||
builder.mergeFrom(
|
||||
TestAllExtensions.newBuilder()
|
||||
.addRepeatedField(REPEATED_NESTED_MESSAGE_EXTENSION, NestedMessage.getDefaultInstance())
|
||||
.build());
|
||||
|
||||
// Changes to nestedMessageBuilder should still be reflected in the parent builder.
|
||||
nestedMessageBuilder.setField(NESTED_MESSAGE_BB_FIELD, 100);
|
||||
|
||||
assertThat(builder.getRepeatedField(REPEATED_NESTED_MESSAGE_EXTENSION, 0))
|
||||
.isEqualTo(NestedMessage.newBuilder().setBb(100).build());
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,49 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
package com.google.protobuf;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
|
||||
@RunWith(JUnit4.class)
|
||||
public class InvalidProtocolBufferExceptionTest {
|
||||
|
||||
@Test
|
||||
public void testWrapRuntimeException() {
|
||||
ArrayIndexOutOfBoundsException root = new ArrayIndexOutOfBoundsException();
|
||||
InvalidProtocolBufferException wrapper = new InvalidProtocolBufferException(root);
|
||||
assertThat(wrapper).hasCauseThat().isEqualTo(root);
|
||||
}
|
||||
|
||||
}
|
@ -254,7 +254,7 @@ public class LazyMessageLiteTest {
|
||||
ByteString data1 = outer.toByteString();
|
||||
|
||||
// The following should not alter the content of the 'outer' message.
|
||||
LazyMessageLite.Builder merged = LazyMessageLite.newBuilder().mergeFrom(outer);
|
||||
LazyMessageLite.Builder merged = outer.toBuilder();
|
||||
LazyInnerMessageLite anotherInner = LazyInnerMessageLite.newBuilder().setNum(12345).build();
|
||||
merged.setOneofInner(anotherInner);
|
||||
|
||||
|
@ -537,6 +537,7 @@ public final class MapLiteTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("ProtoNewBuilderMergeFrom")
|
||||
public void testUnknownEnumValues() throws Exception {
|
||||
TestMap.Builder builder =
|
||||
TestMap.newBuilder()
|
||||
|
@ -992,6 +992,7 @@ public class MapTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("ProtoNewBuilderMergeFrom")
|
||||
public void testUnknownEnumValues() throws Exception {
|
||||
TestMap.Builder builder =
|
||||
TestMap.newBuilder()
|
||||
|
@ -218,11 +218,11 @@ public class ParseExceptionsTest {
|
||||
public void messageBuilder_mergeDelimitedFrom_InputStream_malformed() throws Exception {
|
||||
byte[] body = new byte[80];
|
||||
CodedOutputStream cos = CodedOutputStream.newInstance(body);
|
||||
cos.writeRawVarint32(90); // Greater than bytes in stream
|
||||
cos.writeUInt32NoTag(90); // Greater than bytes in stream
|
||||
cos.writeTag(DescriptorProto.ENUM_TYPE_FIELD_NUMBER, WireFormat.WIRETYPE_LENGTH_DELIMITED);
|
||||
cos.writeRawVarint32(98); // Nested message with size larger than parent
|
||||
cos.writeUInt32NoTag(98); // Nested message with size larger than parent
|
||||
cos.writeTag(1000, WireFormat.WIRETYPE_LENGTH_DELIMITED);
|
||||
cos.writeRawVarint32(100); // Unknown field with size larger than parent
|
||||
cos.writeUInt32NoTag(100); // Unknown field with size larger than parent
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(body);
|
||||
try {
|
||||
DescriptorProto.parseDelimitedFrom(bais);
|
||||
|
@ -31,10 +31,15 @@
|
||||
package com.google.protobuf;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth.assertWithMessage;
|
||||
|
||||
import com.google.protobuf.UnittestLite.TestAllExtensionsLite;
|
||||
import com.google.protobuf.UnittestLite.TestAllTypesLite;
|
||||
import com.google.protobuf.UnittestLite.TestMergeExceptionLite;
|
||||
import com.google.protobuf.UnittestLite.TestPackedExtensionsLite;
|
||||
import com.google.protobuf.UnittestLite.TestParsingMergeLite;
|
||||
import protobuf_unittest.MapLiteUnittest;
|
||||
import protobuf_unittest.MapLiteUnittest.TestRequiredLite;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.InputStream;
|
||||
@ -200,4 +205,70 @@ public class ParserLiteTest {
|
||||
assertThat(parsingMerge.getRepeatedGroupCount()).isEqualTo(3);
|
||||
assertThat(parsingMerge.getExtensionCount(TestParsingMergeLite.repeatedExt)).isEqualTo(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExceptionWhenMergingExtendedMessagesMissingRequiredFieldsLite() {
|
||||
// create a TestMergeExceptionLite message (missing required fields) that looks like
|
||||
// all_extensions {
|
||||
// [TestRequiredLite.single] {
|
||||
// }
|
||||
// }
|
||||
TestMergeExceptionLite.Builder message = TestMergeExceptionLite.newBuilder();
|
||||
message.setAllExtensions(
|
||||
TestAllExtensionsLite.newBuilder()
|
||||
.setExtension(TestRequiredLite.single, TestRequiredLite.newBuilder().buildPartial())
|
||||
.buildPartial());
|
||||
ByteString byteString = message.buildPartial().toByteString();
|
||||
|
||||
// duplicate the bytestring to make the `all_extensions` field repeat twice, so that it will
|
||||
// need merging when parsing back
|
||||
ByteString duplicatedByteString = byteString.concat(byteString);
|
||||
|
||||
byte[] bytes = duplicatedByteString.toByteArray();
|
||||
ExtensionRegistryLite registry = ExtensionRegistryLite.newInstance();
|
||||
MapLiteUnittest.registerAllExtensions(registry);
|
||||
|
||||
// `parseFrom` should throw InvalidProtocolBufferException, not UninitializedMessageException,
|
||||
// for each of the 5 possible input types:
|
||||
|
||||
// parseFrom(ByteString)
|
||||
try {
|
||||
TestMergeExceptionLite.parseFrom(duplicatedByteString, registry);
|
||||
assertWithMessage("Expected InvalidProtocolBufferException").fail();
|
||||
} catch (Exception e) {
|
||||
assertThat(e.getClass()).isEqualTo(InvalidProtocolBufferException.class);
|
||||
}
|
||||
|
||||
// parseFrom(ByteArray)
|
||||
try {
|
||||
TestMergeExceptionLite.parseFrom(bytes, registry);
|
||||
assertWithMessage("Expected InvalidProtocolBufferException").fail();
|
||||
} catch (Exception e) {
|
||||
assertThat(e.getClass()).isEqualTo(InvalidProtocolBufferException.class);
|
||||
}
|
||||
|
||||
// parseFrom(InputStream)
|
||||
try {
|
||||
TestMergeExceptionLite.parseFrom(new ByteArrayInputStream(bytes), registry);
|
||||
assertWithMessage("Expected InvalidProtocolBufferException").fail();
|
||||
} catch (Exception e) {
|
||||
assertThat(e.getClass()).isEqualTo(InvalidProtocolBufferException.class);
|
||||
}
|
||||
|
||||
// parseFrom(CodedInputStream)
|
||||
try {
|
||||
TestMergeExceptionLite.parseFrom(CodedInputStream.newInstance(bytes), registry);
|
||||
assertWithMessage("Expected InvalidProtocolBufferException").fail();
|
||||
} catch (Exception e) {
|
||||
assertThat(e.getClass()).isEqualTo(InvalidProtocolBufferException.class);
|
||||
}
|
||||
|
||||
// parseFrom(ByteBuffer)
|
||||
try {
|
||||
TestMergeExceptionLite.parseFrom(duplicatedByteString.asReadOnlyByteBuffer(), registry);
|
||||
assertWithMessage("Expected InvalidProtocolBufferException").fail();
|
||||
} catch (Exception e) {
|
||||
assertThat(e.getClass()).isEqualTo(InvalidProtocolBufferException.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -40,6 +40,7 @@ import protobuf_unittest.UnittestProto;
|
||||
import protobuf_unittest.UnittestProto.ForeignMessage;
|
||||
import protobuf_unittest.UnittestProto.TestAllTypes;
|
||||
import protobuf_unittest.UnittestProto.TestEmptyMessage;
|
||||
import protobuf_unittest.UnittestProto.TestMergeException;
|
||||
import protobuf_unittest.UnittestProto.TestParsingMerge;
|
||||
import protobuf_unittest.UnittestProto.TestRequired;
|
||||
import java.io.ByteArrayInputStream;
|
||||
@ -291,6 +292,71 @@ public class ParserTest {
|
||||
assertThat(parsingMerge.getExtensionCount(TestParsingMerge.repeatedExt)).isEqualTo(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExceptionWhenMergingExtendedMessagesMissingRequiredFields() {
|
||||
// create a TestMergeException message (missing required fields) that looks like
|
||||
// all_extensions {
|
||||
// [TestRequired.single] {
|
||||
// }
|
||||
// }
|
||||
TestMergeException.Builder message = TestMergeException.newBuilder();
|
||||
message
|
||||
.getAllExtensionsBuilder()
|
||||
.setExtension(TestRequired.single, TestRequired.newBuilder().buildPartial());
|
||||
ByteString byteString = message.buildPartial().toByteString();
|
||||
|
||||
// duplicate the bytestring to make the `all_extensions` field repeat twice, so that it will
|
||||
// need merging when parsing back
|
||||
ByteString duplicatedByteString = byteString.concat(byteString);
|
||||
|
||||
byte[] bytes = duplicatedByteString.toByteArray();
|
||||
ExtensionRegistry registry = ExtensionRegistry.newInstance();
|
||||
UnittestProto.registerAllExtensions(registry);
|
||||
|
||||
// `parseFrom` should throw InvalidProtocolBufferException, not UninitializedMessageException,
|
||||
// for each of the 5 possible input types:
|
||||
|
||||
// parseFrom(ByteString)
|
||||
try {
|
||||
TestMergeException.parseFrom(duplicatedByteString, registry);
|
||||
assertWithMessage("Expected InvalidProtocolBufferException").fail();
|
||||
} catch (Exception e) {
|
||||
assertThat(e.getClass()).isEqualTo(InvalidProtocolBufferException.class);
|
||||
}
|
||||
|
||||
// parseFrom(ByteArray)
|
||||
try {
|
||||
TestMergeException.parseFrom(bytes, registry);
|
||||
assertWithMessage("Expected InvalidProtocolBufferException").fail();
|
||||
} catch (Exception e) {
|
||||
assertThat(e.getClass()).isEqualTo(InvalidProtocolBufferException.class);
|
||||
}
|
||||
|
||||
// parseFrom(InputStream)
|
||||
try {
|
||||
TestMergeException.parseFrom(new ByteArrayInputStream(bytes), registry);
|
||||
assertWithMessage("Expected InvalidProtocolBufferException").fail();
|
||||
} catch (Exception e) {
|
||||
assertThat(e.getClass()).isEqualTo(InvalidProtocolBufferException.class);
|
||||
}
|
||||
|
||||
// parseFrom(CodedInputStream)
|
||||
try {
|
||||
TestMergeException.parseFrom(CodedInputStream.newInstance(bytes), registry);
|
||||
assertWithMessage("Expected InvalidProtocolBufferException").fail();
|
||||
} catch (Exception e) {
|
||||
assertThat(e.getClass()).isEqualTo(InvalidProtocolBufferException.class);
|
||||
}
|
||||
|
||||
// parseFrom(ByteBuffer)
|
||||
try {
|
||||
TestMergeException.parseFrom(duplicatedByteString.asReadOnlyByteBuffer(), registry);
|
||||
assertWithMessage("Expected InvalidProtocolBufferException").fail();
|
||||
} catch (Exception e) {
|
||||
assertThat(e.getClass()).isEqualTo(InvalidProtocolBufferException.class);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParseDelimitedFrom_firstByteInterrupted_preservesCause() {
|
||||
try {
|
||||
|
@ -52,7 +52,6 @@ public class Proto2ExtensionLookupSchemaTest {
|
||||
public void setup() {
|
||||
TestSchemas.registerGenericProto2Schemas();
|
||||
|
||||
Protobuf.getInstance().schemaFor(Proto2MessageWithExtensions.class);
|
||||
data = new Proto2MessageFactory(10, 20, 1, 1).newMessage().toByteArray();
|
||||
extensionRegistry = ExtensionRegistry.newInstance();
|
||||
Proto2Testing.registerAllExtensions(extensionRegistry);
|
||||
|
@ -239,7 +239,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.logging.Handler;
|
||||
import java.util.logging.LogRecord;
|
||||
import junit.framework.Assert;
|
||||
import org.junit.Assert;
|
||||
|
||||
/**
|
||||
* Contains methods for setting all fields of {@code TestAllTypes} to some values as well as
|
||||
@ -901,8 +901,8 @@ public final class TestUtil {
|
||||
Assert.assertEquals(208L, message.getRepeatedFixed64(0));
|
||||
Assert.assertEquals(209, message.getRepeatedSfixed32(0));
|
||||
Assert.assertEquals(210L, message.getRepeatedSfixed64(0));
|
||||
Assert.assertEquals(211F, message.getRepeatedFloat(0));
|
||||
Assert.assertEquals(212D, message.getRepeatedDouble(0));
|
||||
Assert.assertEquals(211F, message.getRepeatedFloat(0), 0.0);
|
||||
Assert.assertEquals(212D, message.getRepeatedDouble(0), 0.0);
|
||||
Assert.assertEquals(true, message.getRepeatedBool(0));
|
||||
Assert.assertEquals("215", message.getRepeatedString(0));
|
||||
Assert.assertEquals(toBytes("216"), message.getRepeatedBytes(0));
|
||||
@ -931,8 +931,8 @@ public final class TestUtil {
|
||||
Assert.assertEquals(508L, message.getRepeatedFixed64(1));
|
||||
Assert.assertEquals(509, message.getRepeatedSfixed32(1));
|
||||
Assert.assertEquals(510L, message.getRepeatedSfixed64(1));
|
||||
Assert.assertEquals(511F, message.getRepeatedFloat(1));
|
||||
Assert.assertEquals(512D, message.getRepeatedDouble(1));
|
||||
Assert.assertEquals(511F, message.getRepeatedFloat(1), 0.0);
|
||||
Assert.assertEquals(512D, message.getRepeatedDouble(1), 0.0);
|
||||
Assert.assertEquals(true, message.getRepeatedBool(1));
|
||||
Assert.assertEquals("515", message.getRepeatedString(1));
|
||||
Assert.assertEquals(toBytes("516"), message.getRepeatedBytes(1));
|
||||
|
@ -69,8 +69,6 @@ import org.junit.runners.JUnit4;
|
||||
|
||||
/**
|
||||
* Test case for {@link TextFormat}.
|
||||
*
|
||||
* <p>TODO(wenboz): ExtensionTest and rest of text_format_unittest.cc.
|
||||
*/
|
||||
@RunWith(JUnit4.class)
|
||||
public class TextFormatTest {
|
||||
|
@ -54,6 +54,7 @@ import org.junit.runners.JUnit4;
|
||||
public class UnknownEnumValueTest {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("ProtoNewBuilderMergeFrom")
|
||||
public void testUnknownEnumValues() throws Exception {
|
||||
TestAllTypes.Builder builder = TestAllTypes.newBuilder();
|
||||
builder.setOptionalNestedEnumValue(4321);
|
||||
|
@ -0,0 +1,57 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
<<<<<<<< HEAD:java/kotlin-lite/src/test/proto/com/google/protobuf/multiple_files_proto3.proto
|
||||
syntax = "proto3";
|
||||
|
||||
package protobuf.kotlin.generator;
|
||||
|
||||
option java_package = "com.google.protobuf.kotlin.generator";
|
||||
option java_multiple_files = true;
|
||||
|
||||
enum NestedEnum { FOO = 0; }
|
||||
|
||||
message MultipleFilesMessageA {}
|
||||
|
||||
message MultipleFilesMessageB {}
|
||||
========
|
||||
syntax = "proto2";
|
||||
|
||||
package dynamic_message_test;
|
||||
|
||||
option java_package = "dynamicmessagetest";
|
||||
option java_outer_classname = "DynamicMessageTestProto";
|
||||
|
||||
message EmptyMessage {}
|
||||
|
||||
message MessageWithMapFields {
|
||||
map<string, EmptyMessage> string_message_map = 1;
|
||||
}
|
||||
>>>>>>>> refs/tags/sync-piper:java/core/src/test/proto/com/google/protobuf/dynamic_message_test.proto
|
@ -35,8 +35,6 @@
|
||||
|
||||
syntax = "proto2";
|
||||
|
||||
// Some generic_services option(s) added automatically.
|
||||
// See: http://go/proto2-generic-services-default
|
||||
package io_protocol_tests;
|
||||
|
||||
option java_generic_services = true; // auto-added
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -28,6 +28,7 @@
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
<<<<<<<< HEAD:java/kotlin-lite/src/test/proto/com/google/protobuf/multiple_files_proto3.proto
|
||||
syntax = "proto3";
|
||||
|
||||
package protobuf.kotlin.generator;
|
||||
@ -40,3 +41,17 @@ enum NestedEnum { FOO = 0; }
|
||||
message MultipleFilesMessageA {}
|
||||
|
||||
message MultipleFilesMessageB {}
|
||||
========
|
||||
syntax = "proto2";
|
||||
|
||||
package dynamic_message_test;
|
||||
|
||||
option java_package = "dynamicmessagetest";
|
||||
option java_outer_classname = "DynamicMessageTestProto";
|
||||
|
||||
message EmptyMessage {}
|
||||
|
||||
message MessageWithMapFields {
|
||||
map<string, EmptyMessage> string_message_map = 1;
|
||||
}
|
||||
>>>>>>>> refs/tags/sync-piper:java/core/src/test/proto/com/google/protobuf/dynamic_message_test.proto
|
||||
|
@ -58,6 +58,7 @@ import protobuf_unittest.UnittestProto.TestEmptyMessageWithExtensions
|
||||
import protobuf_unittest.copy
|
||||
import protobuf_unittest.foreignMessage
|
||||
import protobuf_unittest.optionalGroupExtension
|
||||
import protobuf_unittest.optionalNestedMessageOrNull
|
||||
import protobuf_unittest.repeatedGroupExtension
|
||||
import protobuf_unittest.testAllExtensions
|
||||
import protobuf_unittest.testAllTypes
|
||||
@ -953,4 +954,16 @@ class Proto2Test {
|
||||
assertThat(hasDo_()).isFalse()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testGetOrNull() {
|
||||
val noNestedMessage = testAllTypes {}
|
||||
assertThat(noNestedMessage.optionalNestedMessageOrNull).isEqualTo(null)
|
||||
|
||||
val someNestedMessage = testAllTypes {
|
||||
optionalNestedMessage = TestAllTypesKt.nestedMessage { bb = 118 }
|
||||
}
|
||||
assertThat(someNestedMessage.optionalNestedMessageOrNull)
|
||||
.isEqualTo(TestAllTypesKt.nestedMessage { bb = 118 })
|
||||
}
|
||||
}
|
||||
|
@ -44,6 +44,7 @@ import proto3_unittest.UnittestProto3.TestAllTypes
|
||||
import proto3_unittest.UnittestProto3.TestAllTypes.NestedEnum
|
||||
import proto3_unittest.UnittestProto3.TestEmptyMessage
|
||||
import proto3_unittest.copy
|
||||
import proto3_unittest.optionalNestedMessageOrNull
|
||||
import proto3_unittest.testAllTypes
|
||||
import proto3_unittest.testEmptyMessage
|
||||
import org.junit.Test
|
||||
@ -86,66 +87,61 @@ class Proto3Test {
|
||||
assertThat(repeatedString).isEqualTo(listOf("5", "2", "3", "4"))
|
||||
|
||||
repeatedNestedMessage.addAll(listOf(nestedMessage { bb = 1 }, nestedMessage { bb = 2 }))
|
||||
assertThat(repeatedNestedMessage).isEqualTo(
|
||||
listOf(
|
||||
nestedMessage { bb = 1 },
|
||||
nestedMessage { bb = 2 }
|
||||
)
|
||||
)
|
||||
assertThat(repeatedNestedMessage)
|
||||
.isEqualTo(listOf(nestedMessage { bb = 1 }, nestedMessage { bb = 2 }))
|
||||
repeatedNestedMessage += listOf(nestedMessage { bb = 3 }, nestedMessage { bb = 4 })
|
||||
assertThat(repeatedNestedMessage).isEqualTo(
|
||||
listOf(
|
||||
nestedMessage { bb = 1 },
|
||||
nestedMessage { bb = 2 },
|
||||
nestedMessage { bb = 3 },
|
||||
nestedMessage { bb = 4 }
|
||||
assertThat(repeatedNestedMessage)
|
||||
.isEqualTo(
|
||||
listOf(
|
||||
nestedMessage { bb = 1 },
|
||||
nestedMessage { bb = 2 },
|
||||
nestedMessage { bb = 3 },
|
||||
nestedMessage { bb = 4 }
|
||||
)
|
||||
)
|
||||
)
|
||||
repeatedNestedMessage[0] = nestedMessage { bb = 5 }
|
||||
assertThat(repeatedNestedMessage).isEqualTo(
|
||||
listOf(
|
||||
nestedMessage { bb = 5 },
|
||||
nestedMessage { bb = 2 },
|
||||
nestedMessage { bb = 3 },
|
||||
nestedMessage { bb = 4 }
|
||||
assertThat(repeatedNestedMessage)
|
||||
.isEqualTo(
|
||||
listOf(
|
||||
nestedMessage { bb = 5 },
|
||||
nestedMessage { bb = 2 },
|
||||
nestedMessage { bb = 3 },
|
||||
nestedMessage { bb = 4 }
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
repeatedNestedEnum.addAll(listOf(NestedEnum.FOO, NestedEnum.BAR))
|
||||
assertThat(repeatedNestedEnum).isEqualTo(listOf(NestedEnum.FOO, NestedEnum.BAR))
|
||||
repeatedNestedEnum += listOf(NestedEnum.BAZ, NestedEnum.FOO)
|
||||
assertThat(repeatedNestedEnum).isEqualTo(
|
||||
listOf(NestedEnum.FOO, NestedEnum.BAR, NestedEnum.BAZ, NestedEnum.FOO)
|
||||
)
|
||||
assertThat(repeatedNestedEnum)
|
||||
.isEqualTo(listOf(NestedEnum.FOO, NestedEnum.BAR, NestedEnum.BAZ, NestedEnum.FOO))
|
||||
repeatedNestedEnum[0] = NestedEnum.BAR
|
||||
assertThat(repeatedNestedEnum).isEqualTo(
|
||||
listOf(NestedEnum.BAR, NestedEnum.BAR, NestedEnum.BAZ, NestedEnum.FOO)
|
||||
)
|
||||
assertThat(repeatedNestedEnum)
|
||||
.isEqualTo(listOf(NestedEnum.BAR, NestedEnum.BAR, NestedEnum.BAZ, NestedEnum.FOO))
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testClears() {
|
||||
assertThat(
|
||||
testAllTypes {
|
||||
optionalInt32 = 101
|
||||
clearOptionalInt32()
|
||||
testAllTypes {
|
||||
optionalInt32 = 101
|
||||
clearOptionalInt32()
|
||||
|
||||
optionalString = "115"
|
||||
clearOptionalString()
|
||||
optionalString = "115"
|
||||
clearOptionalString()
|
||||
|
||||
optionalNestedMessage = TestAllTypesKt.nestedMessage { bb = 118 }
|
||||
clearOptionalNestedMessage()
|
||||
optionalNestedMessage = TestAllTypesKt.nestedMessage { bb = 118 }
|
||||
clearOptionalNestedMessage()
|
||||
|
||||
optionalNestedEnum = NestedEnum.BAZ
|
||||
clearOptionalNestedEnum()
|
||||
optionalNestedEnum = NestedEnum.BAZ
|
||||
clearOptionalNestedEnum()
|
||||
|
||||
oneofUint32 = 601
|
||||
clearOneofUint32()
|
||||
}
|
||||
).isEqualTo(
|
||||
TestAllTypes.newBuilder().build()
|
||||
)
|
||||
oneofUint32 = 601
|
||||
clearOneofUint32()
|
||||
}
|
||||
)
|
||||
.isEqualTo(TestAllTypes.newBuilder().build())
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -154,126 +150,110 @@ class Proto3Test {
|
||||
optionalInt32 = 101
|
||||
optionalString = "115"
|
||||
}
|
||||
val modifiedMessage = message.copy {
|
||||
optionalInt32 = 201
|
||||
}
|
||||
val modifiedMessage = message.copy { optionalInt32 = 201 }
|
||||
|
||||
assertThat(message).isEqualTo(
|
||||
TestAllTypes.newBuilder()
|
||||
.setOptionalInt32(101)
|
||||
.setOptionalString("115")
|
||||
.build()
|
||||
)
|
||||
assertThat(modifiedMessage).isEqualTo(
|
||||
TestAllTypes.newBuilder()
|
||||
.setOptionalInt32(201)
|
||||
.setOptionalString("115")
|
||||
.build()
|
||||
)
|
||||
assertThat(message)
|
||||
.isEqualTo(TestAllTypes.newBuilder().setOptionalInt32(101).setOptionalString("115").build())
|
||||
assertThat(modifiedMessage)
|
||||
.isEqualTo(TestAllTypes.newBuilder().setOptionalInt32(201).setOptionalString("115").build())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testOneof() {
|
||||
val message = testAllTypes {
|
||||
oneofString = "foo"
|
||||
assertThat(oneofFieldCase)
|
||||
.isEqualTo(TestAllTypes.OneofFieldCase.ONEOF_STRING)
|
||||
assertThat(oneofFieldCase).isEqualTo(TestAllTypes.OneofFieldCase.ONEOF_STRING)
|
||||
assertThat(oneofString).isEqualTo("foo")
|
||||
clearOneofField()
|
||||
assertThat(oneofFieldCase)
|
||||
.isEqualTo(TestAllTypes.OneofFieldCase.ONEOFFIELD_NOT_SET)
|
||||
assertThat(oneofFieldCase).isEqualTo(TestAllTypes.OneofFieldCase.ONEOFFIELD_NOT_SET)
|
||||
oneofUint32 = 5
|
||||
}
|
||||
|
||||
assertThat(message.getOneofFieldCase())
|
||||
.isEqualTo(TestAllTypes.OneofFieldCase.ONEOF_UINT32)
|
||||
assertThat(message.getOneofFieldCase()).isEqualTo(TestAllTypes.OneofFieldCase.ONEOF_UINT32)
|
||||
assertThat(message.getOneofUint32()).isEqualTo(5)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testEmptyMessages() {
|
||||
assertThat(
|
||||
testEmptyMessage {}
|
||||
).isEqualTo(
|
||||
TestEmptyMessage.newBuilder().build()
|
||||
)
|
||||
assertThat(testEmptyMessage {}).isEqualTo(TestEmptyMessage.newBuilder().build())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testEvilNames() {
|
||||
assertThat(
|
||||
evilNamesProto3 {
|
||||
initialized = true
|
||||
hasFoo = true
|
||||
bar = "foo"
|
||||
isInitialized = true
|
||||
fooBar = "foo"
|
||||
aLLCAPS += "foo"
|
||||
aLLCAPSMAP[1] = true
|
||||
hasUnderbarPrecedingNumeric1Foo = true
|
||||
hasUnderbarPrecedingNumeric42Bar = true
|
||||
hasUnderbarPrecedingNumeric123Foo42BarBaz = true
|
||||
extension += "foo"
|
||||
class_ = "foo"
|
||||
int = 1.0
|
||||
long = true
|
||||
boolean = 1L
|
||||
sealed = "foo"
|
||||
interface_ = 1F
|
||||
in_ = 1
|
||||
object_ = "foo"
|
||||
cachedSize_ = "foo"
|
||||
serializedSize_ = true
|
||||
value = "foo"
|
||||
index = 1L
|
||||
values += "foo"
|
||||
newValues += "foo"
|
||||
builder = true
|
||||
k[1] = 1
|
||||
v["foo"] = "foo"
|
||||
key["foo"] = 1
|
||||
map[1] = "foo"
|
||||
pairs["foo"] = 1
|
||||
LeadingUnderscore = "foo"
|
||||
option = 1
|
||||
}
|
||||
).isEqualTo(
|
||||
EvilNamesProto3.newBuilder()
|
||||
.setInitialized(true)
|
||||
.setHasFoo(true)
|
||||
.setBar("foo")
|
||||
.setIsInitialized(true)
|
||||
.setFooBar("foo")
|
||||
.addALLCAPS("foo")
|
||||
.putALLCAPSMAP(1, true)
|
||||
.setHasUnderbarPrecedingNumeric1Foo(true)
|
||||
.setHasUnderbarPrecedingNumeric42Bar(true)
|
||||
.setHasUnderbarPrecedingNumeric123Foo42BarBaz(true)
|
||||
.addExtension("foo")
|
||||
.setClass_("foo")
|
||||
.setInt(1.0)
|
||||
.setLong(true)
|
||||
.setBoolean(1L)
|
||||
.setSealed("foo")
|
||||
.setInterface(1F)
|
||||
.setIn(1)
|
||||
.setObject("foo")
|
||||
.setCachedSize_("foo")
|
||||
.setSerializedSize_(true)
|
||||
.setValue("foo")
|
||||
.setIndex(1L)
|
||||
.addValues("foo")
|
||||
.addNewValues("foo")
|
||||
.setBuilder(true)
|
||||
.putK(1, 1)
|
||||
.putV("foo", "foo")
|
||||
.putKey("foo", 1)
|
||||
.putMap(1, "foo")
|
||||
.putPairs("foo", 1)
|
||||
.setLeadingUnderscore("foo")
|
||||
.setOption(1)
|
||||
.build()
|
||||
)
|
||||
evilNamesProto3 {
|
||||
initialized = true
|
||||
hasFoo = true
|
||||
bar = "foo"
|
||||
isInitialized = true
|
||||
fooBar = "foo"
|
||||
aLLCAPS += "foo"
|
||||
aLLCAPSMAP[1] = true
|
||||
hasUnderbarPrecedingNumeric1Foo = true
|
||||
hasUnderbarPrecedingNumeric42Bar = true
|
||||
hasUnderbarPrecedingNumeric123Foo42BarBaz = true
|
||||
extension += "foo"
|
||||
class_ = "foo"
|
||||
int = 1.0
|
||||
long = true
|
||||
boolean = 1L
|
||||
sealed = "foo"
|
||||
interface_ = 1F
|
||||
in_ = 1
|
||||
object_ = "foo"
|
||||
cachedSize_ = "foo"
|
||||
serializedSize_ = true
|
||||
value = "foo"
|
||||
index = 1L
|
||||
values += "foo"
|
||||
newValues += "foo"
|
||||
builder = true
|
||||
k[1] = 1
|
||||
v["foo"] = "foo"
|
||||
key["foo"] = 1
|
||||
map[1] = "foo"
|
||||
pairs["foo"] = 1
|
||||
LeadingUnderscore = "foo"
|
||||
option = 1
|
||||
}
|
||||
)
|
||||
.isEqualTo(
|
||||
EvilNamesProto3.newBuilder()
|
||||
.setInitialized(true)
|
||||
.setHasFoo(true)
|
||||
.setBar("foo")
|
||||
.setIsInitialized(true)
|
||||
.setFooBar("foo")
|
||||
.addALLCAPS("foo")
|
||||
.putALLCAPSMAP(1, true)
|
||||
.setHasUnderbarPrecedingNumeric1Foo(true)
|
||||
.setHasUnderbarPrecedingNumeric42Bar(true)
|
||||
.setHasUnderbarPrecedingNumeric123Foo42BarBaz(true)
|
||||
.addExtension("foo")
|
||||
.setClass_("foo")
|
||||
.setInt(1.0)
|
||||
.setLong(true)
|
||||
.setBoolean(1L)
|
||||
.setSealed("foo")
|
||||
.setInterface(1F)
|
||||
.setIn(1)
|
||||
.setObject("foo")
|
||||
.setCachedSize_("foo")
|
||||
.setSerializedSize_(true)
|
||||
.setValue("foo")
|
||||
.setIndex(1L)
|
||||
.addValues("foo")
|
||||
.addNewValues("foo")
|
||||
.setBuilder(true)
|
||||
.putK(1, 1)
|
||||
.putV("foo", "foo")
|
||||
.putKey("foo", 1)
|
||||
.putMap(1, "foo")
|
||||
.putPairs("foo", 1)
|
||||
.setLeadingUnderscore("foo")
|
||||
.setOption(1)
|
||||
.build()
|
||||
)
|
||||
|
||||
assertThat(class_ {}).isEqualTo(Class.newBuilder().build())
|
||||
}
|
||||
@ -350,16 +330,22 @@ class Proto3Test {
|
||||
|
||||
@Test
|
||||
fun testMultipleFiles() {
|
||||
assertThat(
|
||||
com.google.protobuf.kotlin.generator.multipleFilesMessageA {}
|
||||
).isEqualTo(
|
||||
com.google.protobuf.kotlin.generator.MultipleFilesMessageA.newBuilder().build()
|
||||
)
|
||||
assertThat(com.google.protobuf.kotlin.generator.multipleFilesMessageA {})
|
||||
.isEqualTo(com.google.protobuf.kotlin.generator.MultipleFilesMessageA.newBuilder().build())
|
||||
|
||||
assertThat(
|
||||
com.google.protobuf.kotlin.generator.multipleFilesMessageB {}
|
||||
).isEqualTo(
|
||||
com.google.protobuf.kotlin.generator.MultipleFilesMessageB.newBuilder().build()
|
||||
)
|
||||
assertThat(com.google.protobuf.kotlin.generator.multipleFilesMessageB {})
|
||||
.isEqualTo(com.google.protobuf.kotlin.generator.MultipleFilesMessageB.newBuilder().build())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testGetOrNull() {
|
||||
val noNestedMessage = testAllTypes {}
|
||||
assertThat(noNestedMessage.optionalNestedMessageOrNull).isEqualTo(null)
|
||||
|
||||
val someNestedMessage = testAllTypes {
|
||||
optionalNestedMessage = TestAllTypesKt.nestedMessage { bb = 118 }
|
||||
}
|
||||
assertThat(someNestedMessage.optionalNestedMessageOrNull)
|
||||
.isEqualTo(TestAllTypesKt.nestedMessage { bb = 118 })
|
||||
}
|
||||
}
|
||||
|
@ -1345,6 +1345,7 @@ public class LiteTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("ProtoNewBuilderMergeFrom")
|
||||
public void testBuilderMergeFromNull() throws Exception {
|
||||
try {
|
||||
TestAllTypesLite.newBuilder().mergeFrom((TestAllTypesLite) null);
|
||||
@ -1899,6 +1900,7 @@ public class LiteTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("ProtoNewBuilderMergeFrom")
|
||||
public void testMergeFromNoLazyFieldSharing() throws Exception {
|
||||
TestAllTypesLite.Builder sourceBuilder =
|
||||
TestAllTypesLite.newBuilder().setOptionalLazyMessage(NestedMessage.newBuilder().setBb(1));
|
||||
@ -2487,9 +2489,9 @@ public class LiteTest {
|
||||
assertWithMessage("expected exception").fail();
|
||||
} catch (InvalidProtocolBufferException expected) {
|
||||
assertThat(
|
||||
TestAllExtensionsLite.newBuilder()
|
||||
.setExtension(UnittestLite.optionalInt32ExtensionLite, 123)
|
||||
.build())
|
||||
TestAllExtensionsLite.newBuilder()
|
||||
.setExtension(UnittestLite.optionalInt32ExtensionLite, 123)
|
||||
.build())
|
||||
.isEqualTo(expected.getUnfinishedMessage());
|
||||
}
|
||||
}
|
||||
@ -2782,7 +2784,7 @@ public class LiteTest {
|
||||
assertThat(message1).isNotEqualTo(message2);
|
||||
}
|
||||
|
||||
private String encodeHex(ByteString bytes) {
|
||||
private static String encodeHex(ByteString bytes) {
|
||||
String hexDigits = "0123456789abcdef";
|
||||
StringBuilder stringBuilder = new StringBuilder(bytes.size() * 2);
|
||||
for (byte b : bytes) {
|
||||
@ -2792,7 +2794,7 @@ public class LiteTest {
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
private boolean contains(ByteString a, ByteString b) {
|
||||
private static boolean contains(ByteString a, ByteString b) {
|
||||
for (int i = 0; i <= a.size() - b.size(); ++i) {
|
||||
if (a.substring(i, i + b.size()).equals(b)) {
|
||||
return true;
|
||||
|
@ -238,13 +238,13 @@ public final class Durations {
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse from a string to produce a duration.
|
||||
* Parse a string to produce a duration.
|
||||
*
|
||||
* @return A Duration parsed from the string.
|
||||
* @throws ParseException if parsing fails.
|
||||
* @return a Duration parsed from the string
|
||||
* @throws ParseException if the string is not in the duration format
|
||||
*/
|
||||
public static Duration parse(String value) throws ParseException {
|
||||
// Must ended with "s".
|
||||
// Must end with "s".
|
||||
if (value.isEmpty() || value.charAt(value.length() - 1) != 's') {
|
||||
throw new ParseException("Invalid duration string: " + value, 0);
|
||||
}
|
||||
@ -272,7 +272,9 @@ public final class Durations {
|
||||
try {
|
||||
return normalizedDuration(seconds, nanos);
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new ParseException("Duration value is out of range.", 0);
|
||||
ParseException ex = new ParseException("Duration value is out of range.", 0);
|
||||
ex.initCause(e);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,10 +44,11 @@ import java.util.TreeMap;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* A tree representation of a FieldMask. Each leaf node in this tree represent
|
||||
* a field path in the FieldMask.
|
||||
* A tree representation of a FieldMask. Each leaf node in this tree represent a field path in the
|
||||
* FieldMask.
|
||||
*
|
||||
* <p>For example, FieldMask "foo.bar,foo.baz,bar.baz" as a tree will be:
|
||||
*
|
||||
* <pre>
|
||||
* [root] -+- foo -+- bar
|
||||
* | |
|
||||
@ -56,10 +57,9 @@ import java.util.logging.Logger;
|
||||
* +- bar --- baz
|
||||
* </pre>
|
||||
*
|
||||
* <p>By representing FieldMasks with this tree structure we can easily convert
|
||||
* a FieldMask to a canonical form, merge two FieldMasks, calculate the
|
||||
* intersection to two FieldMasks and traverse all fields specified by the
|
||||
* FieldMask in a message tree.
|
||||
* <p>By representing FieldMasks with this tree structure we can easily convert a FieldMask to a
|
||||
* canonical form, merge two FieldMasks, calculate the intersection to two FieldMasks and traverse
|
||||
* all fields specified by the FieldMask in a message tree.
|
||||
*/
|
||||
final class FieldMaskTree {
|
||||
private static final Logger logger = Logger.getLogger(FieldMaskTree.class.getName());
|
||||
@ -72,14 +72,10 @@ final class FieldMaskTree {
|
||||
|
||||
private final Node root = new Node();
|
||||
|
||||
/**
|
||||
* Creates an empty FieldMaskTree.
|
||||
*/
|
||||
/** Creates an empty FieldMaskTree. */
|
||||
FieldMaskTree() {}
|
||||
|
||||
/**
|
||||
* Creates a FieldMaskTree for a given FieldMask.
|
||||
*/
|
||||
/** Creates a FieldMaskTree for a given FieldMask. */
|
||||
FieldMaskTree(FieldMask mask) {
|
||||
mergeFromFieldMask(mask);
|
||||
}
|
||||
@ -143,11 +139,10 @@ final class FieldMaskTree {
|
||||
* When removing a field path from the tree:
|
||||
* <li>All sub-paths will be removed. That is, after removing "foo.bar" from the tree,
|
||||
* "foo.bar.baz" will be removed.
|
||||
* <li>If all children of a node has been removed, the node itself will be removed as well.
|
||||
* <li>If all children of a node have been removed, the node itself will be removed as well.
|
||||
* That is, if "foo" only has one child "bar" and "foo.bar" only has one child "baz",
|
||||
* removing "foo.bar.barz" would remove both "foo" and "foo.bar".
|
||||
* If "foo" has both "bar" and "qux" as children, removing "foo.bar" would leave the path
|
||||
* "foo.qux" intact.
|
||||
* removing "foo.bar.barz" would remove both "foo" and "foo.bar". If "foo" has both "bar"
|
||||
* and "qux" as children, removing "foo.bar" would leave the path "foo.qux" intact.
|
||||
* <li>If the field path to remove is a non-exist sub-path, nothing will be changed.
|
||||
* </ul>
|
||||
*/
|
||||
@ -195,9 +190,7 @@ final class FieldMaskTree {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts this tree to a FieldMask.
|
||||
*/
|
||||
/** Converts this tree to a FieldMask. */
|
||||
FieldMask toFieldMask() {
|
||||
if (root.children.isEmpty()) {
|
||||
return FieldMask.getDefaultInstance();
|
||||
@ -219,9 +212,7 @@ final class FieldMaskTree {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the intersection of this tree with the given {@code path} to {@code output}.
|
||||
*/
|
||||
/** Adds the intersection of this tree with the given {@code path} to {@code output}. */
|
||||
void intersectFieldPath(String path, FieldMaskTree output) {
|
||||
if (root.children.isEmpty()) {
|
||||
return;
|
||||
@ -262,21 +253,18 @@ final class FieldMaskTree {
|
||||
if (root.children.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
merge(root, "", source, destination, options);
|
||||
merge(root, source, destination, options);
|
||||
}
|
||||
|
||||
/** Merges all fields specified by a sub-tree from {@code source} to {@code destination}. */
|
||||
private static void merge(
|
||||
Node node,
|
||||
String path,
|
||||
Message source,
|
||||
Message.Builder destination,
|
||||
FieldMaskUtil.MergeOptions options) {
|
||||
Node node, Message source, Message.Builder destination, FieldMaskUtil.MergeOptions options) {
|
||||
if (source.getDescriptorForType() != destination.getDescriptorForType()) {
|
||||
throw new IllegalArgumentException(
|
||||
String.format(
|
||||
"source (%s) and destination (%s) descriptor must be equal",
|
||||
source.getDescriptorForType(), destination.getDescriptorForType()));
|
||||
source.getDescriptorForType().getFullName(),
|
||||
destination.getDescriptorForType().getFullName()));
|
||||
}
|
||||
|
||||
Descriptor descriptor = source.getDescriptorForType();
|
||||
@ -304,9 +292,8 @@ final class FieldMaskTree {
|
||||
// so we don't create unnecessary empty messages.
|
||||
continue;
|
||||
}
|
||||
String childPath = path.isEmpty() ? entry.getKey() : path + "." + entry.getKey();
|
||||
Message.Builder childBuilder = ((Message) destination.getField(field)).toBuilder();
|
||||
merge(entry.getValue(), childPath, (Message) source.getField(field), childBuilder, options);
|
||||
merge(entry.getValue(), (Message) source.getField(field), childBuilder, options);
|
||||
destination.setField(field, childBuilder.buildPartial());
|
||||
continue;
|
||||
}
|
||||
@ -331,9 +318,7 @@ final class FieldMaskTree {
|
||||
destination.setField(
|
||||
field,
|
||||
((Message) destination.getField(field))
|
||||
.toBuilder()
|
||||
.mergeFrom((Message) source.getField(field))
|
||||
.build());
|
||||
.toBuilder().mergeFrom((Message) source.getField(field)).build());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user