PROTOBUF_SYNC_PIPER
pull/9576/head
Adam Cozzette 3 years ago
commit b0f9799a7c
  1. 4
      CHANGES.txt
  2. 28
      cmake/CMakeLists.txt
  3. 6
      cmake/libprotobuf-lite.cmake
  4. 7
      cmake/libprotobuf.cmake
  5. 6
      cmake/libprotoc.cmake
  6. 2
      configure.ac
  7. 4
      java/core/BUILD
  8. 4
      java/core/pom.xml
  9. 4
      java/core/src/main/java/com/google/protobuf/TextFormat.java
  10. 4
      java/kotlin-lite/pom.xml
  11. 4
      java/kotlin/pom.xml
  12. 4
      java/lite/pom.xml
  13. 6
      java/pom.xml
  14. 4
      java/util/pom.xml
  15. 4
      java/util/src/main/java/com/google/protobuf/util/JsonFormat.java
  16. 8
      java/util/src/test/java/com/google/protobuf/util/JsonFormatTest.java
  17. 130
      maven_install.json
  18. 2
      protobuf_deps.bzl
  19. 14
      python/google/protobuf/descriptor_pool.py
  20. 49
      python/google/protobuf/internal/import_test.py
  21. 40
      python/google/protobuf/internal/import_test_package/import_public.proto
  22. 40
      python/google/protobuf/internal/import_test_package/import_public_nested.proto
  23. 3
      python/google/protobuf/internal/import_test_package/inner.proto
  24. 1
      python/google/protobuf/internal/import_test_package/outer.proto
  25. 2
      python/google/protobuf/pyext/message.cc
  26. 8
      src/Makefile.am
  27. 4
      src/google/protobuf/compiler/cpp/cpp_helpers.h
  28. 3
      src/google/protobuf/compiler/cpp/cpp_message.h
  29. 8
      src/google/protobuf/compiler/cpp/cpp_parse_function_generator.cc
  30. 1
      src/google/protobuf/compiler/importer.h
  31. 6
      src/google/protobuf/compiler/parser.cc
  32. 4
      src/google/protobuf/compiler/parser.h
  33. 78
      src/google/protobuf/descriptor.cc
  34. 1
      src/google/protobuf/extension_set.h
  35. 6
      src/google/protobuf/generated_message_tctable_lite.cc
  36. 3
      src/google/protobuf/map_field.h
  37. 1
      src/google/protobuf/map_field_lite.h
  38. 13
      src/google/protobuf/port.h

@ -24,7 +24,8 @@ Unreleased Changes (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
* Fix comments for message set wire format.
Kotlin
* Add orNull extensions for optional message fields in Kotlin.
* Add orNull extensions for optional message fields.
* Add orNull extensions to all proto3 message fields.
Python
* Fix type annotations of some Duration and Timestamp methods.
@ -90,6 +91,7 @@ Unreleased Changes (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
* Add missing overload for reference wrapped fields.
* Add MergedDescriptorDatabase::FindAllFileNames()
* RepeatedField now defines an iterator type instead of using a pointer.
* Remove obsolete macros GOOGLE_PROTOBUF_HAS_ONEOF and GOOGLE_PROTOBUF_HAS_ARENAS.
2022-01-28 version 3.19.4 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)

@ -1,5 +1,5 @@
# Minimum CMake required
cmake_minimum_required(VERSION 3.1.3)
cmake_minimum_required(VERSION 3.10)
if(protobuf_VERBOSE)
message(STATUS "Protocol Buffers Configuring...")
@ -127,6 +127,30 @@ if (protobuf_DISABLE_RTTI)
add_definitions(-DGOOGLE_PROTOBUF_NO_RTTI=1)
endif()
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/cmaketest.map
"{
global:
main;
local:
*;
};")
# CheckLinkerFlag module available in CMake >=3.18.
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.18)
include(CheckLinkerFlag)
check_linker_flag(CXX -Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/cmaketest.map protobuf_HAVE_LD_VERSION_SCRIPT)
else()
include(CheckCXXSourceCompiles)
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} -Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/cmaketest.map)
check_cxx_source_compiles("
int main() {
return 0;
}
" protobuf_HAVE_LD_VERSION_SCRIPT)
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
endif()
file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/cmaketest.map)
find_package(Threads REQUIRED)
set(_protobuf_FIND_ZLIB)
@ -182,7 +206,7 @@ else (protobuf_BUILD_SHARED_LIBS)
# Prior to CMake 3.15, the MSVC runtime library was pushed into the same flags
# making programmatic control difficult. Prefer the functionality in newer
# CMake versions when available.
if(CMAKE_VERSION VERSION_GREATER 3.15 OR CMAKE_VERSION VERSION_EQUAL 3.15)
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.15)
if (protobuf_MSVC_STATIC_RUNTIME)
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded$<$<CONFIG:Debug>:Debug>)
else()

@ -93,6 +93,11 @@ endif()
add_library(libprotobuf-lite ${protobuf_SHARED_OR_STATIC}
${libprotobuf_lite_files} ${libprotobuf_lite_includes} ${libprotobuf_lite_rc_files})
if(protobuf_HAVE_LD_VERSION_SCRIPT)
target_link_options(libprotobuf-lite PRIVATE -Wl,--version-script=${protobuf_source_dir}/src/libprotobuf-lite.map)
set_target_properties(libprotobuf-lite PROPERTIES
LINK_DEPENDS ${protobuf_source_dir}/src/libprotobuf-lite.map)
endif()
target_link_libraries(libprotobuf-lite ${CMAKE_THREAD_LIBS_INIT})
if(protobuf_LINK_LIBATOMIC)
target_link_libraries(libprotobuf-lite atomic)
@ -108,6 +113,7 @@ if(protobuf_BUILD_SHARED_LIBS)
endif()
set_target_properties(libprotobuf-lite PROPERTIES
VERSION ${protobuf_VERSION}
SOVERSION 30
OUTPUT_NAME ${LIB_PREFIX}protobuf-lite
DEBUG_POSTFIX "${protobuf_DEBUG_POSTFIX}")
add_library(protobuf::libprotobuf-lite ALIAS libprotobuf-lite)

@ -90,7 +90,6 @@ set(libprotobuf_includes
${protobuf_source_dir}/src/google/protobuf/util/delimited_message_util.h
${protobuf_source_dir}/src/google/protobuf/util/field_comparator.h
${protobuf_source_dir}/src/google/protobuf/util/field_mask_util.h
${protobuf_source_dir}/src/google/protobuf/util/internal/json_escaping.h
${protobuf_source_dir}/src/google/protobuf/util/json_util.h
${protobuf_source_dir}/src/google/protobuf/util/message_differencer.h
${protobuf_source_dir}/src/google/protobuf/util/time_util.h
@ -108,6 +107,11 @@ endif()
add_library(libprotobuf ${protobuf_SHARED_OR_STATIC}
${libprotobuf_lite_files} ${libprotobuf_files} ${libprotobuf_includes} ${libprotobuf_rc_files})
if(protobuf_HAVE_LD_VERSION_SCRIPT)
target_link_options(libprotobuf PRIVATE -Wl,--version-script=${protobuf_source_dir}/src/libprotobuf.map)
set_target_properties(libprotobuf PROPERTIES
LINK_DEPENDS ${protobuf_source_dir}/src/libprotobuf.map)
endif()
target_link_libraries(libprotobuf ${CMAKE_THREAD_LIBS_INIT})
if(protobuf_WITH_ZLIB)
target_link_libraries(libprotobuf ${ZLIB_LIBRARIES})
@ -126,7 +130,6 @@ if(protobuf_BUILD_SHARED_LIBS)
endif()
set_target_properties(libprotobuf PROPERTIES
VERSION ${protobuf_VERSION}
# Use only the first SO version component for compatibility with Makefile emitted SONAME.
SOVERSION 30
OUTPUT_NAME ${LIB_PREFIX}protobuf
DEBUG_POSTFIX "${protobuf_DEBUG_POSTFIX}")

@ -131,6 +131,11 @@ endif()
add_library(libprotoc ${protobuf_SHARED_OR_STATIC}
${libprotoc_files} ${libprotoc_headers} ${libprotoc_rc_files})
if(protobuf_HAVE_LD_VERSION_SCRIPT)
target_link_options(libprotoc PRIVATE -Wl,--version-script=${protobuf_source_dir}/src/libprotoc.map)
set_target_properties(libprotoc PROPERTIES
LINK_DEPENDS ${protobuf_source_dir}/src/libprotoc.map)
endif()
target_link_libraries(libprotoc libprotobuf)
if(MSVC AND protobuf_BUILD_SHARED_LIBS)
target_compile_definitions(libprotoc
@ -140,6 +145,7 @@ endif()
set_target_properties(libprotoc PROPERTIES
COMPILE_DEFINITIONS LIBPROTOC_EXPORTS
VERSION ${protobuf_VERSION}
SOVERSION 30
OUTPUT_NAME ${LIB_PREFIX}protoc
DEBUG_POSTFIX "${protobuf_DEBUG_POSTFIX}")
add_library(protobuf::libprotoc ALIAS libprotoc)

@ -80,7 +80,7 @@ AC_LANG([C++])
ACX_USE_SYSTEM_EXTENSIONS
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
AM_CONDITIONAL(GCC, test "$GCC" = yes) # let the Makefile know if we're gcc
AC_PROG_OBJC
AS_CASE([$target_os], [darwin*], [AC_PROG_OBJC], [AM_CONDITIONAL([am__fastdepOBJC], [false])])
# test_util.cc takes forever to compile with GCC and optimization turned on.
AC_MSG_CHECKING([C++ compiler flags...])

@ -281,7 +281,7 @@ junit_tests(
"@maven//:com_google_guava_guava",
"@maven//:com_google_truth_truth",
"@maven//:junit_junit",
"@maven//:org_easymock_easymock",
"@maven//:org_mockito_mockito_core",
],
)
@ -408,6 +408,6 @@ junit_tests(
":test_util_lite",
"@maven//:com_google_truth_truth",
"@maven//:junit_junit",
"@maven//:org_easymock_easymock",
"@maven//:org_mockito_mockito_core",
],
)

@ -23,8 +23,8 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>

@ -1554,10 +1554,6 @@ public final class TextFormat {
public static class Parser {
private int debugStringSilentMarker;
int getSilentMarkerCount() {
return debugStringSilentMarker;
}
/**
* A valid silent marker appears between a field name and its value. If there is a ":" in
* between, the silent marker will only appear after the colon. This is called after a field

@ -31,8 +31,8 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>

@ -30,8 +30,8 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>

@ -23,8 +23,8 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>

@ -79,9 +79,9 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<version>3.2</version>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>4.3.1</version>
<scope>test</scope>
</dependency>
<dependency>

@ -52,8 +52,8 @@
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>

@ -1319,11 +1319,11 @@ public class JsonFormat {
if (e.getCause() instanceof IOException) {
throw (IOException) e.getCause();
} else {
throw new InvalidProtocolBufferException(e.getMessage());
throw new InvalidProtocolBufferException(e.getMessage(), e);
}
} catch (RuntimeException e) {
// We convert all exceptions from JSON parsing to our own exceptions.
throw new InvalidProtocolBufferException(e.getMessage());
throw new InvalidProtocolBufferException(e.getMessage(), e);
}
}

@ -34,6 +34,7 @@ import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import com.google.common.collect.ImmutableSet;
import com.google.gson.JsonSyntaxException;
import com.google.protobuf.Any;
import com.google.protobuf.BoolValue;
import com.google.protobuf.ByteString;
@ -1861,7 +1862,7 @@ public class JsonFormatTest {
// Test that we are not leaking out JSON exceptions.
@Test
public void testJsonException() throws Exception {
public void testJsonException_forwardsIOException() throws Exception {
InputStream throwingInputStream =
new InputStream() {
@Override
@ -1879,7 +1880,10 @@ public class JsonFormatTest {
} catch (IOException e) {
assertThat(e).hasMessageThat().isEqualTo("12345");
}
}
@Test
public void testJsonException_forwardsJsonException() throws Exception {
Reader invalidJsonReader = new StringReader("{ xxx - yyy }");
// When the JSON parser throws parser exceptions, JsonFormat should turn
// that into InvalidProtocolBufferException.
@ -1888,7 +1892,7 @@ public class JsonFormatTest {
JsonFormat.parser().merge(invalidJsonReader, builder);
assertWithMessage("Exception is expected.").fail();
} catch (InvalidProtocolBufferException e) {
// Expected.
assertThat(e.getCause()).isInstanceOf(JsonSyntaxException.class);
}
}

@ -1,25 +1,13 @@
{
"dependency_tree": {
"__AUTOGENERATED_FILE_DO_NOT_MODIFY_THIS_FILE_MANUALLY": "THERE_IS_NO_DATA_ONLY_ZUUL",
"__INPUT_ARTIFACTS_HASH": 1634601905,
"__RESOLVED_ARTIFACTS_HASH": -143733866,
"__INPUT_ARTIFACTS_HASH": -1867950668,
"__RESOLVED_ARTIFACTS_HASH": 1254982283,
"conflict_resolution": {
"com.google.errorprone:error_prone_annotations:2.3.2": "com.google.errorprone:error_prone_annotations:2.5.1",
"junit:junit:4.12": "junit:junit:4.13.2"
},
"dependencies": [
{
"coord": "cglib:cglib-nodep:2.2.2",
"dependencies": [],
"directDependencies": [],
"file": "v1/https/repo1.maven.org/maven2/cglib/cglib-nodep/2.2.2/cglib-nodep-2.2.2.jar",
"mirror_urls": [
"https://repo1.maven.org/maven2/cglib/cglib-nodep/2.2.2/cglib-nodep-2.2.2.jar",
"https://repo.maven.apache.org/maven2/cglib/cglib-nodep/2.2.2/cglib-nodep-2.2.2.jar"
],
"sha256": "e78c7792e59554ed8a23d18a12e3a0d2f7a244217ecf89621477f63aec074f15",
"url": "https://repo1.maven.org/maven2/cglib/cglib-nodep/2.2.2/cglib-nodep-2.2.2.jar"
},
{
"coord": "com.google.auto.value:auto-value-annotations:1.7.4",
"dependencies": [],
@ -83,21 +71,21 @@
{
"coord": "com.google.guava:guava-testlib:30.1.1-jre",
"dependencies": [
"com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava",
"com.google.j2objc:j2objc-annotations:1.3",
"com.google.code.findbugs:jsr305:3.0.2",
"org.hamcrest:hamcrest-core:1.3",
"com.google.guava:guava:30.1.1-jre",
"com.google.guava:failureaccess:1.0.1",
"com.google.errorprone:error_prone_annotations:2.5.1",
"com.google.guava:failureaccess:1.0.1",
"com.google.guava:guava:30.1.1-jre",
"com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava",
"com.google.j2objc:j2objc-annotations:1.3",
"junit:junit:4.13.2",
"org.checkerframework:checker-qual:3.9.1"
"org.checkerframework:checker-qual:3.9.1",
"org.hamcrest:hamcrest-core:1.3"
],
"directDependencies": [
"com.google.j2objc:j2objc-annotations:1.3",
"com.google.code.findbugs:jsr305:3.0.2",
"com.google.guava:guava:30.1.1-jre",
"com.google.errorprone:error_prone_annotations:2.5.1",
"com.google.guava:guava:30.1.1-jre",
"com.google.j2objc:j2objc-annotations:1.3",
"junit:junit:4.13.2",
"org.checkerframework:checker-qual:3.9.1"
],
@ -112,19 +100,19 @@
{
"coord": "com.google.guava:guava:30.1.1-jre",
"dependencies": [
"com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava",
"com.google.j2objc:j2objc-annotations:1.3",
"com.google.code.findbugs:jsr305:3.0.2",
"com.google.guava:failureaccess:1.0.1",
"com.google.errorprone:error_prone_annotations:2.5.1",
"com.google.guava:failureaccess:1.0.1",
"com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava",
"com.google.j2objc:j2objc-annotations:1.3",
"org.checkerframework:checker-qual:3.9.1"
],
"directDependencies": [
"com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava",
"com.google.j2objc:j2objc-annotations:1.3",
"com.google.code.findbugs:jsr305:3.0.2",
"com.google.guava:failureaccess:1.0.1",
"com.google.errorprone:error_prone_annotations:2.5.1",
"com.google.guava:failureaccess:1.0.1",
"com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava",
"com.google.j2objc:j2objc-annotations:1.3",
"org.checkerframework:checker-qual:3.9.1"
],
"file": "v1/https/repo1.maven.org/maven2/com/google/guava/guava/30.1.1-jre/guava-30.1.1-jre.jar",
@ -162,20 +150,20 @@
{
"coord": "com.google.truth:truth:1.1.2",
"dependencies": [
"org.ow2.asm:asm:9.0",
"com.google.auto.value:auto-value-annotations:1.7.4",
"com.google.guava:guava:30.1.1-jre",
"com.google.errorprone:error_prone_annotations:2.5.1",
"com.google.guava:guava:30.1.1-jre",
"junit:junit:4.13.2",
"org.checkerframework:checker-qual:3.9.1"
"org.checkerframework:checker-qual:3.9.1",
"org.ow2.asm:asm:9.0"
],
"directDependencies": [
"org.ow2.asm:asm:9.0",
"com.google.auto.value:auto-value-annotations:1.7.4",
"com.google.guava:guava:30.1.1-jre",
"com.google.errorprone:error_prone_annotations:2.5.1",
"com.google.guava:guava:30.1.1-jre",
"junit:junit:4.13.2",
"org.checkerframework:checker-qual:3.9.1"
"org.checkerframework:checker-qual:3.9.1",
"org.ow2.asm:asm:9.0"
],
"file": "v1/https/repo1.maven.org/maven2/com/google/truth/truth/1.1.2/truth-1.1.2.jar",
"mirror_urls": [
@ -201,6 +189,30 @@
"sha256": "8e495b634469d64fb8acfa3495a065cbacc8a0fff55ce1e31007be4c16dc57d3",
"url": "https://repo1.maven.org/maven2/junit/junit/4.13.2/junit-4.13.2.jar"
},
{
"coord": "net.bytebuddy:byte-buddy-agent:1.12.7",
"dependencies": [],
"directDependencies": [],
"file": "v1/https/repo1.maven.org/maven2/net/bytebuddy/byte-buddy-agent/1.12.7/byte-buddy-agent-1.12.7.jar",
"mirror_urls": [
"https://repo1.maven.org/maven2/net/bytebuddy/byte-buddy-agent/1.12.7/byte-buddy-agent-1.12.7.jar",
"https://repo.maven.apache.org/maven2/net/bytebuddy/byte-buddy-agent/1.12.7/byte-buddy-agent-1.12.7.jar"
],
"sha256": "73d84bb6e8e8980e674d796a29063f510ceb527c6f8c912a08a13e236be05c71",
"url": "https://repo1.maven.org/maven2/net/bytebuddy/byte-buddy-agent/1.12.7/byte-buddy-agent-1.12.7.jar"
},
{
"coord": "net.bytebuddy:byte-buddy:1.12.7",
"dependencies": [],
"directDependencies": [],
"file": "v1/https/repo1.maven.org/maven2/net/bytebuddy/byte-buddy/1.12.7/byte-buddy-1.12.7.jar",
"mirror_urls": [
"https://repo1.maven.org/maven2/net/bytebuddy/byte-buddy/1.12.7/byte-buddy-1.12.7.jar",
"https://repo.maven.apache.org/maven2/net/bytebuddy/byte-buddy/1.12.7/byte-buddy-1.12.7.jar"
],
"sha256": "d2e46555699e70361b5471a7e142f9c67855bba6907a285177ebd8ad973775d8",
"url": "https://repo1.maven.org/maven2/net/bytebuddy/byte-buddy/1.12.7/byte-buddy-1.12.7.jar"
},
{
"coord": "org.checkerframework:checker-qual:3.9.1",
"dependencies": [],
@ -213,24 +225,6 @@
"sha256": "ab0468b1ba35bb2ae45f61a60dc4960bd887660ab8f05113a662a7e675eae776",
"url": "https://repo1.maven.org/maven2/org/checkerframework/checker-qual/3.9.1/checker-qual-3.9.1.jar"
},
{
"coord": "org.easymock:easymock:3.2",
"dependencies": [
"cglib:cglib-nodep:2.2.2",
"org.objenesis:objenesis:1.3"
],
"directDependencies": [
"cglib:cglib-nodep:2.2.2",
"org.objenesis:objenesis:1.3"
],
"file": "v1/https/repo1.maven.org/maven2/org/easymock/easymock/3.2/easymock-3.2.jar",
"mirror_urls": [
"https://repo1.maven.org/maven2/org/easymock/easymock/3.2/easymock-3.2.jar",
"https://repo.maven.apache.org/maven2/org/easymock/easymock/3.2/easymock-3.2.jar"
],
"sha256": "b3dd1cf5019f942d8cc2afad0aa6aef4b21532446fe90a6b68d567e3389763dd",
"url": "https://repo1.maven.org/maven2/org/easymock/easymock/3.2/easymock-3.2.jar"
},
{
"coord": "org.hamcrest:hamcrest-core:1.3",
"dependencies": [],
@ -244,16 +238,36 @@
"url": "https://repo1.maven.org/maven2/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar"
},
{
"coord": "org.objenesis:objenesis:1.3",
"coord": "org.mockito:mockito-core:4.3.1",
"dependencies": [
"net.bytebuddy:byte-buddy-agent:1.12.7",
"net.bytebuddy:byte-buddy:1.12.7",
"org.objenesis:objenesis:3.2"
],
"directDependencies": [
"net.bytebuddy:byte-buddy-agent:1.12.7",
"net.bytebuddy:byte-buddy:1.12.7",
"org.objenesis:objenesis:3.2"
],
"file": "v1/https/repo1.maven.org/maven2/org/mockito/mockito-core/4.3.1/mockito-core-4.3.1.jar",
"mirror_urls": [
"https://repo1.maven.org/maven2/org/mockito/mockito-core/4.3.1/mockito-core-4.3.1.jar",
"https://repo.maven.apache.org/maven2/org/mockito/mockito-core/4.3.1/mockito-core-4.3.1.jar"
],
"sha256": "148de2c6928365db29443ca12d35c930d9f481172b934fdd801d1cb1409ea83a",
"url": "https://repo1.maven.org/maven2/org/mockito/mockito-core/4.3.1/mockito-core-4.3.1.jar"
},
{
"coord": "org.objenesis:objenesis:3.2",
"dependencies": [],
"directDependencies": [],
"file": "v1/https/repo1.maven.org/maven2/org/objenesis/objenesis/1.3/objenesis-1.3.jar",
"file": "v1/https/repo1.maven.org/maven2/org/objenesis/objenesis/3.2/objenesis-3.2.jar",
"mirror_urls": [
"https://repo1.maven.org/maven2/org/objenesis/objenesis/1.3/objenesis-1.3.jar",
"https://repo.maven.apache.org/maven2/org/objenesis/objenesis/1.3/objenesis-1.3.jar"
"https://repo1.maven.org/maven2/org/objenesis/objenesis/3.2/objenesis-3.2.jar",
"https://repo.maven.apache.org/maven2/org/objenesis/objenesis/3.2/objenesis-3.2.jar"
],
"sha256": "dd4ef3d3091063a4fec578cbb2bbe6c1f921c00091ba2993dcd9afd25ff9444a",
"url": "https://repo1.maven.org/maven2/org/objenesis/objenesis/1.3/objenesis-1.3.jar"
"sha256": "03d960bd5aef03c653eb000413ada15eb77cdd2b8e4448886edf5692805e35f3",
"url": "https://repo1.maven.org/maven2/org/objenesis/objenesis/3.2/objenesis-3.2.jar"
},
{
"coord": "org.ow2.asm:asm:9.0",

@ -11,7 +11,7 @@ PROTOBUF_MAVEN_ARTIFACTS = [
"com.google.guava:guava-testlib:30.1.1-jre",
"com.google.truth:truth:1.1.2",
"junit:junit:4.12",
"org.easymock:easymock:3.2",
"org.mockito:mockito-core:4.3.1",
]
def protobuf_deps():

@ -1235,21 +1235,25 @@ class DescriptorPool(object):
for enum in desc.enum_types:
yield (_PrefixWithDot(enum.full_name), enum)
def _GetDeps(self, dependencies):
def _GetDeps(self, dependencies, visited=None):
"""Recursively finds dependencies for file protos.
Args:
dependencies: The names of the files being depended on.
visited: The names of files already found.
Yields:
Each direct and indirect dependency.
"""
visited = visited or set()
for dependency in dependencies:
dep_desc = self.FindFileByName(dependency)
yield dep_desc
for parent_dep in dep_desc.dependencies:
yield parent_dep
if dependency not in visited:
visited.add(dependency)
dep_desc = self.FindFileByName(dependency)
yield dep_desc
public_files = [d.name for d in dep_desc.public_dependencies]
yield from self._GetDeps(public_files, visited)
def _GetTypeFromScope(self, package, type_name, scope):
"""Finds a given type name in the current scope.

@ -0,0 +1,49 @@
# -*- coding: utf-8 -*-
# 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.
"""Unittest for nested public imports."""
import unittest
from google.protobuf.internal.import_test_package import outer_pb2
class ImportTest(unittest.TestCase):
def testPackageInitializationImport(self):
"""Test that we can import nested import public messages."""
msg = outer_pb2.Outer()
self.assertEqual(58, msg.import_public_nested.value)
if __name__ == '__main__':
unittest.main()

@ -0,0 +1,40 @@
// 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.
// A proto file which is imported by inner.proto to test public importing.
syntax = "proto2";
package google.protobuf.python.internal.import_test_package;
option optimize_for = SPEED;
// Test nested public import
import public "google/protobuf/internal/import_test_package/import_public_nested.proto";

@ -0,0 +1,40 @@
// 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.
// A proto file which is imported by import_public.proto to test nested public
// importing.
syntax = "proto2";
package google.protobuf.python.internal.import_test_package;
message ImportPublicNestedMessage {
optional int32 value = 1 [default = 58];
}

@ -32,6 +32,9 @@ syntax = "proto2";
package google.protobuf.python.internal.import_test_package;
// Test public import
import public "google/protobuf/internal/import_test_package/import_public.proto";
message Inner {
optional int32 value = 1 [default = 57];
}

@ -36,4 +36,5 @@ import "google/protobuf/internal/import_test_package/inner.proto";
message Outer {
optional Inner inner = 1;
optional ImportPublicNestedMessage import_public_nested = 2;
}

@ -593,6 +593,7 @@ bool CheckAndGetInteger(PyObject* arg, T* value) {
if (std::numeric_limits<T>::min() == 0) {
// Unsigned case.
unsigned PY_LONG_LONG ulong_result = PyLong_AsUnsignedLongLong(arg_py_int);
Py_DECREF(arg_py_int);
if (VerifyIntegerCastAndRange<T, unsigned PY_LONG_LONG>(arg,
ulong_result)) {
*value = static_cast<T>(ulong_result);
@ -601,6 +602,7 @@ bool CheckAndGetInteger(PyObject* arg, T* value) {
}
} else {
// Signed case.
Py_DECREF(arg_py_int);
PY_LONG_LONG long_result = PyLong_AsLongLong(arg);
if (VerifyIntegerCastAndRange<T, PY_LONG_LONG>(arg, long_result)) {
*value = static_cast<T>(long_result);

@ -172,7 +172,6 @@ nobase_include_HEADERS = \
google/protobuf/util/delimited_message_util.h \
google/protobuf/util/field_comparator.h \
google/protobuf/util/field_mask_util.h \
google/protobuf/util/internal/json_escaping.h \
google/protobuf/util/json_util.h \
google/protobuf/util/message_differencer.h \
google/protobuf/util/time_util.h \
@ -285,6 +284,7 @@ libprotobuf_la_SOURCES = \
google/protobuf/util/internal/field_mask_utility.cc \
google/protobuf/util/internal/field_mask_utility.h \
google/protobuf/util/internal/json_escaping.cc \
google/protobuf/util/internal/json_escaping.h \
google/protobuf/util/internal/json_objectwriter.cc \
google/protobuf/util/internal/json_objectwriter.h \
google/protobuf/util/internal/json_stream_parser.cc \
@ -803,6 +803,12 @@ protobuf_test_SOURCES = \
google/protobuf/util/delimited_message_util_test.cc \
google/protobuf/util/field_comparator_test.cc \
google/protobuf/util/field_mask_util_test.cc \
google/protobuf/util/internal/default_value_objectwriter_test.cc \
google/protobuf/util/internal/json_objectwriter_test.cc \
google/protobuf/util/internal/json_stream_parser_test.cc \
google/protobuf/util/internal/protostream_objectsource_test.cc \
google/protobuf/util/internal/protostream_objectwriter_test.cc \
google/protobuf/util/internal/type_info_test_helper.cc \
google/protobuf/util/json_util_test.cc \
google/protobuf/util/message_differencer_unittest.cc \
google/protobuf/util/time_util_test.cc \

@ -522,6 +522,10 @@ inline std::string MakeVarintCachedSizeFieldName(const FieldDescriptor* field) {
return StrCat("_", FieldName(field), "_cached_byte_size_");
}
// Note: A lot of libraries detect Any protos based on Descriptor::full_name()
// while the two functions below use FileDescriptor::name(). In a sane world the
// two approaches should be equivalent. But if you are dealing with descriptors
// from untrusted sources, you might need to match semantics across libraries.
bool IsAnyMessage(const FileDescriptor* descriptor, const Options& options);
bool IsAnyMessage(const Descriptor* descriptor, const Options& options);

@ -200,7 +200,8 @@ class MessageGenerator {
int max_has_bit_index_;
// A map from field index to inlined_string index. For non-inlined-string
// fields, the element is -1.
// fields, the element is -1. If there is no inlined string in the message,
// this is empty.
std::vector<int> inlined_string_indices_;
// The count of inlined_string fields in the message.
int max_inlined_string_index_;

@ -295,15 +295,9 @@ TailCallTableInfo::TailCallTableInfo(
"_fl::Offset{offsetof(", ClassName(descriptor), ", _oneof_case_)}"));
}
int inlined_string_count = 0;
for (const FieldDescriptor* field : ordered_fields) {
if (IsString(field, options) && IsStringInlined(field, options)) {
++inlined_string_count;
}
}
// If this message has any inlined string fields, store the donation state
// offset in the second auxiliary entry.
if (inlined_string_count > 0) {
if (!inlined_string_indices.empty()) {
aux_entries.resize(2); // pad if necessary
aux_entries[1] =
StrCat("_fl::Offset{offsetof(", ClassName(descriptor),

@ -41,6 +41,7 @@
#include <string>
#include <utility>
#include <vector>
#include <google/protobuf/compiler/parser.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/descriptor_database.h>

@ -46,11 +46,11 @@
#include <google/protobuf/stubs/casts.h>
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/io/tokenizer.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/wire_format.h>
#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/descriptor.pb.h>
#include <google/protobuf/io/tokenizer.h>
#include <google/protobuf/wire_format.h>
#include <google/protobuf/stubs/map_util.h>
#include <google/protobuf/stubs/hash.h>

@ -42,10 +42,10 @@
#include <string>
#include <utility>
#include <google/protobuf/io/tokenizer.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/repeated_field.h>
#include <google/protobuf/descriptor.pb.h>
#include <google/protobuf/io/tokenizer.h>
#include <google/protobuf/repeated_field.h>
// Must be included last.
#include <google/protobuf/port_def.inc>

@ -162,47 +162,45 @@ constexpr size_t EffectiveAlignof() {
return std::is_same<T, char>::value ? 8 : alignof(T);
}
template <int align, typename U, typename... T>
using AppendIfAlign =
typename std::conditional<EffectiveAlignof<U>() == align, void (*)(T..., U),
void (*)(T...)>::type;
// Metafunction to sort types in descending order of alignment.
// Useful for the flat allocator to ensure proper alignment of all elements
// without having to add padding.
// Instead of implementing a proper sort metafunction we just do a
// filter+merge, which is much simpler to write as a metafunction.
// We have a fixed set of alignments we can filter on.
// For simplicity we use a function pointer as a type list.
struct TypeListSorter {
template <int align, typename U, typename... T>
static auto AppendIfAlign(void (*)(T...)) ->
typename std::conditional<EffectiveAlignof<U>() == align,
void (*)(T..., U), void (*)(T...)>::type {
return nullptr;
}
template <typename... T16, typename... T8, typename... T4, typename... T2,
typename... T1>
static auto SortImpl(void (*)(), void (*)(T16...), void (*)(T8...),
void (*)(T4...), void (*)(T2...), void (*)(T1...))
-> void (*)(T16..., T8..., T4..., T2..., T1...) {
return nullptr;
}
template <typename T, typename... Ts, typename T16, typename T8, typename T4,
typename T2, typename T1, typename Self = TypeListSorter>
static auto SortImpl(void (*)(T, Ts...), T16 p16, T8 p8, T4 p4, T2 p2, T1 p1)
-> decltype(Self::template SortImpl(
static_cast<void (*)(Ts...)>(nullptr), AppendIfAlign<16, T>(p16),
AppendIfAlign<8, T>(p8), AppendIfAlign<4, T>(p4),
AppendIfAlign<2, T>(p2), AppendIfAlign<1, T>(p1))) {
return nullptr;
}
template <typename In, typename T16, typename T8, typename T4, typename T2,
typename T1>
struct TypeListSortImpl;
template <typename... T16, typename... T8, typename... T4, typename... T2,
typename... T1>
struct TypeListSortImpl<void (*)(), void (*)(T16...), void (*)(T8...),
void (*)(T4...), void (*)(T2...), void (*)(T1...)> {
using type = void (*)(T16..., T8..., T4..., T2..., T1...);
};
// Instead of implementing a proper sort metafunction we just do a
// filter+merge, which is much simpler to write as a metafunction.
// We have a fixed set of alignments we can filter on.
template <typename... T>
static auto SortByAlignment(void (*p)() = nullptr)
-> decltype(SortImpl(static_cast<void (*)(T...)>(nullptr), p, p, p, p,
p)) {
return nullptr;
}
template <typename First, typename... Rest, typename... T16, typename... T8,
typename... T4, typename... T2, typename... T1>
struct TypeListSortImpl<void (*)(First, Rest...), void (*)(T16...),
void (*)(T8...), void (*)(T4...), void (*)(T2...),
void (*)(T1...)> {
using type = typename TypeListSortImpl<
void (*)(Rest...), AppendIfAlign<16, First, T16...>,
AppendIfAlign<8, First, T8...>, AppendIfAlign<4, First, T4...>,
AppendIfAlign<2, First, T2...>, AppendIfAlign<1, First, T1...>>::type;
};
template <typename... T>
using SortByAlignment =
typename TypeListSortImpl<void (*)(T...), void (*)(), void (*)(),
void (*)(), void (*)(), void (*)()>::type;
template <template <typename...> class C, typename... T>
auto ApplyTypeList(void (*)(T...)) -> C<T...>;
@ -1239,12 +1237,12 @@ namespace internal {
// necessarily in the same order.
class FlatAllocator
: public decltype(ApplyTypeList<FlatAllocatorImpl>(
TypeListSorter::SortByAlignment<
char, std::string, SourceCodeInfo, FileDescriptorTables,
// Option types
MessageOptions, FieldOptions, EnumOptions, EnumValueOptions,
ExtensionRangeOptions, OneofOptions, ServiceOptions,
MethodOptions, FileOptions>())) {};
SortByAlignment<char, std::string, SourceCodeInfo,
FileDescriptorTables,
// Option types
MessageOptions, FieldOptions, EnumOptions,
EnumValueOptions, ExtensionRangeOptions, OneofOptions,
ServiceOptions, MethodOptions, FileOptions>())) {};
} // namespace internal

@ -190,6 +190,7 @@ class PROTOBUF_EXPORT ExtensionSet {
public:
constexpr ExtensionSet();
explicit ExtensionSet(Arena* arena);
ExtensionSet(ArenaInitialized, Arena* arena) : ExtensionSet(arena) {}
~ExtensionSet();
// These are called at startup by protocol-compiler-generated code to

@ -34,6 +34,7 @@
#include <google/protobuf/extension_set.h>
#include <google/protobuf/generated_message_tctable_decl.h>
#include <google/protobuf/generated_message_tctable_impl.h>
#include <google/protobuf/inlined_string_field.h>
#include <google/protobuf/message_lite.h>
#include <google/protobuf/parse_context.h>
#include <google/protobuf/wire_format_lite.h>
@ -1698,8 +1699,9 @@ const char* TcParser::MpString(PROTOBUF_TC_PARAM_DECL) {
break;
}
case field_layout::kRepIString:
break; // note: skipped above
case field_layout::kRepIString: {
break;
}
}
if (ptr == nullptr || !is_valid) {

@ -502,6 +502,8 @@ class TypeDefinedMapFieldBase : public MapFieldBase {
constexpr TypeDefinedMapFieldBase(ConstantInitialized tag)
: MapFieldBase(tag) {}
explicit TypeDefinedMapFieldBase(Arena* arena) : MapFieldBase(arena) {}
TypeDefinedMapFieldBase(ArenaInitialized, Arena* arena)
: TypeDefinedMapFieldBase(arena) {}
protected:
~TypeDefinedMapFieldBase() {}
@ -574,6 +576,7 @@ class MapField : public TypeDefinedMapFieldBase<Key, T> {
: TypeDefinedMapFieldBase<Key, T>(tag), impl_() {}
explicit MapField(Arena* arena)
: TypeDefinedMapFieldBase<Key, T>(arena), impl_(arena) {}
MapField(ArenaInitialized, Arena* arena) : MapField(arena) {}
// Implement MapFieldBase
bool ContainsMapKey(const MapKey& map_key) const override;

@ -70,6 +70,7 @@ class MapFieldLite {
constexpr MapFieldLite() : map_() {}
explicit MapFieldLite(Arena* arena) : map_(arena) {}
MapFieldLite(ArenaInitialized, Arena* arena) : MapFieldLite(arena) {}
#ifdef NDEBUG
void Destruct() { map_.~Map(); }

@ -58,12 +58,21 @@ inline void SizedArrayDelete(void* p, size_t size) {
#endif
}
// Tag type used to invoke the constinit constructor overload of some classes.
// Such constructors are internal implementation details of the library.
// Tag type used to invoke the constinit constructor overload of classes
// such as ArenaStringPtr and MapFieldBase. Such constructors are internal
// implementation details of the library.
struct ConstantInitialized {
explicit ConstantInitialized() = default;
};
// Tag type used to invoke the arena constructor overload of classes such
// as ExtensionSet and MapFieldLite in aggregate initialization. These
// classes typically don't have move/copy constructors, which rules out
// explicit initialization in pre-C++17.
struct ArenaInitialized {
explicit ArenaInitialized() = default;
};
} // namespace internal
} // namespace protobuf
} // namespace google

Loading…
Cancel
Save