aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am310
-rw-r--r--Protobuf.podspec2
-rw-r--r--conformance/Makefile.am4
-rw-r--r--conformance/failure_list_csharp.txt73
-rw-r--r--conformance/failure_list_python.txt92
-rw-r--r--conformance/failure_list_python_cpp.txt92
-rw-r--r--csharp/src/Google.Protobuf.Conformance/Program.cs27
-rw-r--r--csharp/src/Google.Protobuf.Test/JsonFormatterTest.cs57
-rw-r--r--csharp/src/Google.Protobuf.Test/JsonParserTest.cs102
-rw-r--r--csharp/src/Google.Protobuf.Test/TestProtos/UnittestWellKnownTypes.cs43
-rw-r--r--csharp/src/Google.Protobuf.Test/WellKnownTypes/DurationTest.cs30
-rw-r--r--csharp/src/Google.Protobuf.Test/WellKnownTypes/TimestampTest.cs23
-rw-r--r--csharp/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs24
-rw-r--r--csharp/src/Google.Protobuf/Collections/RepeatedField.cs9
-rw-r--r--csharp/src/Google.Protobuf/FieldCodec.cs138
-rw-r--r--csharp/src/Google.Protobuf/InvalidProtocolBufferException.cs11
-rw-r--r--csharp/src/Google.Protobuf/JsonFormatter.cs78
-rw-r--r--csharp/src/Google.Protobuf/JsonParser.cs90
-rw-r--r--csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs18
-rw-r--r--csharp/src/Google.Protobuf/WellKnownTypes/DurationPartial.cs23
-rw-r--r--csharp/src/Google.Protobuf/WellKnownTypes/TimestampPartial.cs22
-rw-r--r--java/core/generate-sources-build.xml20
-rw-r--r--java/core/generate-test-sources-build.xml43
-rw-r--r--java/core/pom.xml118
-rw-r--r--java/core/src/main/java/com/google/protobuf/AbstractMessage.java (renamed from java/src/main/java/com/google/protobuf/AbstractMessage.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/AbstractMessageLite.java (renamed from java/src/main/java/com/google/protobuf/AbstractMessageLite.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/AbstractParser.java (renamed from java/src/main/java/com/google/protobuf/AbstractParser.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/AbstractProtobufList.java (renamed from java/src/main/java/com/google/protobuf/AbstractProtobufList.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/BlockingRpcChannel.java (renamed from java/src/main/java/com/google/protobuf/BlockingRpcChannel.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/BlockingService.java (renamed from java/src/main/java/com/google/protobuf/BlockingService.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/BooleanArrayList.java (renamed from java/src/main/java/com/google/protobuf/BooleanArrayList.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/BoundedByteString.java (renamed from java/src/main/java/com/google/protobuf/BoundedByteString.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/ByteString.java (renamed from java/src/main/java/com/google/protobuf/ByteString.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/CodedInputStream.java (renamed from java/src/main/java/com/google/protobuf/CodedInputStream.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/CodedOutputStream.java (renamed from java/src/main/java/com/google/protobuf/CodedOutputStream.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/Descriptors.java (renamed from java/src/main/java/com/google/protobuf/Descriptors.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/DoubleArrayList.java (renamed from java/src/main/java/com/google/protobuf/DoubleArrayList.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/DynamicMessage.java (renamed from java/src/main/java/com/google/protobuf/DynamicMessage.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/Extension.java (renamed from java/src/main/java/com/google/protobuf/Extension.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/ExtensionLite.java (renamed from java/src/main/java/com/google/protobuf/ExtensionLite.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/ExtensionRegistry.java (renamed from java/src/main/java/com/google/protobuf/ExtensionRegistry.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/ExtensionRegistryLite.java (renamed from java/src/main/java/com/google/protobuf/ExtensionRegistryLite.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/FieldSet.java (renamed from java/src/main/java/com/google/protobuf/FieldSet.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/FloatArrayList.java (renamed from java/src/main/java/com/google/protobuf/FloatArrayList.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/GeneratedMessage.java (renamed from java/src/main/java/com/google/protobuf/GeneratedMessage.java)60
-rw-r--r--java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java (renamed from java/src/main/java/com/google/protobuf/GeneratedMessageLite.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/IntArrayList.java (renamed from java/src/main/java/com/google/protobuf/IntArrayList.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/Internal.java (renamed from java/src/main/java/com/google/protobuf/Internal.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java (renamed from java/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java)12
-rw-r--r--java/core/src/main/java/com/google/protobuf/LazyField.java (renamed from java/src/main/java/com/google/protobuf/LazyField.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/LazyFieldLite.java (renamed from java/src/main/java/com/google/protobuf/LazyFieldLite.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/LazyStringArrayList.java (renamed from java/src/main/java/com/google/protobuf/LazyStringArrayList.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/LazyStringList.java (renamed from java/src/main/java/com/google/protobuf/LazyStringList.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/LiteralByteString.java (renamed from java/src/main/java/com/google/protobuf/LiteralByteString.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/LongArrayList.java (renamed from java/src/main/java/com/google/protobuf/LongArrayList.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/MapEntry.java (renamed from java/src/main/java/com/google/protobuf/MapEntry.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/MapEntryLite.java (renamed from java/src/main/java/com/google/protobuf/MapEntryLite.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/MapField.java (renamed from java/src/main/java/com/google/protobuf/MapField.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/MapFieldLite.java (renamed from java/src/main/java/com/google/protobuf/MapFieldLite.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/Message.java (renamed from java/src/main/java/com/google/protobuf/Message.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/MessageLite.java (renamed from java/src/main/java/com/google/protobuf/MessageLite.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/MessageLiteOrBuilder.java (renamed from java/src/main/java/com/google/protobuf/MessageLiteOrBuilder.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/MessageLiteToString.java (renamed from java/src/main/java/com/google/protobuf/MessageLiteToString.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/MessageOrBuilder.java (renamed from java/src/main/java/com/google/protobuf/MessageOrBuilder.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/MessageReflection.java (renamed from java/src/main/java/com/google/protobuf/MessageReflection.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/MutabilityOracle.java (renamed from java/src/main/java/com/google/protobuf/MutabilityOracle.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/NioByteString.java (renamed from java/src/main/java/com/google/protobuf/NioByteString.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/Parser.java (renamed from java/src/main/java/com/google/protobuf/Parser.java)12
-rw-r--r--java/core/src/main/java/com/google/protobuf/ProtobufArrayList.java (renamed from java/src/main/java/com/google/protobuf/ProtobufArrayList.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/ProtocolMessageEnum.java (renamed from java/src/main/java/com/google/protobuf/ProtocolMessageEnum.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/ProtocolStringList.java (renamed from java/src/main/java/com/google/protobuf/ProtocolStringList.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/RepeatedFieldBuilder.java (renamed from java/src/main/java/com/google/protobuf/RepeatedFieldBuilder.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/RopeByteString.java (renamed from java/src/main/java/com/google/protobuf/RopeByteString.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/RpcCallback.java (renamed from java/src/main/java/com/google/protobuf/RpcCallback.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/RpcChannel.java (renamed from java/src/main/java/com/google/protobuf/RpcChannel.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/RpcController.java (renamed from java/src/main/java/com/google/protobuf/RpcController.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/RpcUtil.java (renamed from java/src/main/java/com/google/protobuf/RpcUtil.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/Service.java (renamed from java/src/main/java/com/google/protobuf/Service.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/ServiceException.java (renamed from java/src/main/java/com/google/protobuf/ServiceException.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/SingleFieldBuilder.java (renamed from java/src/main/java/com/google/protobuf/SingleFieldBuilder.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/SmallSortedMap.java (renamed from java/src/main/java/com/google/protobuf/SmallSortedMap.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/TextFormat.java (renamed from java/src/main/java/com/google/protobuf/TextFormat.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/TextFormatEscaper.java (renamed from java/src/main/java/com/google/protobuf/TextFormatEscaper.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/UninitializedMessageException.java (renamed from java/src/main/java/com/google/protobuf/UninitializedMessageException.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/UnknownFieldSet.java (renamed from java/src/main/java/com/google/protobuf/UnknownFieldSet.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/UnknownFieldSetLite.java (renamed from java/src/main/java/com/google/protobuf/UnknownFieldSetLite.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/UnmodifiableLazyStringList.java (renamed from java/src/main/java/com/google/protobuf/UnmodifiableLazyStringList.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/UnsafeByteStrings.java (renamed from java/src/main/java/com/google/protobuf/UnsafeByteStrings.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/Utf8.java (renamed from java/src/main/java/com/google/protobuf/Utf8.java)0
-rw-r--r--java/core/src/main/java/com/google/protobuf/WireFormat.java (renamed from java/src/main/java/com/google/protobuf/WireFormat.java)0
-rw-r--r--java/core/src/test/java/com/google/protobuf/AbstractMessageTest.java (renamed from java/src/test/java/com/google/protobuf/AbstractMessageTest.java)0
-rw-r--r--java/core/src/test/java/com/google/protobuf/AnyTest.java (renamed from java/src/test/java/com/google/protobuf/AnyTest.java)0
-rw-r--r--java/core/src/test/java/com/google/protobuf/BooleanArrayListTest.java (renamed from java/src/test/java/com/google/protobuf/BooleanArrayListTest.java)0
-rw-r--r--java/core/src/test/java/com/google/protobuf/BoundedByteStringTest.java (renamed from java/src/test/java/com/google/protobuf/BoundedByteStringTest.java)0
-rw-r--r--java/core/src/test/java/com/google/protobuf/ByteStringTest.java (renamed from java/src/test/java/com/google/protobuf/ByteStringTest.java)0
-rw-r--r--java/core/src/test/java/com/google/protobuf/CheckUtf8Test.java (renamed from java/src/test/java/com/google/protobuf/CheckUtf8Test.java)0
-rw-r--r--java/core/src/test/java/com/google/protobuf/CodedInputStreamTest.java (renamed from java/src/test/java/com/google/protobuf/CodedInputStreamTest.java)0
-rw-r--r--java/core/src/test/java/com/google/protobuf/CodedOutputStreamTest.java (renamed from java/src/test/java/com/google/protobuf/CodedOutputStreamTest.java)0
-rw-r--r--java/core/src/test/java/com/google/protobuf/DeprecatedFieldTest.java (renamed from java/src/test/java/com/google/protobuf/DeprecatedFieldTest.java)0
-rw-r--r--java/core/src/test/java/com/google/protobuf/DescriptorsTest.java (renamed from java/src/test/java/com/google/protobuf/DescriptorsTest.java)0
-rw-r--r--java/core/src/test/java/com/google/protobuf/DoubleArrayListTest.java (renamed from java/src/test/java/com/google/protobuf/DoubleArrayListTest.java)0
-rw-r--r--java/core/src/test/java/com/google/protobuf/DynamicMessageTest.java (renamed from java/src/test/java/com/google/protobuf/DynamicMessageTest.java)0
-rw-r--r--java/core/src/test/java/com/google/protobuf/FieldPresenceTest.java (renamed from java/src/test/java/com/google/protobuf/FieldPresenceTest.java)0
-rw-r--r--java/core/src/test/java/com/google/protobuf/FloatArrayListTest.java (renamed from java/src/test/java/com/google/protobuf/FloatArrayListTest.java)0
-rw-r--r--java/core/src/test/java/com/google/protobuf/ForceFieldBuildersPreRun.java (renamed from java/src/test/java/com/google/protobuf/ForceFieldBuildersPreRun.java)0
-rw-r--r--java/core/src/test/java/com/google/protobuf/GeneratedMessageTest.java (renamed from java/src/test/java/com/google/protobuf/GeneratedMessageTest.java)0
-rw-r--r--java/core/src/test/java/com/google/protobuf/IntArrayListTest.java (renamed from java/src/test/java/com/google/protobuf/IntArrayListTest.java)0
-rw-r--r--java/core/src/test/java/com/google/protobuf/IsValidUtf8Test.java (renamed from java/src/test/java/com/google/protobuf/IsValidUtf8Test.java)0
-rw-r--r--java/core/src/test/java/com/google/protobuf/IsValidUtf8TestUtil.java (renamed from java/src/test/java/com/google/protobuf/IsValidUtf8TestUtil.java)0
-rw-r--r--java/core/src/test/java/com/google/protobuf/LazyFieldLiteTest.java (renamed from java/src/test/java/com/google/protobuf/LazyFieldLiteTest.java)0
-rw-r--r--java/core/src/test/java/com/google/protobuf/LazyFieldTest.java (renamed from java/src/test/java/com/google/protobuf/LazyFieldTest.java)0
-rw-r--r--java/core/src/test/java/com/google/protobuf/LazyMessageLiteTest.java (renamed from java/src/test/java/com/google/protobuf/LazyMessageLiteTest.java)0
-rw-r--r--java/core/src/test/java/com/google/protobuf/LazyStringArrayListTest.java (renamed from java/src/test/java/com/google/protobuf/LazyStringArrayListTest.java)0
-rw-r--r--java/core/src/test/java/com/google/protobuf/LazyStringEndToEndTest.java (renamed from java/src/test/java/com/google/protobuf/LazyStringEndToEndTest.java)0
-rw-r--r--java/core/src/test/java/com/google/protobuf/LiteEqualsAndHashTest.java (renamed from java/src/test/java/com/google/protobuf/LiteEqualsAndHashTest.java)0
-rw-r--r--java/core/src/test/java/com/google/protobuf/LiteTest.java (renamed from java/src/test/java/com/google/protobuf/LiteTest.java)0
-rw-r--r--java/core/src/test/java/com/google/protobuf/LiteralByteStringTest.java (renamed from java/src/test/java/com/google/protobuf/LiteralByteStringTest.java)0
-rw-r--r--java/core/src/test/java/com/google/protobuf/LongArrayListTest.java (renamed from java/src/test/java/com/google/protobuf/LongArrayListTest.java)0
-rw-r--r--java/core/src/test/java/com/google/protobuf/MapForProto2LiteTest.java (renamed from java/src/test/java/com/google/protobuf/MapForProto2LiteTest.java)0
-rw-r--r--java/core/src/test/java/com/google/protobuf/MapForProto2Test.java (renamed from java/src/test/java/com/google/protobuf/MapForProto2Test.java)0
-rw-r--r--java/core/src/test/java/com/google/protobuf/MapTest.java (renamed from java/src/test/java/com/google/protobuf/MapTest.java)0
-rw-r--r--java/core/src/test/java/com/google/protobuf/MessageTest.java (renamed from java/src/test/java/com/google/protobuf/MessageTest.java)0
-rw-r--r--java/core/src/test/java/com/google/protobuf/NestedBuildersTest.java (renamed from java/src/test/java/com/google/protobuf/NestedBuildersTest.java)0
-rw-r--r--java/core/src/test/java/com/google/protobuf/NioByteStringTest.java (renamed from java/src/test/java/com/google/protobuf/NioByteStringTest.java)0
-rw-r--r--java/core/src/test/java/com/google/protobuf/ParseExceptionsTest.java211
-rw-r--r--java/core/src/test/java/com/google/protobuf/ParserTest.java (renamed from java/src/test/java/com/google/protobuf/ParserTest.java)0
-rw-r--r--java/core/src/test/java/com/google/protobuf/ProtobufArrayListTest.java (renamed from java/src/test/java/com/google/protobuf/ProtobufArrayListTest.java)0
-rw-r--r--java/core/src/test/java/com/google/protobuf/RepeatedFieldBuilderTest.java (renamed from java/src/test/java/com/google/protobuf/RepeatedFieldBuilderTest.java)0
-rw-r--r--java/core/src/test/java/com/google/protobuf/RopeByteStringSubstringTest.java (renamed from java/src/test/java/com/google/protobuf/RopeByteStringSubstringTest.java)0
-rw-r--r--java/core/src/test/java/com/google/protobuf/RopeByteStringTest.java (renamed from java/src/test/java/com/google/protobuf/RopeByteStringTest.java)0
-rw-r--r--java/core/src/test/java/com/google/protobuf/ServiceTest.java (renamed from java/src/test/java/com/google/protobuf/ServiceTest.java)0
-rw-r--r--java/core/src/test/java/com/google/protobuf/SingleFieldBuilderTest.java (renamed from java/src/test/java/com/google/protobuf/SingleFieldBuilderTest.java)0
-rw-r--r--java/core/src/test/java/com/google/protobuf/SmallSortedMapTest.java (renamed from java/src/test/java/com/google/protobuf/SmallSortedMapTest.java)0
-rw-r--r--java/core/src/test/java/com/google/protobuf/TestBadIdentifiers.java (renamed from java/src/test/java/com/google/protobuf/TestBadIdentifiers.java)0
-rw-r--r--java/core/src/test/java/com/google/protobuf/TestUtil.java (renamed from java/src/test/java/com/google/protobuf/TestUtil.java)0
-rw-r--r--java/core/src/test/java/com/google/protobuf/TextFormatTest.java (renamed from java/src/test/java/com/google/protobuf/TextFormatTest.java)0
-rw-r--r--java/core/src/test/java/com/google/protobuf/UnknownEnumValueTest.java (renamed from java/src/test/java/com/google/protobuf/UnknownEnumValueTest.java)0
-rw-r--r--java/core/src/test/java/com/google/protobuf/UnknownFieldSetLiteTest.java (renamed from java/src/test/java/com/google/protobuf/UnknownFieldSetLiteTest.java)0
-rw-r--r--java/core/src/test/java/com/google/protobuf/UnknownFieldSetTest.java (renamed from java/src/test/java/com/google/protobuf/UnknownFieldSetTest.java)0
-rw-r--r--java/core/src/test/java/com/google/protobuf/UnmodifiableLazyStringListTest.java (renamed from java/src/test/java/com/google/protobuf/UnmodifiableLazyStringListTest.java)0
-rw-r--r--java/core/src/test/java/com/google/protobuf/WellKnownTypesTest.java (renamed from java/src/test/java/com/google/protobuf/WellKnownTypesTest.java)0
-rw-r--r--java/core/src/test/java/com/google/protobuf/WireFormatTest.java (renamed from java/src/test/java/com/google/protobuf/WireFormatTest.java)0
-rw-r--r--java/core/src/test/proto/com/google/protobuf/any_test.proto (renamed from java/src/test/java/com/google/protobuf/any_test.proto)0
-rw-r--r--java/core/src/test/proto/com/google/protobuf/field_presence_test.proto (renamed from java/src/test/java/com/google/protobuf/field_presence_test.proto)0
-rw-r--r--java/core/src/test/proto/com/google/protobuf/lazy_fields_lite.proto (renamed from java/src/test/java/com/google/protobuf/lazy_fields_lite.proto)0
-rw-r--r--java/core/src/test/proto/com/google/protobuf/lite_equals_and_hash.proto (renamed from java/src/test/java/com/google/protobuf/lite_equals_and_hash.proto)0
-rw-r--r--java/core/src/test/proto/com/google/protobuf/map_for_proto2_lite_test.proto (renamed from java/src/test/java/com/google/protobuf/map_for_proto2_lite_test.proto)0
-rw-r--r--java/core/src/test/proto/com/google/protobuf/map_for_proto2_test.proto (renamed from java/src/test/java/com/google/protobuf/map_for_proto2_test.proto)0
-rw-r--r--java/core/src/test/proto/com/google/protobuf/map_initialization_order_test.proto (renamed from java/src/test/java/com/google/protobuf/map_initialization_order_test.proto)0
-rw-r--r--java/core/src/test/proto/com/google/protobuf/map_test.proto (renamed from java/src/test/java/com/google/protobuf/map_test.proto)0
-rw-r--r--java/core/src/test/proto/com/google/protobuf/multiple_files_test.proto (renamed from java/src/test/java/com/google/protobuf/multiple_files_test.proto)0
-rw-r--r--java/core/src/test/proto/com/google/protobuf/nested_builders_test.proto (renamed from java/src/test/java/com/google/protobuf/nested_builders_test.proto)0
-rw-r--r--java/core/src/test/proto/com/google/protobuf/nested_extension.proto (renamed from java/src/test/java/com/google/protobuf/nested_extension.proto)0
-rw-r--r--java/core/src/test/proto/com/google/protobuf/nested_extension_lite.proto (renamed from java/src/test/java/com/google/protobuf/nested_extension_lite.proto)0
-rw-r--r--java/core/src/test/proto/com/google/protobuf/non_nested_extension.proto (renamed from java/src/test/java/com/google/protobuf/non_nested_extension.proto)0
-rw-r--r--java/core/src/test/proto/com/google/protobuf/non_nested_extension_lite.proto (renamed from java/src/test/java/com/google/protobuf/non_nested_extension_lite.proto)0
-rw-r--r--java/core/src/test/proto/com/google/protobuf/outer_class_name_test.proto (renamed from java/src/test/java/com/google/protobuf/outer_class_name_test.proto)0
-rw-r--r--java/core/src/test/proto/com/google/protobuf/outer_class_name_test2.proto (renamed from java/src/test/java/com/google/protobuf/outer_class_name_test2.proto)0
-rw-r--r--java/core/src/test/proto/com/google/protobuf/outer_class_name_test3.proto (renamed from java/src/test/java/com/google/protobuf/outer_class_name_test3.proto)0
-rw-r--r--java/core/src/test/proto/com/google/protobuf/test_bad_identifiers.proto (renamed from java/src/test/java/com/google/protobuf/test_bad_identifiers.proto)0
-rw-r--r--java/core/src/test/proto/com/google/protobuf/test_check_utf8.proto (renamed from java/src/test/java/com/google/protobuf/test_check_utf8.proto)0
-rw-r--r--java/core/src/test/proto/com/google/protobuf/test_check_utf8_size.proto (renamed from java/src/test/java/com/google/protobuf/test_check_utf8_size.proto)0
-rw-r--r--java/core/src/test/proto/com/google/protobuf/test_custom_options.proto (renamed from java/src/test/java/com/google/protobuf/test_custom_options.proto)0
-rw-r--r--java/core/src/test/proto/com/google/protobuf/test_extra_interfaces.proto (renamed from java/src/test/java/com/google/protobuf/test_extra_interfaces.proto)0
-rw-r--r--java/lite/pom.xml158
-rw-r--r--java/pom.xml420
-rw-r--r--java/util/pom.xml189
-rw-r--r--java/util/src/test/proto/com/google/protobuf/util/json_test.proto (renamed from java/util/src/test/java/com/google/protobuf/util/json_test.proto)0
-rw-r--r--python/google/protobuf/pyext/map_container.cc2
-rw-r--r--src/google/protobuf/compiler/java/java_message.cc17
-rw-r--r--src/google/protobuf/compiler/java/java_message_builder.cc2
-rw-r--r--src/google/protobuf/repeated_field.h2
-rw-r--r--src/google/protobuf/unittest_well_known_types.proto2
173 files changed, 1518 insertions, 1018 deletions
diff --git a/Makefile.am b/Makefile.am
index 3d39a898..2f810954 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -181,160 +181,162 @@ csharp_EXTRA_DIST= \
csharp/src/Google.Protobuf/packages.config \
csharp/src/packages/repositories.config
-java_EXTRA_DIST= \
- java/src/main/java/com/google/protobuf/AbstractMessage.java \
- java/src/main/java/com/google/protobuf/AbstractMessageLite.java \
- java/src/main/java/com/google/protobuf/AbstractParser.java \
- java/src/main/java/com/google/protobuf/AbstractProtobufList.java \
- java/src/main/java/com/google/protobuf/BlockingRpcChannel.java \
- java/src/main/java/com/google/protobuf/BlockingService.java \
- java/src/main/java/com/google/protobuf/BooleanArrayList.java \
- java/src/main/java/com/google/protobuf/BoundedByteString.java \
- java/src/main/java/com/google/protobuf/ByteString.java \
- java/src/main/java/com/google/protobuf/CodedInputStream.java \
- java/src/main/java/com/google/protobuf/CodedOutputStream.java \
- java/src/main/java/com/google/protobuf/Descriptors.java \
- java/src/main/java/com/google/protobuf/DoubleArrayList.java \
- java/src/main/java/com/google/protobuf/DynamicMessage.java \
- java/src/main/java/com/google/protobuf/Extension.java \
- java/src/main/java/com/google/protobuf/ExtensionLite.java \
- java/src/main/java/com/google/protobuf/ExtensionRegistry.java \
- java/src/main/java/com/google/protobuf/ExtensionRegistryLite.java \
- java/src/main/java/com/google/protobuf/FieldSet.java \
- java/src/main/java/com/google/protobuf/FloatArrayList.java \
- java/src/main/java/com/google/protobuf/GeneratedMessage.java \
- java/src/main/java/com/google/protobuf/GeneratedMessageLite.java \
- java/src/main/java/com/google/protobuf/IntArrayList.java \
- java/src/main/java/com/google/protobuf/Internal.java \
- java/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java \
- java/src/main/java/com/google/protobuf/LazyField.java \
- java/src/main/java/com/google/protobuf/LazyFieldLite.java \
- java/src/main/java/com/google/protobuf/LazyStringArrayList.java \
- java/src/main/java/com/google/protobuf/LazyStringList.java \
- java/src/main/java/com/google/protobuf/LiteralByteString.java \
- java/src/main/java/com/google/protobuf/LongArrayList.java \
- java/src/main/java/com/google/protobuf/MapEntry.java \
- java/src/main/java/com/google/protobuf/MapEntryLite.java \
- java/src/main/java/com/google/protobuf/MapField.java \
- java/src/main/java/com/google/protobuf/MapFieldLite.java \
- java/src/main/java/com/google/protobuf/Message.java \
- java/src/main/java/com/google/protobuf/MessageLite.java \
- java/src/main/java/com/google/protobuf/MessageLiteOrBuilder.java \
- java/src/main/java/com/google/protobuf/MessageLiteToString.java \
- java/src/main/java/com/google/protobuf/MessageLiteToString.java \
- java/src/main/java/com/google/protobuf/MessageOrBuilder.java \
- java/src/main/java/com/google/protobuf/MessageReflection.java \
- java/src/main/java/com/google/protobuf/MutabilityOracle.java \
- java/src/main/java/com/google/protobuf/NioByteString.java \
- java/src/main/java/com/google/protobuf/Parser.java \
- java/src/main/java/com/google/protobuf/ProtobufArrayList.java \
- java/src/main/java/com/google/protobuf/ProtocolMessageEnum.java \
- java/src/main/java/com/google/protobuf/ProtocolStringList.java \
- java/src/main/java/com/google/protobuf/RepeatedFieldBuilder.java \
- java/src/main/java/com/google/protobuf/RopeByteString.java \
- java/src/main/java/com/google/protobuf/RpcCallback.java \
- java/src/main/java/com/google/protobuf/RpcChannel.java \
- java/src/main/java/com/google/protobuf/RpcController.java \
- java/src/main/java/com/google/protobuf/RpcUtil.java \
- java/src/main/java/com/google/protobuf/Service.java \
- java/src/main/java/com/google/protobuf/ServiceException.java \
- java/src/main/java/com/google/protobuf/SingleFieldBuilder.java \
- java/src/main/java/com/google/protobuf/SmallSortedMap.java \
- java/src/main/java/com/google/protobuf/TextFormat.java \
- java/src/main/java/com/google/protobuf/TextFormatEscaper.java \
- java/src/main/java/com/google/protobuf/TextFormatEscaper.java \
- java/src/main/java/com/google/protobuf/UninitializedMessageException.java \
- java/src/main/java/com/google/protobuf/UnknownFieldSet.java \
- java/src/main/java/com/google/protobuf/UnknownFieldSetLite.java \
- java/src/main/java/com/google/protobuf/UnmodifiableLazyStringList.java \
- java/src/main/java/com/google/protobuf/UnsafeByteStrings.java \
- java/src/main/java/com/google/protobuf/Utf8.java \
- java/src/main/java/com/google/protobuf/WireFormat.java \
- java/src/test/java/com/google/protobuf/AbstractMessageTest.java \
- java/src/test/java/com/google/protobuf/AnyTest.java \
- java/src/test/java/com/google/protobuf/BooleanArrayListTest.java \
- java/src/test/java/com/google/protobuf/BoundedByteStringTest.java \
- java/src/test/java/com/google/protobuf/ByteStringTest.java \
- java/src/test/java/com/google/protobuf/CheckUtf8Test.java \
- java/src/test/java/com/google/protobuf/CodedInputStreamTest.java \
- java/src/test/java/com/google/protobuf/CodedOutputStreamTest.java \
- java/src/test/java/com/google/protobuf/DeprecatedFieldTest.java \
- java/src/test/java/com/google/protobuf/DescriptorsTest.java \
- java/src/test/java/com/google/protobuf/DoubleArrayListTest.java \
- java/src/test/java/com/google/protobuf/DynamicMessageTest.java \
- java/src/test/java/com/google/protobuf/FieldPresenceTest.java \
- java/src/test/java/com/google/protobuf/FloatArrayListTest.java \
- java/src/test/java/com/google/protobuf/ForceFieldBuildersPreRun.java \
- java/src/test/java/com/google/protobuf/GeneratedMessageTest.java \
- java/src/test/java/com/google/protobuf/IntArrayListTest.java \
- java/src/test/java/com/google/protobuf/IsValidUtf8Test.java \
- java/src/test/java/com/google/protobuf/IsValidUtf8TestUtil.java \
- java/src/test/java/com/google/protobuf/LazyFieldLiteTest.java \
- java/src/test/java/com/google/protobuf/LazyFieldTest.java \
- java/src/test/java/com/google/protobuf/LazyMessageLiteTest.java \
- java/src/test/java/com/google/protobuf/LazyStringArrayListTest.java \
- java/src/test/java/com/google/protobuf/LazyStringEndToEndTest.java \
- java/src/test/java/com/google/protobuf/LiteEqualsAndHashTest.java \
- java/src/test/java/com/google/protobuf/LiteTest.java \
- java/src/test/java/com/google/protobuf/LiteralByteStringTest.java \
- java/src/test/java/com/google/protobuf/LongArrayListTest.java \
- java/src/test/java/com/google/protobuf/MapForProto2LiteTest.java \
- java/src/test/java/com/google/protobuf/MapForProto2Test.java \
- java/src/test/java/com/google/protobuf/MapTest.java \
- java/src/test/java/com/google/protobuf/MessageTest.java \
- java/src/test/java/com/google/protobuf/NestedBuildersTest.java \
- java/src/test/java/com/google/protobuf/NioByteStringTest.java \
- java/src/test/java/com/google/protobuf/ParserTest.java \
- java/src/test/java/com/google/protobuf/ProtobufArrayListTest.java \
- java/src/test/java/com/google/protobuf/RepeatedFieldBuilderTest.java \
- java/src/test/java/com/google/protobuf/RopeByteStringSubstringTest.java \
- java/src/test/java/com/google/protobuf/RopeByteStringTest.java \
- java/src/test/java/com/google/protobuf/ServiceTest.java \
- java/src/test/java/com/google/protobuf/SingleFieldBuilderTest.java \
- java/src/test/java/com/google/protobuf/SmallSortedMapTest.java \
- java/src/test/java/com/google/protobuf/TestBadIdentifiers.java \
- java/src/test/java/com/google/protobuf/TestUtil.java \
- java/src/test/java/com/google/protobuf/TextFormatTest.java \
- java/src/test/java/com/google/protobuf/UnknownEnumValueTest.java \
- java/src/test/java/com/google/protobuf/UnknownFieldSetLiteTest.java \
- java/src/test/java/com/google/protobuf/UnknownFieldSetTest.java \
- java/src/test/java/com/google/protobuf/UnmodifiableLazyStringListTest.java \
- java/src/test/java/com/google/protobuf/WellKnownTypesTest.java \
- java/src/test/java/com/google/protobuf/WireFormatTest.java \
- java/src/test/java/com/google/protobuf/any_test.proto \
- java/src/test/java/com/google/protobuf/field_presence_test.proto \
- java/src/test/java/com/google/protobuf/lazy_fields_lite.proto \
- java/src/test/java/com/google/protobuf/lite_equals_and_hash.proto \
- java/src/test/java/com/google/protobuf/map_for_proto2_lite_test.proto \
- java/src/test/java/com/google/protobuf/map_for_proto2_test.proto \
- java/src/test/java/com/google/protobuf/map_initialization_order_test.proto \
- java/src/test/java/com/google/protobuf/map_test.proto \
- java/src/test/java/com/google/protobuf/multiple_files_test.proto \
- java/src/test/java/com/google/protobuf/nested_builders_test.proto \
- java/src/test/java/com/google/protobuf/nested_extension.proto \
- java/src/test/java/com/google/protobuf/nested_extension_lite.proto \
- java/src/test/java/com/google/protobuf/non_nested_extension.proto \
- java/src/test/java/com/google/protobuf/non_nested_extension_lite.proto \
- java/src/test/java/com/google/protobuf/outer_class_name_test.proto \
- java/src/test/java/com/google/protobuf/outer_class_name_test2.proto \
- java/src/test/java/com/google/protobuf/outer_class_name_test3.proto \
- java/src/test/java/com/google/protobuf/test_bad_identifiers.proto \
- java/src/test/java/com/google/protobuf/test_check_utf8.proto \
- java/src/test/java/com/google/protobuf/test_check_utf8_size.proto \
- java/src/test/java/com/google/protobuf/test_custom_options.proto \
- java/src/test/java/com/google/protobuf/test_extra_interfaces.proto \
- java/util/pom.xml \
- java/util/src/main/java/com/google/protobuf/util/FieldMaskTree.java \
- java/util/src/main/java/com/google/protobuf/util/FieldMaskUtil.java \
- java/util/src/main/java/com/google/protobuf/util/JsonFormat.java \
- java/util/src/main/java/com/google/protobuf/util/TimeUtil.java \
- java/util/src/test/java/com/google/protobuf/util/FieldMaskTreeTest.java \
- java/util/src/test/java/com/google/protobuf/util/FieldMaskUtilTest.java \
- java/util/src/test/java/com/google/protobuf/util/JsonFormatTest.java \
- java/util/src/test/java/com/google/protobuf/util/TimeUtilTest.java \
- java/util/src/test/java/com/google/protobuf/util/json_test.proto \
- java/pom.xml \
- java/README.md
+java_EXTRA_DIST= \
+ java/README.md \
+ java/core/generate-sources-build.xml \
+ java/core/generate-test-sources-build.xml \
+ java/core/pom.xml \
+ java/core/src/main/java/com/google/protobuf/AbstractMessage.java \
+ 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/BlockingRpcChannel.java \
+ java/core/src/main/java/com/google/protobuf/BlockingService.java \
+ java/core/src/main/java/com/google/protobuf/BooleanArrayList.java \
+ java/core/src/main/java/com/google/protobuf/BoundedByteString.java \
+ java/core/src/main/java/com/google/protobuf/ByteString.java \
+ java/core/src/main/java/com/google/protobuf/CodedInputStream.java \
+ java/core/src/main/java/com/google/protobuf/CodedOutputStream.java \
+ java/core/src/main/java/com/google/protobuf/Descriptors.java \
+ java/core/src/main/java/com/google/protobuf/DoubleArrayList.java \
+ java/core/src/main/java/com/google/protobuf/DynamicMessage.java \
+ java/core/src/main/java/com/google/protobuf/Extension.java \
+ java/core/src/main/java/com/google/protobuf/ExtensionLite.java \
+ java/core/src/main/java/com/google/protobuf/ExtensionRegistry.java \
+ java/core/src/main/java/com/google/protobuf/ExtensionRegistryLite.java \
+ java/core/src/main/java/com/google/protobuf/FieldSet.java \
+ java/core/src/main/java/com/google/protobuf/FloatArrayList.java \
+ java/core/src/main/java/com/google/protobuf/GeneratedMessage.java \
+ java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java \
+ java/core/src/main/java/com/google/protobuf/IntArrayList.java \
+ java/core/src/main/java/com/google/protobuf/Internal.java \
+ java/core/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java \
+ java/core/src/main/java/com/google/protobuf/LazyField.java \
+ java/core/src/main/java/com/google/protobuf/LazyFieldLite.java \
+ java/core/src/main/java/com/google/protobuf/LazyStringArrayList.java \
+ java/core/src/main/java/com/google/protobuf/LazyStringList.java \
+ java/core/src/main/java/com/google/protobuf/LiteralByteString.java \
+ java/core/src/main/java/com/google/protobuf/LongArrayList.java \
+ java/core/src/main/java/com/google/protobuf/MapEntry.java \
+ java/core/src/main/java/com/google/protobuf/MapEntryLite.java \
+ java/core/src/main/java/com/google/protobuf/MapField.java \
+ java/core/src/main/java/com/google/protobuf/MapFieldLite.java \
+ java/core/src/main/java/com/google/protobuf/Message.java \
+ java/core/src/main/java/com/google/protobuf/MessageLite.java \
+ java/core/src/main/java/com/google/protobuf/MessageLiteOrBuilder.java \
+ java/core/src/main/java/com/google/protobuf/MessageLiteToString.java \
+ java/core/src/main/java/com/google/protobuf/MessageOrBuilder.java \
+ java/core/src/main/java/com/google/protobuf/MessageReflection.java \
+ java/core/src/main/java/com/google/protobuf/MutabilityOracle.java \
+ java/core/src/main/java/com/google/protobuf/NioByteString.java \
+ java/core/src/main/java/com/google/protobuf/Parser.java \
+ java/core/src/main/java/com/google/protobuf/ProtobufArrayList.java \
+ java/core/src/main/java/com/google/protobuf/ProtocolMessageEnum.java \
+ java/core/src/main/java/com/google/protobuf/ProtocolStringList.java \
+ java/core/src/main/java/com/google/protobuf/RepeatedFieldBuilder.java \
+ java/core/src/main/java/com/google/protobuf/RopeByteString.java \
+ java/core/src/main/java/com/google/protobuf/RpcCallback.java \
+ java/core/src/main/java/com/google/protobuf/RpcChannel.java \
+ java/core/src/main/java/com/google/protobuf/RpcController.java \
+ java/core/src/main/java/com/google/protobuf/RpcUtil.java \
+ java/core/src/main/java/com/google/protobuf/Service.java \
+ java/core/src/main/java/com/google/protobuf/ServiceException.java \
+ java/core/src/main/java/com/google/protobuf/SingleFieldBuilder.java \
+ java/core/src/main/java/com/google/protobuf/SmallSortedMap.java \
+ java/core/src/main/java/com/google/protobuf/TextFormat.java \
+ java/core/src/main/java/com/google/protobuf/TextFormatEscaper.java \
+ java/core/src/main/java/com/google/protobuf/UninitializedMessageException.java \
+ java/core/src/main/java/com/google/protobuf/UnknownFieldSet.java \
+ java/core/src/main/java/com/google/protobuf/UnknownFieldSetLite.java \
+ java/core/src/main/java/com/google/protobuf/UnmodifiableLazyStringList.java \
+ java/core/src/main/java/com/google/protobuf/UnsafeByteStrings.java \
+ java/core/src/main/java/com/google/protobuf/Utf8.java \
+ java/core/src/main/java/com/google/protobuf/WireFormat.java \
+ java/core/src/test/java/com/google/protobuf/AbstractMessageTest.java \
+ java/core/src/test/java/com/google/protobuf/AnyTest.java \
+ java/core/src/test/java/com/google/protobuf/BooleanArrayListTest.java \
+ java/core/src/test/java/com/google/protobuf/BoundedByteStringTest.java \
+ java/core/src/test/java/com/google/protobuf/ByteStringTest.java \
+ java/core/src/test/java/com/google/protobuf/CheckUtf8Test.java \
+ java/core/src/test/java/com/google/protobuf/CodedInputStreamTest.java \
+ java/core/src/test/java/com/google/protobuf/CodedOutputStreamTest.java \
+ java/core/src/test/java/com/google/protobuf/DeprecatedFieldTest.java \
+ java/core/src/test/java/com/google/protobuf/DescriptorsTest.java \
+ java/core/src/test/java/com/google/protobuf/DoubleArrayListTest.java \
+ java/core/src/test/java/com/google/protobuf/DynamicMessageTest.java \
+ java/core/src/test/java/com/google/protobuf/FieldPresenceTest.java \
+ java/core/src/test/java/com/google/protobuf/FloatArrayListTest.java \
+ java/core/src/test/java/com/google/protobuf/ForceFieldBuildersPreRun.java \
+ java/core/src/test/java/com/google/protobuf/GeneratedMessageTest.java \
+ java/core/src/test/java/com/google/protobuf/IntArrayListTest.java \
+ java/core/src/test/java/com/google/protobuf/IsValidUtf8Test.java \
+ java/core/src/test/java/com/google/protobuf/IsValidUtf8TestUtil.java \
+ java/core/src/test/java/com/google/protobuf/LazyFieldLiteTest.java \
+ java/core/src/test/java/com/google/protobuf/LazyFieldTest.java \
+ java/core/src/test/java/com/google/protobuf/LazyMessageLiteTest.java \
+ java/core/src/test/java/com/google/protobuf/LazyStringArrayListTest.java \
+ java/core/src/test/java/com/google/protobuf/LazyStringEndToEndTest.java \
+ java/core/src/test/java/com/google/protobuf/LiteEqualsAndHashTest.java \
+ java/core/src/test/java/com/google/protobuf/LiteTest.java \
+ java/core/src/test/java/com/google/protobuf/LiteralByteStringTest.java \
+ java/core/src/test/java/com/google/protobuf/LongArrayListTest.java \
+ java/core/src/test/java/com/google/protobuf/MapForProto2LiteTest.java \
+ java/core/src/test/java/com/google/protobuf/MapForProto2Test.java \
+ java/core/src/test/java/com/google/protobuf/MapTest.java \
+ java/core/src/test/java/com/google/protobuf/MessageTest.java \
+ java/core/src/test/java/com/google/protobuf/NestedBuildersTest.java \
+ java/core/src/test/java/com/google/protobuf/NioByteStringTest.java \
+ java/core/src/test/java/com/google/protobuf/ParserTest.java \
+ java/core/src/test/java/com/google/protobuf/ProtobufArrayListTest.java \
+ java/core/src/test/java/com/google/protobuf/RepeatedFieldBuilderTest.java \
+ java/core/src/test/java/com/google/protobuf/RopeByteStringSubstringTest.java \
+ java/core/src/test/java/com/google/protobuf/RopeByteStringTest.java \
+ java/core/src/test/java/com/google/protobuf/ServiceTest.java \
+ java/core/src/test/java/com/google/protobuf/SingleFieldBuilderTest.java \
+ java/core/src/test/java/com/google/protobuf/SmallSortedMapTest.java \
+ java/core/src/test/java/com/google/protobuf/TestBadIdentifiers.java \
+ java/core/src/test/java/com/google/protobuf/TestUtil.java \
+ java/core/src/test/java/com/google/protobuf/TextFormatTest.java \
+ java/core/src/test/java/com/google/protobuf/UnknownEnumValueTest.java \
+ java/core/src/test/java/com/google/protobuf/UnknownFieldSetLiteTest.java \
+ java/core/src/test/java/com/google/protobuf/UnknownFieldSetTest.java \
+ java/core/src/test/java/com/google/protobuf/UnmodifiableLazyStringListTest.java \
+ java/core/src/test/java/com/google/protobuf/WellKnownTypesTest.java \
+ java/core/src/test/java/com/google/protobuf/WireFormatTest.java \
+ java/core/src/test/proto/com/google/protobuf/any_test.proto \
+ java/core/src/test/proto/com/google/protobuf/field_presence_test.proto \
+ java/core/src/test/proto/com/google/protobuf/lazy_fields_lite.proto \
+ java/core/src/test/proto/com/google/protobuf/lite_equals_and_hash.proto \
+ java/core/src/test/proto/com/google/protobuf/map_for_proto2_lite_test.proto \
+ java/core/src/test/proto/com/google/protobuf/map_for_proto2_test.proto \
+ java/core/src/test/proto/com/google/protobuf/map_initialization_order_test.proto \
+ java/core/src/test/proto/com/google/protobuf/map_test.proto \
+ java/core/src/test/proto/com/google/protobuf/multiple_files_test.proto \
+ java/core/src/test/proto/com/google/protobuf/nested_builders_test.proto \
+ java/core/src/test/proto/com/google/protobuf/nested_extension.proto \
+ java/core/src/test/proto/com/google/protobuf/nested_extension_lite.proto \
+ java/core/src/test/proto/com/google/protobuf/non_nested_extension.proto \
+ java/core/src/test/proto/com/google/protobuf/non_nested_extension_lite.proto \
+ java/core/src/test/proto/com/google/protobuf/outer_class_name_test.proto \
+ java/core/src/test/proto/com/google/protobuf/outer_class_name_test2.proto \
+ java/core/src/test/proto/com/google/protobuf/outer_class_name_test3.proto \
+ java/core/src/test/proto/com/google/protobuf/test_bad_identifiers.proto \
+ java/core/src/test/proto/com/google/protobuf/test_check_utf8.proto \
+ java/core/src/test/proto/com/google/protobuf/test_check_utf8_size.proto \
+ java/core/src/test/proto/com/google/protobuf/test_custom_options.proto \
+ java/core/src/test/proto/com/google/protobuf/test_extra_interfaces.proto \
+ java/lite/pom.xml \
+ java/pom.xml \
+ java/util/pom.xml \
+ java/util/src/main/java/com/google/protobuf/util/FieldMaskTree.java \
+ java/util/src/main/java/com/google/protobuf/util/FieldMaskUtil.java \
+ java/util/src/main/java/com/google/protobuf/util/JsonFormat.java \
+ java/util/src/main/java/com/google/protobuf/util/TimeUtil.java \
+ java/util/src/test/java/com/google/protobuf/util/FieldMaskTreeTest.java \
+ java/util/src/test/java/com/google/protobuf/util/FieldMaskUtilTest.java \
+ java/util/src/test/java/com/google/protobuf/util/JsonFormatTest.java \
+ java/util/src/test/java/com/google/protobuf/util/TimeUtilTest.java \
+ java/util/src/test/proto/com/google/protobuf/util/json_test.proto
javanano_EXTRA_DIST= \
javanano/src/main/java/com/google/protobuf/nano/CodedOutputByteBufferNano.java \
diff --git a/Protobuf.podspec b/Protobuf.podspec
index 92ff2904..73a60222 100644
--- a/Protobuf.podspec
+++ b/Protobuf.podspec
@@ -5,7 +5,7 @@
# dependent projects use the :git notation to refer to the library.
Pod::Spec.new do |s|
s.name = 'Protobuf'
- s.version = '3.0.0-alpha-4.1'
+ s.version = '3.0.0-beta-2'
s.summary = 'Protocol Buffers v.3 runtime library for Objective-C.'
s.homepage = 'https://github.com/google/protobuf'
s.license = 'New BSD'
diff --git a/conformance/Makefile.am b/conformance/Makefile.am
index 9703101a..2a43113b 100644
--- a/conformance/Makefile.am
+++ b/conformance/Makefile.am
@@ -114,13 +114,13 @@ MAINTAINERCLEANFILES = \
Makefile.in
javac_middleman: ConformanceJava.java protoc_middleman $(other_language_protoc_outputs)
- jar=`ls ../java/util/target/*.jar` && javac -classpath ../java/target/classes:$$jar ConformanceJava.java com/google/protobuf/conformance/Conformance.java
+ jar=`ls ../java/util/target/*jar-with-dependencies.jar` && javac -classpath ../java/target/classes:$$jar ConformanceJava.java com/google/protobuf/conformance/Conformance.java
@touch javac_middleman
conformance-java: javac_middleman
@echo "Writing shortcut script conformance-java..."
@echo '#! /bin/sh' > conformance-java
- @jar=`ls ../java/util/target/*.jar` && echo java -classpath .:../java/target/classes:$$jar ConformanceJava '$$@' >> conformance-java
+ @jar=`ls ../java/util/target/*jar-with-dependencies.jar` && echo java -classpath .:../java/target/classes:$$jar ConformanceJava '$$@' >> conformance-java
@chmod +x conformance-java
# Currently the conformance code is alongside the rest of the C#
diff --git a/conformance/failure_list_csharp.txt b/conformance/failure_list_csharp.txt
index feb17689..a46cee47 100644
--- a/conformance/failure_list_csharp.txt
+++ b/conformance/failure_list_csharp.txt
@@ -1,89 +1,16 @@
-DurationProtoInputTooLarge.JsonOutput
-DurationProtoInputTooSmall.JsonOutput
-FieldMaskNumbersDontRoundTrip.JsonOutput
-FieldMaskPathsDontRoundTrip.JsonOutput
-FieldMaskTooManyUnderscore.JsonOutput
JsonInput.AnyWithValueForInteger.JsonOutput
JsonInput.AnyWithValueForJsonObject.JsonOutput
-JsonInput.BoolFieldAllCapitalFalse
-JsonInput.BoolFieldAllCapitalTrue
-JsonInput.BoolFieldCamelCaseFalse
-JsonInput.BoolFieldCamelCaseTrue
-JsonInput.BoolMapFieldKeyNotQuoted
-JsonInput.BytesFieldInvalidBase64Characters
-JsonInput.BytesFieldNoPadding
-JsonInput.DoubleFieldInfinityNotQuoted
-JsonInput.DoubleFieldNanNotQuoted
-JsonInput.DoubleFieldNegativeInfinityNotQuoted
-JsonInput.DoubleFieldTooLarge
-JsonInput.DoubleFieldTooSmall
-JsonInput.DurationHas3FractionalDigits.Validator
-JsonInput.DurationHas6FractionalDigits.Validator
-JsonInput.DurationHas9FractionalDigits.Validator
-JsonInput.DurationMaxValue.JsonOutput
-JsonInput.DurationMaxValue.ProtobufOutput
-JsonInput.DurationMinValue.JsonOutput
-JsonInput.DurationMinValue.ProtobufOutput
-JsonInput.EnumFieldNotQuoted
-JsonInput.EnumFieldNumericValueNonZero.JsonOutput
-JsonInput.EnumFieldNumericValueNonZero.ProtobufOutput
-JsonInput.EnumFieldNumericValueZero.JsonOutput
-JsonInput.EnumFieldNumericValueZero.ProtobufOutput
-JsonInput.EnumFieldUnknownValue.Validator
-JsonInput.FieldMaskInvalidCharacter
-JsonInput.FieldNameDuplicate
-JsonInput.FieldNameDuplicateDifferentCasing2
JsonInput.FieldNameInLowerCamelCase.Validator
JsonInput.FieldNameInSnakeCase.JsonOutput
JsonInput.FieldNameInSnakeCase.ProtobufOutput
-JsonInput.FieldNameNotQuoted
JsonInput.FieldNameWithMixedCases.JsonOutput
JsonInput.FieldNameWithMixedCases.ProtobufOutput
JsonInput.FieldNameWithMixedCases.Validator
-JsonInput.FloatFieldInfinityNotQuoted
-JsonInput.FloatFieldNanNotQuoted
-JsonInput.FloatFieldNegativeInfinityNotQuoted
-JsonInput.Int32FieldLeadingZero
JsonInput.Int32FieldMinFloatValue.JsonOutput
JsonInput.Int32FieldMinValue.JsonOutput
-JsonInput.Int32FieldNegativeWithLeadingZero
-JsonInput.Int32FieldPlusSign
-JsonInput.Int32MapFieldKeyNotQuoted
JsonInput.Int64FieldMaxValueNotQuoted.JsonOutput
JsonInput.Int64FieldMaxValueNotQuoted.ProtobufOutput
-JsonInput.Int64MapFieldKeyNotQuoted
-JsonInput.JsonWithComments
-JsonInput.MapFieldKeyIsNull
-JsonInput.MapFieldValueIsNull
-JsonInput.OneofFieldDuplicate
JsonInput.OriginalProtoFieldName.JsonOutput
-JsonInput.OriginalProtoFieldName.ProtobufOutput
-JsonInput.RepeatedBoolWrapper.ProtobufOutput
-JsonInput.RepeatedDoubleWrapper.ProtobufOutput
-JsonInput.RepeatedFieldMessageElementIsNull
-JsonInput.RepeatedFieldPrimitiveElementIsNull
-JsonInput.RepeatedFieldTrailingComma
-JsonInput.RepeatedFloatWrapper.ProtobufOutput
-JsonInput.RepeatedInt32Wrapper.ProtobufOutput
-JsonInput.RepeatedInt64Wrapper.ProtobufOutput
-JsonInput.RepeatedUint32Wrapper.ProtobufOutput
-JsonInput.RepeatedUint64Wrapper.ProtobufOutput
-JsonInput.StringFieldInvalidEscape
-JsonInput.StringFieldSurrogateInWrongOrder
JsonInput.StringFieldSurrogatePair.JsonOutput
-JsonInput.StringFieldUnpairedHighSurrogate
-JsonInput.StringFieldUnpairedLowSurrogate
-JsonInput.StringFieldUnterminatedEscape
-JsonInput.StringFieldUppercaseEscapeLetter
-JsonInput.TimestampHas3FractionalDigits.Validator
-JsonInput.TimestampHas6FractionalDigits.Validator
-JsonInput.TimestampHas9FractionalDigits.Validator
-JsonInput.TrailingCommaInAnObject
-JsonInput.Uint32MapFieldKeyNotQuoted
JsonInput.Uint64FieldMaxValueNotQuoted.JsonOutput
JsonInput.Uint64FieldMaxValueNotQuoted.ProtobufOutput
-JsonInput.Uint64MapFieldKeyNotQuoted
-JsonInput.ValueAcceptNull.JsonOutput
-JsonInput.ValueAcceptNull.ProtobufOutput
-TimestampProtoInputTooLarge.JsonOutput
-TimestampProtoInputTooSmall.JsonOutput
diff --git a/conformance/failure_list_python.txt b/conformance/failure_list_python.txt
index c9934598..d2e52637 100644
--- a/conformance/failure_list_python.txt
+++ b/conformance/failure_list_python.txt
@@ -3,11 +3,10 @@ DurationProtoInputTooSmall.JsonOutput
FieldMaskNumbersDontRoundTrip.JsonOutput
FieldMaskPathsDontRoundTrip.JsonOutput
FieldMaskTooManyUnderscore.JsonOutput
-JsonInput.AllFieldAcceptNull.JsonOutput
JsonInput.Any.JsonOutput
+JsonInput.Any.ProtobufOutput
JsonInput.AnyNested.JsonOutput
JsonInput.AnyNested.ProtobufOutput
-JsonInput.Any.ProtobufOutput
JsonInput.AnyUnorderedTypeTag.JsonOutput
JsonInput.AnyUnorderedTypeTag.ProtobufOutput
JsonInput.AnyWithDuration.JsonOutput
@@ -24,132 +23,50 @@ JsonInput.AnyWithValueForInteger.JsonOutput
JsonInput.AnyWithValueForInteger.ProtobufOutput
JsonInput.AnyWithValueForJsonObject.JsonOutput
JsonInput.AnyWithValueForJsonObject.ProtobufOutput
-JsonInput.BoolFieldFalse.JsonOutput
-JsonInput.BoolFieldTrue.JsonOutput
-JsonInput.BoolMapEscapedKey.JsonOutput
-JsonInput.BoolMapField.JsonOutput
JsonInput.BytesFieldInvalidBase64Characters
-JsonInput.BytesField.JsonOutput
-JsonInput.BytesRepeatedField.JsonOutput
-JsonInput.DoubleFieldInfinity.JsonOutput
JsonInput.DoubleFieldInfinityNotQuoted
-JsonInput.DoubleFieldMaxNegativeValue.JsonOutput
-JsonInput.DoubleFieldMaxPositiveValue.JsonOutput
-JsonInput.DoubleFieldMinNegativeValue.JsonOutput
-JsonInput.DoubleFieldMinPositiveValue.JsonOutput
-JsonInput.DoubleFieldNan.JsonOutput
JsonInput.DoubleFieldNanNotQuoted
-JsonInput.DoubleFieldNegativeInfinity.JsonOutput
JsonInput.DoubleFieldNegativeInfinityNotQuoted
-JsonInput.DoubleFieldQuotedValue.JsonOutput
JsonInput.DoubleFieldTooSmall
JsonInput.DurationJsonInputTooLarge
JsonInput.DurationJsonInputTooSmall
-JsonInput.DurationMaxValue.JsonOutput
-JsonInput.DurationMinValue.JsonOutput
JsonInput.DurationMissingS
-JsonInput.DurationRepeatedValue.JsonOutput
-JsonInput.EnumField.JsonOutput
JsonInput.EnumFieldNumericValueNonZero.JsonOutput
JsonInput.EnumFieldNumericValueNonZero.ProtobufOutput
JsonInput.EnumFieldNumericValueZero.JsonOutput
JsonInput.EnumFieldNumericValueZero.ProtobufOutput
JsonInput.EnumFieldUnknownValue.Validator
-JsonInput.EnumRepeatedField.JsonOutput
-JsonInput.FieldMaskInvalidCharacter
-JsonInput.FieldMask.JsonOutput
JsonInput.FieldMask.ProtobufOutput
-JsonInput.FieldNameEscaped.JsonOutput
+JsonInput.FieldMaskInvalidCharacter
JsonInput.FieldNameInLowerCamelCase.Validator
JsonInput.FieldNameInSnakeCase.JsonOutput
JsonInput.FieldNameInSnakeCase.ProtobufOutput
-JsonInput.FieldNameWithMixedCases.JsonOutput
-JsonInput.FieldNameWithNumbers.JsonOutput
-JsonInput.FloatFieldInfinity.JsonOutput
JsonInput.FloatFieldInfinityNotQuoted
-JsonInput.FloatFieldMaxNegativeValue.JsonOutput
-JsonInput.FloatFieldMaxPositiveValue.JsonOutput
-JsonInput.FloatFieldMinNegativeValue.JsonOutput
-JsonInput.FloatFieldMinPositiveValue.JsonOutput
-JsonInput.FloatFieldNan.JsonOutput
JsonInput.FloatFieldNanNotQuoted
-JsonInput.FloatFieldNegativeInfinity.JsonOutput
JsonInput.FloatFieldNegativeInfinityNotQuoted
-JsonInput.FloatFieldQuotedValue.JsonOutput
JsonInput.FloatFieldTooLarge
JsonInput.FloatFieldTooSmall
-JsonInput.HelloWorld.JsonOutput
JsonInput.Int32FieldExponentialFormat.JsonOutput
JsonInput.Int32FieldExponentialFormat.ProtobufOutput
JsonInput.Int32FieldFloatTrailingZero.JsonOutput
JsonInput.Int32FieldFloatTrailingZero.ProtobufOutput
JsonInput.Int32FieldMaxFloatValue.JsonOutput
JsonInput.Int32FieldMaxFloatValue.ProtobufOutput
-JsonInput.Int32FieldMaxValue.JsonOutput
JsonInput.Int32FieldMinFloatValue.JsonOutput
JsonInput.Int32FieldMinFloatValue.ProtobufOutput
JsonInput.Int32FieldMinValue.JsonOutput
-JsonInput.Int32FieldStringValueEscaped.JsonOutput
-JsonInput.Int32FieldStringValue.JsonOutput
-JsonInput.Int32MapEscapedKey.JsonOutput
-JsonInput.Int32MapField.JsonOutput
-JsonInput.Int64FieldMaxValue.JsonOutput
-JsonInput.Int64FieldMaxValueNotQuoted.JsonOutput
-JsonInput.Int64FieldMinValue.JsonOutput
-JsonInput.Int64FieldMinValueNotQuoted.JsonOutput
-JsonInput.Int64MapEscapedKey.JsonOutput
-JsonInput.Int64MapField.JsonOutput
-JsonInput.MessageField.JsonOutput
-JsonInput.MessageMapField.JsonOutput
-JsonInput.MessageRepeatedField.JsonOutput
-JsonInput.OptionalBoolWrapper.JsonOutput
-JsonInput.OptionalBytesWrapper.JsonOutput
-JsonInput.OptionalDoubleWrapper.JsonOutput
-JsonInput.OptionalFloatWrapper.JsonOutput
-JsonInput.OptionalInt32Wrapper.JsonOutput
-JsonInput.OptionalInt64Wrapper.JsonOutput
-JsonInput.OptionalStringWrapper.JsonOutput
-JsonInput.OptionalUint32Wrapper.JsonOutput
-JsonInput.OptionalUint64Wrapper.JsonOutput
-JsonInput.OptionalWrapperTypesWithNonDefaultValue.JsonOutput
JsonInput.OriginalProtoFieldName.JsonOutput
JsonInput.OriginalProtoFieldName.ProtobufOutput
-JsonInput.PrimitiveRepeatedField.JsonOutput
-JsonInput.RepeatedBoolWrapper.JsonOutput
-JsonInput.RepeatedBytesWrapper.JsonOutput
-JsonInput.RepeatedDoubleWrapper.JsonOutput
JsonInput.RepeatedFieldMessageElementIsNull
JsonInput.RepeatedFieldPrimitiveElementIsNull
JsonInput.RepeatedFieldWrongElementTypeExpectingIntegersGotBool
-JsonInput.RepeatedFloatWrapper.JsonOutput
-JsonInput.RepeatedInt32Wrapper.JsonOutput
-JsonInput.RepeatedInt64Wrapper.JsonOutput
-JsonInput.RepeatedStringWrapper.JsonOutput
-JsonInput.RepeatedUint32Wrapper.JsonOutput
-JsonInput.RepeatedUint64Wrapper.JsonOutput
-JsonInput.StringFieldEscape.JsonOutput
-JsonInput.StringField.JsonOutput
JsonInput.StringFieldSurrogatePair.JsonOutput
-JsonInput.StringFieldUnicodeEscape.JsonOutput
-JsonInput.StringFieldUnicodeEscapeWithLowercaseHexLetters.JsonOutput
-JsonInput.StringFieldUnicode.JsonOutput
JsonInput.StringFieldUnpairedLowSurrogate
-JsonInput.StringRepeatedField.JsonOutput
JsonInput.Struct.JsonOutput
JsonInput.Struct.ProtobufOutput
JsonInput.TimestampJsonInputLowercaseT
-JsonInput.TimestampMaxValue.JsonOutput
-JsonInput.TimestampMinValue.JsonOutput
-JsonInput.TimestampRepeatedValue.JsonOutput
-JsonInput.TimestampWithNegativeOffset.JsonOutput
-JsonInput.TimestampWithPositiveOffset.JsonOutput
JsonInput.Uint32FieldMaxFloatValue.JsonOutput
JsonInput.Uint32FieldMaxFloatValue.ProtobufOutput
-JsonInput.Uint32FieldMaxValue.JsonOutput
-JsonInput.Uint32MapField.JsonOutput
-JsonInput.Uint64FieldMaxValue.JsonOutput
-JsonInput.Uint64FieldMaxValueNotQuoted.JsonOutput
-JsonInput.Uint64MapField.JsonOutput
JsonInput.ValueAcceptBool.JsonOutput
JsonInput.ValueAcceptBool.ProtobufOutput
JsonInput.ValueAcceptFloat.JsonOutput
@@ -164,10 +81,5 @@ JsonInput.ValueAcceptObject.JsonOutput
JsonInput.ValueAcceptObject.ProtobufOutput
JsonInput.ValueAcceptString.JsonOutput
JsonInput.ValueAcceptString.ProtobufOutput
-JsonInput.WrapperTypesWithNullValue.JsonOutput
-ProtobufInput.DoubleFieldNormalizeQuietNan.JsonOutput
-ProtobufInput.DoubleFieldNormalizeSignalingNan.JsonOutput
-ProtobufInput.FloatFieldNormalizeQuietNan.JsonOutput
-ProtobufInput.FloatFieldNormalizeSignalingNan.JsonOutput
TimestampProtoInputTooLarge.JsonOutput
TimestampProtoInputTooSmall.JsonOutput
diff --git a/conformance/failure_list_python_cpp.txt b/conformance/failure_list_python_cpp.txt
index 9c710e99..7b5e45f9 100644
--- a/conformance/failure_list_python_cpp.txt
+++ b/conformance/failure_list_python_cpp.txt
@@ -12,11 +12,10 @@ DurationProtoInputTooSmall.JsonOutput
FieldMaskNumbersDontRoundTrip.JsonOutput
FieldMaskPathsDontRoundTrip.JsonOutput
FieldMaskTooManyUnderscore.JsonOutput
-JsonInput.AllFieldAcceptNull.JsonOutput
JsonInput.Any.JsonOutput
+JsonInput.Any.ProtobufOutput
JsonInput.AnyNested.JsonOutput
JsonInput.AnyNested.ProtobufOutput
-JsonInput.Any.ProtobufOutput
JsonInput.AnyUnorderedTypeTag.JsonOutput
JsonInput.AnyUnorderedTypeTag.ProtobufOutput
JsonInput.AnyWithDuration.JsonOutput
@@ -33,132 +32,50 @@ JsonInput.AnyWithValueForInteger.JsonOutput
JsonInput.AnyWithValueForInteger.ProtobufOutput
JsonInput.AnyWithValueForJsonObject.JsonOutput
JsonInput.AnyWithValueForJsonObject.ProtobufOutput
-JsonInput.BoolFieldFalse.JsonOutput
-JsonInput.BoolFieldTrue.JsonOutput
-JsonInput.BoolMapEscapedKey.JsonOutput
-JsonInput.BoolMapField.JsonOutput
JsonInput.BytesFieldInvalidBase64Characters
-JsonInput.BytesField.JsonOutput
-JsonInput.BytesRepeatedField.JsonOutput
-JsonInput.DoubleFieldInfinity.JsonOutput
JsonInput.DoubleFieldInfinityNotQuoted
-JsonInput.DoubleFieldMaxNegativeValue.JsonOutput
-JsonInput.DoubleFieldMaxPositiveValue.JsonOutput
-JsonInput.DoubleFieldMinNegativeValue.JsonOutput
-JsonInput.DoubleFieldMinPositiveValue.JsonOutput
-JsonInput.DoubleFieldNan.JsonOutput
JsonInput.DoubleFieldNanNotQuoted
-JsonInput.DoubleFieldNegativeInfinity.JsonOutput
JsonInput.DoubleFieldNegativeInfinityNotQuoted
-JsonInput.DoubleFieldQuotedValue.JsonOutput
JsonInput.DoubleFieldTooSmall
JsonInput.DurationJsonInputTooLarge
JsonInput.DurationJsonInputTooSmall
-JsonInput.DurationMaxValue.JsonOutput
-JsonInput.DurationMinValue.JsonOutput
JsonInput.DurationMissingS
-JsonInput.DurationRepeatedValue.JsonOutput
-JsonInput.EnumField.JsonOutput
JsonInput.EnumFieldNumericValueNonZero.JsonOutput
JsonInput.EnumFieldNumericValueNonZero.ProtobufOutput
JsonInput.EnumFieldNumericValueZero.JsonOutput
JsonInput.EnumFieldNumericValueZero.ProtobufOutput
JsonInput.EnumFieldUnknownValue.Validator
-JsonInput.EnumRepeatedField.JsonOutput
-JsonInput.FieldMaskInvalidCharacter
-JsonInput.FieldMask.JsonOutput
JsonInput.FieldMask.ProtobufOutput
-JsonInput.FieldNameEscaped.JsonOutput
+JsonInput.FieldMaskInvalidCharacter
JsonInput.FieldNameInLowerCamelCase.Validator
JsonInput.FieldNameInSnakeCase.JsonOutput
JsonInput.FieldNameInSnakeCase.ProtobufOutput
-JsonInput.FieldNameWithMixedCases.JsonOutput
-JsonInput.FieldNameWithNumbers.JsonOutput
-JsonInput.FloatFieldInfinity.JsonOutput
JsonInput.FloatFieldInfinityNotQuoted
-JsonInput.FloatFieldMaxNegativeValue.JsonOutput
-JsonInput.FloatFieldMaxPositiveValue.JsonOutput
-JsonInput.FloatFieldMinNegativeValue.JsonOutput
-JsonInput.FloatFieldMinPositiveValue.JsonOutput
-JsonInput.FloatFieldNan.JsonOutput
JsonInput.FloatFieldNanNotQuoted
-JsonInput.FloatFieldNegativeInfinity.JsonOutput
JsonInput.FloatFieldNegativeInfinityNotQuoted
-JsonInput.FloatFieldQuotedValue.JsonOutput
JsonInput.FloatFieldTooLarge
JsonInput.FloatFieldTooSmall
-JsonInput.HelloWorld.JsonOutput
JsonInput.Int32FieldExponentialFormat.JsonOutput
JsonInput.Int32FieldExponentialFormat.ProtobufOutput
JsonInput.Int32FieldFloatTrailingZero.JsonOutput
JsonInput.Int32FieldFloatTrailingZero.ProtobufOutput
JsonInput.Int32FieldMaxFloatValue.JsonOutput
JsonInput.Int32FieldMaxFloatValue.ProtobufOutput
-JsonInput.Int32FieldMaxValue.JsonOutput
JsonInput.Int32FieldMinFloatValue.JsonOutput
JsonInput.Int32FieldMinFloatValue.ProtobufOutput
JsonInput.Int32FieldMinValue.JsonOutput
-JsonInput.Int32FieldStringValueEscaped.JsonOutput
-JsonInput.Int32FieldStringValue.JsonOutput
-JsonInput.Int32MapEscapedKey.JsonOutput
-JsonInput.Int32MapField.JsonOutput
-JsonInput.Int64FieldMaxValue.JsonOutput
-JsonInput.Int64FieldMaxValueNotQuoted.JsonOutput
-JsonInput.Int64FieldMinValue.JsonOutput
-JsonInput.Int64FieldMinValueNotQuoted.JsonOutput
-JsonInput.Int64MapEscapedKey.JsonOutput
-JsonInput.Int64MapField.JsonOutput
-JsonInput.MessageField.JsonOutput
-JsonInput.MessageMapField.JsonOutput
-JsonInput.MessageRepeatedField.JsonOutput
-JsonInput.OptionalBoolWrapper.JsonOutput
-JsonInput.OptionalBytesWrapper.JsonOutput
-JsonInput.OptionalDoubleWrapper.JsonOutput
-JsonInput.OptionalFloatWrapper.JsonOutput
-JsonInput.OptionalInt32Wrapper.JsonOutput
-JsonInput.OptionalInt64Wrapper.JsonOutput
-JsonInput.OptionalStringWrapper.JsonOutput
-JsonInput.OptionalUint32Wrapper.JsonOutput
-JsonInput.OptionalUint64Wrapper.JsonOutput
-JsonInput.OptionalWrapperTypesWithNonDefaultValue.JsonOutput
JsonInput.OriginalProtoFieldName.JsonOutput
JsonInput.OriginalProtoFieldName.ProtobufOutput
-JsonInput.PrimitiveRepeatedField.JsonOutput
-JsonInput.RepeatedBoolWrapper.JsonOutput
-JsonInput.RepeatedBytesWrapper.JsonOutput
-JsonInput.RepeatedDoubleWrapper.JsonOutput
JsonInput.RepeatedFieldMessageElementIsNull
JsonInput.RepeatedFieldPrimitiveElementIsNull
JsonInput.RepeatedFieldWrongElementTypeExpectingIntegersGotBool
-JsonInput.RepeatedFloatWrapper.JsonOutput
-JsonInput.RepeatedInt32Wrapper.JsonOutput
-JsonInput.RepeatedInt64Wrapper.JsonOutput
-JsonInput.RepeatedStringWrapper.JsonOutput
-JsonInput.RepeatedUint32Wrapper.JsonOutput
-JsonInput.RepeatedUint64Wrapper.JsonOutput
-JsonInput.StringFieldEscape.JsonOutput
-JsonInput.StringField.JsonOutput
JsonInput.StringFieldSurrogatePair.JsonOutput
-JsonInput.StringFieldUnicodeEscape.JsonOutput
-JsonInput.StringFieldUnicodeEscapeWithLowercaseHexLetters.JsonOutput
-JsonInput.StringFieldUnicode.JsonOutput
JsonInput.StringFieldUnpairedLowSurrogate
-JsonInput.StringRepeatedField.JsonOutput
JsonInput.Struct.JsonOutput
JsonInput.Struct.ProtobufOutput
JsonInput.TimestampJsonInputLowercaseT
-JsonInput.TimestampMaxValue.JsonOutput
-JsonInput.TimestampMinValue.JsonOutput
-JsonInput.TimestampRepeatedValue.JsonOutput
-JsonInput.TimestampWithNegativeOffset.JsonOutput
-JsonInput.TimestampWithPositiveOffset.JsonOutput
JsonInput.Uint32FieldMaxFloatValue.JsonOutput
JsonInput.Uint32FieldMaxFloatValue.ProtobufOutput
-JsonInput.Uint32FieldMaxValue.JsonOutput
-JsonInput.Uint32MapField.JsonOutput
-JsonInput.Uint64FieldMaxValue.JsonOutput
-JsonInput.Uint64FieldMaxValueNotQuoted.JsonOutput
-JsonInput.Uint64MapField.JsonOutput
JsonInput.ValueAcceptBool.JsonOutput
JsonInput.ValueAcceptBool.ProtobufOutput
JsonInput.ValueAcceptFloat.JsonOutput
@@ -173,11 +90,6 @@ JsonInput.ValueAcceptObject.JsonOutput
JsonInput.ValueAcceptObject.ProtobufOutput
JsonInput.ValueAcceptString.JsonOutput
JsonInput.ValueAcceptString.ProtobufOutput
-JsonInput.WrapperTypesWithNullValue.JsonOutput
-ProtobufInput.DoubleFieldNormalizeQuietNan.JsonOutput
-ProtobufInput.DoubleFieldNormalizeSignalingNan.JsonOutput
-ProtobufInput.FloatFieldNormalizeQuietNan.JsonOutput
-ProtobufInput.FloatFieldNormalizeSignalingNan.JsonOutput
ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE
ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE
ProtobufInput.PrematureEofInPackedField.BOOL
diff --git a/csharp/src/Google.Protobuf.Conformance/Program.cs b/csharp/src/Google.Protobuf.Conformance/Program.cs
index 8f72c8f9..f3f7e295 100644
--- a/csharp/src/Google.Protobuf.Conformance/Program.cs
+++ b/csharp/src/Google.Protobuf.Conformance/Program.cs
@@ -101,15 +101,26 @@ namespace Google.Protobuf.Conformance
{
return new ConformanceResponse { ParseError = e.Message };
}
- switch (request.RequestedOutputFormat)
+ catch (InvalidJsonException e)
{
- case global::Conformance.WireFormat.JSON:
- var formatter = new JsonFormatter(new JsonFormatter.Settings(false, typeRegistry));
- return new ConformanceResponse { JsonPayload = formatter.Format(message) };
- case global::Conformance.WireFormat.PROTOBUF:
- return new ConformanceResponse { ProtobufPayload = message.ToByteString() };
- default:
- throw new Exception("Unsupported request output format: " + request.PayloadCase);
+ return new ConformanceResponse { ParseError = e.Message };
+ }
+ try
+ {
+ switch (request.RequestedOutputFormat)
+ {
+ case global::Conformance.WireFormat.JSON:
+ var formatter = new JsonFormatter(new JsonFormatter.Settings(false, typeRegistry));
+ return new ConformanceResponse { JsonPayload = formatter.Format(message) };
+ case global::Conformance.WireFormat.PROTOBUF:
+ return new ConformanceResponse { ProtobufPayload = message.ToByteString() };
+ default:
+ throw new Exception("Unsupported request output format: " + request.PayloadCase);
+ }
+ }
+ catch (InvalidOperationException e)
+ {
+ return new ConformanceResponse { SerializeError = e.Message };
}
}
diff --git a/csharp/src/Google.Protobuf.Test/JsonFormatterTest.cs b/csharp/src/Google.Protobuf.Test/JsonFormatterTest.cs
index ace70b00..9e994a6a 100644
--- a/csharp/src/Google.Protobuf.Test/JsonFormatterTest.cs
+++ b/csharp/src/Google.Protobuf.Test/JsonFormatterTest.cs
@@ -165,34 +165,31 @@ namespace Google.Protobuf
}
[Test]
- public void UnknownEnumValueOmitted_SingleField()
+ public void UnknownEnumValueNumeric_SingleField()
{
var message = new TestAllTypes { SingleForeignEnum = (ForeignEnum) 100 };
- AssertJson("{ }", JsonFormatter.Default.Format(message));
+ AssertJson("{ 'singleForeignEnum': 100 }", JsonFormatter.Default.Format(message));
}
[Test]
- public void UnknownEnumValueOmitted_RepeatedField()
+ public void UnknownEnumValueNumeric_RepeatedField()
{
var message = new TestAllTypes { RepeatedForeignEnum = { ForeignEnum.FOREIGN_BAZ, (ForeignEnum) 100, ForeignEnum.FOREIGN_FOO } };
- AssertJson("{ 'repeatedForeignEnum': [ 'FOREIGN_BAZ', 'FOREIGN_FOO' ] }", JsonFormatter.Default.Format(message));
+ AssertJson("{ 'repeatedForeignEnum': [ 'FOREIGN_BAZ', 100, 'FOREIGN_FOO' ] }", JsonFormatter.Default.Format(message));
}
[Test]
- public void UnknownEnumValueOmitted_MapField()
+ public void UnknownEnumValueNumeric_MapField()
{
- // This matches the C++ behaviour.
var message = new TestMap { MapInt32Enum = { { 1, MapEnum.MAP_ENUM_FOO }, { 2, (MapEnum) 100 }, { 3, MapEnum.MAP_ENUM_BAR } } };
- AssertJson("{ 'mapInt32Enum': { '1': 'MAP_ENUM_FOO', '3': 'MAP_ENUM_BAR' } }", JsonFormatter.Default.Format(message));
+ AssertJson("{ 'mapInt32Enum': { '1': 'MAP_ENUM_FOO', '2': 100, '3': 'MAP_ENUM_BAR' } }", JsonFormatter.Default.Format(message));
}
[Test]
- public void UnknownEnumValueOmitted_RepeatedField_AllEntriesUnknown()
+ public void UnknownEnumValue_RepeatedField_AllEntriesUnknown()
{
- // *Maybe* we should hold off on writing the "[" until we find that we've got at least one value to write...
- // but this is what happens at the moment, and it doesn't seem too awful.
var message = new TestAllTypes { RepeatedForeignEnum = { (ForeignEnum) 200, (ForeignEnum) 100 } };
- AssertJson("{ 'repeatedForeignEnum': [ ] }", JsonFormatter.Default.Format(message));
+ AssertJson("{ 'repeatedForeignEnum': [ 200, 100 ] }", JsonFormatter.Default.Format(message));
}
[Test]
@@ -315,6 +312,15 @@ namespace Google.Protobuf
[Test]
[TestCase("1970-01-01T00:00:00Z", 0)]
+ [TestCase("1970-01-01T00:00:00.000000001Z", 1)]
+ [TestCase("1970-01-01T00:00:00.000000010Z", 10)]
+ [TestCase("1970-01-01T00:00:00.000000100Z", 100)]
+ [TestCase("1970-01-01T00:00:00.000001Z", 1000)]
+ [TestCase("1970-01-01T00:00:00.000010Z", 10000)]
+ [TestCase("1970-01-01T00:00:00.000100Z", 100000)]
+ [TestCase("1970-01-01T00:00:00.001Z", 1000000)]
+ [TestCase("1970-01-01T00:00:00.010Z", 10000000)]
+ [TestCase("1970-01-01T00:00:00.100Z", 100000000)]
[TestCase("1970-01-01T00:00:00.100Z", 100000000)]
[TestCase("1970-01-01T00:00:00.120Z", 120000000)]
[TestCase("1970-01-01T00:00:00.123Z", 123000000)]
@@ -350,6 +356,14 @@ namespace Google.Protobuf
[TestCase(0, 0, "0s")]
[TestCase(1, 0, "1s")]
[TestCase(-1, 0, "-1s")]
+ [TestCase(0, 1, "0.000000001s")]
+ [TestCase(0, 10, "0.000000010s")]
+ [TestCase(0, 100, "0.000000100s")]
+ [TestCase(0, 1000, "0.000001s")]
+ [TestCase(0, 10000, "0.000010s")]
+ [TestCase(0, 100000, "0.000100s")]
+ [TestCase(0, 1000000, "0.001s")]
+ [TestCase(0, 10000000, "0.010s")]
[TestCase(0, 100000000, "0.100s")]
[TestCase(0, 120000000, "0.120s")]
[TestCase(0, 123000000, "0.123s")]
@@ -362,15 +376,20 @@ namespace Google.Protobuf
[TestCase(0, -100000000, "-0.100s")]
[TestCase(1, 100000000, "1.100s")]
[TestCase(-1, -100000000, "-1.100s")]
- // Non-normalized examples
- [TestCase(1, 2123456789, "3.123456789s")]
- [TestCase(1, -100000000, "0.900s")]
public void DurationStandalone(long seconds, int nanoseconds, string expected)
{
Assert.AreEqual(WrapInQuotes(expected), new Duration { Seconds = seconds, Nanos = nanoseconds }.ToString());
}
[Test]
+ [TestCase(1, 2123456789)]
+ [TestCase(1, -100000000)]
+ public void DurationStandalone_NonNormalized(long seconds, int nanoseconds)
+ {
+ Assert.Throws<InvalidOperationException>(() => new Duration { Seconds = seconds, Nanos = nanoseconds }.ToString());
+ }
+
+ [Test]
public void DurationField()
{
var message = new TestWellKnownTypes { DurationField = new Duration() };
@@ -396,6 +415,16 @@ namespace Google.Protobuf
}
[Test]
+ [TestCase("foo__bar")]
+ [TestCase("foo_3_ar")]
+ [TestCase("fooBar")]
+ public void FieldMaskInvalid(string input)
+ {
+ var mask = new FieldMask { Paths = { input } };
+ Assert.Throws<InvalidOperationException>(() => JsonFormatter.Default.Format(mask));
+ }
+
+ [Test]
public void FieldMaskStandalone()
{
var fieldMask = new FieldMask { Paths = { "", "single", "with_underscore", "nested.field.name", "nested..double_dot" } };
diff --git a/csharp/src/Google.Protobuf.Test/JsonParserTest.cs b/csharp/src/Google.Protobuf.Test/JsonParserTest.cs
index 4443ab4a..c4f6dfb4 100644
--- a/csharp/src/Google.Protobuf.Test/JsonParserTest.cs
+++ b/csharp/src/Google.Protobuf.Test/JsonParserTest.cs
@@ -72,6 +72,14 @@ namespace Google.Protobuf
}
[Test]
+ public void OriginalFieldNameAccepted()
+ {
+ var json = "{ \"single_int32\": 10 }";
+ var expected = new TestAllTypes { SingleInt32 = 10 };
+ Assert.AreEqual(expected, TestAllTypes.Parser.ParseJson(json));
+ }
+
+ [Test]
public void SourceContextRoundtrip()
{
AssertRoundtrip(new SourceContext { FileName = "foo.proto" });
@@ -116,7 +124,9 @@ namespace Google.Protobuf
[Test]
public void SingularWrappers_ExplicitNulls()
{
- var message = new TestWellKnownTypes();
+ // When we parse the "valueField": null part, we remember it... basically, it's one case
+ // where explicit default values don't fully roundtrip.
+ var message = new TestWellKnownTypes { ValueField = Value.ForNull() };
var json = new JsonFormatter(new JsonFormatter.Settings(true)).Format(message);
var parsed = JsonParser.Default.Parse<TestWellKnownTypes>(json);
Assert.AreEqual(message, parsed);
@@ -143,6 +153,14 @@ namespace Google.Protobuf
}
[Test]
+ public void ExplicitNullValue()
+ {
+ string json = "{\"valueField\": null}";
+ var message = JsonParser.Default.Parse<TestWellKnownTypes>(json);
+ Assert.AreEqual(new TestWellKnownTypes { ValueField = Value.ForNull() }, message);
+ }
+
+ [Test]
public void BytesWrapper_Standalone()
{
ByteString data = ByteString.CopyFrom(1, 2, 3);
@@ -171,6 +189,36 @@ namespace Google.Protobuf
}
[Test]
+ public void RepeatedField_NullElementProhibited()
+ {
+ string json = "{ \"repeated_foreign_message\": [null] }";
+ Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseJson(json));
+ }
+
+ [Test]
+ public void RepeatedField_NullOverallValueAllowed()
+ {
+ string json = "{ \"repeated_foreign_message\": null }";
+ Assert.AreEqual(new TestAllTypes(), TestAllTypes.Parser.ParseJson(json));
+ }
+
+ [Test]
+ [TestCase("{ \"mapInt32Int32\": { \"10\": null }")]
+ [TestCase("{ \"mapStringString\": { \"abc\": null }")]
+ [TestCase("{ \"mapInt32ForeignMessage\": { \"10\": null }")]
+ public void MapField_NullValueProhibited(string json)
+ {
+ Assert.Throws<InvalidProtocolBufferException>(() => TestMap.Parser.ParseJson(json));
+ }
+
+ [Test]
+ public void MapField_NullOverallValueAllowed()
+ {
+ string json = "{ \"mapInt32Int32\": null }";
+ Assert.AreEqual(new TestMap(), TestMap.Parser.ParseJson(json));
+ }
+
+ [Test]
public void IndividualWrapperTypes()
{
Assert.AreEqual(new StringValue { Value = "foo" }, StringValue.Parser.ParseJson("\"foo\""));
@@ -715,7 +763,6 @@ namespace Google.Protobuf
[TestCase("--0.123456789s", Description = "Double minus sign")]
// Violate upper/lower bounds in various ways
[TestCase("315576000001s", Description = "Integer part too large")]
- [TestCase("315576000000.000000001s", Description = "Integer part is upper bound; non-zero fraction")]
[TestCase("3155760000000s", Description = "Integer part too long (positive)")]
[TestCase("-3155760000000s", Description = "Integer part too long (negative)")]
public void Duration_Invalid(string jsonValue)
@@ -742,6 +789,14 @@ namespace Google.Protobuf
}
[Test]
+ [TestCase("foo_bar")]
+ public void FieldMask_Invalid(string jsonValue)
+ {
+ string json = WrapInQuotes(jsonValue);
+ Assert.Throws<InvalidProtocolBufferException>(() => FieldMask.Parser.ParseJson(json));
+ }
+
+ [Test]
public void Any_RegularMessage()
{
var registry = TypeRegistry.FromMessages(TestAllTypes.Descriptor);
@@ -763,6 +818,13 @@ namespace Google.Protobuf
}
[Test]
+ public void Any_NoTypeUrl()
+ {
+ string json = "{ \"foo\": \"bar\" }";
+ Assert.Throws<InvalidProtocolBufferException>(() => Any.Parser.ParseJson(json));
+ }
+
+ [Test]
public void Any_WellKnownType()
{
var registry = TypeRegistry.FromMessages(Timestamp.Descriptor);
@@ -814,6 +876,42 @@ namespace Google.Protobuf
Assert.Throws<InvalidProtocolBufferException>(() => parser63.Parse<TestRecursiveMessage>(data64));
}
+ [Test]
+ [TestCase("AQI")]
+ [TestCase("_-==")]
+ public void Bytes_InvalidBase64(string badBase64)
+ {
+ string json = "{ \"singleBytes\": \"" + badBase64 + "\" }";
+ Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseJson(json));
+ }
+
+ [Test]
+ [TestCase("\"FOREIGN_BAR\"", ForeignEnum.FOREIGN_BAR)]
+ [TestCase("5", ForeignEnum.FOREIGN_BAR)]
+ [TestCase("100", (ForeignEnum) 100)]
+ public void EnumValid(string value, ForeignEnum expectedValue)
+ {
+ string json = "{ \"singleForeignEnum\": " + value + " }";
+ var parsed = TestAllTypes.Parser.ParseJson(json);
+ Assert.AreEqual(new TestAllTypes { SingleForeignEnum = expectedValue }, parsed);
+ }
+
+ [Test]
+ [TestCase("\"NOT_A_VALID_VALUE\"")]
+ [TestCase("5.5")]
+ public void Enum_Invalid(string value)
+ {
+ string json = "{ \"singleForeignEnum\": " + value + " }";
+ Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseJson(json));
+ }
+
+ [Test]
+ public void OneofDuplicate_Invalid()
+ {
+ string json = "{ \"oneofString\": \"x\", \"oneofUint32\": 10 }";
+ Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseJson(json));
+ }
+
/// <summary>
/// Various tests use strings which have quotes round them for parsing or as the result
/// of formatting, but without those quotes being specified in the tests (for the sake of readability).
diff --git a/csharp/src/Google.Protobuf.Test/TestProtos/UnittestWellKnownTypes.cs b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestWellKnownTypes.cs
index dfada6bd..2079a960 100644
--- a/csharp/src/Google.Protobuf.Test/TestProtos/UnittestWellKnownTypes.cs
+++ b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestWellKnownTypes.cs
@@ -31,7 +31,7 @@ namespace Google.Protobuf.TestProtos {
"L3Byb3RvYnVmL3NvdXJjZV9jb250ZXh0LnByb3RvGhxnb29nbGUvcHJvdG9i",
"dWYvc3RydWN0LnByb3RvGh9nb29nbGUvcHJvdG9idWYvdGltZXN0YW1wLnBy",
"b3RvGhpnb29nbGUvcHJvdG9idWYvdHlwZS5wcm90bxoeZ29vZ2xlL3Byb3Rv",
- "YnVmL3dyYXBwZXJzLnByb3RvIpEHChJUZXN0V2VsbEtub3duVHlwZXMSJwoJ",
+ "YnVmL3dyYXBwZXJzLnByb3RvIr4HChJUZXN0V2VsbEtub3duVHlwZXMSJwoJ",
"YW55X2ZpZWxkGAEgASgLMhQuZ29vZ2xlLnByb3RvYnVmLkFueRInCglhcGlf",
"ZmllbGQYAiABKAsyFC5nb29nbGUucHJvdG9idWYuQXBpEjEKDmR1cmF0aW9u",
"X2ZpZWxkGAMgASgLMhkuZ29vZ2xlLnByb3RvYnVmLkR1cmF0aW9uEisKC2Vt",
@@ -51,7 +51,8 @@ namespace Google.Protobuf.TestProtos {
"cm90b2J1Zi5VSW50MzJWYWx1ZRIuCgpib29sX2ZpZWxkGBAgASgLMhouZ29v",
"Z2xlLnByb3RvYnVmLkJvb2xWYWx1ZRIyCgxzdHJpbmdfZmllbGQYESABKAsy",
"HC5nb29nbGUucHJvdG9idWYuU3RyaW5nVmFsdWUSMAoLYnl0ZXNfZmllbGQY",
- "EiABKAsyGy5nb29nbGUucHJvdG9idWYuQnl0ZXNWYWx1ZSKVBwoWUmVwZWF0",
+ "EiABKAsyGy5nb29nbGUucHJvdG9idWYuQnl0ZXNWYWx1ZRIrCgt2YWx1ZV9m",
+ "aWVsZBgTIAEoCzIWLmdvb2dsZS5wcm90b2J1Zi5WYWx1ZSKVBwoWUmVwZWF0",
"ZWRXZWxsS25vd25UeXBlcxInCglhbnlfZmllbGQYASADKAsyFC5nb29nbGUu",
"cHJvdG9idWYuQW55EicKCWFwaV9maWVsZBgCIAMoCzIULmdvb2dsZS5wcm90",
"b2J1Zi5BcGkSMQoOZHVyYXRpb25fZmllbGQYAyADKAsyGS5nb29nbGUucHJv",
@@ -162,7 +163,7 @@ namespace Google.Protobuf.TestProtos {
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { global::Google.Protobuf.WellKnownTypes.AnyReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.ApiReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.DurationReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.EmptyReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.FieldMaskReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.SourceContextReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.StructReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.TimestampReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.TypeReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.WrappersReflection.Descriptor, },
new pbr::GeneratedCodeInfo(null, new pbr::GeneratedCodeInfo[] {
- new pbr::GeneratedCodeInfo(typeof(global::Google.Protobuf.TestProtos.TestWellKnownTypes), global::Google.Protobuf.TestProtos.TestWellKnownTypes.Parser, new[]{ "AnyField", "ApiField", "DurationField", "EmptyField", "FieldMaskField", "SourceContextField", "StructField", "TimestampField", "TypeField", "DoubleField", "FloatField", "Int64Field", "Uint64Field", "Int32Field", "Uint32Field", "BoolField", "StringField", "BytesField" }, null, null, null),
+ new pbr::GeneratedCodeInfo(typeof(global::Google.Protobuf.TestProtos.TestWellKnownTypes), global::Google.Protobuf.TestProtos.TestWellKnownTypes.Parser, new[]{ "AnyField", "ApiField", "DurationField", "EmptyField", "FieldMaskField", "SourceContextField", "StructField", "TimestampField", "TypeField", "DoubleField", "FloatField", "Int64Field", "Uint64Field", "Int32Field", "Uint32Field", "BoolField", "StringField", "BytesField", "ValueField" }, null, null, null),
new pbr::GeneratedCodeInfo(typeof(global::Google.Protobuf.TestProtos.RepeatedWellKnownTypes), global::Google.Protobuf.TestProtos.RepeatedWellKnownTypes.Parser, new[]{ "AnyField", "ApiField", "DurationField", "EmptyField", "FieldMaskField", "SourceContextField", "StructField", "TimestampField", "TypeField", "DoubleField", "FloatField", "Int64Field", "Uint64Field", "Int32Field", "Uint32Field", "BoolField", "StringField", "BytesField" }, null, null, null),
new pbr::GeneratedCodeInfo(typeof(global::Google.Protobuf.TestProtos.OneofWellKnownTypes), global::Google.Protobuf.TestProtos.OneofWellKnownTypes.Parser, new[]{ "AnyField", "ApiField", "DurationField", "EmptyField", "FieldMaskField", "SourceContextField", "StructField", "TimestampField", "TypeField", "DoubleField", "FloatField", "Int64Field", "Uint64Field", "Int32Field", "Uint32Field", "BoolField", "StringField", "BytesField" }, new[]{ "OneofField" }, null, null),
new pbr::GeneratedCodeInfo(typeof(global::Google.Protobuf.TestProtos.MapWellKnownTypes), global::Google.Protobuf.TestProtos.MapWellKnownTypes.Parser, new[]{ "AnyField", "ApiField", "DurationField", "EmptyField", "FieldMaskField", "SourceContextField", "StructField", "TimestampField", "TypeField", "DoubleField", "FloatField", "Int64Field", "Uint64Field", "Int32Field", "Uint32Field", "BoolField", "StringField", "BytesField" }, null, null, new pbr::GeneratedCodeInfo[] { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, })
@@ -215,6 +216,7 @@ namespace Google.Protobuf.TestProtos {
BoolField = other.BoolField;
StringField = other.StringField;
BytesField = other.BytesField;
+ ValueField = other.valueField_ != null ? other.ValueField.Clone() : null;
}
public TestWellKnownTypes Clone() {
@@ -410,6 +412,19 @@ namespace Google.Protobuf.TestProtos {
}
}
+ /// <summary>Field number for the "value_field" field.</summary>
+ public const int ValueFieldFieldNumber = 19;
+ private global::Google.Protobuf.WellKnownTypes.Value valueField_;
+ /// <summary>
+ /// Part of struct, but useful to be able to test separately
+ /// </summary>
+ public global::Google.Protobuf.WellKnownTypes.Value ValueField {
+ get { return valueField_; }
+ set {
+ valueField_ = value;
+ }
+ }
+
public override bool Equals(object other) {
return Equals(other as TestWellKnownTypes);
}
@@ -439,6 +454,7 @@ namespace Google.Protobuf.TestProtos {
if (BoolField != other.BoolField) return false;
if (StringField != other.StringField) return false;
if (BytesField != other.BytesField) return false;
+ if (!object.Equals(ValueField, other.ValueField)) return false;
return true;
}
@@ -462,6 +478,7 @@ namespace Google.Protobuf.TestProtos {
if (boolField_ != null) hash ^= BoolField.GetHashCode();
if (stringField_ != null) hash ^= StringField.GetHashCode();
if (bytesField_ != null) hash ^= BytesField.GetHashCode();
+ if (valueField_ != null) hash ^= ValueField.GetHashCode();
return hash;
}
@@ -533,6 +550,10 @@ namespace Google.Protobuf.TestProtos {
if (bytesField_ != null) {
_single_bytesField_codec.WriteTagAndValue(output, BytesField);
}
+ if (valueField_ != null) {
+ output.WriteRawTag(154, 1);
+ output.WriteMessage(ValueField);
+ }
}
public int CalculateSize() {
@@ -591,6 +612,9 @@ namespace Google.Protobuf.TestProtos {
if (bytesField_ != null) {
size += _single_bytesField_codec.CalculateSizeWithTag(BytesField);
}
+ if (valueField_ != null) {
+ size += 2 + pb::CodedOutputStream.ComputeMessageSize(ValueField);
+ }
return size;
}
@@ -697,6 +721,12 @@ namespace Google.Protobuf.TestProtos {
BytesField = other.BytesField;
}
}
+ if (other.valueField_ != null) {
+ if (valueField_ == null) {
+ valueField_ = new global::Google.Protobuf.WellKnownTypes.Value();
+ }
+ ValueField.MergeFrom(other.ValueField);
+ }
}
public void MergeFrom(pb::CodedInputStream input) {
@@ -832,6 +862,13 @@ namespace Google.Protobuf.TestProtos {
}
break;
}
+ case 154: {
+ if (valueField_ == null) {
+ valueField_ = new global::Google.Protobuf.WellKnownTypes.Value();
+ }
+ input.ReadMessage(valueField_);
+ break;
+ }
}
}
}
diff --git a/csharp/src/Google.Protobuf.Test/WellKnownTypes/DurationTest.cs b/csharp/src/Google.Protobuf.Test/WellKnownTypes/DurationTest.cs
index 36012e63..1aa02e16 100644
--- a/csharp/src/Google.Protobuf.Test/WellKnownTypes/DurationTest.cs
+++ b/csharp/src/Google.Protobuf.Test/WellKnownTypes/DurationTest.cs
@@ -50,11 +50,6 @@ namespace Google.Protobuf.WellKnownTypes
// Rounding is towards 0
Assert.AreEqual(TimeSpan.FromTicks(2), new Duration { Nanos = 250 }.ToTimeSpan());
Assert.AreEqual(TimeSpan.FromTicks(-2), new Duration { Nanos = -250 }.ToTimeSpan());
-
- // Non-normalized durations
- Assert.AreEqual(TimeSpan.FromSeconds(3), new Duration { Seconds = 1, Nanos = 2 * Duration.NanosecondsPerSecond }.ToTimeSpan());
- Assert.AreEqual(TimeSpan.FromSeconds(1), new Duration { Seconds = 3, Nanos = -2 * Duration.NanosecondsPerSecond }.ToTimeSpan());
- Assert.AreEqual(TimeSpan.FromSeconds(-1), new Duration { Seconds = 1, Nanos = -2 * Duration.NanosecondsPerSecond }.ToTimeSpan());
}
[Test]
@@ -100,5 +95,30 @@ namespace Google.Protobuf.WellKnownTypes
Assert.AreEqual(new Duration { Seconds = 1 }, Duration.FromTimeSpan(TimeSpan.FromSeconds(1)));
Assert.AreEqual(new Duration { Nanos = Duration.NanosecondsPerTick }, Duration.FromTimeSpan(TimeSpan.FromTicks(1)));
}
+
+ [Test]
+ [TestCase(0, Duration.MaxNanoseconds + 1)]
+ [TestCase(0, Duration.MinNanoseconds - 1)]
+ [TestCase(Duration.MinSeconds - 1, 0)]
+ [TestCase(Duration.MaxSeconds + 1, 0)]
+ [TestCase(1, -1)]
+ [TestCase(-1, 1)]
+ public void ToTimeSpan_Invalid(long seconds, int nanoseconds)
+ {
+ var duration = new Duration { Seconds = seconds, Nanos = nanoseconds };
+ Assert.Throws<InvalidOperationException>(() => duration.ToTimeSpan());
+ }
+
+ [Test]
+ [TestCase(0, Duration.MaxNanoseconds)]
+ [TestCase(0, Duration.MinNanoseconds)]
+ [TestCase(Duration.MinSeconds, Duration.MinNanoseconds)]
+ [TestCase(Duration.MaxSeconds, Duration.MaxNanoseconds)]
+ public void ToTimeSpan_Valid(long seconds, int nanoseconds)
+ {
+ // Only testing that these values don't throw, unlike their similar tests in ToTimeSpan_Invalid
+ var duration = new Duration { Seconds = seconds, Nanos = nanoseconds };
+ duration.ToTimeSpan();
+ }
}
}
diff --git a/csharp/src/Google.Protobuf.Test/WellKnownTypes/TimestampTest.cs b/csharp/src/Google.Protobuf.Test/WellKnownTypes/TimestampTest.cs
index 597539eb..84717d66 100644
--- a/csharp/src/Google.Protobuf.Test/WellKnownTypes/TimestampTest.cs
+++ b/csharp/src/Google.Protobuf.Test/WellKnownTypes/TimestampTest.cs
@@ -61,6 +61,29 @@ namespace Google.Protobuf.WellKnownTypes
Assert.AreEqual(new DateTime(1969, 12, 31, 23, 59, 59).AddMilliseconds(1), t2.ToDateTime());
}
+ [Test]
+ [TestCase(Timestamp.UnixSecondsAtBclMinValue - 1, Timestamp.MaxNanos)]
+ [TestCase(Timestamp.UnixSecondsAtBclMaxValue + 1, 0)]
+ [TestCase(0, -1)]
+ [TestCase(0, Timestamp.MaxNanos + 1)]
+ public void ToDateTime_OutOfRange(long seconds, int nanoseconds)
+ {
+ var value = new Timestamp { Seconds = seconds, Nanos = nanoseconds };
+ Assert.Throws<InvalidOperationException>(() => value.ToDateTime());
+ }
+
+ // 1ns larger or smaller than the above values
+ [Test]
+ [TestCase(Timestamp.UnixSecondsAtBclMinValue, 0)]
+ [TestCase(Timestamp.UnixSecondsAtBclMaxValue, Timestamp.MaxNanos)]
+ [TestCase(0, 0)]
+ [TestCase(0, Timestamp.MaxNanos)]
+ public void ToDateTime_ValidBoundaries(long seconds, int nanoseconds)
+ {
+ var value = new Timestamp { Seconds = seconds, Nanos = nanoseconds };
+ value.ToDateTime();
+ }
+
private static void AssertRoundtrip(Timestamp timestamp, DateTime dateTime)
{
Assert.AreEqual(timestamp, Timestamp.FromDateTime(dateTime));
diff --git a/csharp/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs b/csharp/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs
index b72ef982..a2c833fe 100644
--- a/csharp/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs
+++ b/csharp/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs
@@ -149,6 +149,30 @@ namespace Google.Protobuf.WellKnownTypes
}
[Test]
+ public void RepeatedWrappersBinaryFormat()
+ {
+ // At one point we accidentally used a packed format for repeated wrappers, which is wrong (and weird).
+ // This test is just to prove that we use the right format.
+
+ var rawOutput = new MemoryStream();
+ var output = new CodedOutputStream(rawOutput);
+ // Write a value of 5
+ output.WriteTag(RepeatedWellKnownTypes.Int32FieldFieldNumber, WireFormat.WireType.LengthDelimited);
+ output.WriteLength(2);
+ output.WriteTag(WrappersReflection.WrapperValueFieldNumber, WireFormat.WireType.Varint);
+ output.WriteInt32(5);
+ // Write a value of 0 (empty message)
+ output.WriteTag(RepeatedWellKnownTypes.Int32FieldFieldNumber, WireFormat.WireType.LengthDelimited);
+ output.WriteLength(0);
+ output.Flush();
+ var expectedBytes = rawOutput.ToArray();
+
+ var message = new RepeatedWellKnownTypes { Int32Field = { 5, 0 } };
+ var actualBytes = message.ToByteArray();
+ Assert.AreEqual(expectedBytes, actualBytes);
+ }
+
+ [Test]
public void MapWrappersSerializeDeserialize()
{
// Note: no null values here, as they are prohibited in map fields
diff --git a/csharp/src/Google.Protobuf/Collections/RepeatedField.cs b/csharp/src/Google.Protobuf/Collections/RepeatedField.cs
index e3f65afe..1cde03bc 100644
--- a/csharp/src/Google.Protobuf/Collections/RepeatedField.cs
+++ b/csharp/src/Google.Protobuf/Collections/RepeatedField.cs
@@ -34,7 +34,6 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
-using Google.Protobuf.Compatibility;
namespace Google.Protobuf.Collections
{
@@ -96,8 +95,8 @@ namespace Google.Protobuf.Collections
// iteration.
uint tag = input.LastTag;
var reader = codec.ValueReader;
- // Value types can be packed or not.
- if (typeof(T).IsValueType() && WireFormat.GetTagWireType(tag) == WireFormat.WireType.LengthDelimited)
+ // Non-nullable value types can be packed or not.
+ if (FieldCodec<T>.IsPackedRepeatedField(tag))
{
int length = input.ReadLength();
if (length > 0)
@@ -134,7 +133,7 @@ namespace Google.Protobuf.Collections
return 0;
}
uint tag = codec.Tag;
- if (typeof(T).IsValueType() && WireFormat.GetTagWireType(tag) == WireFormat.WireType.LengthDelimited)
+ if (codec.PackedRepeatedField)
{
int dataSize = CalculatePackedDataSize(codec);
return CodedOutputStream.ComputeRawVarint32Size(tag) +
@@ -186,7 +185,7 @@ namespace Google.Protobuf.Collections
}
var writer = codec.ValueWriter;
var tag = codec.Tag;
- if (typeof(T).IsValueType() && WireFormat.GetTagWireType(tag) == WireFormat.WireType.LengthDelimited)
+ if (codec.PackedRepeatedField)
{
// Packed primitive type
uint size = (uint)CalculatePackedDataSize(codec);
diff --git a/csharp/src/Google.Protobuf/FieldCodec.cs b/csharp/src/Google.Protobuf/FieldCodec.cs
index c2b8d268..98313088 100644
--- a/csharp/src/Google.Protobuf/FieldCodec.cs
+++ b/csharp/src/Google.Protobuf/FieldCodec.cs
@@ -30,6 +30,7 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endregion
+using Google.Protobuf.Compatibility;
using Google.Protobuf.WellKnownTypes;
using System;
using System.Collections.Generic;
@@ -329,17 +330,24 @@ namespace Google.Protobuf
}
/// <summary>
+ /// <para>
/// An encode/decode pair for a single field. This effectively encapsulates
/// all the information needed to read or write the field value from/to a coded
/// stream.
+ /// </para>
+ /// <para>
+ /// This class is public and has to be as it is used by generated code, but its public
+ /// API is very limited - just what the generated code needs to call directly.
+ /// </para>
/// </summary>
/// <remarks>
- /// This never writes default values to the stream, and is not currently designed
- /// to play well with packed arrays.
+ /// This never writes default values to the stream, and does not address "packedness"
+ /// in repeated fields itself, other than to know whether or not the field *should* be packed.
/// </remarks>
public sealed class FieldCodec<T>
{
private static readonly T DefaultDefault;
+ private static readonly bool TypeSupportsPacking = typeof(T).IsValueType() && Nullable.GetUnderlyingType(typeof(T)) == null;
static FieldCodec()
{
@@ -354,75 +362,31 @@ namespace Google.Protobuf
// Otherwise it's the default value of the CLR type
}
- private readonly Func<CodedInputStream, T> reader;
- private readonly Action<CodedOutputStream, T> writer;
- private readonly Func<T, int> sizeCalculator;
- private readonly uint tag;
- private readonly int tagSize;
- private readonly int fixedSize;
- // Default value for this codec. Usually the same for every instance of the same type, but
- // for string/ByteString wrapper fields the codec's default value is null, whereas for
- // other string/ByteString fields it's "" or ByteString.Empty.
- private readonly T defaultValue;
+ internal static bool IsPackedRepeatedField(uint tag) =>
+ TypeSupportsPacking && WireFormat.GetTagWireType(tag) == WireFormat.WireType.LengthDelimited;
- internal FieldCodec(
- Func<CodedInputStream, T> reader,
- Action<CodedOutputStream, T> writer,
- Func<T, int> sizeCalculator,
- uint tag) : this(reader, writer, sizeCalculator, tag, DefaultDefault)
- {
- }
-
- internal FieldCodec(
- Func<CodedInputStream, T> reader,
- Action<CodedOutputStream, T> writer,
- Func<T, int> sizeCalculator,
- uint tag,
- T defaultValue)
- {
- this.reader = reader;
- this.writer = writer;
- this.sizeCalculator = sizeCalculator;
- this.fixedSize = 0;
- this.tag = tag;
- this.defaultValue = defaultValue;
- tagSize = CodedOutputStream.ComputeRawVarint32Size(tag);
- }
-
- internal FieldCodec(
- Func<CodedInputStream, T> reader,
- Action<CodedOutputStream, T> writer,
- int fixedSize,
- uint tag)
- {
- this.reader = reader;
- this.writer = writer;
- this.sizeCalculator = _ => fixedSize;
- this.fixedSize = fixedSize;
- this.tag = tag;
- tagSize = CodedOutputStream.ComputeRawVarint32Size(tag);
- }
+ internal bool PackedRepeatedField { get; }
/// <summary>
- /// Returns the size calculator for just a value.
+ /// Returns a delegate to write a value (unconditionally) to a coded output stream.
/// </summary>
- internal Func<T, int> ValueSizeCalculator { get { return sizeCalculator; } }
+ internal Action<CodedOutputStream, T> ValueWriter { get; }
/// <summary>
- /// Returns a delegate to write a value (unconditionally) to a coded output stream.
+ /// Returns the size calculator for just a value.
/// </summary>
- internal Action<CodedOutputStream, T> ValueWriter { get { return writer; } }
+ internal Func<T, int> ValueSizeCalculator { get; }
/// <summary>
/// Returns a delegate to read a value from a coded input stream. It is assumed that
/// the stream is already positioned on the appropriate tag.
/// </summary>
- internal Func<CodedInputStream, T> ValueReader { get { return reader; } }
+ internal Func<CodedInputStream, T> ValueReader { get; }
/// <summary>
/// Returns the fixed size for an entry, or 0 if sizes vary.
/// </summary>
- internal int FixedSize { get { return fixedSize; } }
+ internal int FixedSize { get; }
/// <summary>
/// Gets the tag of the codec.
@@ -430,15 +394,54 @@ namespace Google.Protobuf
/// <value>
/// The tag of the codec.
/// </value>
- public uint Tag { get { return tag; } }
+ internal uint Tag { get; }
/// <summary>
- /// Gets the default value of the codec's type.
+ /// Default value for this codec. Usually the same for every instance of the same type, but
+ /// for string/ByteString wrapper fields the codec's default value is null, whereas for
+ /// other string/ByteString fields it's "" or ByteString.Empty.
/// </summary>
/// <value>
/// The default value of the codec's type.
/// </value>
- public T DefaultValue { get { return defaultValue; } }
+ internal T DefaultValue { get; }
+
+ private readonly int tagSize;
+
+ internal FieldCodec(
+ Func<CodedInputStream, T> reader,
+ Action<CodedOutputStream, T> writer,
+ int fixedSize,
+ uint tag) : this(reader, writer, _ => fixedSize, tag)
+ {
+ FixedSize = fixedSize;
+ }
+
+ internal FieldCodec(
+ Func<CodedInputStream, T> reader,
+ Action<CodedOutputStream, T> writer,
+ Func<T, int> sizeCalculator,
+ uint tag) : this(reader, writer, sizeCalculator, tag, DefaultDefault)
+ {
+ }
+
+ internal FieldCodec(
+ Func<CodedInputStream, T> reader,
+ Action<CodedOutputStream, T> writer,
+ Func<T, int> sizeCalculator,
+ uint tag,
+ T defaultValue)
+ {
+ ValueReader = reader;
+ ValueWriter = writer;
+ ValueSizeCalculator = sizeCalculator;
+ FixedSize = 0;
+ Tag = tag;
+ DefaultValue = defaultValue;
+ tagSize = CodedOutputStream.ComputeRawVarint32Size(tag);
+ // Detect packed-ness once, so we can check for it within RepeatedField<T>.
+ PackedRepeatedField = IsPackedRepeatedField(tag);
+ }
/// <summary>
/// Write a tag and the given value, *if* the value is not the default.
@@ -447,8 +450,8 @@ namespace Google.Protobuf
{
if (!IsDefault(value))
{
- output.WriteTag(tag);
- writer(output, value);
+ output.WriteTag(Tag);
+ ValueWriter(output, value);
}
}
@@ -457,23 +460,14 @@ namespace Google.Protobuf
/// </summary>
/// <param name="input">The input stream to read from.</param>
/// <returns>The value read from the stream.</returns>
- public T Read(CodedInputStream input)
- {
- return reader(input);
- }
+ public T Read(CodedInputStream input) => ValueReader(input);
/// <summary>
/// Calculates the size required to write the given value, with a tag,
/// if the value is not the default.
/// </summary>
- public int CalculateSizeWithTag(T value)
- {
- return IsDefault(value) ? 0 : sizeCalculator(value) + tagSize;
- }
+ public int CalculateSizeWithTag(T value) => IsDefault(value) ? 0 : ValueSizeCalculator(value) + tagSize;
- private bool IsDefault(T value)
- {
- return EqualityComparer<T>.Default.Equals(value, defaultValue);
- }
+ private bool IsDefault(T value) => EqualityComparer<T>.Default.Equals(value, DefaultValue);
}
}
diff --git a/csharp/src/Google.Protobuf/InvalidProtocolBufferException.cs b/csharp/src/Google.Protobuf/InvalidProtocolBufferException.cs
index cacda648..eeb0f13a 100644
--- a/csharp/src/Google.Protobuf/InvalidProtocolBufferException.cs
+++ b/csharp/src/Google.Protobuf/InvalidProtocolBufferException.cs
@@ -30,6 +30,7 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endregion
+using System;
using System.IO;
namespace Google.Protobuf
@@ -45,6 +46,11 @@ namespace Google.Protobuf
{
}
+ internal InvalidProtocolBufferException(string message, Exception innerException)
+ : base(message, innerException)
+ {
+ }
+
internal static InvalidProtocolBufferException MoreDataAvailable()
{
return new InvalidProtocolBufferException(
@@ -82,6 +88,11 @@ namespace Google.Protobuf
"Protocol message contained an invalid tag (zero).");
}
+ internal static InvalidProtocolBufferException InvalidBase64(Exception innerException)
+ {
+ return new InvalidProtocolBufferException("Invalid base64 data", innerException);
+ }
+
internal static InvalidProtocolBufferException InvalidEndTag()
{
return new InvalidProtocolBufferException(
diff --git a/csharp/src/Google.Protobuf/JsonFormatter.cs b/csharp/src/Google.Protobuf/JsonFormatter.cs
index e89154b4..21239cf2 100644
--- a/csharp/src/Google.Protobuf/JsonFormatter.cs
+++ b/csharp/src/Google.Protobuf/JsonFormatter.cs
@@ -214,11 +214,6 @@ namespace Google.Protobuf
{
continue;
}
- // Omit awkward (single) values such as unknown enum values
- if (!field.IsRepeated && !field.IsMap && !CanWriteSingleValue(value))
- {
- continue;
- }
// Okay, all tests complete: let's write the field value...
if (!first)
@@ -233,6 +228,31 @@ namespace Google.Protobuf
return !first;
}
+ /// <summary>
+ /// Camel-case converter with added strictness for field mask formatting.
+ /// </summary>
+ /// <exception cref="InvalidOperationException">The field mask is invalid for JSON representation</exception>
+ private static string ToCamelCaseForFieldMask(string input)
+ {
+ for (int i = 0; i < input.Length; i++)
+ {
+ char c = input[i];
+ if (c >= 'A' && c <= 'Z')
+ {
+ throw new InvalidOperationException($"Invalid field mask to be converted to JSON: {input}");
+ }
+ if (c == '_' && i < input.Length - 1)
+ {
+ char next = input[i + 1];
+ if (next < 'a' || next > 'z')
+ {
+ throw new InvalidOperationException($"Invalid field mask to be converted to JSON: {input}");
+ }
+ }
+ }
+ return ToCamelCase(input);
+ }
+
// Converted from src/google/protobuf/util/internal/utility.cc ToCamelCase
// TODO: Use the new field in FieldDescriptor.
internal static string ToCamelCase(string input)
@@ -381,7 +401,14 @@ namespace Google.Protobuf
}
else if (value is System.Enum)
{
- WriteString(builder, value.ToString());
+ if (System.Enum.IsDefined(value.GetType(), value))
+ {
+ WriteString(builder, value.ToString());
+ }
+ else
+ {
+ WriteValue(builder, (int) value);
+ }
}
else if (value is float || value is double)
{
@@ -494,13 +521,14 @@ namespace Google.Protobuf
int nanos = (int) value.Descriptor.Fields[Timestamp.NanosFieldNumber].Accessor.GetValue(value);
long seconds = (long) value.Descriptor.Fields[Timestamp.SecondsFieldNumber].Accessor.GetValue(value);
- // Even if the original message isn't using the built-in classes, we can still build one... and then
- // rely on it being normalized.
- Timestamp normalized = Timestamp.Normalize(seconds, nanos);
+ // Even if the original message isn't using the built-in classes, we can still build one... and its
+ // conversion will check whether or not it's normalized.
+ // TODO: Perhaps the diagnostic-only formatter should not throw for non-normalized values?
+ Timestamp ts = new Timestamp { Seconds = seconds, Nanos = nanos };
// Use .NET's formatting for the value down to the second, including an opening double quote (as it's a string value)
- DateTime dateTime = normalized.ToDateTime();
+ DateTime dateTime = ts.ToDateTime();
builder.Append(dateTime.ToString("yyyy'-'MM'-'dd'T'HH:mm:ss", CultureInfo.InvariantCulture));
- AppendNanoseconds(builder, Math.Abs(normalized.Nanos));
+ AppendNanoseconds(builder, Math.Abs(ts.Nanos));
builder.Append("Z\"");
}
@@ -511,25 +539,29 @@ namespace Google.Protobuf
int nanos = (int) value.Descriptor.Fields[Duration.NanosFieldNumber].Accessor.GetValue(value);
long seconds = (long) value.Descriptor.Fields[Duration.SecondsFieldNumber].Accessor.GetValue(value);
+ // TODO: Perhaps the diagnostic-only formatter should not throw for non-normalized values?
// Even if the original message isn't using the built-in classes, we can still build one... and then
// rely on it being normalized.
- Duration normalized = Duration.Normalize(seconds, nanos);
+ if (!Duration.IsNormalized(seconds, nanos))
+ {
+ throw new InvalidOperationException("Non-normalized duration value");
+ }
// The seconds part will normally provide the minus sign if we need it, but not if it's 0...
- if (normalized.Seconds == 0 && normalized.Nanos < 0)
+ if (seconds == 0 && nanos < 0)
{
builder.Append('-');
}
- builder.Append(normalized.Seconds.ToString("d", CultureInfo.InvariantCulture));
- AppendNanoseconds(builder, Math.Abs(normalized.Nanos));
+ builder.Append(seconds.ToString("d", CultureInfo.InvariantCulture));
+ AppendNanoseconds(builder, Math.Abs(nanos));
builder.Append("s\"");
}
private void WriteFieldMask(StringBuilder builder, IMessage value)
{
IList paths = (IList) value.Descriptor.Fields[FieldMask.PathsFieldNumber].Accessor.GetValue(value);
- WriteString(builder, string.Join(",", paths.Cast<string>().Select(ToCamelCase)));
+ WriteString(builder, string.Join(",", paths.Cast<string>().Select(ToCamelCaseForFieldMask)));
}
private void WriteAny(StringBuilder builder, IMessage value)
@@ -607,15 +639,15 @@ namespace Google.Protobuf
// Output to 3, 6 or 9 digits.
if (nanos % 1000000 == 0)
{
- builder.Append((nanos / 1000000).ToString("d", CultureInfo.InvariantCulture));
+ builder.Append((nanos / 1000000).ToString("d3", CultureInfo.InvariantCulture));
}
else if (nanos % 1000 == 0)
{
- builder.Append((nanos / 1000).ToString("d", CultureInfo.InvariantCulture));
+ builder.Append((nanos / 1000).ToString("d6", CultureInfo.InvariantCulture));
}
else
{
- builder.Append(nanos.ToString("d", CultureInfo.InvariantCulture));
+ builder.Append(nanos.ToString("d9", CultureInfo.InvariantCulture));
}
}
}
@@ -683,10 +715,6 @@ namespace Google.Protobuf
bool first = true;
foreach (var value in list)
{
- if (!CanWriteSingleValue(value))
- {
- continue;
- }
if (!first)
{
builder.Append(PropertySeparator);
@@ -704,10 +732,6 @@ namespace Google.Protobuf
// This will box each pair. Could use IDictionaryEnumerator, but that's ugly in terms of disposal.
foreach (DictionaryEntry pair in dictionary)
{
- if (!CanWriteSingleValue(pair.Value))
- {
- continue;
- }
if (!first)
{
builder.Append(PropertySeparator);
diff --git a/csharp/src/Google.Protobuf/JsonParser.cs b/csharp/src/Google.Protobuf/JsonParser.cs
index 300a66b4..c07b16ea 100644
--- a/csharp/src/Google.Protobuf/JsonParser.cs
+++ b/csharp/src/Google.Protobuf/JsonParser.cs
@@ -168,6 +168,10 @@ namespace Google.Protobuf
}
var descriptor = message.Descriptor;
var jsonFieldMap = descriptor.Fields.ByJsonName();
+ // All the oneof fields we've already accounted for - we can only see each of them once.
+ // The set is created lazily to avoid the overhead of creating a set for every message
+ // we parsed, when oneofs are relatively rare.
+ HashSet<OneofDescriptor> seenOneofs = null;
while (true)
{
token = tokenizer.Next();
@@ -183,6 +187,17 @@ namespace Google.Protobuf
FieldDescriptor field;
if (jsonFieldMap.TryGetValue(name, out field))
{
+ if (field.ContainingOneof != null)
+ {
+ if (seenOneofs == null)
+ {
+ seenOneofs = new HashSet<OneofDescriptor>();
+ }
+ if (!seenOneofs.Add(field.ContainingOneof))
+ {
+ throw new InvalidProtocolBufferException($"Multiple values specified for oneof {field.ContainingOneof.Name}");
+ }
+ }
MergeField(message, field, tokenizer);
}
else
@@ -200,10 +215,15 @@ namespace Google.Protobuf
var token = tokenizer.Next();
if (token.Type == JsonToken.TokenType.Null)
{
+ // Clear the field if we see a null token, unless it's for a singular field of type
+ // google.protobuf.Value.
// Note: different from Java API, which just ignores it.
// TODO: Bring it more in line? Discuss...
- field.Accessor.Clear(message);
- return;
+ if (field.IsMap || field.IsRepeated || !IsGoogleProtobufValueField(field))
+ {
+ field.Accessor.Clear(message);
+ return;
+ }
}
tokenizer.PushBack(token);
@@ -239,6 +259,10 @@ namespace Google.Protobuf
return;
}
tokenizer.PushBack(token);
+ if (token.Type == JsonToken.TokenType.Null)
+ {
+ throw new InvalidProtocolBufferException("Repeated field elements cannot be null");
+ }
list.Add(ParseSingleValue(field, tokenizer));
}
}
@@ -270,19 +294,30 @@ namespace Google.Protobuf
}
object key = ParseMapKey(keyField, token.StringValue);
object value = ParseSingleValue(valueField, tokenizer);
- // TODO: Null handling
+ if (value == null)
+ {
+ throw new InvalidProtocolBufferException("Map values must not be null");
+ }
dictionary[key] = value;
}
}
+ private static bool IsGoogleProtobufValueField(FieldDescriptor field)
+ {
+ return field.FieldType == FieldType.Message &&
+ field.MessageType.FullName == Value.Descriptor.FullName;
+ }
+
private object ParseSingleValue(FieldDescriptor field, JsonTokenizer tokenizer)
{
var token = tokenizer.Next();
if (token.Type == JsonToken.TokenType.Null)
{
- if (field.FieldType == FieldType.Message && field.MessageType.FullName == Value.Descriptor.FullName)
+ // TODO: In order to support dynamic messages, we should really build this up
+ // dynamically.
+ if (IsGoogleProtobufValueField(field))
{
- return new Value { NullValue = NullValue.NULL_VALUE };
+ return Value.ForNull();
}
return null;
}
@@ -464,6 +499,11 @@ namespace Google.Protobuf
{
tokens.Add(token);
token = tokenizer.Next();
+
+ if (tokenizer.ObjectDepth < typeUrlObjectDepth)
+ {
+ throw new InvalidProtocolBufferException("Any message with no @type");
+ }
}
// Don't add the @type property or its value to the recorded token list
@@ -603,6 +643,11 @@ namespace Google.Protobuf
throw new InvalidProtocolBufferException($"Value out of range: {value}");
}
return (float) value;
+ case FieldType.Enum:
+ CheckInteger(value);
+ // Just return it as an int, and let the CLR convert it.
+ // Note that we deliberately don't check that it's a known value.
+ return (int) value;
default:
throw new InvalidProtocolBufferException($"Unsupported conversion from JSON number for field type {field.FieldType}");
}
@@ -633,7 +678,14 @@ namespace Google.Protobuf
case FieldType.String:
return text;
case FieldType.Bytes:
- return ByteString.FromBase64(text);
+ try
+ {
+ return ByteString.FromBase64(text);
+ }
+ catch (FormatException e)
+ {
+ throw InvalidProtocolBufferException.InvalidBase64(e);
+ }
case FieldType.Int32:
case FieldType.SInt32:
case FieldType.SFixed32:
@@ -826,28 +878,24 @@ namespace Google.Protobuf
try
{
- long seconds = long.Parse(secondsText, CultureInfo.InvariantCulture);
+ long seconds = long.Parse(secondsText, CultureInfo.InvariantCulture) * multiplier;
int nanos = 0;
if (subseconds != "")
{
// This should always work, as we've got 1-9 digits.
int parsedFraction = int.Parse(subseconds.Substring(1));
- nanos = parsedFraction * SubsecondScalingFactors[subseconds.Length];
+ nanos = parsedFraction * SubsecondScalingFactors[subseconds.Length] * multiplier;
}
- if (seconds >= Duration.MaxSeconds)
+ if (!Duration.IsNormalized(seconds, nanos))
{
- // Allow precisely 315576000000 seconds, but prohibit even 1ns more.
- if (seconds > Duration.MaxSeconds || nanos > 0)
- {
- throw new InvalidProtocolBufferException("Invalid Duration value: " + token.StringValue);
- }
+ throw new InvalidProtocolBufferException($"Invalid Duration value: {token.StringValue}");
}
- message.Descriptor.Fields[Duration.SecondsFieldNumber].Accessor.SetValue(message, seconds * multiplier);
- message.Descriptor.Fields[Duration.NanosFieldNumber].Accessor.SetValue(message, nanos * multiplier);
+ message.Descriptor.Fields[Duration.SecondsFieldNumber].Accessor.SetValue(message, seconds);
+ message.Descriptor.Fields[Duration.NanosFieldNumber].Accessor.SetValue(message, nanos);
}
catch (FormatException)
{
- throw new InvalidProtocolBufferException("Invalid Duration value: " + token.StringValue);
+ throw new InvalidProtocolBufferException($"Invalid Duration value: {token.StringValue}");
}
}
@@ -870,6 +918,8 @@ namespace Google.Protobuf
private static string ToSnakeCase(string text)
{
var builder = new StringBuilder(text.Length * 2);
+ // Note: this is probably unnecessary now, but currently retained to be as close as possible to the
+ // C++, whilst still throwing an exception on underscores.
bool wasNotUnderscore = false; // Initialize to false for case 1 (below)
bool wasNotCap = false;
@@ -903,7 +953,11 @@ namespace Google.Protobuf
else
{
builder.Append(c);
- wasNotUnderscore = c != '_';
+ if (c == '_')
+ {
+ throw new InvalidProtocolBufferException($"Invalid field mask: {text}");
+ }
+ wasNotUnderscore = true;
wasNotCap = true;
}
}
diff --git a/csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs b/csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs
index d1732b2e..f43803a6 100644
--- a/csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs
+++ b/csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs
@@ -92,11 +92,22 @@ namespace Google.Protobuf.Reflection
new FieldDescriptor(field, file, this, index, generatedCodeInfo?.PropertyNames[index]));
fieldsInNumberOrder = new ReadOnlyCollection<FieldDescriptor>(fieldsInDeclarationOrder.OrderBy(field => field.FieldNumber).ToArray());
// TODO: Use field => field.Proto.JsonName when we're confident it's appropriate. (And then use it in the formatter, too.)
- jsonFieldMap = new ReadOnlyDictionary<string, FieldDescriptor>(fieldsInNumberOrder.ToDictionary(field => JsonFormatter.ToCamelCase(field.Name)));
+ jsonFieldMap = CreateJsonFieldMap(fieldsInNumberOrder);
file.DescriptorPool.AddSymbol(this);
Fields = new FieldCollection(this);
}
+ private static ReadOnlyDictionary<string, FieldDescriptor> CreateJsonFieldMap(IList<FieldDescriptor> fields)
+ {
+ var map = new Dictionary<string, FieldDescriptor>();
+ foreach (var field in fields)
+ {
+ map[JsonFormatter.ToCamelCase(field.Name)] = field;
+ map[field.Name] = field;
+ }
+ return new ReadOnlyDictionary<string, FieldDescriptor>(map);
+ }
+
/// <summary>
/// The brief name of the descriptor's target.
/// </summary>
@@ -255,9 +266,10 @@ namespace Google.Protobuf.Reflection
// TODO: consider making this public in the future. (Being conservative for now...)
/// <value>
- /// Returns a read-only dictionary mapping the field names in this message as they're used
+ /// Returns a read-only dictionary mapping the field names in this message as they're available
/// in the JSON representation to the field descriptors. For example, a field <c>foo_bar</c>
- /// in the message would result in an entry with a key <c>fooBar</c>.
+ /// in the message would result two entries, one with a key <c>fooBar</c> and one with a key
+ /// <c>foo_bar</c>, both referring to the same field.
/// </value>
internal IDictionary<string, FieldDescriptor> ByJsonName() => messageDescriptor.jsonFieldMap;
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/DurationPartial.cs b/csharp/src/Google.Protobuf/WellKnownTypes/DurationPartial.cs
index 324f48fc..b8eba9d3 100644
--- a/csharp/src/Google.Protobuf/WellKnownTypes/DurationPartial.cs
+++ b/csharp/src/Google.Protobuf/WellKnownTypes/DurationPartial.cs
@@ -57,15 +57,38 @@ namespace Google.Protobuf.WellKnownTypes
/// </summary>
public const long MinSeconds = -315576000000L;
+ internal const int MaxNanoseconds = NanosecondsPerSecond - 1;
+ internal const int MinNanoseconds = -NanosecondsPerSecond + 1;
+
+ internal static bool IsNormalized(long seconds, int nanoseconds)
+ {
+ // Simple boundaries
+ if (seconds < MinSeconds || seconds > MaxSeconds ||
+ nanoseconds < MinNanoseconds || nanoseconds > MaxNanoseconds)
+ {
+ return false;
+ }
+ // We only have a problem is one is strictly negative and the other is
+ // strictly positive.
+ return Math.Sign(seconds) * Math.Sign(nanoseconds) != -1;
+ }
+
+
/// <summary>
/// Converts this <see cref="Duration"/> to a <see cref="TimeSpan"/>.
/// </summary>
/// <remarks>If the duration is not a precise number of ticks, it is truncated towards 0.</remarks>
/// <returns>The value of this duration, as a <c>TimeSpan</c>.</returns>
+ /// <exception cref="InvalidOperationException">This value isn't a valid normalized duration, as
+ /// described in the documentation.</exception>
public TimeSpan ToTimeSpan()
{
checked
{
+ if (!IsNormalized(Seconds, Nanos))
+ {
+ throw new InvalidOperationException("Duration was not a valid normalized duration");
+ }
long ticks = Seconds * TimeSpan.TicksPerSecond + Nanos / NanosecondsPerTick;
return TimeSpan.FromTicks(ticks);
}
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/TimestampPartial.cs b/csharp/src/Google.Protobuf/WellKnownTypes/TimestampPartial.cs
index d284acd6..7c50a3d7 100644
--- a/csharp/src/Google.Protobuf/WellKnownTypes/TimestampPartial.cs
+++ b/csharp/src/Google.Protobuf/WellKnownTypes/TimestampPartial.cs
@@ -37,9 +37,17 @@ namespace Google.Protobuf.WellKnownTypes
public partial class Timestamp
{
private static readonly DateTime UnixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
- private static readonly long BclSecondsAtUnixEpoch = UnixEpoch.Ticks / TimeSpan.TicksPerSecond;
- internal static readonly long UnixSecondsAtBclMinValue = -BclSecondsAtUnixEpoch;
- internal static readonly long UnixSecondsAtBclMaxValue = (DateTime.MaxValue.Ticks / TimeSpan.TicksPerSecond) - BclSecondsAtUnixEpoch;
+ // Constants determined programmatically, but then hard-coded so they can be constant expressions.
+ private const long BclSecondsAtUnixEpoch = 62135596800;
+ internal const long UnixSecondsAtBclMaxValue = 253402300799;
+ internal const long UnixSecondsAtBclMinValue = -BclSecondsAtUnixEpoch;
+ internal const int MaxNanos = Duration.NanosecondsPerSecond - 1;
+
+ private bool IsNormalized =>
+ Nanos >= 0 &&
+ Nanos <= MaxNanos &&
+ Seconds >= UnixSecondsAtBclMinValue &&
+ Seconds <= UnixSecondsAtBclMaxValue;
/// <summary>
/// Returns the difference between one <see cref="Timestamp"/> and another, as a <see cref="Duration"/>.
@@ -99,8 +107,14 @@ namespace Google.Protobuf.WellKnownTypes
/// <see cref="DateTime"/> value precisely on a second.
/// </remarks>
/// <returns>This timestamp as a <c>DateTime</c>.</returns>
+ /// <exception cref="InvalidOperationException">The timestamp contains invalid values; either it is
+ /// incorrectly normalized or is outside the valid range.</exception>
public DateTime ToDateTime()
{
+ if (!IsNormalized)
+ {
+ throw new InvalidOperationException(@"Timestamp contains invalid values: Seconds={Seconds}; Nanos={Nanos}");
+ }
return UnixEpoch.AddSeconds(Seconds).AddTicks(Nanos / Duration.NanosecondsPerTick);
}
@@ -114,6 +128,8 @@ namespace Google.Protobuf.WellKnownTypes
/// <see cref="DateTimeOffset"/> value precisely on a second.
/// </remarks>
/// <returns>This timestamp as a <c>DateTimeOffset</c>.</returns>
+ /// <exception cref="InvalidOperationException">The timestamp contains invalid values; either it is
+ /// incorrectly normalized or is outside the valid range.</exception>
public DateTimeOffset ToDateTimeOffset()
{
return new DateTimeOffset(ToDateTime(), TimeSpan.Zero);
diff --git a/java/core/generate-sources-build.xml b/java/core/generate-sources-build.xml
new file mode 100644
index 00000000..0996e5ff
--- /dev/null
+++ b/java/core/generate-sources-build.xml
@@ -0,0 +1,20 @@
+<project name="generate-sources">
+ <echo message="Running protoc ..."/>
+ <mkdir dir="${generated.sources.dir}"/>
+ <exec executable="${protoc}">
+ <arg value="--java_out=${generated.sources.dir}"/>
+ <arg value="--proto_path=${protobuf.source.dir}"/>
+ <arg value="${protobuf.source.dir}/google/protobuf/any.proto"/>
+ <arg value="${protobuf.source.dir}/google/protobuf/api.proto"/>
+ <arg value="${protobuf.source.dir}/google/protobuf/descriptor.proto"/>
+ <arg value="${protobuf.source.dir}/google/protobuf/duration.proto"/>
+ <arg value="${protobuf.source.dir}/google/protobuf/empty.proto"/>
+ <arg value="${protobuf.source.dir}/google/protobuf/field_mask.proto"/>
+ <arg value="${protobuf.source.dir}/google/protobuf/source_context.proto"/>
+ <arg value="${protobuf.source.dir}/google/protobuf/struct.proto"/>
+ <arg value="${protobuf.source.dir}/google/protobuf/timestamp.proto"/>
+ <arg value="${protobuf.source.dir}/google/protobuf/type.proto"/>
+ <arg value="${protobuf.source.dir}/google/protobuf/wrappers.proto"/>
+ <arg value="${protobuf.source.dir}/google/protobuf/compiler/plugin.proto"/>
+ </exec>
+</project> \ No newline at end of file
diff --git a/java/core/generate-test-sources-build.xml b/java/core/generate-test-sources-build.xml
new file mode 100644
index 00000000..ab415db6
--- /dev/null
+++ b/java/core/generate-test-sources-build.xml
@@ -0,0 +1,43 @@
+<project name="generate-test-sources">
+ <mkdir dir="${generated.testsources.dir}"/>
+ <exec executable="${protoc}">
+ <arg value="--java_out=${generated.testsources.dir}"/>
+ <arg value="--proto_path=${protobuf.source.dir}"/>
+ <arg value="--proto_path=${test.proto.dir}"/>
+ <arg value="${protobuf.source.dir}/google/protobuf/unittest.proto"/>
+ <arg value="${protobuf.source.dir}/google/protobuf/unittest_import.proto"/>
+ <arg value="${protobuf.source.dir}/google/protobuf/unittest_import_public.proto"/>
+ <arg value="${protobuf.source.dir}/google/protobuf/unittest_mset.proto"/>
+ <arg value="${protobuf.source.dir}/google/protobuf/unittest_mset_wire_format.proto"/>
+ <arg value="${protobuf.source.dir}/google/protobuf/unittest_optimize_for.proto"/>
+ <arg value="${protobuf.source.dir}/google/protobuf/unittest_custom_options.proto"/>
+ <arg value="${protobuf.source.dir}/google/protobuf/unittest_lite.proto"/>
+ <arg value="${protobuf.source.dir}/google/protobuf/unittest_import_lite.proto"/>
+ <arg value="${protobuf.source.dir}/google/protobuf/unittest_import_public_lite.proto"/>
+ <arg value="${protobuf.source.dir}/google/protobuf/unittest_lite_imports_nonlite.proto"/>
+ <arg value="${protobuf.source.dir}/google/protobuf/unittest_enormous_descriptor.proto"/>
+ <arg value="${protobuf.source.dir}/google/protobuf/unittest_no_generic_services.proto"/>
+ <arg value="${protobuf.source.dir}/google/protobuf/unittest_well_known_types.proto"/>
+ <arg value="${test.proto.dir}/com/google/protobuf/lazy_fields_lite.proto"/>
+ <arg value="${test.proto.dir}/com/google/protobuf/lite_equals_and_hash.proto"/>
+ <arg value="${test.proto.dir}/com/google/protobuf/multiple_files_test.proto"/>
+ <arg value="${test.proto.dir}/com/google/protobuf/nested_builders_test.proto"/>
+ <arg value="${test.proto.dir}/com/google/protobuf/nested_extension.proto"/>
+ <arg value="${test.proto.dir}/com/google/protobuf/nested_extension_lite.proto"/>
+ <arg value="${test.proto.dir}/com/google/protobuf/non_nested_extension.proto"/>
+ <arg value="${test.proto.dir}/com/google/protobuf/non_nested_extension_lite.proto"/>
+ <arg value="${test.proto.dir}/com/google/protobuf/outer_class_name_test.proto"/>
+ <arg value="${test.proto.dir}/com/google/protobuf/outer_class_name_test2.proto"/>
+ <arg value="${test.proto.dir}/com/google/protobuf/outer_class_name_test3.proto"/>
+ <arg value="${test.proto.dir}/com/google/protobuf/test_bad_identifiers.proto"/>
+ <arg value="${test.proto.dir}/com/google/protobuf/test_check_utf8.proto"/>
+ <arg value="${test.proto.dir}/com/google/protobuf/test_check_utf8_size.proto"/>
+ <arg value="${test.proto.dir}/com/google/protobuf/test_custom_options.proto"/>
+ <arg value="${test.proto.dir}/com/google/protobuf/any_test.proto"/>
+ <arg value="${test.proto.dir}/com/google/protobuf/field_presence_test.proto"/>
+ <arg value="${test.proto.dir}/com/google/protobuf/map_for_proto2_lite_test.proto"/>
+ <arg value="${test.proto.dir}/com/google/protobuf/map_for_proto2_test.proto"/>
+ <arg value="${test.proto.dir}/com/google/protobuf/map_test.proto"/>
+ <arg value="${test.proto.dir}/com/google/protobuf/map_initialization_order_test.proto"/>
+ </exec>
+</project> \ No newline at end of file
diff --git a/java/core/pom.xml b/java/core/pom.xml
new file mode 100644
index 00000000..74d5ead3
--- /dev/null
+++ b/java/core/pom.xml
@@ -0,0 +1,118 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>com.google.protobuf</groupId>
+ <artifactId>protobuf-parent</artifactId>
+ <version>3.0.0-beta-2</version>
+ </parent>
+
+ <artifactId>protobuf-java</artifactId>
+ <packaging>bundle</packaging>
+
+ <name>Protocol Buffers [Core]</name>
+ <description>
+ Core Protocol Buffers library. Protocol Buffers are a way of encoding structured data in an
+ efficient yet extensible format.
+ </description>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymockclassextension</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <!-- Include core protos in the bundle as resources -->
+ <resources>
+ <resource>
+ <directory>${protobuf.source.dir}</directory>
+ <includes>
+ <include>google/protobuf/any.proto</include>
+ <include>google/protobuf/api.proto</include>
+ <include>google/protobuf/descriptor.proto</include>
+ <include>google/protobuf/duration.proto</include>
+ <include>google/protobuf/empty.proto</include>
+ <include>google/protobuf/field_mask.proto</include>
+ <include>google/protobuf/source_context.proto</include>
+ <include>google/protobuf/struct.proto</include>
+ <include>google/protobuf/timestamp.proto</include>
+ <include>google/protobuf/type.proto</include>
+ <include>google/protobuf/wrappers.proto</include>
+ <include>google/protobuf/compiler/plugin.proto</include>
+ </includes>
+ </resource>
+ </resources>
+
+ <plugins>
+ <!-- Use Antrun plugin to generate sources with protoc -->
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <!-- Generate core protos -->
+ <execution>
+ <id>generate-sources</id>
+ <phase>generate-sources</phase>
+ <configuration>
+ <target>
+ <ant antfile="generate-sources-build.xml"/>
+ </target>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ <!-- Generate the test protos -->
+ <execution>
+ <id>generate-test-sources</id>
+ <phase>generate-test-sources</phase>
+ <configuration>
+ <target>
+ <ant antfile="generate-test-sources-build.xml"/>
+ </target>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!-- Add the generated sources to the build -->
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <generatedSourcesDirectory>${generated.sources.dir}</generatedSourcesDirectory>
+ <generatedTestSourcesDirectory>${generated.testsources.dir}</generatedTestSourcesDirectory>
+ </configuration>
+ </plugin>
+
+ <!-- OSGI bundle configuration -->
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-DocURL>https://developers.google.com/protocol-buffers/</Bundle-DocURL>
+ <Bundle-SymbolicName>com.google.protobuf</Bundle-SymbolicName>
+ <Export-Package>com.google.protobuf;version=${project.version}</Export-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/java/src/main/java/com/google/protobuf/AbstractMessage.java b/java/core/src/main/java/com/google/protobuf/AbstractMessage.java
index 9f418f2b..9f418f2b 100644
--- a/java/src/main/java/com/google/protobuf/AbstractMessage.java
+++ b/java/core/src/main/java/com/google/protobuf/AbstractMessage.java
diff --git a/java/src/main/java/com/google/protobuf/AbstractMessageLite.java b/java/core/src/main/java/com/google/protobuf/AbstractMessageLite.java
index 12384983..12384983 100644
--- a/java/src/main/java/com/google/protobuf/AbstractMessageLite.java
+++ b/java/core/src/main/java/com/google/protobuf/AbstractMessageLite.java
diff --git a/java/src/main/java/com/google/protobuf/AbstractParser.java b/java/core/src/main/java/com/google/protobuf/AbstractParser.java
index 1a4c6311..1a4c6311 100644
--- a/java/src/main/java/com/google/protobuf/AbstractParser.java
+++ b/java/core/src/main/java/com/google/protobuf/AbstractParser.java
diff --git a/java/src/main/java/com/google/protobuf/AbstractProtobufList.java b/java/core/src/main/java/com/google/protobuf/AbstractProtobufList.java
index bb6446b2..bb6446b2 100644
--- a/java/src/main/java/com/google/protobuf/AbstractProtobufList.java
+++ b/java/core/src/main/java/com/google/protobuf/AbstractProtobufList.java
diff --git a/java/src/main/java/com/google/protobuf/BlockingRpcChannel.java b/java/core/src/main/java/com/google/protobuf/BlockingRpcChannel.java
index d535efb9..d535efb9 100644
--- a/java/src/main/java/com/google/protobuf/BlockingRpcChannel.java
+++ b/java/core/src/main/java/com/google/protobuf/BlockingRpcChannel.java
diff --git a/java/src/main/java/com/google/protobuf/BlockingService.java b/java/core/src/main/java/com/google/protobuf/BlockingService.java
index d01f0b8f..d01f0b8f 100644
--- a/java/src/main/java/com/google/protobuf/BlockingService.java
+++ b/java/core/src/main/java/com/google/protobuf/BlockingService.java
diff --git a/java/src/main/java/com/google/protobuf/BooleanArrayList.java b/java/core/src/main/java/com/google/protobuf/BooleanArrayList.java
index 70e042f5..70e042f5 100644
--- a/java/src/main/java/com/google/protobuf/BooleanArrayList.java
+++ b/java/core/src/main/java/com/google/protobuf/BooleanArrayList.java
diff --git a/java/src/main/java/com/google/protobuf/BoundedByteString.java b/java/core/src/main/java/com/google/protobuf/BoundedByteString.java
index 934c9030..934c9030 100644
--- a/java/src/main/java/com/google/protobuf/BoundedByteString.java
+++ b/java/core/src/main/java/com/google/protobuf/BoundedByteString.java
diff --git a/java/src/main/java/com/google/protobuf/ByteString.java b/java/core/src/main/java/com/google/protobuf/ByteString.java
index 68f20d51..68f20d51 100644
--- a/java/src/main/java/com/google/protobuf/ByteString.java
+++ b/java/core/src/main/java/com/google/protobuf/ByteString.java
diff --git a/java/src/main/java/com/google/protobuf/CodedInputStream.java b/java/core/src/main/java/com/google/protobuf/CodedInputStream.java
index adc91536..adc91536 100644
--- a/java/src/main/java/com/google/protobuf/CodedInputStream.java
+++ b/java/core/src/main/java/com/google/protobuf/CodedInputStream.java
diff --git a/java/src/main/java/com/google/protobuf/CodedOutputStream.java b/java/core/src/main/java/com/google/protobuf/CodedOutputStream.java
index d8ebad21..d8ebad21 100644
--- a/java/src/main/java/com/google/protobuf/CodedOutputStream.java
+++ b/java/core/src/main/java/com/google/protobuf/CodedOutputStream.java
diff --git a/java/src/main/java/com/google/protobuf/Descriptors.java b/java/core/src/main/java/com/google/protobuf/Descriptors.java
index 5e15cfbe..5e15cfbe 100644
--- a/java/src/main/java/com/google/protobuf/Descriptors.java
+++ b/java/core/src/main/java/com/google/protobuf/Descriptors.java
diff --git a/java/src/main/java/com/google/protobuf/DoubleArrayList.java b/java/core/src/main/java/com/google/protobuf/DoubleArrayList.java
index bcc9d6ee..bcc9d6ee 100644
--- a/java/src/main/java/com/google/protobuf/DoubleArrayList.java
+++ b/java/core/src/main/java/com/google/protobuf/DoubleArrayList.java
diff --git a/java/src/main/java/com/google/protobuf/DynamicMessage.java b/java/core/src/main/java/com/google/protobuf/DynamicMessage.java
index 3ea1b688..3ea1b688 100644
--- a/java/src/main/java/com/google/protobuf/DynamicMessage.java
+++ b/java/core/src/main/java/com/google/protobuf/DynamicMessage.java
diff --git a/java/src/main/java/com/google/protobuf/Extension.java b/java/core/src/main/java/com/google/protobuf/Extension.java
index 68d29f33..68d29f33 100644
--- a/java/src/main/java/com/google/protobuf/Extension.java
+++ b/java/core/src/main/java/com/google/protobuf/Extension.java
diff --git a/java/src/main/java/com/google/protobuf/ExtensionLite.java b/java/core/src/main/java/com/google/protobuf/ExtensionLite.java
index f8f5bd2c..f8f5bd2c 100644
--- a/java/src/main/java/com/google/protobuf/ExtensionLite.java
+++ b/java/core/src/main/java/com/google/protobuf/ExtensionLite.java
diff --git a/java/src/main/java/com/google/protobuf/ExtensionRegistry.java b/java/core/src/main/java/com/google/protobuf/ExtensionRegistry.java
index 0067392f..0067392f 100644
--- a/java/src/main/java/com/google/protobuf/ExtensionRegistry.java
+++ b/java/core/src/main/java/com/google/protobuf/ExtensionRegistry.java
diff --git a/java/src/main/java/com/google/protobuf/ExtensionRegistryLite.java b/java/core/src/main/java/com/google/protobuf/ExtensionRegistryLite.java
index 65cf7385..65cf7385 100644
--- a/java/src/main/java/com/google/protobuf/ExtensionRegistryLite.java
+++ b/java/core/src/main/java/com/google/protobuf/ExtensionRegistryLite.java
diff --git a/java/src/main/java/com/google/protobuf/FieldSet.java b/java/core/src/main/java/com/google/protobuf/FieldSet.java
index 47924b65..47924b65 100644
--- a/java/src/main/java/com/google/protobuf/FieldSet.java
+++ b/java/core/src/main/java/com/google/protobuf/FieldSet.java
diff --git a/java/src/main/java/com/google/protobuf/FloatArrayList.java b/java/core/src/main/java/com/google/protobuf/FloatArrayList.java
index 033b5eed..033b5eed 100644
--- a/java/src/main/java/com/google/protobuf/FloatArrayList.java
+++ b/java/core/src/main/java/com/google/protobuf/FloatArrayList.java
diff --git a/java/src/main/java/com/google/protobuf/GeneratedMessage.java b/java/core/src/main/java/com/google/protobuf/GeneratedMessage.java
index d84fa75c..ceb97a4e 100644
--- a/java/src/main/java/com/google/protobuf/GeneratedMessage.java
+++ b/java/core/src/main/java/com/google/protobuf/GeneratedMessage.java
@@ -36,15 +36,13 @@ import com.google.protobuf.Descriptors.EnumValueDescriptor;
import com.google.protobuf.Descriptors.FieldDescriptor;
import com.google.protobuf.Descriptors.FileDescriptor;
import com.google.protobuf.Descriptors.OneofDescriptor;
-import com.google.protobuf.GeneratedMessageLite.ExtendableMessage;
-import com.google.protobuf.GeneratedMessageLite.GeneratedExtension;
import java.io.IOException;
+import java.io.InputStream;
import java.io.ObjectStreamException;
import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
-import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
@@ -276,6 +274,60 @@ public abstract class GeneratedMessage extends AbstractMessage
return unknownFields.mergeFieldFrom(tag, input);
}
+ protected static <M extends Message> M parseWithIOException(Parser<M> parser, InputStream input)
+ throws IOException {
+ try {
+ return parser.parseFrom(input);
+ } catch (InvalidProtocolBufferException e) {
+ throw e.unwrapIOException();
+ }
+ }
+
+ protected static <M extends Message> M parseWithIOException(Parser<M> parser, InputStream input,
+ ExtensionRegistryLite extensions) throws IOException {
+ try {
+ return parser.parseFrom(input, extensions);
+ } catch (InvalidProtocolBufferException e) {
+ throw e.unwrapIOException();
+ }
+ }
+
+ protected static <M extends Message> M parseWithIOException(Parser<M> parser,
+ CodedInputStream input) throws IOException {
+ try {
+ return parser.parseFrom(input);
+ } catch (InvalidProtocolBufferException e) {
+ throw e.unwrapIOException();
+ }
+ }
+
+ protected static <M extends Message> M parseWithIOException(Parser<M> parser,
+ CodedInputStream input, ExtensionRegistryLite extensions) throws IOException {
+ try {
+ return parser.parseFrom(input, extensions);
+ } catch (InvalidProtocolBufferException e) {
+ throw e.unwrapIOException();
+ }
+ }
+
+ protected static <M extends Message> M parseDelimitedWithIOException(Parser<M> parser,
+ InputStream input) throws IOException {
+ try {
+ return parser.parseDelimitedFrom(input);
+ } catch (InvalidProtocolBufferException e) {
+ throw e.unwrapIOException();
+ }
+ }
+
+ protected static <M extends Message> M parseDelimitedWithIOException(Parser<M> parser,
+ InputStream input, ExtensionRegistryLite extensions) throws IOException {
+ try {
+ return parser.parseDelimitedFrom(input, extensions);
+ } catch (InvalidProtocolBufferException e) {
+ throw e.unwrapIOException();
+ }
+ }
+
@Override
public void writeTo(final CodedOutputStream output) throws IOException {
MessageReflection.writeMessageTo(this, getAllFieldsRaw(), output, false);
@@ -667,7 +719,7 @@ public abstract class GeneratedMessage extends AbstractMessage
"No map fields found in " + getClass().getName());
}
- /** Like {@link internalGetMapField} but return a mutable version. */
+ /** Like {@link #internalGetMapField} but return a mutable version. */
@SuppressWarnings({"unused", "rawtypes"})
protected MapField internalGetMutableMapField(int fieldNumber) {
// Note that we can't use descriptor names here because this method will
diff --git a/java/src/main/java/com/google/protobuf/GeneratedMessageLite.java b/java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java
index 81e1862c..81e1862c 100644
--- a/java/src/main/java/com/google/protobuf/GeneratedMessageLite.java
+++ b/java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java
diff --git a/java/src/main/java/com/google/protobuf/IntArrayList.java b/java/core/src/main/java/com/google/protobuf/IntArrayList.java
index f4e68ed8..f4e68ed8 100644
--- a/java/src/main/java/com/google/protobuf/IntArrayList.java
+++ b/java/core/src/main/java/com/google/protobuf/IntArrayList.java
diff --git a/java/src/main/java/com/google/protobuf/Internal.java b/java/core/src/main/java/com/google/protobuf/Internal.java
index 11901998..11901998 100644
--- a/java/src/main/java/com/google/protobuf/Internal.java
+++ b/java/core/src/main/java/com/google/protobuf/Internal.java
diff --git a/java/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java b/java/core/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java
index 0a761052..85ce7b24 100644
--- a/java/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java
+++ b/java/core/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java
@@ -46,6 +46,10 @@ public class InvalidProtocolBufferException extends IOException {
super(description);
}
+ public InvalidProtocolBufferException(IOException e) {
+ super(e.getMessage(), e);
+ }
+
/**
* Attaches an unfinished message to the exception to support best-effort
* parsing in {@code Parser} interface.
@@ -66,6 +70,14 @@ public class InvalidProtocolBufferException extends IOException {
return unfinishedMessage;
}
+ /**
+ * Unwraps the underlying {@link IOException} if this exception was caused by an I/O
+ * problem. Otherwise, returns {@code this}.
+ */
+ public IOException unwrapIOException() {
+ return getCause() instanceof IOException ? (IOException) getCause() : this;
+ }
+
static InvalidProtocolBufferException truncatedMessage() {
return new InvalidProtocolBufferException(
"While parsing a protocol message, the input ended unexpectedly " +
diff --git a/java/src/main/java/com/google/protobuf/LazyField.java b/java/core/src/main/java/com/google/protobuf/LazyField.java
index 5e0a485c..5e0a485c 100644
--- a/java/src/main/java/com/google/protobuf/LazyField.java
+++ b/java/core/src/main/java/com/google/protobuf/LazyField.java
diff --git a/java/src/main/java/com/google/protobuf/LazyFieldLite.java b/java/core/src/main/java/com/google/protobuf/LazyFieldLite.java
index eea1fe3c..eea1fe3c 100644
--- a/java/src/main/java/com/google/protobuf/LazyFieldLite.java
+++ b/java/core/src/main/java/com/google/protobuf/LazyFieldLite.java
diff --git a/java/src/main/java/com/google/protobuf/LazyStringArrayList.java b/java/core/src/main/java/com/google/protobuf/LazyStringArrayList.java
index c3be3cca..c3be3cca 100644
--- a/java/src/main/java/com/google/protobuf/LazyStringArrayList.java
+++ b/java/core/src/main/java/com/google/protobuf/LazyStringArrayList.java
diff --git a/java/src/main/java/com/google/protobuf/LazyStringList.java b/java/core/src/main/java/com/google/protobuf/LazyStringList.java
index 3eeedca1..3eeedca1 100644
--- a/java/src/main/java/com/google/protobuf/LazyStringList.java
+++ b/java/core/src/main/java/com/google/protobuf/LazyStringList.java
diff --git a/java/src/main/java/com/google/protobuf/LiteralByteString.java b/java/core/src/main/java/com/google/protobuf/LiteralByteString.java
index a18c2792..a18c2792 100644
--- a/java/src/main/java/com/google/protobuf/LiteralByteString.java
+++ b/java/core/src/main/java/com/google/protobuf/LiteralByteString.java
diff --git a/java/src/main/java/com/google/protobuf/LongArrayList.java b/java/core/src/main/java/com/google/protobuf/LongArrayList.java
index ebe62029..ebe62029 100644
--- a/java/src/main/java/com/google/protobuf/LongArrayList.java
+++ b/java/core/src/main/java/com/google/protobuf/LongArrayList.java
diff --git a/java/src/main/java/com/google/protobuf/MapEntry.java b/java/core/src/main/java/com/google/protobuf/MapEntry.java
index 31414bb4..31414bb4 100644
--- a/java/src/main/java/com/google/protobuf/MapEntry.java
+++ b/java/core/src/main/java/com/google/protobuf/MapEntry.java
diff --git a/java/src/main/java/com/google/protobuf/MapEntryLite.java b/java/core/src/main/java/com/google/protobuf/MapEntryLite.java
index bcffa946..bcffa946 100644
--- a/java/src/main/java/com/google/protobuf/MapEntryLite.java
+++ b/java/core/src/main/java/com/google/protobuf/MapEntryLite.java
diff --git a/java/src/main/java/com/google/protobuf/MapField.java b/java/core/src/main/java/com/google/protobuf/MapField.java
index b290993c..b290993c 100644
--- a/java/src/main/java/com/google/protobuf/MapField.java
+++ b/java/core/src/main/java/com/google/protobuf/MapField.java
diff --git a/java/src/main/java/com/google/protobuf/MapFieldLite.java b/java/core/src/main/java/com/google/protobuf/MapFieldLite.java
index 16d3e6d2..16d3e6d2 100644
--- a/java/src/main/java/com/google/protobuf/MapFieldLite.java
+++ b/java/core/src/main/java/com/google/protobuf/MapFieldLite.java
diff --git a/java/src/main/java/com/google/protobuf/Message.java b/java/core/src/main/java/com/google/protobuf/Message.java
index 9516d71f..9516d71f 100644
--- a/java/src/main/java/com/google/protobuf/Message.java
+++ b/java/core/src/main/java/com/google/protobuf/Message.java
diff --git a/java/src/main/java/com/google/protobuf/MessageLite.java b/java/core/src/main/java/com/google/protobuf/MessageLite.java
index 798b7943..798b7943 100644
--- a/java/src/main/java/com/google/protobuf/MessageLite.java
+++ b/java/core/src/main/java/com/google/protobuf/MessageLite.java
diff --git a/java/src/main/java/com/google/protobuf/MessageLiteOrBuilder.java b/java/core/src/main/java/com/google/protobuf/MessageLiteOrBuilder.java
index 818386ce..818386ce 100644
--- a/java/src/main/java/com/google/protobuf/MessageLiteOrBuilder.java
+++ b/java/core/src/main/java/com/google/protobuf/MessageLiteOrBuilder.java
diff --git a/java/src/main/java/com/google/protobuf/MessageLiteToString.java b/java/core/src/main/java/com/google/protobuf/MessageLiteToString.java
index e69de29b..e69de29b 100644
--- a/java/src/main/java/com/google/protobuf/MessageLiteToString.java
+++ b/java/core/src/main/java/com/google/protobuf/MessageLiteToString.java
diff --git a/java/src/main/java/com/google/protobuf/MessageOrBuilder.java b/java/core/src/main/java/com/google/protobuf/MessageOrBuilder.java
index f0fc4859..f0fc4859 100644
--- a/java/src/main/java/com/google/protobuf/MessageOrBuilder.java
+++ b/java/core/src/main/java/com/google/protobuf/MessageOrBuilder.java
diff --git a/java/src/main/java/com/google/protobuf/MessageReflection.java b/java/core/src/main/java/com/google/protobuf/MessageReflection.java
index de4bfd3e..de4bfd3e 100644
--- a/java/src/main/java/com/google/protobuf/MessageReflection.java
+++ b/java/core/src/main/java/com/google/protobuf/MessageReflection.java
diff --git a/java/src/main/java/com/google/protobuf/MutabilityOracle.java b/java/core/src/main/java/com/google/protobuf/MutabilityOracle.java
index 82b723c9..82b723c9 100644
--- a/java/src/main/java/com/google/protobuf/MutabilityOracle.java
+++ b/java/core/src/main/java/com/google/protobuf/MutabilityOracle.java
diff --git a/java/src/main/java/com/google/protobuf/NioByteString.java b/java/core/src/main/java/com/google/protobuf/NioByteString.java
index f71e41b2..f71e41b2 100644
--- a/java/src/main/java/com/google/protobuf/NioByteString.java
+++ b/java/core/src/main/java/com/google/protobuf/NioByteString.java
diff --git a/java/src/main/java/com/google/protobuf/Parser.java b/java/core/src/main/java/com/google/protobuf/Parser.java
index 227c02b7..3fa11c3b 100644
--- a/java/src/main/java/com/google/protobuf/Parser.java
+++ b/java/core/src/main/java/com/google/protobuf/Parser.java
@@ -30,6 +30,7 @@
package com.google.protobuf;
+import java.io.IOException;
import java.io.InputStream;
/**
@@ -37,9 +38,20 @@ import java.io.InputStream;
*
* The implementation should be stateless and thread-safe.
*
+ * <p>All methods may throw {@link InvalidProtocolBufferException}. In the event of invalid data,
+ * like an encoding error, the cause of the thrown exception will be {@code null}. However, if an
+ * I/O problem occurs, an exception is thrown with an {@link IOException} cause.
+ *
* @author liujisi@google.com (Pherl Liu)
*/
public interface Parser<MessageType> {
+
+ // NB(jh): Other parts of the protobuf API that parse messages distinguish between an I/O problem
+ // (like failure reading bytes from a socket) and invalid data (encoding error) via the type of
+ // thrown exception. But it would be source-incompatible to make the methods in this interface do
+ // so since they were originally spec'ed to only throw InvalidProtocolBufferException. So callers
+ // must inspect the cause of the exception to distinguish these two cases.
+
/**
* Parses a message of {@code MessageType} from the input.
*
diff --git a/java/src/main/java/com/google/protobuf/ProtobufArrayList.java b/java/core/src/main/java/com/google/protobuf/ProtobufArrayList.java
index d2f82ac5..d2f82ac5 100644
--- a/java/src/main/java/com/google/protobuf/ProtobufArrayList.java
+++ b/java/core/src/main/java/com/google/protobuf/ProtobufArrayList.java
diff --git a/java/src/main/java/com/google/protobuf/ProtocolMessageEnum.java b/java/core/src/main/java/com/google/protobuf/ProtocolMessageEnum.java
index 0c8df989..0c8df989 100644
--- a/java/src/main/java/com/google/protobuf/ProtocolMessageEnum.java
+++ b/java/core/src/main/java/com/google/protobuf/ProtocolMessageEnum.java
diff --git a/java/src/main/java/com/google/protobuf/ProtocolStringList.java b/java/core/src/main/java/com/google/protobuf/ProtocolStringList.java
index d553b41e..d553b41e 100644
--- a/java/src/main/java/com/google/protobuf/ProtocolStringList.java
+++ b/java/core/src/main/java/com/google/protobuf/ProtocolStringList.java
diff --git a/java/src/main/java/com/google/protobuf/RepeatedFieldBuilder.java b/java/core/src/main/java/com/google/protobuf/RepeatedFieldBuilder.java
index f91cdbce..f91cdbce 100644
--- a/java/src/main/java/com/google/protobuf/RepeatedFieldBuilder.java
+++ b/java/core/src/main/java/com/google/protobuf/RepeatedFieldBuilder.java
diff --git a/java/src/main/java/com/google/protobuf/RopeByteString.java b/java/core/src/main/java/com/google/protobuf/RopeByteString.java
index 6e8eb724..6e8eb724 100644
--- a/java/src/main/java/com/google/protobuf/RopeByteString.java
+++ b/java/core/src/main/java/com/google/protobuf/RopeByteString.java
diff --git a/java/src/main/java/com/google/protobuf/RpcCallback.java b/java/core/src/main/java/com/google/protobuf/RpcCallback.java
index 10752968..10752968 100644
--- a/java/src/main/java/com/google/protobuf/RpcCallback.java
+++ b/java/core/src/main/java/com/google/protobuf/RpcCallback.java
diff --git a/java/src/main/java/com/google/protobuf/RpcChannel.java b/java/core/src/main/java/com/google/protobuf/RpcChannel.java
index f272f4ad..f272f4ad 100644
--- a/java/src/main/java/com/google/protobuf/RpcChannel.java
+++ b/java/core/src/main/java/com/google/protobuf/RpcChannel.java
diff --git a/java/src/main/java/com/google/protobuf/RpcController.java b/java/core/src/main/java/com/google/protobuf/RpcController.java
index a92dd7be..a92dd7be 100644
--- a/java/src/main/java/com/google/protobuf/RpcController.java
+++ b/java/core/src/main/java/com/google/protobuf/RpcController.java
diff --git a/java/src/main/java/com/google/protobuf/RpcUtil.java b/java/core/src/main/java/com/google/protobuf/RpcUtil.java
index 694b8d13..694b8d13 100644
--- a/java/src/main/java/com/google/protobuf/RpcUtil.java
+++ b/java/core/src/main/java/com/google/protobuf/RpcUtil.java
diff --git a/java/src/main/java/com/google/protobuf/Service.java b/java/core/src/main/java/com/google/protobuf/Service.java
index ba7b033e..ba7b033e 100644
--- a/java/src/main/java/com/google/protobuf/Service.java
+++ b/java/core/src/main/java/com/google/protobuf/Service.java
diff --git a/java/src/main/java/com/google/protobuf/ServiceException.java b/java/core/src/main/java/com/google/protobuf/ServiceException.java
index 00d57075..00d57075 100644
--- a/java/src/main/java/com/google/protobuf/ServiceException.java
+++ b/java/core/src/main/java/com/google/protobuf/ServiceException.java
diff --git a/java/src/main/java/com/google/protobuf/SingleFieldBuilder.java b/java/core/src/main/java/com/google/protobuf/SingleFieldBuilder.java
index aba65e32..aba65e32 100644
--- a/java/src/main/java/com/google/protobuf/SingleFieldBuilder.java
+++ b/java/core/src/main/java/com/google/protobuf/SingleFieldBuilder.java
diff --git a/java/src/main/java/com/google/protobuf/SmallSortedMap.java b/java/core/src/main/java/com/google/protobuf/SmallSortedMap.java
index 0674d2e2..0674d2e2 100644
--- a/java/src/main/java/com/google/protobuf/SmallSortedMap.java
+++ b/java/core/src/main/java/com/google/protobuf/SmallSortedMap.java
diff --git a/java/src/main/java/com/google/protobuf/TextFormat.java b/java/core/src/main/java/com/google/protobuf/TextFormat.java
index c99b5285..c99b5285 100644
--- a/java/src/main/java/com/google/protobuf/TextFormat.java
+++ b/java/core/src/main/java/com/google/protobuf/TextFormat.java
diff --git a/java/src/main/java/com/google/protobuf/TextFormatEscaper.java b/java/core/src/main/java/com/google/protobuf/TextFormatEscaper.java
index e69de29b..e69de29b 100644
--- a/java/src/main/java/com/google/protobuf/TextFormatEscaper.java
+++ b/java/core/src/main/java/com/google/protobuf/TextFormatEscaper.java
diff --git a/java/src/main/java/com/google/protobuf/UninitializedMessageException.java b/java/core/src/main/java/com/google/protobuf/UninitializedMessageException.java
index 5714c063..5714c063 100644
--- a/java/src/main/java/com/google/protobuf/UninitializedMessageException.java
+++ b/java/core/src/main/java/com/google/protobuf/UninitializedMessageException.java
diff --git a/java/src/main/java/com/google/protobuf/UnknownFieldSet.java b/java/core/src/main/java/com/google/protobuf/UnknownFieldSet.java
index 7cd2250e..7cd2250e 100644
--- a/java/src/main/java/com/google/protobuf/UnknownFieldSet.java
+++ b/java/core/src/main/java/com/google/protobuf/UnknownFieldSet.java
diff --git a/java/src/main/java/com/google/protobuf/UnknownFieldSetLite.java b/java/core/src/main/java/com/google/protobuf/UnknownFieldSetLite.java
index 435ad4d4..435ad4d4 100644
--- a/java/src/main/java/com/google/protobuf/UnknownFieldSetLite.java
+++ b/java/core/src/main/java/com/google/protobuf/UnknownFieldSetLite.java
diff --git a/java/src/main/java/com/google/protobuf/UnmodifiableLazyStringList.java b/java/core/src/main/java/com/google/protobuf/UnmodifiableLazyStringList.java
index 5257c5a2..5257c5a2 100644
--- a/java/src/main/java/com/google/protobuf/UnmodifiableLazyStringList.java
+++ b/java/core/src/main/java/com/google/protobuf/UnmodifiableLazyStringList.java
diff --git a/java/src/main/java/com/google/protobuf/UnsafeByteStrings.java b/java/core/src/main/java/com/google/protobuf/UnsafeByteStrings.java
index c1997515..c1997515 100644
--- a/java/src/main/java/com/google/protobuf/UnsafeByteStrings.java
+++ b/java/core/src/main/java/com/google/protobuf/UnsafeByteStrings.java
diff --git a/java/src/main/java/com/google/protobuf/Utf8.java b/java/core/src/main/java/com/google/protobuf/Utf8.java
index 48c7e9e6..48c7e9e6 100644
--- a/java/src/main/java/com/google/protobuf/Utf8.java
+++ b/java/core/src/main/java/com/google/protobuf/Utf8.java
diff --git a/java/src/main/java/com/google/protobuf/WireFormat.java b/java/core/src/main/java/com/google/protobuf/WireFormat.java
index 8dbe1ae3..8dbe1ae3 100644
--- a/java/src/main/java/com/google/protobuf/WireFormat.java
+++ b/java/core/src/main/java/com/google/protobuf/WireFormat.java
diff --git a/java/src/test/java/com/google/protobuf/AbstractMessageTest.java b/java/core/src/test/java/com/google/protobuf/AbstractMessageTest.java
index d964ef59..d964ef59 100644
--- a/java/src/test/java/com/google/protobuf/AbstractMessageTest.java
+++ b/java/core/src/test/java/com/google/protobuf/AbstractMessageTest.java
diff --git a/java/src/test/java/com/google/protobuf/AnyTest.java b/java/core/src/test/java/com/google/protobuf/AnyTest.java
index e169f69d..e169f69d 100644
--- a/java/src/test/java/com/google/protobuf/AnyTest.java
+++ b/java/core/src/test/java/com/google/protobuf/AnyTest.java
diff --git a/java/src/test/java/com/google/protobuf/BooleanArrayListTest.java b/java/core/src/test/java/com/google/protobuf/BooleanArrayListTest.java
index b8ad1fe4..b8ad1fe4 100644
--- a/java/src/test/java/com/google/protobuf/BooleanArrayListTest.java
+++ b/java/core/src/test/java/com/google/protobuf/BooleanArrayListTest.java
diff --git a/java/src/test/java/com/google/protobuf/BoundedByteStringTest.java b/java/core/src/test/java/com/google/protobuf/BoundedByteStringTest.java
index 2dfae2e6..2dfae2e6 100644
--- a/java/src/test/java/com/google/protobuf/BoundedByteStringTest.java
+++ b/java/core/src/test/java/com/google/protobuf/BoundedByteStringTest.java
diff --git a/java/src/test/java/com/google/protobuf/ByteStringTest.java b/java/core/src/test/java/com/google/protobuf/ByteStringTest.java
index 36f64251..36f64251 100644
--- a/java/src/test/java/com/google/protobuf/ByteStringTest.java
+++ b/java/core/src/test/java/com/google/protobuf/ByteStringTest.java
diff --git a/java/src/test/java/com/google/protobuf/CheckUtf8Test.java b/java/core/src/test/java/com/google/protobuf/CheckUtf8Test.java
index 3d6381c9..3d6381c9 100644
--- a/java/src/test/java/com/google/protobuf/CheckUtf8Test.java
+++ b/java/core/src/test/java/com/google/protobuf/CheckUtf8Test.java
diff --git a/java/src/test/java/com/google/protobuf/CodedInputStreamTest.java b/java/core/src/test/java/com/google/protobuf/CodedInputStreamTest.java
index 18d8142c..18d8142c 100644
--- a/java/src/test/java/com/google/protobuf/CodedInputStreamTest.java
+++ b/java/core/src/test/java/com/google/protobuf/CodedInputStreamTest.java
diff --git a/java/src/test/java/com/google/protobuf/CodedOutputStreamTest.java b/java/core/src/test/java/com/google/protobuf/CodedOutputStreamTest.java
index 6018ea55..6018ea55 100644
--- a/java/src/test/java/com/google/protobuf/CodedOutputStreamTest.java
+++ b/java/core/src/test/java/com/google/protobuf/CodedOutputStreamTest.java
diff --git a/java/src/test/java/com/google/protobuf/DeprecatedFieldTest.java b/java/core/src/test/java/com/google/protobuf/DeprecatedFieldTest.java
index e7905f79..e7905f79 100644
--- a/java/src/test/java/com/google/protobuf/DeprecatedFieldTest.java
+++ b/java/core/src/test/java/com/google/protobuf/DeprecatedFieldTest.java
diff --git a/java/src/test/java/com/google/protobuf/DescriptorsTest.java b/java/core/src/test/java/com/google/protobuf/DescriptorsTest.java
index 82ff34af..82ff34af 100644
--- a/java/src/test/java/com/google/protobuf/DescriptorsTest.java
+++ b/java/core/src/test/java/com/google/protobuf/DescriptorsTest.java
diff --git a/java/src/test/java/com/google/protobuf/DoubleArrayListTest.java b/java/core/src/test/java/com/google/protobuf/DoubleArrayListTest.java
index d3deaa07..d3deaa07 100644
--- a/java/src/test/java/com/google/protobuf/DoubleArrayListTest.java
+++ b/java/core/src/test/java/com/google/protobuf/DoubleArrayListTest.java
diff --git a/java/src/test/java/com/google/protobuf/DynamicMessageTest.java b/java/core/src/test/java/com/google/protobuf/DynamicMessageTest.java
index 55144e7c..55144e7c 100644
--- a/java/src/test/java/com/google/protobuf/DynamicMessageTest.java
+++ b/java/core/src/test/java/com/google/protobuf/DynamicMessageTest.java
diff --git a/java/src/test/java/com/google/protobuf/FieldPresenceTest.java b/java/core/src/test/java/com/google/protobuf/FieldPresenceTest.java
index eaeec0b8..eaeec0b8 100644
--- a/java/src/test/java/com/google/protobuf/FieldPresenceTest.java
+++ b/java/core/src/test/java/com/google/protobuf/FieldPresenceTest.java
diff --git a/java/src/test/java/com/google/protobuf/FloatArrayListTest.java b/java/core/src/test/java/com/google/protobuf/FloatArrayListTest.java
index a5e65424..a5e65424 100644
--- a/java/src/test/java/com/google/protobuf/FloatArrayListTest.java
+++ b/java/core/src/test/java/com/google/protobuf/FloatArrayListTest.java
diff --git a/java/src/test/java/com/google/protobuf/ForceFieldBuildersPreRun.java b/java/core/src/test/java/com/google/protobuf/ForceFieldBuildersPreRun.java
index a92ba374..a92ba374 100644
--- a/java/src/test/java/com/google/protobuf/ForceFieldBuildersPreRun.java
+++ b/java/core/src/test/java/com/google/protobuf/ForceFieldBuildersPreRun.java
diff --git a/java/src/test/java/com/google/protobuf/GeneratedMessageTest.java b/java/core/src/test/java/com/google/protobuf/GeneratedMessageTest.java
index 70812b95..70812b95 100644
--- a/java/src/test/java/com/google/protobuf/GeneratedMessageTest.java
+++ b/java/core/src/test/java/com/google/protobuf/GeneratedMessageTest.java
diff --git a/java/src/test/java/com/google/protobuf/IntArrayListTest.java b/java/core/src/test/java/com/google/protobuf/IntArrayListTest.java
index 3733eb30..3733eb30 100644
--- a/java/src/test/java/com/google/protobuf/IntArrayListTest.java
+++ b/java/core/src/test/java/com/google/protobuf/IntArrayListTest.java
diff --git a/java/src/test/java/com/google/protobuf/IsValidUtf8Test.java b/java/core/src/test/java/com/google/protobuf/IsValidUtf8Test.java
index 8751baae..8751baae 100644
--- a/java/src/test/java/com/google/protobuf/IsValidUtf8Test.java
+++ b/java/core/src/test/java/com/google/protobuf/IsValidUtf8Test.java
diff --git a/java/src/test/java/com/google/protobuf/IsValidUtf8TestUtil.java b/java/core/src/test/java/com/google/protobuf/IsValidUtf8TestUtil.java
index 321669f3..321669f3 100644
--- a/java/src/test/java/com/google/protobuf/IsValidUtf8TestUtil.java
+++ b/java/core/src/test/java/com/google/protobuf/IsValidUtf8TestUtil.java
diff --git a/java/src/test/java/com/google/protobuf/LazyFieldLiteTest.java b/java/core/src/test/java/com/google/protobuf/LazyFieldLiteTest.java
index 211b5697..211b5697 100644
--- a/java/src/test/java/com/google/protobuf/LazyFieldLiteTest.java
+++ b/java/core/src/test/java/com/google/protobuf/LazyFieldLiteTest.java
diff --git a/java/src/test/java/com/google/protobuf/LazyFieldTest.java b/java/core/src/test/java/com/google/protobuf/LazyFieldTest.java
index 2b900065..2b900065 100644
--- a/java/src/test/java/com/google/protobuf/LazyFieldTest.java
+++ b/java/core/src/test/java/com/google/protobuf/LazyFieldTest.java
diff --git a/java/src/test/java/com/google/protobuf/LazyMessageLiteTest.java b/java/core/src/test/java/com/google/protobuf/LazyMessageLiteTest.java
index afe0fffd..afe0fffd 100644
--- a/java/src/test/java/com/google/protobuf/LazyMessageLiteTest.java
+++ b/java/core/src/test/java/com/google/protobuf/LazyMessageLiteTest.java
diff --git a/java/src/test/java/com/google/protobuf/LazyStringArrayListTest.java b/java/core/src/test/java/com/google/protobuf/LazyStringArrayListTest.java
index 0f42ac50..0f42ac50 100644
--- a/java/src/test/java/com/google/protobuf/LazyStringArrayListTest.java
+++ b/java/core/src/test/java/com/google/protobuf/LazyStringArrayListTest.java
diff --git a/java/src/test/java/com/google/protobuf/LazyStringEndToEndTest.java b/java/core/src/test/java/com/google/protobuf/LazyStringEndToEndTest.java
index 0ef414aa..0ef414aa 100644
--- a/java/src/test/java/com/google/protobuf/LazyStringEndToEndTest.java
+++ b/java/core/src/test/java/com/google/protobuf/LazyStringEndToEndTest.java
diff --git a/java/src/test/java/com/google/protobuf/LiteEqualsAndHashTest.java b/java/core/src/test/java/com/google/protobuf/LiteEqualsAndHashTest.java
index 035917c8..035917c8 100644
--- a/java/src/test/java/com/google/protobuf/LiteEqualsAndHashTest.java
+++ b/java/core/src/test/java/com/google/protobuf/LiteEqualsAndHashTest.java
diff --git a/java/src/test/java/com/google/protobuf/LiteTest.java b/java/core/src/test/java/com/google/protobuf/LiteTest.java
index b1f298ff..b1f298ff 100644
--- a/java/src/test/java/com/google/protobuf/LiteTest.java
+++ b/java/core/src/test/java/com/google/protobuf/LiteTest.java
diff --git a/java/src/test/java/com/google/protobuf/LiteralByteStringTest.java b/java/core/src/test/java/com/google/protobuf/LiteralByteStringTest.java
index c8495633..c8495633 100644
--- a/java/src/test/java/com/google/protobuf/LiteralByteStringTest.java
+++ b/java/core/src/test/java/com/google/protobuf/LiteralByteStringTest.java
diff --git a/java/src/test/java/com/google/protobuf/LongArrayListTest.java b/java/core/src/test/java/com/google/protobuf/LongArrayListTest.java
index 1bd094f7..1bd094f7 100644
--- a/java/src/test/java/com/google/protobuf/LongArrayListTest.java
+++ b/java/core/src/test/java/com/google/protobuf/LongArrayListTest.java
diff --git a/java/src/test/java/com/google/protobuf/MapForProto2LiteTest.java b/java/core/src/test/java/com/google/protobuf/MapForProto2LiteTest.java
index 3d8c9bc4..3d8c9bc4 100644
--- a/java/src/test/java/com/google/protobuf/MapForProto2LiteTest.java
+++ b/java/core/src/test/java/com/google/protobuf/MapForProto2LiteTest.java
diff --git a/java/src/test/java/com/google/protobuf/MapForProto2Test.java b/java/core/src/test/java/com/google/protobuf/MapForProto2Test.java
index 1fa3cbdb..1fa3cbdb 100644
--- a/java/src/test/java/com/google/protobuf/MapForProto2Test.java
+++ b/java/core/src/test/java/com/google/protobuf/MapForProto2Test.java
diff --git a/java/src/test/java/com/google/protobuf/MapTest.java b/java/core/src/test/java/com/google/protobuf/MapTest.java
index 0e5c1284..0e5c1284 100644
--- a/java/src/test/java/com/google/protobuf/MapTest.java
+++ b/java/core/src/test/java/com/google/protobuf/MapTest.java
diff --git a/java/src/test/java/com/google/protobuf/MessageTest.java b/java/core/src/test/java/com/google/protobuf/MessageTest.java
index abcd3a1d..abcd3a1d 100644
--- a/java/src/test/java/com/google/protobuf/MessageTest.java
+++ b/java/core/src/test/java/com/google/protobuf/MessageTest.java
diff --git a/java/src/test/java/com/google/protobuf/NestedBuildersTest.java b/java/core/src/test/java/com/google/protobuf/NestedBuildersTest.java
index 23653126..23653126 100644
--- a/java/src/test/java/com/google/protobuf/NestedBuildersTest.java
+++ b/java/core/src/test/java/com/google/protobuf/NestedBuildersTest.java
diff --git a/java/src/test/java/com/google/protobuf/NioByteStringTest.java b/java/core/src/test/java/com/google/protobuf/NioByteStringTest.java
index 0679937f..0679937f 100644
--- a/java/src/test/java/com/google/protobuf/NioByteStringTest.java
+++ b/java/core/src/test/java/com/google/protobuf/NioByteStringTest.java
diff --git a/java/core/src/test/java/com/google/protobuf/ParseExceptionsTest.java b/java/core/src/test/java/com/google/protobuf/ParseExceptionsTest.java
new file mode 100644
index 00000000..37fa242d
--- /dev/null
+++ b/java/core/src/test/java/com/google/protobuf/ParseExceptionsTest.java
@@ -0,0 +1,211 @@
+package com.google.protobuf;
+
+import com.google.protobuf.DescriptorProtos.DescriptorProto;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.FilterInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+/**
+ * Tests the exceptions thrown when parsing from a stream. The methods on the {@link Parser}
+ * interface are specified to only throw {@link InvalidProtocolBufferException}. But we really want
+ * to distinguish between invalid protos vs. actual I/O errors (like failures reading from a
+ * socket, etc.). So, when we're not using the parser directly, an {@link IOException} should be
+ * thrown where appropriate, instead of always an {@link InvalidProtocolBufferException}.
+ *
+ * @author jh@squareup.com (Joshua Humphries)
+ */
+public class ParseExceptionsTest {
+
+ private interface ParseTester {
+ DescriptorProto parse(InputStream in) throws IOException;
+ }
+
+ private byte serializedProto[];
+
+ private void setup() {
+ serializedProto = DescriptorProto.getDescriptor().toProto().toByteArray();
+ }
+
+ private void setupDelimited() {
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ try {
+ DescriptorProto.getDescriptor().toProto().writeDelimitedTo(bos);
+ } catch (IOException e) {
+ fail("Exception not expected: " + e);
+ }
+ serializedProto = bos.toByteArray();
+ }
+
+ @Test public void message_parseFrom_InputStream() {
+ setup();
+ verifyExceptions(new ParseTester() {
+ public DescriptorProto parse(InputStream in) throws IOException {
+ return DescriptorProto.parseFrom(in);
+ }
+ });
+ }
+
+ @Test public void message_parseFrom_InputStreamAndExtensionRegistry() {
+ setup();
+ verifyExceptions(new ParseTester() {
+ public DescriptorProto parse(InputStream in) throws IOException {
+ return DescriptorProto.parseFrom(in, ExtensionRegistry.newInstance());
+ }
+ });
+ }
+
+ @Test public void message_parseFrom_CodedInputStream() {
+ setup();
+ verifyExceptions(new ParseTester() {
+ public DescriptorProto parse(InputStream in) throws IOException {
+ return DescriptorProto.parseFrom(CodedInputStream.newInstance(in));
+ }
+ });
+ }
+
+ @Test public void message_parseFrom_CodedInputStreamAndExtensionRegistry() {
+ setup();
+ verifyExceptions(new ParseTester() {
+ public DescriptorProto parse(InputStream in) throws IOException {
+ return DescriptorProto.parseFrom(CodedInputStream.newInstance(in),
+ ExtensionRegistry.newInstance());
+ }
+ });
+ }
+
+ @Test public void message_parseDelimitedFrom_InputStream() {
+ setupDelimited();
+ verifyExceptions(new ParseTester() {
+ public DescriptorProto parse(InputStream in) throws IOException {
+ return DescriptorProto.parseDelimitedFrom(in);
+ }
+ });
+ }
+
+ @Test public void message_parseDelimitedFrom_InputStreamAndExtensionRegistry() {
+ setupDelimited();
+ verifyExceptions(new ParseTester() {
+ public DescriptorProto parse(InputStream in) throws IOException {
+ return DescriptorProto.parseDelimitedFrom(in, ExtensionRegistry.newInstance());
+ }
+ });
+ }
+
+ @Test public void messageBuilder_mergeFrom_InputStream() {
+ setup();
+ verifyExceptions(new ParseTester() {
+ public DescriptorProto parse(InputStream in) throws IOException {
+ return DescriptorProto.newBuilder().mergeFrom(in).build();
+ }
+ });
+ }
+
+ @Test public void messageBuilder_mergeFrom_InputStreamAndExtensionRegistry() {
+ setup();
+ verifyExceptions(new ParseTester() {
+ public DescriptorProto parse(InputStream in) throws IOException {
+ return DescriptorProto.newBuilder().mergeFrom(in, ExtensionRegistry.newInstance()).build();
+ }
+ });
+ }
+
+ @Test public void messageBuilder_mergeFrom_CodedInputStream() {
+ setup();
+ verifyExceptions(new ParseTester() {
+ public DescriptorProto parse(InputStream in) throws IOException {
+ return DescriptorProto.newBuilder().mergeFrom(CodedInputStream.newInstance(in)).build();
+ }
+ });
+ }
+
+ @Test public void messageBuilder_mergeFrom_CodedInputStreamAndExtensionRegistry() {
+ setup();
+ verifyExceptions(new ParseTester() {
+ public DescriptorProto parse(InputStream in) throws IOException {
+ return DescriptorProto.newBuilder()
+ .mergeFrom(CodedInputStream.newInstance(in), ExtensionRegistry.newInstance()).build();
+ }
+ });
+ }
+
+ @Test public void messageBuilder_mergeDelimitedFrom_InputStream() {
+ setupDelimited();
+ verifyExceptions(new ParseTester() {
+ public DescriptorProto parse(InputStream in) throws IOException {
+ DescriptorProto.Builder builder = DescriptorProto.newBuilder();
+ builder.mergeDelimitedFrom(in);
+ return builder.build();
+ }
+ });
+ }
+
+ @Test public void messageBuilder_mergeDelimitedFrom_InputStreamAndExtensionRegistry() {
+ setupDelimited();
+ verifyExceptions(new ParseTester() {
+ public DescriptorProto parse(InputStream in) throws IOException {
+ DescriptorProto.Builder builder = DescriptorProto.newBuilder();
+ builder.mergeDelimitedFrom(in, ExtensionRegistry.newInstance());
+ return builder.build();
+ }
+ });
+ }
+
+ private void verifyExceptions(ParseTester parseTester) {
+ // No exception
+ try {
+ assertEquals(DescriptorProto.getDescriptor().toProto(),
+ parseTester.parse(new ByteArrayInputStream(serializedProto)));
+ } catch (IOException e) {
+ fail("No exception expected: " + e);
+ }
+
+ // IOException
+ try {
+ // using a "broken" stream that will throw part-way through reading the message
+ parseTester.parse(broken(new ByteArrayInputStream(serializedProto)));
+ fail("IOException expected but not thrown");
+ } catch (IOException e) {
+ assertFalse(e instanceof InvalidProtocolBufferException);
+ }
+
+ // InvalidProtocolBufferException
+ try {
+ // make the serialized proto invalid
+ for (int i = 0; i < 50; i++) {
+ serializedProto[i] = -1;
+ }
+ parseTester.parse(new ByteArrayInputStream(serializedProto));
+ fail("InvalidProtocolBufferException expected but not thrown");
+ } catch (IOException e) {
+ assertTrue(e instanceof InvalidProtocolBufferException);
+ }
+ }
+
+ private InputStream broken(InputStream i) {
+ return new FilterInputStream(i) {
+ int count = 0;
+
+ @Override public int read() throws IOException {
+ if (count++ >= 50) {
+ throw new IOException("I'm broken!");
+ }
+ return super.read();
+ }
+
+ @Override public int read(byte b[], int off, int len) throws IOException {
+ if ((count += len) >= 50) {
+ throw new IOException("I'm broken!");
+ }
+ return super.read(b, off, len);
+ }
+ };
+ }
+}
diff --git a/java/src/test/java/com/google/protobuf/ParserTest.java b/java/core/src/test/java/com/google/protobuf/ParserTest.java
index 5a92bacf..5a92bacf 100644
--- a/java/src/test/java/com/google/protobuf/ParserTest.java
+++ b/java/core/src/test/java/com/google/protobuf/ParserTest.java
diff --git a/java/src/test/java/com/google/protobuf/ProtobufArrayListTest.java b/java/core/src/test/java/com/google/protobuf/ProtobufArrayListTest.java
index 245c3dee..245c3dee 100644
--- a/java/src/test/java/com/google/protobuf/ProtobufArrayListTest.java
+++ b/java/core/src/test/java/com/google/protobuf/ProtobufArrayListTest.java
diff --git a/java/src/test/java/com/google/protobuf/RepeatedFieldBuilderTest.java b/java/core/src/test/java/com/google/protobuf/RepeatedFieldBuilderTest.java
index 49d52321..49d52321 100644
--- a/java/src/test/java/com/google/protobuf/RepeatedFieldBuilderTest.java
+++ b/java/core/src/test/java/com/google/protobuf/RepeatedFieldBuilderTest.java
diff --git a/java/src/test/java/com/google/protobuf/RopeByteStringSubstringTest.java b/java/core/src/test/java/com/google/protobuf/RopeByteStringSubstringTest.java
index dc56f2e9..dc56f2e9 100644
--- a/java/src/test/java/com/google/protobuf/RopeByteStringSubstringTest.java
+++ b/java/core/src/test/java/com/google/protobuf/RopeByteStringSubstringTest.java
diff --git a/java/src/test/java/com/google/protobuf/RopeByteStringTest.java b/java/core/src/test/java/com/google/protobuf/RopeByteStringTest.java
index 4ec3a409..4ec3a409 100644
--- a/java/src/test/java/com/google/protobuf/RopeByteStringTest.java
+++ b/java/core/src/test/java/com/google/protobuf/RopeByteStringTest.java
diff --git a/java/src/test/java/com/google/protobuf/ServiceTest.java b/java/core/src/test/java/com/google/protobuf/ServiceTest.java
index ff980d66..ff980d66 100644
--- a/java/src/test/java/com/google/protobuf/ServiceTest.java
+++ b/java/core/src/test/java/com/google/protobuf/ServiceTest.java
diff --git a/java/src/test/java/com/google/protobuf/SingleFieldBuilderTest.java b/java/core/src/test/java/com/google/protobuf/SingleFieldBuilderTest.java
index 58b80007..58b80007 100644
--- a/java/src/test/java/com/google/protobuf/SingleFieldBuilderTest.java
+++ b/java/core/src/test/java/com/google/protobuf/SingleFieldBuilderTest.java
diff --git a/java/src/test/java/com/google/protobuf/SmallSortedMapTest.java b/java/core/src/test/java/com/google/protobuf/SmallSortedMapTest.java
index 366086d3..366086d3 100644
--- a/java/src/test/java/com/google/protobuf/SmallSortedMapTest.java
+++ b/java/core/src/test/java/com/google/protobuf/SmallSortedMapTest.java
diff --git a/java/src/test/java/com/google/protobuf/TestBadIdentifiers.java b/java/core/src/test/java/com/google/protobuf/TestBadIdentifiers.java
index 2c60fe0e..2c60fe0e 100644
--- a/java/src/test/java/com/google/protobuf/TestBadIdentifiers.java
+++ b/java/core/src/test/java/com/google/protobuf/TestBadIdentifiers.java
diff --git a/java/src/test/java/com/google/protobuf/TestUtil.java b/java/core/src/test/java/com/google/protobuf/TestUtil.java
index 01acb884..01acb884 100644
--- a/java/src/test/java/com/google/protobuf/TestUtil.java
+++ b/java/core/src/test/java/com/google/protobuf/TestUtil.java
diff --git a/java/src/test/java/com/google/protobuf/TextFormatTest.java b/java/core/src/test/java/com/google/protobuf/TextFormatTest.java
index 1df4fad7..1df4fad7 100644
--- a/java/src/test/java/com/google/protobuf/TextFormatTest.java
+++ b/java/core/src/test/java/com/google/protobuf/TextFormatTest.java
diff --git a/java/src/test/java/com/google/protobuf/UnknownEnumValueTest.java b/java/core/src/test/java/com/google/protobuf/UnknownEnumValueTest.java
index 8f45976f..8f45976f 100644
--- a/java/src/test/java/com/google/protobuf/UnknownEnumValueTest.java
+++ b/java/core/src/test/java/com/google/protobuf/UnknownEnumValueTest.java
diff --git a/java/src/test/java/com/google/protobuf/UnknownFieldSetLiteTest.java b/java/core/src/test/java/com/google/protobuf/UnknownFieldSetLiteTest.java
index dc987379..dc987379 100644
--- a/java/src/test/java/com/google/protobuf/UnknownFieldSetLiteTest.java
+++ b/java/core/src/test/java/com/google/protobuf/UnknownFieldSetLiteTest.java
diff --git a/java/src/test/java/com/google/protobuf/UnknownFieldSetTest.java b/java/core/src/test/java/com/google/protobuf/UnknownFieldSetTest.java
index 8c9dcafe..8c9dcafe 100644
--- a/java/src/test/java/com/google/protobuf/UnknownFieldSetTest.java
+++ b/java/core/src/test/java/com/google/protobuf/UnknownFieldSetTest.java
diff --git a/java/src/test/java/com/google/protobuf/UnmodifiableLazyStringListTest.java b/java/core/src/test/java/com/google/protobuf/UnmodifiableLazyStringListTest.java
index b1c75fc3..b1c75fc3 100644
--- a/java/src/test/java/com/google/protobuf/UnmodifiableLazyStringListTest.java
+++ b/java/core/src/test/java/com/google/protobuf/UnmodifiableLazyStringListTest.java
diff --git a/java/src/test/java/com/google/protobuf/WellKnownTypesTest.java b/java/core/src/test/java/com/google/protobuf/WellKnownTypesTest.java
index 982e200f..982e200f 100644
--- a/java/src/test/java/com/google/protobuf/WellKnownTypesTest.java
+++ b/java/core/src/test/java/com/google/protobuf/WellKnownTypesTest.java
diff --git a/java/src/test/java/com/google/protobuf/WireFormatTest.java b/java/core/src/test/java/com/google/protobuf/WireFormatTest.java
index 0175005d..0175005d 100644
--- a/java/src/test/java/com/google/protobuf/WireFormatTest.java
+++ b/java/core/src/test/java/com/google/protobuf/WireFormatTest.java
diff --git a/java/src/test/java/com/google/protobuf/any_test.proto b/java/core/src/test/proto/com/google/protobuf/any_test.proto
index 80173d8a..80173d8a 100644
--- a/java/src/test/java/com/google/protobuf/any_test.proto
+++ b/java/core/src/test/proto/com/google/protobuf/any_test.proto
diff --git a/java/src/test/java/com/google/protobuf/field_presence_test.proto b/java/core/src/test/proto/com/google/protobuf/field_presence_test.proto
index 8f3ca8c6..8f3ca8c6 100644
--- a/java/src/test/java/com/google/protobuf/field_presence_test.proto
+++ b/java/core/src/test/proto/com/google/protobuf/field_presence_test.proto
diff --git a/java/src/test/java/com/google/protobuf/lazy_fields_lite.proto b/java/core/src/test/proto/com/google/protobuf/lazy_fields_lite.proto
index 5580f72d..5580f72d 100644
--- a/java/src/test/java/com/google/protobuf/lazy_fields_lite.proto
+++ b/java/core/src/test/proto/com/google/protobuf/lazy_fields_lite.proto
diff --git a/java/src/test/java/com/google/protobuf/lite_equals_and_hash.proto b/java/core/src/test/proto/com/google/protobuf/lite_equals_and_hash.proto
index 86837250..86837250 100644
--- a/java/src/test/java/com/google/protobuf/lite_equals_and_hash.proto
+++ b/java/core/src/test/proto/com/google/protobuf/lite_equals_and_hash.proto
diff --git a/java/src/test/java/com/google/protobuf/map_for_proto2_lite_test.proto b/java/core/src/test/proto/com/google/protobuf/map_for_proto2_lite_test.proto
index d5418f28..d5418f28 100644
--- a/java/src/test/java/com/google/protobuf/map_for_proto2_lite_test.proto
+++ b/java/core/src/test/proto/com/google/protobuf/map_for_proto2_lite_test.proto
diff --git a/java/src/test/java/com/google/protobuf/map_for_proto2_test.proto b/java/core/src/test/proto/com/google/protobuf/map_for_proto2_test.proto
index a9be5166..a9be5166 100644
--- a/java/src/test/java/com/google/protobuf/map_for_proto2_test.proto
+++ b/java/core/src/test/proto/com/google/protobuf/map_for_proto2_test.proto
diff --git a/java/src/test/java/com/google/protobuf/map_initialization_order_test.proto b/java/core/src/test/proto/com/google/protobuf/map_initialization_order_test.proto
index b02ac599..b02ac599 100644
--- a/java/src/test/java/com/google/protobuf/map_initialization_order_test.proto
+++ b/java/core/src/test/proto/com/google/protobuf/map_initialization_order_test.proto
diff --git a/java/src/test/java/com/google/protobuf/map_test.proto b/java/core/src/test/proto/com/google/protobuf/map_test.proto
index 2280ac03..2280ac03 100644
--- a/java/src/test/java/com/google/protobuf/map_test.proto
+++ b/java/core/src/test/proto/com/google/protobuf/map_test.proto
diff --git a/java/src/test/java/com/google/protobuf/multiple_files_test.proto b/java/core/src/test/proto/com/google/protobuf/multiple_files_test.proto
index 92790506..92790506 100644
--- a/java/src/test/java/com/google/protobuf/multiple_files_test.proto
+++ b/java/core/src/test/proto/com/google/protobuf/multiple_files_test.proto
diff --git a/java/src/test/java/com/google/protobuf/nested_builders_test.proto b/java/core/src/test/proto/com/google/protobuf/nested_builders_test.proto
index a5dd66d8..a5dd66d8 100644
--- a/java/src/test/java/com/google/protobuf/nested_builders_test.proto
+++ b/java/core/src/test/proto/com/google/protobuf/nested_builders_test.proto
diff --git a/java/src/test/java/com/google/protobuf/nested_extension.proto b/java/core/src/test/proto/com/google/protobuf/nested_extension.proto
index 704e649e..704e649e 100644
--- a/java/src/test/java/com/google/protobuf/nested_extension.proto
+++ b/java/core/src/test/proto/com/google/protobuf/nested_extension.proto
diff --git a/java/src/test/java/com/google/protobuf/nested_extension_lite.proto b/java/core/src/test/proto/com/google/protobuf/nested_extension_lite.proto
index a95c38b2..a95c38b2 100644
--- a/java/src/test/java/com/google/protobuf/nested_extension_lite.proto
+++ b/java/core/src/test/proto/com/google/protobuf/nested_extension_lite.proto
diff --git a/java/src/test/java/com/google/protobuf/non_nested_extension.proto b/java/core/src/test/proto/com/google/protobuf/non_nested_extension.proto
index 31fac552..31fac552 100644
--- a/java/src/test/java/com/google/protobuf/non_nested_extension.proto
+++ b/java/core/src/test/proto/com/google/protobuf/non_nested_extension.proto
diff --git a/java/src/test/java/com/google/protobuf/non_nested_extension_lite.proto b/java/core/src/test/proto/com/google/protobuf/non_nested_extension_lite.proto
index 37c369ed..37c369ed 100644
--- a/java/src/test/java/com/google/protobuf/non_nested_extension_lite.proto
+++ b/java/core/src/test/proto/com/google/protobuf/non_nested_extension_lite.proto
diff --git a/java/src/test/java/com/google/protobuf/outer_class_name_test.proto b/java/core/src/test/proto/com/google/protobuf/outer_class_name_test.proto
index 42083681..42083681 100644
--- a/java/src/test/java/com/google/protobuf/outer_class_name_test.proto
+++ b/java/core/src/test/proto/com/google/protobuf/outer_class_name_test.proto
diff --git a/java/src/test/java/com/google/protobuf/outer_class_name_test2.proto b/java/core/src/test/proto/com/google/protobuf/outer_class_name_test2.proto
index 3e5956b0..3e5956b0 100644
--- a/java/src/test/java/com/google/protobuf/outer_class_name_test2.proto
+++ b/java/core/src/test/proto/com/google/protobuf/outer_class_name_test2.proto
diff --git a/java/src/test/java/com/google/protobuf/outer_class_name_test3.proto b/java/core/src/test/proto/com/google/protobuf/outer_class_name_test3.proto
index 74a8ba3c..74a8ba3c 100644
--- a/java/src/test/java/com/google/protobuf/outer_class_name_test3.proto
+++ b/java/core/src/test/proto/com/google/protobuf/outer_class_name_test3.proto
diff --git a/java/src/test/java/com/google/protobuf/test_bad_identifiers.proto b/java/core/src/test/proto/com/google/protobuf/test_bad_identifiers.proto
index 2b1f65e4..2b1f65e4 100644
--- a/java/src/test/java/com/google/protobuf/test_bad_identifiers.proto
+++ b/java/core/src/test/proto/com/google/protobuf/test_bad_identifiers.proto
diff --git a/java/src/test/java/com/google/protobuf/test_check_utf8.proto b/java/core/src/test/proto/com/google/protobuf/test_check_utf8.proto
index 119c1dcb..119c1dcb 100644
--- a/java/src/test/java/com/google/protobuf/test_check_utf8.proto
+++ b/java/core/src/test/proto/com/google/protobuf/test_check_utf8.proto
diff --git a/java/src/test/java/com/google/protobuf/test_check_utf8_size.proto b/java/core/src/test/proto/com/google/protobuf/test_check_utf8_size.proto
index f06d76d6..f06d76d6 100644
--- a/java/src/test/java/com/google/protobuf/test_check_utf8_size.proto
+++ b/java/core/src/test/proto/com/google/protobuf/test_check_utf8_size.proto
diff --git a/java/src/test/java/com/google/protobuf/test_custom_options.proto b/java/core/src/test/proto/com/google/protobuf/test_custom_options.proto
index f8efd455..f8efd455 100644
--- a/java/src/test/java/com/google/protobuf/test_custom_options.proto
+++ b/java/core/src/test/proto/com/google/protobuf/test_custom_options.proto
diff --git a/java/src/test/java/com/google/protobuf/test_extra_interfaces.proto b/java/core/src/test/proto/com/google/protobuf/test_extra_interfaces.proto
index 645f57b4..645f57b4 100644
--- a/java/src/test/java/com/google/protobuf/test_extra_interfaces.proto
+++ b/java/core/src/test/proto/com/google/protobuf/test_extra_interfaces.proto
diff --git a/java/lite/pom.xml b/java/lite/pom.xml
new file mode 100644
index 00000000..29d8c8c4
--- /dev/null
+++ b/java/lite/pom.xml
@@ -0,0 +1,158 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>com.google.protobuf</groupId>
+ <artifactId>protobuf-parent</artifactId>
+ <version>3.0.0-beta-2</version>
+ </parent>
+
+ <artifactId>protobuf-lite</artifactId>
+ <packaging>bundle</packaging>
+
+ <name>Protocol Buffers [Lite]</name>
+ <description>A trimmed-down version of the Protocol Buffers library.</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymockclassextension</artifactId>
+ </dependency>
+ </dependencies>
+
+ <properties>
+ <core.root>../core</core.root>
+ <test.proto.dir>${core.root}/src/test/proto</test.proto.dir>
+ </properties>
+
+ <build>
+ <sourceDirectory>${core.root}/src/main/java</sourceDirectory>
+ <testSourceDirectory>${core.root}/src/test/java</testSourceDirectory>
+
+ <plugins>
+ <!-- Use Antrun plugin to generate sources with protoc -->
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <!-- Generate core protos -->
+ <execution>
+ <id>generate-sources</id>
+ <phase>generate-sources</phase>
+ <configuration>
+ <target>
+ <ant antfile="${core.root}/generate-sources-build.xml"/>
+ </target>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ <!-- Generate the test protos -->
+ <execution>
+ <id>generate-test-sources</id>
+ <phase>generate-test-sources</phase>
+ <configuration>
+ <target>
+ <ant antfile="${core.root}/generate-test-sources-build.xml"/>
+ </target>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!-- Only compile a subset of the files -->
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <generatedSourcesDirectory>${generated.sources.dir}</generatedSourcesDirectory>
+ <generatedTestSourcesDirectory>${generated.testsources.dir}</generatedTestSourcesDirectory>
+ <includes>
+ <include>**/AbstractMessageLite.java</include>
+ <include>**/AbstractParser.java</include>
+ <include>**/AbstractProtobufList.java</include>
+ <include>**/BoundedByteString.java</include>
+ <include>**/BooleanArrayList.java</include>
+ <include>**/ByteString.java</include>
+ <include>**/CodedInputStream.java</include>
+ <include>**/CodedOutputStream.java</include>
+ <include>**/DoubleArrayList.java</include>
+ <include>**/ExtensionLite.java</include>
+ <include>**/ExtensionRegistryLite.java</include>
+ <include>**/FieldSet.java</include>
+ <include>**/FloatArrayList.java</include>
+ <include>**/GeneratedMessageLite.java</include>
+ <include>**/IntArrayList.java</include>
+ <include>**/Internal.java</include>
+ <include>**/InvalidProtocolBufferException.java</include>
+ <include>**/LazyFieldLite.java</include>
+ <include>**/LazyStringArrayList.java</include>
+ <include>**/LazyStringList.java</include>
+ <include>**/LiteralByteString.java</include>
+ <include>**/LongArrayList.java</include>
+ <include>**/MapEntryLite.java</include>
+ <include>**/MapFieldLite.java</include>
+ <include>**/MessageLite.java</include>
+ <include>**/MessageLiteOrBuilder.java</include>
+ <include>**/MessageLiteToString.java</include>
+ <include>**/MutabilityOracle.java</include>
+ <include>**/NioByteString.java</include>
+ <include>**/Parser.java</include>
+ <include>**/ProtobufArrayList.java</include>
+ <include>**/ProtocolStringList.java</include>
+ <include>**/RopeByteString.java</include>
+ <include>**/SmallSortedMap.java</include>
+ <include>**/TextFormatEscaper.java</include>
+ <include>**/UninitializedMessageException.java</include>
+ <include>**/UnknownFieldSetLite.java</include>
+ <include>**/UnmodifiableLazyStringList.java</include>
+ <include>**/UnsafeByteStrings.java</include>
+ <include>**/Utf8.java</include>
+ <include>**/WireFormat.java</include>
+ </includes>
+ <testIncludes>
+ <testInclude>**/*Lite.java</testInclude>
+ <testInclude>**/BooleanArrayListTest.java</testInclude>
+ <testInclude>**/DoubleArrayListTest.java</testInclude>
+ <testInclude>**/FloatArrayListTest.java</testInclude>
+ <testInclude>**/IntArrayListTest.java</testInclude>
+ <testInclude>**/LazyMessageLiteTest.java</testInclude>
+ <testInclude>**/LiteTest.java</testInclude>
+ <testInclude>**/LongArrayListTest.java</testInclude>
+ <testInclude>**/NioByteStringTest.java</testInclude>
+ <testInclude>**/ProtobufArrayListTest.java</testInclude>
+ <testInclude>**/UnknownFieldSetLiteTest.java</testInclude>
+ </testIncludes>
+ </configuration>
+ </plugin>
+
+ <!-- OSGI bundle configuration -->
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-DocURL>https://developers.google.com/protocol-buffers/</Bundle-DocURL>
+ <Bundle-SymbolicName>com.google.protobuf</Bundle-SymbolicName>
+ <Export-Package>com.google.${project.artifactId};version=${project.version}</Export-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/java/pom.xml b/java/pom.xml
index 3eab00ad..d5719edf 100644
--- a/java/pom.xml
+++ b/java/pom.xml
@@ -8,17 +8,33 @@
<artifactId>google</artifactId>
<version>1</version>
</parent>
+
<groupId>com.google.protobuf</groupId>
- <artifactId>protobuf-java</artifactId>
+ <artifactId>protobuf-parent</artifactId>
<version>3.0.0-beta-2</version>
- <packaging>bundle</packaging>
- <name>Protocol Buffer Java API</name>
+ <packaging>pom</packaging>
+
+ <name>Protocol Buffers [Parent]</name>
+ <inceptionYear>2008</inceptionYear>
+ <url>https://developers.google.com/protocol-buffers/</url>
<description>
Protocol Buffers are a way of encoding structured data in an efficient yet
extensible format.
</description>
- <inceptionYear>2008</inceptionYear>
- <url>https://developers.google.com/protocol-buffers/</url>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+
+ <!-- These are relative to the submodules -->
+ <protobuf.basedir>${project.basedir}/../..</protobuf.basedir>
+ <protobuf.source.dir>${protobuf.basedir}/src</protobuf.source.dir>
+ <protoc>${protobuf.source.dir}/protoc</protoc>
+ <test.proto.dir>src/test/proto</test.proto.dir>
+ <generated.sources.dir>${project.build.directory}/generated-sources</generated.sources.dir>
+ <generated.testsources.dir>${project.build.directory}/generated-test-sources</generated.testsources.dir>
+ </properties>
+
<licenses>
<license>
<name>New BSD license</name>
@@ -26,217 +42,116 @@
<distribution>repo</distribution>
</license>
</licenses>
+
<scm>
<url>https://github.com/google/protobuf</url>
- <connection>
- scm:git:https://github.com/google/protobuf.git
- </connection>
+ <connection>scm:git:https://github.com/google/protobuf.git</connection>
</scm>
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.4</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.easymock</groupId>
- <artifactId>easymock</artifactId>
- <version>2.2</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.easymock</groupId>
- <artifactId>easymockclassextension</artifactId>
- <version>2.2.1</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
+
+ <distributionManagement>
+ <snapshotRepository>
+ <id>sonatype-nexus-staging</id>
+ <url>https://oss.sonatype.org/content/repositories/snapshots</url>
+ </snapshotRepository>
+ <repository>
+ <id>sonatype-nexus-staging</id>
+ <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
+ </repository>
+ </distributionManagement>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.4</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ <version>2.2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymockclassextension</artifactId>
+ <version>2.2.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ <version>18.0</version>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
<build>
- <plugins>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
- </plugin>
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <includes>
- <include>**/*Test.java</include>
- </includes>
- </configuration>
- </plugin>
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <execution>
- <id>generate-sources</id>
- <phase>generate-sources</phase>
- <configuration>
- <tasks>
- <mkdir dir="target/generated-sources" />
- <exec executable="../src/protoc">
- <arg value="--java_out=target/generated-sources" />
- <arg value="--proto_path=../src" />
- <arg value="../src/google/protobuf/any.proto" />
- <arg value="../src/google/protobuf/api.proto" />
- <arg value="../src/google/protobuf/descriptor.proto" />
- <arg value="../src/google/protobuf/duration.proto" />
- <arg value="../src/google/protobuf/empty.proto" />
- <arg value="../src/google/protobuf/field_mask.proto" />
- <arg value="../src/google/protobuf/source_context.proto" />
- <arg value="../src/google/protobuf/struct.proto" />
- <arg value="../src/google/protobuf/timestamp.proto" />
- <arg value="../src/google/protobuf/type.proto" />
- <arg value="../src/google/protobuf/wrappers.proto" />
- <arg value="../src/google/protobuf/compiler/plugin.proto" />
- </exec>
- </tasks>
- <sourceRoot>target/generated-sources</sourceRoot>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- <execution>
- <id>generate-test-sources</id>
- <phase>generate-test-sources</phase>
- <configuration>
- <tasks>
- <mkdir dir="target/generated-test-sources" />
- <exec executable="../src/protoc">
- <arg value="--java_out=target/generated-test-sources" />
- <arg value="--proto_path=../src" />
- <arg value="--proto_path=src/test/java" />
- <arg value="../src/google/protobuf/unittest.proto" />
- <arg value="../src/google/protobuf/unittest_import.proto" />
- <arg value="../src/google/protobuf/unittest_import_public.proto" />
- <arg value="../src/google/protobuf/unittest_mset.proto" />
- <arg value="../src/google/protobuf/unittest_mset_wire_format.proto" />
- <arg value="src/test/java/com/google/protobuf/lazy_fields_lite.proto" />
- <arg value="src/test/java/com/google/protobuf/lite_equals_and_hash.proto" />
- <arg
- value="src/test/java/com/google/protobuf/multiple_files_test.proto" />
- <arg value="src/test/java/com/google/protobuf/nested_builders_test.proto" />
- <arg value="src/test/java/com/google/protobuf/nested_extension.proto" />
- <arg value="src/test/java/com/google/protobuf/nested_extension_lite.proto" />
- <arg value="src/test/java/com/google/protobuf/non_nested_extension.proto" />
- <arg value="src/test/java/com/google/protobuf/non_nested_extension_lite.proto" />
- <arg value="src/test/java/com/google/protobuf/outer_class_name_test.proto" />
- <arg value="src/test/java/com/google/protobuf/outer_class_name_test2.proto" />
- <arg value="src/test/java/com/google/protobuf/outer_class_name_test3.proto" />
- <arg value="src/test/java/com/google/protobuf/test_bad_identifiers.proto" />
- <arg value="src/test/java/com/google/protobuf/test_check_utf8.proto" />
- <arg value="src/test/java/com/google/protobuf/test_check_utf8_size.proto" />
- <arg value="src/test/java/com/google/protobuf/test_custom_options.proto" />
- <arg
- value="../src/google/protobuf/unittest_optimize_for.proto" />
- <arg
- value="../src/google/protobuf/unittest_custom_options.proto" />
- <arg value="../src/google/protobuf/unittest_lite.proto" />
- <arg value="../src/google/protobuf/unittest_import_lite.proto" />
- <arg value="../src/google/protobuf/unittest_import_public_lite.proto" />
- <arg value="../src/google/protobuf/unittest_lite_imports_nonlite.proto" />
- <arg value="../src/google/protobuf/unittest_enormous_descriptor.proto" />
- <arg value="../src/google/protobuf/unittest_no_generic_services.proto" />
- <arg value="../src/google/protobuf/unittest_well_known_types.proto" />
- <arg value="src/test/java/com/google/protobuf/any_test.proto" />
- <arg value="src/test/java/com/google/protobuf/field_presence_test.proto" />
- <arg value="src/test/java/com/google/protobuf/map_for_proto2_lite_test.proto" />
- <arg value="src/test/java/com/google/protobuf/map_for_proto2_test.proto" />
- <arg value="src/test/java/com/google/protobuf/map_test.proto" />
- <arg value="src/test/java/com/google/protobuf/map_initialization_order_test.proto" />
- </exec>
- </tasks>
- <testSourceRoot>target/generated-test-sources</testSourceRoot>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Bundle-DocURL>https://developers.google.com/protocol-buffers/</Bundle-DocURL>
- <Bundle-SymbolicName>com.google.protobuf</Bundle-SymbolicName>
- <Export-Package>com.google.protobuf;version=3.0.0-beta-2</Export-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- <resources>
- <resource>
- <directory>../src</directory>
- <includes>
- <include>google/protobuf/any.proto</include>
- <include>google/protobuf/api.proto</include>
- <include>google/protobuf/descriptor.proto</include>
- <include>google/protobuf/duration.proto</include>
- <include>google/protobuf/empty.proto</include>
- <include>google/protobuf/field_mask.proto</include>
- <include>google/protobuf/source_context.proto</include>
- <include>google/protobuf/struct.proto</include>
- <include>google/protobuf/timestamp.proto</include>
- <include>google/protobuf/type.proto</include>
- <include>google/protobuf/wrappers.proto</include>
- <include>google/protobuf/compiler/plugin.proto</include>
- </includes>
- </resource>
- </resources>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.3</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-source-plugin</artifactId>
+ <version>2.4</version>
+ <executions>
+ <execution>
+ <id>attach-sources</id>
+ <goals>
+ <goal>jar-no-fork</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.10.3</version>
+ <executions>
+ <execution>
+ <id>attach-javadocs</id>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>2.6</version>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.10</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>3.0.1</version>
+ </plugin>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.8</version>
+ </plugin>
+ </plugins>
+ </pluginManagement>
</build>
+
<profiles>
<profile>
<id>release</id>
- <distributionManagement>
- <snapshotRepository>
- <id>sonatype-nexus-staging</id>
- <url>https://oss.sonatype.org/content/repositories/snapshots</url>
- </snapshotRepository>
- <repository>
- <id>sonatype-nexus-staging</id>
- <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
- </repository>
- </distributionManagement>
<build>
<plugins>
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-source-plugin</artifactId>
- <version>2.2.1</version>
- <executions>
- <execution>
- <id>attach-sources</id>
- <goals>
- <goal>jar-no-fork</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <version>2.9.1</version>
- <executions>
- <execution>
- <id>attach-javadocs</id>
- <goals>
- <goal>jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
- <version>1.5</version>
+ <version>1.6</version>
<executions>
<execution>
<id>sign-artifacts</id>
@@ -250,98 +165,23 @@
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
- <version>1.6.3</version>
+ <version>1.6.6</version>
<extensions>true</extensions>
<configuration>
- <serverId>sonatype-nexus-staging</serverId>
- <nexusUrl>https://oss.sonatype.org/</nexusUrl>
- <autoReleaseAfterClose>false</autoReleaseAfterClose>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
- <profile>
- <id>lite</id>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <includes>
- <include>**/AbstractMessageLite.java</include>
- <include>**/AbstractParser.java</include>
- <include>**/AbstractProtobufList.java</include>
- <include>**/BoundedByteString.java</include>
- <include>**/BooleanArrayList.java</include>
- <include>**/ByteString.java</include>
- <include>**/CodedInputStream.java</include>
- <include>**/CodedOutputStream.java</include>
- <include>**/DoublerrayList.java</include>
- <include>**/ExtensionLite.java</include>
- <include>**/ExtensionRegistryLite.java</include>
- <include>**/FieldSet.java</include>
- <include>**/FloatArrayList.java</include>
- <include>**/GeneratedMessageLite.java</include>
- <include>**/IntArrayList.java</include>
- <include>**/Internal.java</include>
- <include>**/InvalidProtocolBufferException.java</include>
- <include>**/LazyFieldLite.java</include>
- <include>**/LazyStringArrayList.java</include>
- <include>**/LazyStringList.java</include>
- <include>**/LiteralByteString.java</include>
- <include>**/LongArrayList.java</include>
- <include>**/MapEntryLite.java</include>
- <include>**/MapFieldLite.java</include>
- <include>**/MessageLite.java</include>
- <include>**/MessageLiteOrBuilder.java</include>
- <include>**/MessageLiteToString.java</include>
- <include>**/MutabilityOracle.java</include>
- <include>**/NioByteString.java</include>
- <include>**/Parser.java</include>
- <include>**/ProtobufArrayList.java</include>
- <include>**/ProtocolStringList.java</include>
- <include>**/RopeByteString.java</include>
- <include>**/SmallSortedMap.java</include>
- <include>**/TextFormatEscaper.java</include>
- <include>**/UninitializedMessageException.java</include>
- <include>**/UnknownFieldSetLite.java</include>
- <include>**/UnmodifiableLazyStringList.java</include>
- <include>**/UnsafeByteStrings.java</include>
- <include>**/Utf8.java</include>
- <include>**/WireFormat.java</include>
- </includes>
- <testIncludes>
- <testInclude>**/*Lite.java</testInclude>
- <testInclude>**/BooleanArrayListTest.java</testInclude>
- <testInclude>**/DoubleArrayListTest.java</testInclude>
- <testInclude>**/FloatArrayListTest.java</testInclude>
- <testInclude>**/IntArrayListTest.java</testInclude>
- <testInclude>**/LazyMessageLiteTest.java</testInclude>
- <testInclude>**/LiteTest.java</testInclude>
- <testInclude>**/LongArrayListTest.java</testInclude>
- <testInclude>**/NioByteStringTest.java</testInclude>
- <testInclude>**/ProtobufArrayListTest.java</testInclude>
- <testInclude>**/UnknownFieldSetLiteTest.java</testInclude>
- </testIncludes>
- </configuration>
- </plugin>
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <includes>
- <include>**/*Test.java</include>
- </includes>
- </configuration>
- </plugin>
- <plugin>
- <artifactId>maven-jar-plugin</artifactId>
- <configuration>
- <classifier>lite</classifier>
+ <serverId>sonatype-nexus-staging</serverId>
+ <nexusUrl>https://oss.sonatype.org/</nexusUrl>
+ <autoReleaseAfterClose>false</autoReleaseAfterClose>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
+
+ <modules>
+ <module>core</module>
+ <module>lite</module>
+ <module>util</module>
+ </modules>
+
</project>
diff --git a/java/util/pom.xml b/java/util/pom.xml
index 70401a4b..26c12c82 100644
--- a/java/util/pom.xml
+++ b/java/util/pom.xml
@@ -4,110 +4,73 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>com.google</groupId>
- <artifactId>google</artifactId>
- <version>1</version>
+ <groupId>com.google.protobuf</groupId>
+ <artifactId>protobuf-parent</artifactId>
+ <version>3.0.0-beta-2</version>
</parent>
- <groupId>com.google.protobuf</groupId>
+
<artifactId>protobuf-java-util</artifactId>
- <version>3.0.0-beta-2</version>
<packaging>bundle</packaging>
- <name>Protocol Buffer Java API</name>
- <description>
- Protocol Buffers are a way of encoding structured data in an efficient yet
- extensible format.
- </description>
- <inceptionYear>2008</inceptionYear>
- <url>https://developers.google.com/protocol-buffers/</url>
- <licenses>
- <license>
- <name>New BSD license</name>
- <url>http://www.opensource.org/licenses/bsd-license.php</url>
- <distribution>repo</distribution>
- </license>
- </licenses>
- <scm>
- <url>https://github.com/google/protobuf</url>
- <connection>
- scm:git:https://github.com/google/protobuf.git
- </connection>
- </scm>
+
+ <name>Protocol Buffers [Util]</name>
+ <description>Utilities for Protocol Buffers</description>
+
<dependencies>
<dependency>
- <groupId>com.google.protobuf</groupId>
+ <groupId>${project.groupId}</groupId>
<artifactId>protobuf-java</artifactId>
- <version>3.0.0-beta-2</version>
- <scope>compile</scope>
+ <version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
- <version>18.0</version>
- <scope>compile</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.3</version>
- <scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>4.4</version>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
- <version>2.2</version>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymockclassextension</artifactId>
- <version>2.2.1</version>
- <scope>test</scope>
</dependency>
</dependencies>
+
+ <properties>
+ <!-- Use the core proto dir so that we can call the core generation script -->
+ <test.proto.dir>../core/src/test/proto</test.proto.dir>
+ </properties>
+
<build>
<plugins>
<plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
- </plugin>
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <includes>
- <include>**/*Test.java</include>
- <include>../src/main/java/com/google/protobuf/TestUtil.java</include>
- </includes>
- </configuration>
- </plugin>
- <plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
+ <!-- Generate the test protos -->
<execution>
<id>generate-test-sources</id>
<phase>generate-test-sources</phase>
<configuration>
- <tasks>
- <mkdir dir="target/generated-test-sources" />
- <exec executable="../../src/protoc">
- <arg value="--java_out=target/generated-test-sources" />
- <arg value="--proto_path=../../src" />
- <arg value="--proto_path=src/test/java" />
- <arg value="../../src/google/protobuf/unittest.proto" />
- <arg value="../../src/google/protobuf/unittest_import.proto" />
- <arg value="../../src/google/protobuf/unittest_import_public.proto" />
- <arg value="src/test/java/com/google/protobuf/util/json_test.proto" />
+ <target>
+ <!-- Generate all of the test protos from the core module -->
+ <ant antfile="../core/generate-test-sources-build.xml"/>
+
+ <!-- Generate additional test protos for this module -->
+ <exec executable="${protoc}">
+ <arg value="--java_out=${generated.testsources.dir}" />
+ <arg value="--proto_path=${protobuf.source.dir}" />
+ <arg value="--proto_path=src/test/proto" />
+ <arg value="src/test/proto/com/google/protobuf/util/json_test.proto" />
</exec>
- </tasks>
- <testSourceRoot>target/generated-test-sources</testSourceRoot>
+ </target>
</configuration>
<goals>
<goal>run</goal>
@@ -115,6 +78,16 @@
</execution>
</executions>
</plugin>
+
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <!-- Add the generated test sources to the build -->
+ <generatedTestSourcesDirectory>${generated.testsources.dir}</generatedTestSourcesDirectory>
+ </configuration>
+ </plugin>
+
+ <!-- Configure the OSGI bundle -->
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
@@ -123,88 +96,20 @@
<instructions>
<Bundle-DocURL>https://developers.google.com/protocol-buffers/</Bundle-DocURL>
<Bundle-SymbolicName>com.google.protobuf.util</Bundle-SymbolicName>
- <Export-Package>com.google.protobuf.util;version=3.0.0-beta-2</Export-Package>
+ <Export-Package>com.google.protobuf.util;version=${project.version}</Export-Package>
</instructions>
</configuration>
</plugin>
+
+ <!-- Configure the fat jar to include all dependencies -->
<plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <configuration>
- <descriptorRefs>
- <descriptorRef>jar-with-dependencies</descriptorRef>
- </descriptorRefs>
- </configuration>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <configuration>
+ <descriptorRefs>
+ <descriptorRef>jar-with-dependencies</descriptorRef>
+ </descriptorRefs>
+ </configuration>
</plugin>
</plugins>
</build>
- <profiles>
- <profile>
- <id>release</id>
- <distributionManagement>
- <snapshotRepository>
- <id>sonatype-nexus-staging</id>
- <url>https://oss.sonatype.org/content/repositories/snapshots</url>
- </snapshotRepository>
- <repository>
- <id>sonatype-nexus-staging</id>
- <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
- </repository>
- </distributionManagement>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-source-plugin</artifactId>
- <version>2.2.1</version>
- <executions>
- <execution>
- <id>attach-sources</id>
- <goals>
- <goal>jar-no-fork</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <version>2.9.1</version>
- <executions>
- <execution>
- <id>attach-javadocs</id>
- <goals>
- <goal>jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-gpg-plugin</artifactId>
- <version>1.5</version>
- <executions>
- <execution>
- <id>sign-artifacts</id>
- <phase>verify</phase>
- <goals>
- <goal>sign</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.sonatype.plugins</groupId>
- <artifactId>nexus-staging-maven-plugin</artifactId>
- <version>1.6.3</version>
- <extensions>true</extensions>
- <configuration>
- <serverId>sonatype-nexus-staging</serverId>
- <nexusUrl>https://oss.sonatype.org/</nexusUrl>
- <autoReleaseAfterClose>false</autoReleaseAfterClose>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
</project>
diff --git a/java/util/src/test/java/com/google/protobuf/util/json_test.proto b/java/util/src/test/proto/com/google/protobuf/util/json_test.proto
index 509c1d69..509c1d69 100644
--- a/java/util/src/test/java/com/google/protobuf/util/json_test.proto
+++ b/java/util/src/test/proto/com/google/protobuf/util/json_test.proto
diff --git a/python/google/protobuf/pyext/map_container.cc b/python/google/protobuf/pyext/map_container.cc
index 516662ee..df9138a4 100644
--- a/python/google/protobuf/pyext/map_container.cc
+++ b/python/google/protobuf/pyext/map_container.cc
@@ -797,7 +797,7 @@ static PyMethodDef MessageMapMethods[] = {
PyType_Spec MessageMapContainer_Type_spec = {
FULL_MODULE_NAME ".MessageMapContainer",
- sizeof(MapContainer),
+ sizeof(MessageMapContainer),
0,
Py_TPFLAGS_DEFAULT,
MessageMapContainer_Type_slots
diff --git a/src/google/protobuf/compiler/java/java_message.cc b/src/google/protobuf/compiler/java/java_message.cc
index 5715a432..22a70c32 100644
--- a/src/google/protobuf/compiler/java/java_message.cc
+++ b/src/google/protobuf/compiler/java/java_message.cc
@@ -664,34 +664,34 @@ GenerateParseFromMethods(io::Printer* printer) {
"}\n"
"public static $classname$ parseFrom(java.io.InputStream input)\n"
" throws java.io.IOException {\n"
- " return PARSER.parseFrom(input);\n"
+ " return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input);"
"}\n"
"public static $classname$ parseFrom(\n"
" java.io.InputStream input,\n"
" com.google.protobuf.ExtensionRegistryLite extensionRegistry)\n"
" throws java.io.IOException {\n"
- " return PARSER.parseFrom(input, extensionRegistry);\n"
+ " return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input, extensionRegistry);"
"}\n"
"public static $classname$ parseDelimitedFrom(java.io.InputStream input)\n"
" throws java.io.IOException {\n"
- " return PARSER.parseDelimitedFrom(input);\n"
+ " return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input);"
"}\n"
"public static $classname$ parseDelimitedFrom(\n"
" java.io.InputStream input,\n"
" com.google.protobuf.ExtensionRegistryLite extensionRegistry)\n"
" throws java.io.IOException {\n"
- " return PARSER.parseDelimitedFrom(input, extensionRegistry);\n"
+ " return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input, extensionRegistry);"
"}\n"
"public static $classname$ parseFrom(\n"
" com.google.protobuf.CodedInputStream input)\n"
" throws java.io.IOException {\n"
- " return PARSER.parseFrom(input);\n"
+ " return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input);"
"}\n"
"public static $classname$ parseFrom(\n"
" com.google.protobuf.CodedInputStream input,\n"
" com.google.protobuf.ExtensionRegistryLite extensionRegistry)\n"
" throws java.io.IOException {\n"
- " return PARSER.parseFrom(input, extensionRegistry);\n"
+ " return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input, extensionRegistry);"
"}\n"
"\n",
"classname", name_resolver_->GetImmutableClassName(descriptor_));
@@ -1217,9 +1217,8 @@ GenerateParsingConstructor(io::Printer* printer) {
"} catch (com.google.protobuf.InvalidProtocolBufferException e) {\n"
" throw new RuntimeException(e.setUnfinishedMessage(this));\n"
"} catch (java.io.IOException e) {\n"
- " throw new RuntimeException(\n"
- " new com.google.protobuf.InvalidProtocolBufferException(\n"
- " e.getMessage()).setUnfinishedMessage(this));\n"
+ " throw new RuntimeException(new com.google.protobuf.InvalidProtocolBufferException(e)\n"
+ " .setUnfinishedMessage(this));\n"
"} finally {\n");
printer->Indent();
diff --git a/src/google/protobuf/compiler/java/java_message_builder.cc b/src/google/protobuf/compiler/java/java_message_builder.cc
index 72694119..5d535034 100644
--- a/src/google/protobuf/compiler/java/java_message_builder.cc
+++ b/src/google/protobuf/compiler/java/java_message_builder.cc
@@ -538,7 +538,7 @@ GenerateBuilderParsingMethods(io::Printer* printer) {
" parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);\n"
" } catch (com.google.protobuf.InvalidProtocolBufferException e) {\n"
" parsedMessage = ($classname$) e.getUnfinishedMessage();\n"
- " throw e;\n"
+ " throw e.unwrapIOException();\n"
" } finally {\n"
" if (parsedMessage != null) {\n"
" mergeFrom(parsedMessage);\n"
diff --git a/src/google/protobuf/repeated_field.h b/src/google/protobuf/repeated_field.h
index 432236ce..61f3f558 100644
--- a/src/google/protobuf/repeated_field.h
+++ b/src/google/protobuf/repeated_field.h
@@ -692,7 +692,7 @@ class LIBPROTOBUF_EXPORT StringTypeHandlerBase {
class StringTypeHandler : public StringTypeHandlerBase {
public:
static int SpaceUsed(const string& value) {
- return sizeof(value) + StringSpaceUsedExcludingSelf(value);
+ return static_cast<int>(sizeof(value)) + StringSpaceUsedExcludingSelf(value);
}
};
diff --git a/src/google/protobuf/unittest_well_known_types.proto b/src/google/protobuf/unittest_well_known_types.proto
index 2cb7775c..c9075244 100644
--- a/src/google/protobuf/unittest_well_known_types.proto
+++ b/src/google/protobuf/unittest_well_known_types.proto
@@ -39,6 +39,8 @@ message TestWellKnownTypes {
google.protobuf.BoolValue bool_field = 16;
google.protobuf.StringValue string_field = 17;
google.protobuf.BytesValue bytes_field = 18;
+ // Part of struct, but useful to be able to test separately
+ google.protobuf.Value value_field = 19;
}
// A repeated field for each well-known type.