Permalink
Browse files

Merge pull request #3988 from acozzette/down-integrate

Integrated internal changes from Google
  • Loading branch information...
acozzette committed Dec 5, 2017
2 parents 173f304 + e372df5 commit 9021f623e1420f513268a01a5ad43a23618a84ba
Showing with 4,456 additions and 3,270 deletions.
  1. +1 −0 Makefile.am
  2. +2 −0 cmake/libprotobuf-lite.cmake
  3. +0 −1 conformance/failure_list_cpp.txt
  4. +1 −1 conformance/failure_list_java.txt
  5. +13 −8 csharp/src/Google.Protobuf/WellKnownTypes/Any.cs
  6. +2 −2 csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs
  7. +57 −0 java/core/src/main/java/com/google/protobuf/Android.java
  8. +2 −8 java/core/src/main/java/com/google/protobuf/ByteString.java
  9. +5 −0 java/core/src/main/java/com/google/protobuf/FieldSet.java
  10. +24 −18 java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java
  11. +35 −0 java/core/src/main/java/com/google/protobuf/TextFormat.java
  12. +0 −9 java/core/src/main/java/com/google/protobuf/UnsafeUtil.java
  13. +5 −7 java/core/src/test/java/com/google/protobuf/AbstractMessageTest.java
  14. +6 −0 java/core/src/test/java/com/google/protobuf/TestUtil.java
  15. +78 −10 java/core/src/test/java/com/google/protobuf/TextFormatTest.java
  16. +46 −11 java/util/src/main/java/com/google/protobuf/util/JsonFormat.java
  17. +9 −2 java/util/src/main/java/com/google/protobuf/util/Timestamps.java
  18. +15 −0 java/util/src/test/java/com/google/protobuf/util/JsonFormatTest.java
  19. +1 −1 js/binary/arith.js
  20. +5 −5 js/binary/decoder.js
  21. +2 −2 js/binary/encoder.js
  22. +25 −25 js/binary/reader.js
  23. +4 −4 js/binary/utils.js
  24. +1 −1 js/binary/utils_test.js
  25. +53 −53 js/binary/writer.js
  26. +1 −0 js/commonjs/export_testdeps.js
  27. +8 −1 js/debug.js
  28. +11 −0 js/debug_test.js
  29. +53 −11 js/message.js
  30. +11 −0 js/message_test.js
  31. +13 −8 objectivec/google/protobuf/Any.pbobjc.h
  32. +2 −2 objectivec/google/protobuf/Timestamp.pbobjc.h
  33. +2 −2 python/google/protobuf/descriptor.py
  34. +18 −8 python/google/protobuf/descriptor_database.py
  35. +32 −0 python/google/protobuf/descriptor_pool.py
  36. +21 −0 python/google/protobuf/internal/descriptor_database_test.py
  37. +56 −0 python/google/protobuf/internal/descriptor_pool_test.py
  38. +2 −1 python/google/protobuf/internal/encoder.py
  39. +5 −2 python/google/protobuf/internal/text_format_test.py
  40. +266 −264 python/google/protobuf/pyext/descriptor_containers.cc
  41. +43 −47 python/google/protobuf/pyext/message.cc
  42. +6 −6 python/google/protobuf/pyext/message.h
  43. +1 −1 python/google/protobuf/text_format.py
  44. +2 −0 src/Makefile.am
  45. +7 −7 src/google/protobuf/any.pb.cc
  46. +11 −2 src/google/protobuf/any.pb.h
  47. +13 −8 src/google/protobuf/any.proto
  48. +40 −36 src/google/protobuf/api.pb.cc
  49. +67 −47 src/google/protobuf/api.pb.h
  50. +203 −168 src/google/protobuf/arena.cc
  51. +65 −18 src/google/protobuf/arena.h
  52. +117 −41 src/google/protobuf/arena_impl.h
  53. +22 −10 src/google/protobuf/arena_unittest.cc
  54. +21 −0 src/google/protobuf/arenastring.h
  55. +4 −22 src/google/protobuf/compiler/annotation_test_util.cc
  56. +6 −11 src/google/protobuf/compiler/annotation_test_util.h
  57. +3 −3 src/google/protobuf/compiler/cpp/cpp_enum_field.cc
  58. +2 −15 src/google/protobuf/compiler/cpp/cpp_field.cc
  59. +4 −0 src/google/protobuf/compiler/cpp/cpp_field.h
  60. +81 −14 src/google/protobuf/compiler/cpp/cpp_file.cc
  61. +31 −8 src/google/protobuf/compiler/cpp/cpp_generator.cc
  62. +1 −1 src/google/protobuf/compiler/cpp/cpp_helpers.cc
  63. +4 −0 src/google/protobuf/compiler/cpp/cpp_helpers.h
  64. +419 −350 src/google/protobuf/compiler/cpp/cpp_message.cc
  65. +3 −0 src/google/protobuf/compiler/cpp/cpp_message.h
  66. +196 −405 src/google/protobuf/compiler/cpp/cpp_message_field.cc
  67. +1 −8 src/google/protobuf/compiler/cpp/cpp_message_field.h
  68. +2 −0 src/google/protobuf/compiler/cpp/cpp_options.h
  69. +4 −4 src/google/protobuf/compiler/cpp/cpp_primitive_field.cc
  70. +59 −47 src/google/protobuf/compiler/cpp/cpp_string_field.cc
  71. +2 −0 src/google/protobuf/compiler/cpp/cpp_string_field.h
  72. +23 −22 src/google/protobuf/compiler/cpp/cpp_unittest.cc
  73. +1 −3 src/google/protobuf/compiler/cpp/metadata_test.cc
  74. +15 −13 src/google/protobuf/compiler/java/java_message.cc
  75. +31 −31 src/google/protobuf/compiler/java/java_message_lite.cc
  76. +24 −11 src/google/protobuf/compiler/js/js_generator.cc
  77. +1 −1 src/google/protobuf/compiler/mock_code_generator.cc
  78. +38 −44 src/google/protobuf/compiler/plugin.pb.cc
  79. +54 −29 src/google/protobuf/compiler/plugin.pb.h
  80. +65 −47 src/google/protobuf/descriptor.cc
  81. +281 −236 src/google/protobuf/descriptor.pb.cc
  82. +483 −364 src/google/protobuf/descriptor.pb.h
  83. +3 −0 src/google/protobuf/descriptor_unittest.cc
  84. +7 −3 src/google/protobuf/duration.pb.cc
  85. +11 −2 src/google/protobuf/duration.pb.h
  86. +44 −34 src/google/protobuf/dynamic_message.cc
  87. +51 −17 src/google/protobuf/dynamic_message_unittest.cc
  88. +7 −3 src/google/protobuf/empty.pb.cc
  89. +11 −2 src/google/protobuf/empty.pb.h
  90. +12 −4 src/google/protobuf/extension_set.cc
  91. +2 −0 src/google/protobuf/extension_set.h
  92. +7 −3 src/google/protobuf/extension_set_heavy.cc
  93. +7 −2 src/google/protobuf/extension_set_unittest.cc
  94. +8 −8 src/google/protobuf/field_mask.pb.cc
  95. +11 −2 src/google/protobuf/field_mask.pb.h
  96. +0 −1 src/google/protobuf/generated_enum_reflection.h
  97. +1 −1 src/google/protobuf/generated_enum_util.h
  98. +0 −12 src/google/protobuf/generated_message_reflection.cc
  99. +2 −6 src/google/protobuf/generated_message_reflection.h
  100. +30 −24 src/google/protobuf/generated_message_table_driven_lite.h
  101. +16 −0 src/google/protobuf/generated_message_util.h
  102. +50 −1 src/google/protobuf/implicit_weak_message.h
  103. +4 −7 src/google/protobuf/io/coded_stream.cc
  104. +23 −38 src/google/protobuf/io/coded_stream.h
  105. +10 −1 src/google/protobuf/map.h
  106. +7 −2 src/google/protobuf/map_entry_lite.h
  107. +5 −2 src/google/protobuf/map_field.cc
  108. +10 −0 src/google/protobuf/map_test.cc
  109. +9 −3 src/google/protobuf/message.h
  110. +19 −0 src/google/protobuf/message_lite.h
  111. +21 −8 src/google/protobuf/reflection_ops.cc
  112. +16 −0 src/google/protobuf/repeated_field.cc
  113. +129 −128 src/google/protobuf/repeated_field.h
  114. +7 −7 src/google/protobuf/source_context.pb.cc
  115. +11 −2 src/google/protobuf/source_context.pb.h
  116. +22 −12 src/google/protobuf/struct.pb.cc
  117. +40 −28 src/google/protobuf/struct.pb.h
  118. +7 −3 src/google/protobuf/timestamp.pb.cc
  119. +11 −2 src/google/protobuf/timestamp.pb.h
  120. +2 −2 src/google/protobuf/timestamp.proto
  121. +65 −55 src/google/protobuf/type.pb.cc
  122. +105 −82 src/google/protobuf/type.pb.h
  123. +3 −0 src/google/protobuf/unittest_lite_imports_nonlite.proto
  124. +10 −0 src/google/protobuf/util/field_comparator.cc
  125. +11 −0 src/google/protobuf/util/field_comparator.h
  126. +9 −0 src/google/protobuf/util/field_mask_util.h
  127. +3 −3 src/google/protobuf/util/field_mask_util_test.cc
  128. +4 −4 src/google/protobuf/util/internal/json_escaping.h
  129. +3 −10 src/google/protobuf/util/internal/json_objectwriter.cc
  130. +20 −22 src/google/protobuf/util/internal/json_objectwriter.h
  131. +6 −0 src/google/protobuf/util/internal/json_objectwriter_test.cc
  132. +0 −7 src/google/protobuf/util/internal/object_writer.h
  133. +0 −2 src/google/protobuf/util/internal/protostream_objectsource.cc
  134. +0 −5 src/google/protobuf/util/internal/utility.cc
  135. +7 −3 src/google/protobuf/util/message_differencer.cc
  136. +13 −1 src/google/protobuf/util/message_differencer.h
  137. +109 −80 src/google/protobuf/wire_format_lite.cc
  138. +7 −7 src/google/protobuf/wire_format_lite.h
  139. +0 −27 src/google/protobuf/wire_format_lite_inl.h
  140. +1 −0 src/google/protobuf/wire_format_unittest.cc
  141. +31 −27 src/google/protobuf/wrappers.pb.cc
  142. +67 −18 src/google/protobuf/wrappers.pb.h
View
@@ -204,6 +204,7 @@ java_EXTRA_DIST=
java/core/src/main/java/com/google/protobuf/AbstractMessageLite.java \
java/core/src/main/java/com/google/protobuf/AbstractParser.java \
java/core/src/main/java/com/google/protobuf/AbstractProtobufList.java \
java/core/src/main/java/com/google/protobuf/Android.java \
java/core/src/main/java/com/google/protobuf/BlockingRpcChannel.java \
java/core/src/main/java/com/google/protobuf/BlockingService.java \
java/core/src/main/java/com/google/protobuf/BooleanArrayList.java \
@@ -4,6 +4,7 @@ set(libprotobuf_lite_files
${protobuf_source_dir}/src/google/protobuf/extension_set.cc
${protobuf_source_dir}/src/google/protobuf/generated_message_table_driven_lite.cc
${protobuf_source_dir}/src/google/protobuf/generated_message_util.cc
${protobuf_source_dir}/src/google/protobuf/implicit_weak_message.cc
${protobuf_source_dir}/src/google/protobuf/io/coded_stream.cc
${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream.cc
${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream_impl_lite.cc
@@ -31,6 +32,7 @@ set(libprotobuf_lite_includes
${protobuf_source_dir}/src/google/protobuf/arenastring.h
${protobuf_source_dir}/src/google/protobuf/extension_set.h
${protobuf_source_dir}/src/google/protobuf/generated_message_util.h
${protobuf_source_dir}/src/google/protobuf/implicit_weak_message.h
${protobuf_source_dir}/src/google/protobuf/io/coded_stream.h
${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream.h
${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream_impl_lite.h
@@ -54,4 +54,3 @@ Required.Proto2.ProtobufInput.PrematureEofInPackedField.SINT32
Required.Proto2.ProtobufInput.PrematureEofInPackedField.SINT64
Required.Proto2.ProtobufInput.PrematureEofInPackedField.UINT32
Required.Proto2.ProtobufInput.PrematureEofInPackedField.UINT64
@@ -44,4 +44,4 @@ Required.Proto3.JsonInput.StringFieldNotAString
Required.Proto3.ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE
Required.Proto3.ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE
Required.Proto2.ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE
Required.Proto2.ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE
Required.Proto2.ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE
@@ -154,17 +154,18 @@ public sealed partial class Any : pb::IMessage<Any> {
public const int TypeUrlFieldNumber = 1;
private string typeUrl_ = "";
/// <summary>
/// A URL/resource name whose content describes the type of the
/// serialized protocol buffer message.
/// A URL/resource name that uniquely identifies the type of the serialized
/// protocol buffer message. The last segment of the URL's path must represent
/// the fully qualified name of the type (as in
/// `path/google.protobuf.Duration`). The name should be in a canonical form
/// (e.g., leading "." is not accepted).
///
/// For URLs which use the scheme `http`, `https`, or no scheme, the
/// following restrictions and interpretations apply:
/// In practice, teams usually precompile into the binary all types that they
/// expect it to use in the context of Any. However, for URLs which use the
/// scheme `http`, `https`, or no scheme, one can optionally set up a type
/// server that maps type URLs to message definitions as follows:
///
/// * If no scheme is provided, `https` is assumed.
/// * The last segment of the URL's path must represent the fully
/// qualified name of the type (as in `path/google.protobuf.Duration`).
/// The name should be in a canonical form (e.g., leading "." is
/// not accepted).
/// * An HTTP GET on the URL must yield a [google.protobuf.Type][]
/// value in binary format, or produce an error.
/// * Applications are allowed to cache lookup results based on the
@@ -173,6 +174,10 @@ public sealed partial class Any : pb::IMessage<Any> {
/// on changes to types. (Use versioned type names to manage
/// breaking changes.)
///
/// Note: this functionality is not currently available in the official
/// protobuf release, and it is not used for type URLs beginning with
/// type.googleapis.com.
///
/// Schemes other than `http`, `https` (or the empty scheme) might be
/// used with implementation specific semantics.
/// </summary>
@@ -112,8 +112,8 @@ public static partial class TimestampReflection {
/// to this format using [`strftime`](https://docs.python.org/2/library/time.html#time.strftime)
/// with the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one
/// can use the Joda Time's [`ISODateTimeFormat.dateTime()`](
/// http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime--)
/// to obtain a formatter capable of generating timestamps in this format.
/// http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime--
/// ) to obtain a formatter capable of generating timestamps in this format.
/// </summary>
public sealed partial class Timestamp : pb::IMessage<Timestamp> {
private static readonly pb::MessageParser<Timestamp> _parser = new pb::MessageParser<Timestamp>(() => new Timestamp());
@@ -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.
package com.google.protobuf;
final class Android {
private static final Class<?> MEMORY_CLASS = getClassForName("libcore.io.Memory");
private static final boolean IS_ROBOLECTRIC =
getClassForName("org.robolectric.Robolectric") != null;
/** Returns {@code true} if running on an Android device. */
static boolean isOnAndroidDevice() {
return MEMORY_CLASS != null && !IS_ROBOLECTRIC;
}
/** Returns the memory class or {@code null} if not on Android device. */
static Class<?> getMemoryClass() {
return MEMORY_CLASS;
}
@SuppressWarnings("unchecked")
private static <T> Class<T> getClassForName(String name) {
try {
return (Class<T>) Class.forName(name);
} catch (Throwable e) {
return null;
}
}
}
@@ -124,14 +124,8 @@
private static final ByteArrayCopier byteArrayCopier;
static {
boolean isAndroid = true;
try {
Class.forName("android.content.Context");
} catch (ClassNotFoundException e) {
isAndroid = false;
}
byteArrayCopier = isAndroid ? new SystemByteArrayCopier() : new ArraysByteArrayCopier();
byteArrayCopier =
Android.isOnAndroidDevice() ? new SystemByteArrayCopier() : new ArraysByteArrayCopier();
}
/**
@@ -102,6 +102,11 @@ private FieldSet(final boolean dummy) {
@SuppressWarnings("rawtypes")
private static final FieldSet DEFAULT_INSTANCE = new FieldSet(true);
/** Returns {@code true} if empty, {@code false} otherwise. */
boolean isEmpty() {
return fields.isEmpty();
}
/** Make this FieldSet immutable from this point forward. */
@SuppressWarnings("unchecked")
public void makeImmutable() {
@@ -504,11 +504,8 @@ public BuilderType mergeFrom(
extends GeneratedMessageLite<MessageType, BuilderType>
implements ExtendableMessageOrBuilder<MessageType, BuilderType> {
/**
* Represents the set of extensions on this message. For use by generated
* code only.
*/
protected FieldSet<ExtensionDescriptor> extensions = FieldSet.newFieldSet();
/** Represents the set of extensions on this message. For use by generated code only. */
protected FieldSet<ExtensionDescriptor> extensions = FieldSet.emptySet();
@SuppressWarnings("unchecked")
protected final void mergeExtensionFields(final MessageType other) {
@@ -578,7 +575,11 @@ private boolean parseExtension(
if (unknown) { // Unknown field or wrong wire type. Skip.
return parseUnknownField(tag, input);
}
if (extensions.isImmutable()) {
extensions = extensions.clone();
}
if (packed) {
int length = input.readRawVarint32();
int limit = input.pushLimit(length);
@@ -942,12 +943,6 @@ protected int extensionsSerializedSizeAsMessageSet() {
implements ExtendableMessageOrBuilder<MessageType, BuilderType> {
protected ExtendableBuilder(MessageType defaultInstance) {
super(defaultInstance);
// TODO(dweis): This is kind of an unnecessary clone since we construct a
// new instance in the parent constructor which makes the extensions
// immutable. This extra allocation shouldn't matter in practice
// though.
instance.extensions = instance.extensions.clone();
}
// For immutable message conversion.
@@ -966,6 +961,15 @@ protected void copyOnWrite() {
instance.extensions = instance.extensions.clone();
}
private FieldSet<ExtensionDescriptor> ensureExtensionsAreMutable() {
FieldSet<ExtensionDescriptor> extensions = instance.extensions;
if (extensions.isImmutable()) {
extensions = extensions.clone();
instance.extensions = extensions;
}
return extensions;
}
@Override
public final MessageType buildPartial() {
if (isBuilt) {
@@ -1024,7 +1028,8 @@ private void verifyExtensionContainingType(
verifyExtensionContainingType(extensionLite);
copyOnWrite();
instance.extensions.setField(extensionLite.descriptor, extensionLite.toFieldSetType(value));
ensureExtensionsAreMutable()
.setField(extensionLite.descriptor, extensionLite.toFieldSetType(value));
return (BuilderType) this;
}
@@ -1037,8 +1042,9 @@ private void verifyExtensionContainingType(
verifyExtensionContainingType(extensionLite);
copyOnWrite();
instance.extensions.setRepeatedField(
extensionLite.descriptor, index, extensionLite.singularToFieldSetType(value));
ensureExtensionsAreMutable()
.setRepeatedField(
extensionLite.descriptor, index, extensionLite.singularToFieldSetType(value));
return (BuilderType) this;
}
@@ -1051,8 +1057,8 @@ private void verifyExtensionContainingType(
verifyExtensionContainingType(extensionLite);
copyOnWrite();
instance.extensions.addRepeatedField(
extensionLite.descriptor, extensionLite.singularToFieldSetType(value));
ensureExtensionsAreMutable()
.addRepeatedField(extensionLite.descriptor, extensionLite.singularToFieldSetType(value));
return (BuilderType) this;
}
@@ -1063,7 +1069,7 @@ private void verifyExtensionContainingType(
verifyExtensionContainingType(extensionLite);
copyOnWrite();
instance.extensions.clearField(extensionLite.descriptor);
ensureExtensionsAreMutable().clearField(extensionLite.descriptor);
return (BuilderType) this;
}
}
@@ -1223,6 +1223,22 @@ public static void merge(final CharSequence input,
PARSER.merge(input, builder);
}
/**
* Parse a text-format message from {@code input}.
*
* @return the parsed message, guaranteed initialized
*/
public static <T extends Message> T parse(final CharSequence input,
final Class<T> protoClass)
throws ParseException {
Message.Builder builder =
Internal.getDefaultInstance(protoClass).newBuilderForType();
merge(input, builder);
@SuppressWarnings("unchecked")
T output = (T) builder.build();
return output;
}
/**
* Parse a text-format message from {@code input} and merge the contents
* into {@code builder}. Extensions will be recognized if they are
@@ -1248,6 +1264,25 @@ public static void merge(final CharSequence input,
PARSER.merge(input, extensionRegistry, builder);
}
/**
* Parse a text-format message from {@code input}. Extensions will be
* recognized if they are registered in {@code extensionRegistry}.
*
* @return the parsed message, guaranteed initialized
*/
public static <T extends Message> T parse(
final CharSequence input,
final ExtensionRegistry extensionRegistry,
final Class<T> protoClass)
throws ParseException {
Message.Builder builder =
Internal.getDefaultInstance(protoClass).newBuilderForType();
merge(input, extensionRegistry, builder);
@SuppressWarnings("unchecked")
T output = (T) builder.build();
return output;
}
/**
* Parser for text-format proto2 instances. This class is thread-safe.
@@ -385,15 +385,6 @@ private static boolean supportsUnsafeByteBufferOperations() {
}
@SuppressWarnings("unchecked")
private static <T> Class<T> getClassForName(String name) {
try {
return (Class<T>) Class.forName(name);
} catch (Throwable e) {
return null;
}
}
/** Finds the address field within a direct {@link Buffer}. */
private static Field bufferAddressField() {
return field(Buffer.class, "address", long.class);
@@ -30,6 +30,9 @@
package com.google.protobuf;
import static com.google.protobuf.TestUtil.TEST_REQUIRED_INITIALIZED;
import static com.google.protobuf.TestUtil.TEST_REQUIRED_UNINITIALIZED;
import com.google.protobuf.Descriptors.FieldDescriptor;
import protobuf_unittest.UnittestOptimizeFor.TestOptimizedForSize;
import protobuf_unittest.UnittestProto;
@@ -346,11 +349,6 @@ public void testOptimizedForSize() throws Exception {
// -----------------------------------------------------------------
// Tests for isInitialized().
private static final TestRequired TEST_REQUIRED_UNINITIALIZED =
TestRequired.getDefaultInstance();
private static final TestRequired TEST_REQUIRED_INITIALIZED =
TestRequired.newBuilder().setA(1).setB(2).setC(3).build();
public void testIsInitialized() throws Exception {
TestRequired.Builder builder = TestRequired.newBuilder();
AbstractMessageWrapper.Builder abstractBuilder =
@@ -380,7 +378,7 @@ public void testForeignIsInitialized() throws Exception {
builder.setOptionalMessage(TEST_REQUIRED_UNINITIALIZED);
assertFalse(abstractBuilder.isInitialized());
assertEquals(
"optional_message.a, optional_message.b, optional_message.c",
"optional_message.b, optional_message.c",
abstractBuilder.getInitializationErrorString());
builder.setOptionalMessage(TEST_REQUIRED_INITIALIZED);
@@ -390,7 +388,7 @@ public void testForeignIsInitialized() throws Exception {
builder.addRepeatedMessage(TEST_REQUIRED_UNINITIALIZED);
assertFalse(abstractBuilder.isInitialized());
assertEquals(
"repeated_message[0].a, repeated_message[0].b, repeated_message[0].c",
"repeated_message[0].b, repeated_message[0].c",
abstractBuilder.getInitializationErrorString());
builder.setRepeatedMessage(0, TEST_REQUIRED_INITIALIZED);
@@ -231,6 +231,7 @@
import protobuf_unittest.UnittestProto.TestOneof2;
import protobuf_unittest.UnittestProto.TestPackedExtensions;
import protobuf_unittest.UnittestProto.TestPackedTypes;
import protobuf_unittest.UnittestProto.TestRequired;
import protobuf_unittest.UnittestProto.TestUnpackedTypes;
import java.io.File;
import java.io.IOException;
@@ -252,6 +253,11 @@
public final class TestUtil {
private TestUtil() {}
public static final TestRequired TEST_REQUIRED_UNINITIALIZED =
TestRequired.newBuilder().setA(1).buildPartial();
public static final TestRequired TEST_REQUIRED_INITIALIZED =
TestRequired.newBuilder().setA(1).setB(2).setC(3).build();
/** Helper to convert a String to ByteString. */
static ByteString toBytes(String str) {
return ByteString.copyFrom(str.getBytes(Internal.UTF_8));
Oops, something went wrong.

3 comments on commit 9021f62

@nlopezgi

This comment has been minimized.

Show comment
Hide comment
@nlopezgi

nlopezgi Dec 7, 2017

My protobuf bazel builds started failing with this CL. I run tests on both a debian8-clang and an ubuntu-gcc environments. Tests fail on both environments with a similar error message:

Message on debian8-clang (gcr.io/cloud-marketplace/google/clang-debian8)
ERROR: /protobuf/BUILD:473:1: Linking of rule '//:test_plugin' failed (Exit 1): clang failed: error executing command
(cd /root/.cache/bazel/_bazel_root/c10d995b71ee2cb34bd3247d67c66df9/execroot/com_google_protobuf &&
exec env -
PWD=/proc/self/cwd
/usr/local/bin/clang -o bazel-out/k8-fastbuild/bin/test_plugin -pthread '-fuse-ld=gold' -B/usr/local/bin -B/usr/bin -Wl,-S -Wl,@bazel-out/k8-fastbuild/bin/test_plugin-2.params)

Use --sandbox_debug to see verbose messages from the sandbox
bazel-out/k8-fastbuild/bin/_objs/protobuf_lite/src/google/protobuf/repeated_field.pic.o:repeated_field.cc:function google::protobuf::internal::RepeatedPtrFieldBase::AddWeak(google::protobuf::MessageLite const*): error: undefined reference to 'typeinfo for google::protobuf::internal::ImplicitWeakMessage'
bazel-out/k8-fastbuild/bin/_objs/protobuf_lite/src/google/protobuf/repeated_field.pic.o:repeated_field.cc:function google::protobuf::internal::ImplicitWeakMessage::ImplicitWeakMessage(): error: undefined reference to 'vtable for google::protobuf::internal::ImplicitWeakMessage'
/usr/bin/ld.gold: the vtable symbol may be undefined because the class is missing its key function
bazel-out/k8-fastbuild/bin/_objs/protobuf_lite/src/google/protobuf/repeated_field.pic.o:repeated_field.cc:function google::protobuf::internal::ImplicitWeakMessage::ImplicitWeakMessage(google::protobuf::Arena*): error: undefined reference to 'vtable for google::protobuf::internal::ImplicitWeakMessage'
/usr/bin/ld.gold: the vtable symbol may be undefined because the class is missing its key function
clang-6.0: error: linker command failed with exit code 1 (use -v to see invocation)
Target //:protobuf_test failed to build

Message on ubuntu-trusty-gcc (stock ubuntu:trusty with gcc + bazel installed):
ERROR: /project_src/BUILD:473:1: Linking of rule '//:test_plugin' failed (Exit 1): gcc failed: error executing command
(cd /root/.cache/bazel/_bazel_root/7e958634aed2e0b9513fa7cce861a282/execroot/com_google_protobuf &&
exec env -
PWD=/proc/self/cwd
/usr/bin/gcc -o bazel-out/k8-fastbuild/bin/test_plugin -pthread '-fuse-ld=gold' -Wl,-no-as-needed -Wl,-z,relro,-z,now -B/usr/bin -B/usr/bin -pass-exit-codes -Wl,-S -Wl,@bazel-out/k8-fastbuild/bin/test_plugin-2.params)
bazel-out/k8-fastbuild/bin/_objs/protobuf_lite/src/google/protobuf/repeated_field.pic.o:repeated_field.cc:function google::protobuf::internal::RepeatedPtrFieldBase::AddWeak(google::protobuf::MessageLite const*): error: undefined reference to 'typeinfo for google::protobuf::internal::ImplicitWeakMessage'
bazel-out/k8-fastbuild/bin/_objs/protobuf_lite/src/google/protobuf/repeated_field.pic.o:repeated_field.cc:function google::protobuf::internal::ImplicitWeakMessage::ImplicitWeakMessage(): error: undefined reference to 'vtable for google::protobuf::internal::ImplicitWeakMessage'
/usr/bin/ld.gold: the vtable symbol may be undefined because the class is missing its key function
bazel-out/k8-fastbuild/bin/_objs/protobuf_lite/src/google/protobuf/repeated_field.pic.o:repeated_field.cc:function google::protobuf::internal::ImplicitWeakMessage::ImplicitWeakMessage(google::protobuf::Arena*): error: undefined reference to 'vtable for google::protobuf::internal::ImplicitWeakMessage'
/usr/bin/ld.gold: the vtable symbol may be undefined because the class is missing its key function
collect2: error: ld returned 1 exit status
Target //:protobuf_test failed to build

nlopezgi replied Dec 7, 2017

My protobuf bazel builds started failing with this CL. I run tests on both a debian8-clang and an ubuntu-gcc environments. Tests fail on both environments with a similar error message:

Message on debian8-clang (gcr.io/cloud-marketplace/google/clang-debian8)
ERROR: /protobuf/BUILD:473:1: Linking of rule '//:test_plugin' failed (Exit 1): clang failed: error executing command
(cd /root/.cache/bazel/_bazel_root/c10d995b71ee2cb34bd3247d67c66df9/execroot/com_google_protobuf &&
exec env -
PWD=/proc/self/cwd
/usr/local/bin/clang -o bazel-out/k8-fastbuild/bin/test_plugin -pthread '-fuse-ld=gold' -B/usr/local/bin -B/usr/bin -Wl,-S -Wl,@bazel-out/k8-fastbuild/bin/test_plugin-2.params)

Use --sandbox_debug to see verbose messages from the sandbox
bazel-out/k8-fastbuild/bin/_objs/protobuf_lite/src/google/protobuf/repeated_field.pic.o:repeated_field.cc:function google::protobuf::internal::RepeatedPtrFieldBase::AddWeak(google::protobuf::MessageLite const*): error: undefined reference to 'typeinfo for google::protobuf::internal::ImplicitWeakMessage'
bazel-out/k8-fastbuild/bin/_objs/protobuf_lite/src/google/protobuf/repeated_field.pic.o:repeated_field.cc:function google::protobuf::internal::ImplicitWeakMessage::ImplicitWeakMessage(): error: undefined reference to 'vtable for google::protobuf::internal::ImplicitWeakMessage'
/usr/bin/ld.gold: the vtable symbol may be undefined because the class is missing its key function
bazel-out/k8-fastbuild/bin/_objs/protobuf_lite/src/google/protobuf/repeated_field.pic.o:repeated_field.cc:function google::protobuf::internal::ImplicitWeakMessage::ImplicitWeakMessage(google::protobuf::Arena*): error: undefined reference to 'vtable for google::protobuf::internal::ImplicitWeakMessage'
/usr/bin/ld.gold: the vtable symbol may be undefined because the class is missing its key function
clang-6.0: error: linker command failed with exit code 1 (use -v to see invocation)
Target //:protobuf_test failed to build

Message on ubuntu-trusty-gcc (stock ubuntu:trusty with gcc + bazel installed):
ERROR: /project_src/BUILD:473:1: Linking of rule '//:test_plugin' failed (Exit 1): gcc failed: error executing command
(cd /root/.cache/bazel/_bazel_root/7e958634aed2e0b9513fa7cce861a282/execroot/com_google_protobuf &&
exec env -
PWD=/proc/self/cwd
/usr/bin/gcc -o bazel-out/k8-fastbuild/bin/test_plugin -pthread '-fuse-ld=gold' -Wl,-no-as-needed -Wl,-z,relro,-z,now -B/usr/bin -B/usr/bin -pass-exit-codes -Wl,-S -Wl,@bazel-out/k8-fastbuild/bin/test_plugin-2.params)
bazel-out/k8-fastbuild/bin/_objs/protobuf_lite/src/google/protobuf/repeated_field.pic.o:repeated_field.cc:function google::protobuf::internal::RepeatedPtrFieldBase::AddWeak(google::protobuf::MessageLite const*): error: undefined reference to 'typeinfo for google::protobuf::internal::ImplicitWeakMessage'
bazel-out/k8-fastbuild/bin/_objs/protobuf_lite/src/google/protobuf/repeated_field.pic.o:repeated_field.cc:function google::protobuf::internal::ImplicitWeakMessage::ImplicitWeakMessage(): error: undefined reference to 'vtable for google::protobuf::internal::ImplicitWeakMessage'
/usr/bin/ld.gold: the vtable symbol may be undefined because the class is missing its key function
bazel-out/k8-fastbuild/bin/_objs/protobuf_lite/src/google/protobuf/repeated_field.pic.o:repeated_field.cc:function google::protobuf::internal::ImplicitWeakMessage::ImplicitWeakMessage(google::protobuf::Arena*): error: undefined reference to 'vtable for google::protobuf::internal::ImplicitWeakMessage'
/usr/bin/ld.gold: the vtable symbol may be undefined because the class is missing its key function
collect2: error: ld returned 1 exit status
Target //:protobuf_test failed to build

@acozzette

This comment has been minimized.

Show comment
Hide comment
@acozzette

acozzette Dec 7, 2017

Contributor

@nlopezgi Sorry about that, I've just sent out pull request #4017 which should fix this.

Contributor

acozzette replied Dec 7, 2017

@nlopezgi Sorry about that, I've just sent out pull request #4017 which should fix this.

@nlopezgi

This comment has been minimized.

Show comment
Hide comment
@nlopezgi

nlopezgi Dec 8, 2017

thanks for the quick response, our builds are now green

nlopezgi replied Dec 8, 2017

thanks for the quick response, our builds are now green

Please sign in to comment.