Skip to content

Protocol Buffers v22.0

Compare
Choose a tag to compare
@zhangskz zhangskz released this 16 Feb 18:17
· 6758 commits to main since this release

Announcements

  • This version includes breaking changes to: Cpp.

    • [Cpp] Migrate to Abseil's logging library. (a9f1ea6)
    • [Cpp] proto2::Map::value_type changes to std::pair<const K, V>. (46656ed)
    • [Cpp] Mark final ZeroCopyInputStream, ZeroCopyOutputStream, and DefaultFieldComparator classes. (bf9c22e)
    • [Cpp] Add a dependency on Abseil (#10416)
    • [Cpp] Remove all autotools usage (#10132)
    • [Cpp] Add C++20 reserved keywords
    • [Cpp] Dropped C++11 Support
    • [Cpp] Delete Arena::Init
    • [Cpp] Replace JSON parser with new implementation
    • [Cpp] Make RepeatedField::GetArena non-const in order to support split RepeatedFields.
  • You can refer to our migration guide for details on what C++ code changes will be necessary to be compatible with 22.0.

  • Protobuf News may include additional announcements or pre-announcements for upcoming changes.

Compiler

  • Breaking change: Migrate to Abseil's logging library. (a9f1ea6)
  • Add debug_redact field option to protobuf. (9238c48)
  • Protoc: accept capital X to indicate hex escape in string literals (#10757)
  • Gracefully handle weird placement of linebreaks around comments (#10660)
  • Open up visibility for some compiler internals (#10608)
  • Protoc: validate reserved names are identifiers (#10586)
  • Protoc: validate custom json_name configuration (#10581)
  • Protoc: fix consistency with parsing very large decimal numbers (#10555)
  • Use protoc version for --version (#10386)
  • Fix for grpc.tools #17995 & protobuf #7474 (handle UTF-8 paths in argumentfile) (#10200)
  • Print full path name of source .proto file on error
  • Include proto message type in the annotation comments.
  • Maven artifact suffix format has changed to -RCN instead of -rc-N

C++

  • Document known quirks of EnumDescriptor::is_closed() when importing across files with different syntaxes. (a594141)
  • Add C++ support for retention attribute (8f882e7)
  • Breaking change: Migrate to Abseil's logging library. (a9f1ea6)
  • No longer define no_threadlocal on OpenBSD (#10610)
  • CMake: Enable projects to set the C++ version (#10464)
  • Breaking Change: Add a dependency on Abseil (#10416)
  • Upgrade third_party/googletest submodule to current main branch (#10393)
  • Breaking Change: Remove all autotools usage (#10132)
  • CMake: use add_compile_options instead of add_definitions for compile options (#10293)
  • Fix #9947: make the ABI identical between debug and non-debug builds (#10271)
  • Allow for CMAKE_INSTALL_LIBDIR to be absolute (#10090)
  • Add header search paths to protobuf-c++ spec (#10024)
  • Cpp_generated_lib_linked support is removed in protoc
  • Reduced .pb.o object file size slightly by explicitly instantiating
  • Breaking Change: Add C++20 reserved keywords.
  • Breaking Change: Dropped C++11 Support
  • Fixed crash in ThreadLocalStorage for pre-C++17 compilers on 32-bit ARM.
  • Clarified that JSON API non-OK statuses are not a stable API.
  • Added a default implementation of MessageDifferencer::Reporter methods.
  • Proto2::MapPair is now an alias to std::pair.
  • Hide C++ RepeatedField::UnsafeArenaSwap
  • Use table-driven parser for reflection based objects.
  • Add ARM-optimized Varint decoding functions.
  • Minor optimization for parsing groups
  • Declare ReflectiveProtoHook class
  • Reduce size of VarintParse code in protocol buffers, by calling the shared
  • Avoid inlining some large heavily duplicated routines in repeated_ptr_field.h
  • Add ReflectiveProtoHook to Reflection.
  • Turns on table-driven parser for reflection based objects.
  • Save code space by avoiding inlining of large-in-aggregate code-space MessageLite::~MessageLite destructor.
  • Undefine the macro linux when compiling protobuf
  • Reduce memory consumption of MessageSet parsing.
  • Save code space by avoiding inlining of large-in-aggregate code-space MessageLite::~MessageLite destructor.
  • Breaking Change: Delete Arena::Init
  • Make a PROTOBUF_POISON/UNPOISON to reduce noise in the source
  • Put alignment functions in "arena_align.h"
  • Split off cleanup arena functions into "arena_cleanup.h"
  • Fix signed / unsigned match in CHECK_EQ
  • Kill Atomic<>. it's not pulling it's weight
  • Move AllocationPolicy out of arena_impl, and unify arena_config for bazel
  • Fix failure case in table-driven parser.
  • Breaking Change: Replace JSON parser with new implementation
  • Introduce the Printer::{SetRedactDebugString,SetRandomizeDebugString} private flags.
  • Introduce global flags to control Printer::{SetRedactDebugString, SetRandomizeDebugString}.
  • Proto3 string fields no longer trigger clang-tidy warning bugprone-branch-clone.
  • Fix the API of DescriptorUpgrader::set_allow_unknown_dependencies to set to True always, and to populate into the DescriptorPool as well.
  • Report line numbers consistently in text-format deprecated-field warnings.
  • Fixed C++ code generation for protos that use int32_t, uint32_t, int64_t, uint64_t, size_t as field names.
  • Annotate generated C++ public aliases for enum types.
  • Change default arena max block size from 8K to 32K.
  • Begin emitting semantic metadata for some C++ proto features. (2880fef)

Java

  • Document known quirks of EnumDescriptor::is_closed() when importing across files with different syntaxes. (a594141)
  • Use LazyStringArrayList directly in gencode. (e6dd59e)
  • Add Java support for retention attribute (1325913)
  • Expect fail when serialize inf and nan for Value.number_value in json format. fixes #11259 (ca1cb1b)
  • Create a helper function that can make a mutable copy of any ProtobufList (5669606)
  • Add debug_redact field option to protobuf. (9238c48)
  • Remove unused package private class ProtobufLists. (b51c551)
  • Mark UnmodifiableLazyStringList deprecated. UnmodifiableLazyStringList is unnecessary and will be removed in a future release. (9595cbb)
  • Make emptyList public and mark the public EMPTY field as deprecated. (c658e27)
  • Enable Text format parser to skip unknown short-formed repeated fields. (6dbd413)
  • Expose internal setExtension method for Kotlin (33d1070)
  • Mark default instance as immutable first to avoid race during static initialization of default instances. (#10770)
  • Add serialVersionUID to ByteString and subclasses (#10718)
  • Fix serialization warnings in generated code when compiling with Java 18 and above (#10561)
  • Fix Timestamps fromDate for negative 'exact second' java.sql.Timestamps (#10321)
  • Fix Timestamps.fromDate to correctly handle java.sql.Timestamps before unix epoch (#10126)
  • Performance improvement for repeated use of FieldMaskUtil#merge by caching
  • Optimized Java proto serialization gencode for protos having many extension ranges with few fields in between.
  • More thoroughly annotate public generated code in Java lite protocol buffers.
  • Fixed Bug in proto3 java lite repeated enum fields. Failed to call copyOnWrite before modifying previously built message. Causes modification to already "built" messages that should be immutable.
  • Fix Java reflection serialization of empty packed fields.
  • Refactoring java full runtime to reuse sub-message builders and prepare to migrate parsing logic from parse constructor to builder.
  • Move proto wireformat parsing functionality from the private "parsing constructor" to the Builder class.
  • Change the Lite runtime to prefer merging from the wireformat into mutable messages rather than building up a new immutable object before merging. This way results in fewer allocations and copy operations.
  • Make message-type extensions merge from wire-format instead of building up instances and merging afterwards. This has much better performance.
  • Fix TextFormat parser to build up recurring (but supposedly not repeated) sub-messages directly from text rather than building a new sub-message and merging the fully formed message into the existing field.
  • Fix bug in nested builder caching logic where cleared sub-field builders would remain dirty after a clear and build in a parent layer. #10624
  • Add exemplar variants of the Java Any.is() and Any.unpack() methods. (60b7149)
  • Use bit-field int values in buildPartial to skip work on unset groups of fields. (2326aef)
  • Maven artifact suffix format has changed to -RCN instead of -rc-N

Kotlin

  • Add debug_redact field option to protobuf. (9238c48)
  • Expose internal setExtension method for Kotlin (33d1070)
  • Add missing public modifier to Kotlin generated code (#10616)
  • Add "public" modifier to Kotlin generated code (#10599)
  • Update rules_kotlin version (#10212)
  • Suppress deprecation warnings in Kotlin generated code.
  • Kotlin generated code comments now use kdoc format instead of javadoc.
  • Escape keywords in package names in proto generated code
  • Add Kotlin enum int value getters and setters

Csharp

  • Make the MergeFrom method of type ReadOnlySequence public (#11124) (c4bac67)
  • Fix a bug in which a possibly invalidated swisstable reference is used. (5c5dcdd)
  • Fix .NET Native AOT warnings in Protobuf reflection (#11128) (c019a79)
  • Use forward slash instead of backslash in nuspec file (#11449) (724250d)
  • Add debug_redact field option to protobuf. (9238c48)
  • Expose internal setExtension method for Kotlin (33d1070)
  • Apply Obsolete attribute to deprecated enums and enum values in C# generated code (#10520)
  • Fix 32-bit floating point JSON parsing of maximal values for C# (#10514)
  • Retain existing array in RepeatedField.Clear (#10508)
  • Implement IComparable for the Duration type (C#) (#10441)
  • Implement correct map merging behavior for C# (#10339)
  • Support indented JSON formatting in C# (#9391)
  • Disambiguate generated properties in C# (#10269)
  • Bugfix/issue 8101 (#10268)
  • Expose plugin protos for C# (#10244)
  • Update to C# 10 and upgrade code style (#10105)
  • Fix failing FieldMask.Merge for well-known wrapper field types (#9602)
  • Helper method on Any to allow an any to be unpacked more easily (#9695)

Objective-C

  • [ObjC] Mark classes that shouldn't be subclassed as such. (a185a6e)
  • [ObjC] Boolean generation options support no value as "true". (7935932)
  • [ObjC] Put out of range closed enum extension values in unknown fields. (903639c)
  • [ObjC] Raise the min OS versions (and required Xcode) (#10652)
  • [ObjC] Provide a protocol for GPBExtensionRegistry's lookup support. (#10597)
  • Mark the syntax on GPBFileDescriptor as deprecated. (c79832b)
  • Add the concept of a "closed enum" and expose it from the GPBEnumDescriptor. (7bb699b)

Python

  • Document known quirks of EnumDescriptor::is_closed() when importing across files with different syntaxes. (a594141)
  • Soft deprecate python MessageFactory (c80e7ef)
  • Add debug_redact field option to protobuf. (9238c48)
  • Raise errors when serialize inf and nan for Value.number_value in json format. fixes #11259 (883ec1c)
  • Resolve #10949: use raise from in json_format.py (#10966) (1e6f876)
  • Allow reserved enums to be negative (1f58f1d)
  • Make generated python files compatible with Cython (#11011) (9aa5272)
  • Raise KeyError in Python ServiceDescriptor.FindMethodByName (#9592) (#9998)
  • Changes ordering of printed fields in .pyi files from lexicographic to the same ordering found in the proto descriptor.
  • Adds GeneratedCodeInfo annotations to python proto .pyi outputs as a base64 encoded docstring in the last line of the .pyi file for code analysis tools.
  • Fix message factory's behavior in python cpp extension to return same message classes for same descriptor, even if the factories are different.
  • Add type annotation for enum value fields in enum classes.
  • Update sphinx 2.3.1 to 3.0.4 (c1a42b3)
  • Added is_closed to EnumDescriptor in protobuf python (da9de8d)

Python C-Extension (Default)

PHP

  • Drop support for PHP <7.4
  • Fix: php 8.2 dynamic property warning in MapFieldIter (#11485) (8e636d5)
  • Chore: fix php lint (#11417) (ade256e)
  • Add debug_redact field option to protobuf. (9238c48)
  • [PHP]Added missing files and fix phpext_protobuf_ptr export in pecl version (#10689)
  • [PHP] Fix empty message serialization for Any (#10595)
  • [PHP] allow dynamic properties in Message (#10594)
  • [PHP] Added getContainingOneof and getRealContainingOneof to descriptor. (#10356)
  • Fix: PHP readonly legacy files for nested messages (#10320)
  • Migrating macos php builds from 7.0/7.3 to 7.4/8.0 (#10274)
  • Exposed more functions in FieldDescriptor and OneofDescriptor. (#10102)
  • Fixed PHP SEGV by not writing to shared memory for zend_class_entry. (#9995)
  • Feat: [PHP] remove legacy generate class file (#9621)

PHP C-Extension

  • Add debug_redact field option to protobuf. (9238c48)
  • Update PHP and Ruby to use the new accessors, delete the old ones (3f36a91)
  • Update Ruby to use the newer upb_Map_Next() iterator (8809a11)
  • Fix the ruby and php builds which were broken by a recent upb change (9cdf347)
  • See also UPB changes below, which may affect PHP C-Extension.

Ruby

  • For Ruby oneof fields, generate hazzers for members (#11655) (d1a3c6d)
  • Migrate ruby release targets to genrule to work around Bazel 5 bug (#11619) (e207bcd)
  • Add ruby release targets (#11468) (5b27b4f)
  • Remove support for ruby 2.5. (4958971)
  • Add debug_redact field option to protobuf. (9238c48)
  • Update PHP and Ruby to use the new accessors, delete the old ones (3f36a91)
  • Replace libc strdup usage with internal impl to restore musl compat. (#10811)
  • Auto capitalize enums name in Ruby (#10454)
  • Ruby: Use class inheritance to save memory (#10281)
  • Ruby: use a valid instance variable name for descriptor (#10282)

Ruby C-Extension

  • For Ruby oneof fields, generate hazzers for members (#11655) (d1a3c6d)
  • Add retention and target field options in descriptor.proto (5a56837)
  • Add ruby release targets (#11468) (5b27b4f)
  • Add debug_redact field option to protobuf. (9238c48)
  • Update PHP and Ruby to use the new accessors, delete the old ones (3f36a91)
  • Hide ruby native extension symbols on FreeBSD (#10832) (2a73e3b)
  • Update Ruby to use the newer upb_Map_Next() iterator (8809a11)
  • See also UPB changes below, which may affect Ruby C-Extension.

UPB (Python/PHP/Ruby C-Extension)

Other

  • Rename Maven artifacts to use “RC” instead of “rc-” as the release candidate prefix.
  • Remove unused headers, include missing headers, match args, etc. (21a6a26)
  • Add a non-const overload of RepeatedPtrField::GetArena and deprecate the const overload. (4bf33da)
  • Optimize Varint Parsing for 32 and 64 bits (ac76ae9)
  • Fix reflection based parser for map entries with closed enum values. (55d2123)
  • Upgrade to Abseil LTS 20230117 (#11622) (7930cd1)
  • Fixed Visual Studio 2022: protobuf\src\google\protobuf\arena.cc(457,51): error C2127: 'thread_cache_': illegal initialization of 'constinit' entity with a non-constant expression #11672 (#11674) (c2e99a1)
  • Clean up a few issues with ARM-optimized varint decoding. (bbe2e68)
  • Fix bool parser for map entries to look at the whole 64-bit varint and not just (43e5937)
  • Breaking Change: proto2::Map::value_type changes to std::pair<const K, V>. (46656ed)
  • Breaking Change: Mark final ZeroCopyInputStream, ZeroCopyOutputStream, and DefaultFieldComparator classes. (bf9c22e)
  • Deprecate repeated field cleared elements API. (84d8b00)
  • Breaking change: Make RepeatedField::GetArena non-const in order to support split RepeatedFields. (514c9a8)
  • Add EpsCopyInputStream::ReadCord() providing an efficient direct Cord API (bc4c156)
  • Add static asserts to container classes. (5a8abe1)
  • Fix proto deserialization issue when parsing a packed repeated enum field whose (afdf6da)
  • Use the "shldq" decoder for the specialized 64-bit Varint parsers, rather than (0ca97a1)
  • Use @utf8_range to reference //third_party/utf8_range (#11352) (2dcd7d8)
  • Place alignas() before lifetime specifiers (#11248) (5712e1a)
  • Add UnknownFieldSet::SerializeToCord() (8661e45)
  • Add support for repeated Cord fields. (b97005b)
  • Add Cord based Parse and Serialize logic to MessageLite (ddde013)
  • Add 'ReadCord and 'WriteCord functions to CodedStream (e5e2ad8)
  • Add CordInputStream and CordOutputStream providing stream support directly from/to Cord data (8afd1b6)
  • Add a WriteCord() method to ZeroCopyInputStream (192cd09)
  • Unify string and cord cleanup nodes in TaggedNode (0783c82)
  • Open source google/protobuf/bridge/message_set.proto (c04f842)
  • FileOutputStream: Properly pass block_size to CopyingOutputStreamAdaptor (1b1e399)
  • Implement ZeroCopyInputStream::ReadCord() in terms of absl::CordBuffer (75d31be)
  • Changing bazel skylib version from 1.2.1 to 1.3.0 (#10979) (1489e8d)
  • Update zlib to 1.2.13. (#10786)
  • Make jsoncpp a formal dependency (#10739)
  • Upgrade to MSVC 2017, since 2015 is no longer supported (#10437)
  • Update CMake configuration to add a dependency on Abseil (#10401)
  • Use release version instead of libtool version in Makefile (#10355)
  • Fix missing google::protobuf::RepeatedPtrField<std::string> issue in GCC (225b936)