diff options
26 files changed, 188 insertions, 347 deletions
diff --git a/Makefile.am b/Makefile.am index da371c67..82b8b8e3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -370,9 +370,7 @@ java_EXTRA_DIST= 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/generate-sources-build.xml \ - java/lite/generate-test-sources-build.xml \ - java/lite/pom.xml \ + java/lite.md \ java/pom.xml \ java/util/pom.xml \ java/util/src/main/java/com/google/protobuf/util/Durations.java \ diff --git a/csharp/src/AddressBook/Addressbook.cs b/csharp/src/AddressBook/Addressbook.cs index ceb93699..21a8ce02 100644 --- a/csharp/src/AddressBook/Addressbook.cs +++ b/csharp/src/AddressBook/Addressbook.cs @@ -78,7 +78,7 @@ namespace Google.Protobuf.Examples.AddressBook { id_ = other.id_; email_ = other.email_; phones_ = other.phones_.Clone(); - LastUpdated = other.lastUpdated_ != null ? other.LastUpdated.Clone() : null; + lastUpdated_ = other.lastUpdated_ != null ? other.lastUpdated_.Clone() : null; _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } diff --git a/csharp/src/Google.Protobuf.Test/TestProtos/MapUnittestProto3.cs b/csharp/src/Google.Protobuf.Test/TestProtos/MapUnittestProto3.cs index cb1bc920..51715a0c 100644 --- a/csharp/src/Google.Protobuf.Test/TestProtos/MapUnittestProto3.cs +++ b/csharp/src/Google.Protobuf.Test/TestProtos/MapUnittestProto3.cs @@ -642,7 +642,7 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestMapSubmessage(TestMapSubmessage other) : this() { - TestMap = other.testMap_ != null ? other.TestMap.Clone() : null; + testMap_ = other.testMap_ != null ? other.testMap_.Clone() : null; _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } diff --git a/csharp/src/Google.Protobuf.Test/TestProtos/TestMessagesProto3.cs b/csharp/src/Google.Protobuf.Test/TestProtos/TestMessagesProto3.cs index a2a236d9..7353be7b 100644 --- a/csharp/src/Google.Protobuf.Test/TestProtos/TestMessagesProto3.cs +++ b/csharp/src/Google.Protobuf.Test/TestProtos/TestMessagesProto3.cs @@ -273,13 +273,13 @@ namespace ProtobufTestMessages.Proto3 { optionalBool_ = other.optionalBool_; optionalString_ = other.optionalString_; optionalBytes_ = other.optionalBytes_; - OptionalNestedMessage = other.optionalNestedMessage_ != null ? other.OptionalNestedMessage.Clone() : null; - OptionalForeignMessage = other.optionalForeignMessage_ != null ? other.OptionalForeignMessage.Clone() : null; + optionalNestedMessage_ = other.optionalNestedMessage_ != null ? other.optionalNestedMessage_.Clone() : null; + optionalForeignMessage_ = other.optionalForeignMessage_ != null ? other.optionalForeignMessage_.Clone() : null; optionalNestedEnum_ = other.optionalNestedEnum_; optionalForeignEnum_ = other.optionalForeignEnum_; optionalStringPiece_ = other.optionalStringPiece_; optionalCord_ = other.optionalCord_; - RecursiveMessage = other.recursiveMessage_ != null ? other.RecursiveMessage.Clone() : null; + recursiveMessage_ = other.recursiveMessage_ != null ? other.recursiveMessage_.Clone() : null; repeatedInt32_ = other.repeatedInt32_.Clone(); repeatedInt64_ = other.repeatedInt64_.Clone(); repeatedUint32_ = other.repeatedUint32_.Clone(); @@ -338,12 +338,12 @@ namespace ProtobufTestMessages.Proto3 { repeatedDoubleWrapper_ = other.repeatedDoubleWrapper_.Clone(); repeatedStringWrapper_ = other.repeatedStringWrapper_.Clone(); repeatedBytesWrapper_ = other.repeatedBytesWrapper_.Clone(); - OptionalDuration = other.optionalDuration_ != null ? other.OptionalDuration.Clone() : null; - OptionalTimestamp = other.optionalTimestamp_ != null ? other.OptionalTimestamp.Clone() : null; - OptionalFieldMask = other.optionalFieldMask_ != null ? other.OptionalFieldMask.Clone() : null; - OptionalStruct = other.optionalStruct_ != null ? other.OptionalStruct.Clone() : null; - OptionalAny = other.optionalAny_ != null ? other.OptionalAny.Clone() : null; - OptionalValue = other.optionalValue_ != null ? other.OptionalValue.Clone() : null; + optionalDuration_ = other.optionalDuration_ != null ? other.optionalDuration_.Clone() : null; + optionalTimestamp_ = other.optionalTimestamp_ != null ? other.optionalTimestamp_.Clone() : null; + optionalFieldMask_ = other.optionalFieldMask_ != null ? other.optionalFieldMask_.Clone() : null; + optionalStruct_ = other.optionalStruct_ != null ? other.optionalStruct_.Clone() : null; + optionalAny_ = other.optionalAny_ != null ? other.optionalAny_.Clone() : null; + optionalValue_ = other.optionalValue_ != null ? other.optionalValue_.Clone() : null; repeatedDuration_ = other.repeatedDuration_.Clone(); repeatedTimestamp_ = other.repeatedTimestamp_.Clone(); repeatedFieldmask_ = other.repeatedFieldmask_.Clone(); @@ -3455,7 +3455,7 @@ namespace ProtobufTestMessages.Proto3 { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public NestedMessage(NestedMessage other) : this() { a_ = other.a_; - Corecursive = other.corecursive_ != null ? other.Corecursive.Clone() : null; + corecursive_ = other.corecursive_ != null ? other.corecursive_.Clone() : null; _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } diff --git a/csharp/src/Google.Protobuf.Test/TestProtos/UnittestCustomOptionsProto3.cs b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestCustomOptionsProto3.cs index 6d02bda6..3ab5a48b 100644 --- a/csharp/src/Google.Protobuf.Test/TestProtos/UnittestCustomOptionsProto3.cs +++ b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestCustomOptionsProto3.cs @@ -1740,9 +1740,9 @@ namespace UnitTest.Issues.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public ComplexOptionType2(ComplexOptionType2 other) : this() { - Bar = other.bar_ != null ? other.Bar.Clone() : null; + bar_ = other.bar_ != null ? other.bar_.Clone() : null; baz_ = other.baz_; - Fred = other.fred_ != null ? other.Fred.Clone() : null; + fred_ = other.fred_ != null ? other.fred_.Clone() : null; barney_ = other.barney_.Clone(); _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } @@ -2331,7 +2331,7 @@ namespace UnitTest.Issues.TestProtos { public Aggregate(Aggregate other) : this() { i_ = other.i_; s_ = other.s_; - Sub = other.sub_ != null ? other.Sub.Clone() : null; + sub_ = other.sub_ != null ? other.sub_.Clone() : null; _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } diff --git a/csharp/src/Google.Protobuf.Test/TestProtos/UnittestIssues.cs b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestIssues.cs index 01a86f8f..819fc201 100644 --- a/csharp/src/Google.Protobuf.Test/TestProtos/UnittestIssues.cs +++ b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestIssues.cs @@ -704,7 +704,7 @@ namespace UnitTest.Issues.TestProtos { public DeprecatedFieldsMessage(DeprecatedFieldsMessage other) : this() { primitiveValue_ = other.primitiveValue_; primitiveArray_ = other.primitiveArray_.Clone(); - MessageValue = other.messageValue_ != null ? other.MessageValue.Clone() : null; + messageValue_ = other.messageValue_ != null ? other.messageValue_.Clone() : null; messageArray_ = other.messageArray_.Clone(); enumValue_ = other.enumValue_; enumArray_ = other.enumArray_.Clone(); diff --git a/csharp/src/Google.Protobuf.Test/TestProtos/UnittestProto3.cs b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestProto3.cs index 4242c192..d5dbe866 100644 --- a/csharp/src/Google.Protobuf.Test/TestProtos/UnittestProto3.cs +++ b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestProto3.cs @@ -280,13 +280,13 @@ namespace Google.Protobuf.TestProtos { singleBool_ = other.singleBool_; singleString_ = other.singleString_; singleBytes_ = other.singleBytes_; - SingleNestedMessage = other.singleNestedMessage_ != null ? other.SingleNestedMessage.Clone() : null; - SingleForeignMessage = other.singleForeignMessage_ != null ? other.SingleForeignMessage.Clone() : null; - SingleImportMessage = other.singleImportMessage_ != null ? other.SingleImportMessage.Clone() : null; + singleNestedMessage_ = other.singleNestedMessage_ != null ? other.singleNestedMessage_.Clone() : null; + singleForeignMessage_ = other.singleForeignMessage_ != null ? other.singleForeignMessage_.Clone() : null; + singleImportMessage_ = other.singleImportMessage_ != null ? other.singleImportMessage_.Clone() : null; singleNestedEnum_ = other.singleNestedEnum_; singleForeignEnum_ = other.singleForeignEnum_; singleImportEnum_ = other.singleImportEnum_; - SinglePublicImportMessage = other.singlePublicImportMessage_ != null ? other.SinglePublicImportMessage.Clone() : null; + singlePublicImportMessage_ = other.singlePublicImportMessage_ != null ? other.singlePublicImportMessage_.Clone() : null; repeatedInt32_ = other.repeatedInt32_.Clone(); repeatedInt64_ = other.repeatedInt64_.Clone(); repeatedUint32_ = other.repeatedUint32_.Clone(); @@ -1786,8 +1786,8 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public NestedTestAllTypes(NestedTestAllTypes other) : this() { - Child = other.child_ != null ? other.Child.Clone() : null; - Payload = other.payload_ != null ? other.Payload.Clone() : null; + child_ = other.child_ != null ? other.child_.Clone() : null; + payload_ = other.payload_ != null ? other.payload_.Clone() : null; repeatedChild_ = other.repeatedChild_.Clone(); _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } @@ -2342,7 +2342,7 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestForeignNested(TestForeignNested other) : this() { - ForeignNested = other.foreignNested_ != null ? other.ForeignNested.Clone() : null; + foreignNested_ = other.foreignNested_ != null ? other.foreignNested_.Clone() : null; _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } @@ -2641,7 +2641,7 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestRecursiveMessage(TestRecursiveMessage other) : this() { - A = other.a_ != null ? other.A.Clone() : null; + a_ = other.a_ != null ? other.a_.Clone() : null; i_ = other.i_; _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } @@ -2807,7 +2807,7 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestMutualRecursionA(TestMutualRecursionA other) : this() { - Bb = other.bb_ != null ? other.Bb.Clone() : null; + bb_ = other.bb_ != null ? other.bb_.Clone() : null; _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } @@ -2942,7 +2942,7 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestMutualRecursionB(TestMutualRecursionB other) : this() { - A = other.a_ != null ? other.A.Clone() : null; + a_ = other.a_ != null ? other.a_.Clone() : null; optionalInt32_ = other.optionalInt32_; _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } @@ -3241,7 +3241,7 @@ namespace Google.Protobuf.TestProtos { primitiveField_ = other.primitiveField_; stringField_ = other.stringField_; enumField_ = other.enumField_; - MessageField = other.messageField_ != null ? other.MessageField.Clone() : null; + messageField_ = other.messageField_ != null ? other.messageField_.Clone() : null; repeatedPrimitiveField_ = other.repeatedPrimitiveField_.Clone(); repeatedStringField_ = other.repeatedStringField_.Clone(); repeatedEnumField_ = other.repeatedEnumField_.Clone(); @@ -3546,7 +3546,7 @@ namespace Google.Protobuf.TestProtos { myString_ = other.myString_; myInt_ = other.myInt_; myFloat_ = other.myFloat_; - SingleNestedMessage = other.singleNestedMessage_ != null ? other.SingleNestedMessage.Clone() : null; + singleNestedMessage_ = other.singleNestedMessage_ != null ? other.singleNestedMessage_.Clone() : null; _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } diff --git a/csharp/src/Google.Protobuf.Test/TestProtos/UnittestWellKnownTypes.cs b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestWellKnownTypes.cs index 2e1d2bd6..fe913802 100644 --- a/csharp/src/Google.Protobuf.Test/TestProtos/UnittestWellKnownTypes.cs +++ b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestWellKnownTypes.cs @@ -204,15 +204,15 @@ namespace Google.Protobuf.TestProtos { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public TestWellKnownTypes(TestWellKnownTypes other) : this() { - AnyField = other.anyField_ != null ? other.AnyField.Clone() : null; - ApiField = other.apiField_ != null ? other.ApiField.Clone() : null; - DurationField = other.durationField_ != null ? other.DurationField.Clone() : null; - EmptyField = other.emptyField_ != null ? other.EmptyField.Clone() : null; - FieldMaskField = other.fieldMaskField_ != null ? other.FieldMaskField.Clone() : null; - SourceContextField = other.sourceContextField_ != null ? other.SourceContextField.Clone() : null; - StructField = other.structField_ != null ? other.StructField.Clone() : null; - TimestampField = other.timestampField_ != null ? other.TimestampField.Clone() : null; - TypeField = other.typeField_ != null ? other.TypeField.Clone() : null; + anyField_ = other.anyField_ != null ? other.anyField_.Clone() : null; + apiField_ = other.apiField_ != null ? other.apiField_.Clone() : null; + durationField_ = other.durationField_ != null ? other.durationField_.Clone() : null; + emptyField_ = other.emptyField_ != null ? other.emptyField_.Clone() : null; + fieldMaskField_ = other.fieldMaskField_ != null ? other.fieldMaskField_.Clone() : null; + sourceContextField_ = other.sourceContextField_ != null ? other.sourceContextField_.Clone() : null; + structField_ = other.structField_ != null ? other.structField_.Clone() : null; + timestampField_ = other.timestampField_ != null ? other.timestampField_.Clone() : null; + typeField_ = other.typeField_ != null ? other.typeField_.Clone() : null; DoubleField = other.DoubleField; FloatField = other.FloatField; Int64Field = other.Int64Field; @@ -222,7 +222,7 @@ namespace Google.Protobuf.TestProtos { BoolField = other.BoolField; StringField = other.StringField; BytesField = other.BytesField; - ValueField = other.valueField_ != null ? other.ValueField.Clone() : null; + valueField_ = other.valueField_ != null ? other.valueField_.Clone() : null; _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } diff --git a/csharp/src/Google.Protobuf/Reflection/Descriptor.cs b/csharp/src/Google.Protobuf/Reflection/Descriptor.cs index af68fa86..343dfecd 100644 --- a/csharp/src/Google.Protobuf/Reflection/Descriptor.cs +++ b/csharp/src/Google.Protobuf/Reflection/Descriptor.cs @@ -350,8 +350,8 @@ namespace Google.Protobuf.Reflection { enumType_ = other.enumType_.Clone(); service_ = other.service_.Clone(); extension_ = other.extension_.Clone(); - Options = other.options_ != null ? other.Options.Clone() : null; - SourceCodeInfo = other.sourceCodeInfo_ != null ? other.SourceCodeInfo.Clone() : null; + options_ = other.options_ != null ? other.options_.Clone() : null; + sourceCodeInfo_ = other.sourceCodeInfo_ != null ? other.sourceCodeInfo_.Clone() : null; syntax_ = other.syntax_; _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } @@ -775,7 +775,7 @@ namespace Google.Protobuf.Reflection { enumType_ = other.enumType_.Clone(); extensionRange_ = other.extensionRange_.Clone(); oneofDecl_ = other.oneofDecl_.Clone(); - Options = other.options_ != null ? other.Options.Clone() : null; + options_ = other.options_ != null ? other.options_.Clone() : null; reservedRange_ = other.reservedRange_.Clone(); reservedName_ = other.reservedName_.Clone(); _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); @@ -1099,7 +1099,7 @@ namespace Google.Protobuf.Reflection { public ExtensionRange(ExtensionRange other) : this() { start_ = other.start_; end_ = other.end_; - Options = other.options_ != null ? other.Options.Clone() : null; + options_ = other.options_ != null ? other.options_.Clone() : null; _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } @@ -1597,7 +1597,7 @@ namespace Google.Protobuf.Reflection { defaultValue_ = other.defaultValue_; oneofIndex_ = other.oneofIndex_; jsonName_ = other.jsonName_; - Options = other.options_ != null ? other.Options.Clone() : null; + options_ = other.options_ != null ? other.options_.Clone() : null; _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } @@ -2078,7 +2078,7 @@ namespace Google.Protobuf.Reflection { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public OneofDescriptorProto(OneofDescriptorProto other) : this() { name_ = other.name_; - Options = other.options_ != null ? other.Options.Clone() : null; + options_ = other.options_ != null ? other.options_.Clone() : null; _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } @@ -2245,7 +2245,7 @@ namespace Google.Protobuf.Reflection { public EnumDescriptorProto(EnumDescriptorProto other) : this() { name_ = other.name_; value_ = other.value_.Clone(); - Options = other.options_ != null ? other.Options.Clone() : null; + options_ = other.options_ != null ? other.options_.Clone() : null; reservedRange_ = other.reservedRange_.Clone(); reservedName_ = other.reservedName_.Clone(); _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); @@ -2658,7 +2658,7 @@ namespace Google.Protobuf.Reflection { public EnumValueDescriptorProto(EnumValueDescriptorProto other) : this() { name_ = other.name_; number_ = other.number_; - Options = other.options_ != null ? other.Options.Clone() : null; + options_ = other.options_ != null ? other.options_.Clone() : null; _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } @@ -2852,7 +2852,7 @@ namespace Google.Protobuf.Reflection { public ServiceDescriptorProto(ServiceDescriptorProto other) : this() { name_ = other.name_; method_ = other.method_.Clone(); - Options = other.options_ != null ? other.Options.Clone() : null; + options_ = other.options_ != null ? other.options_.Clone() : null; _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } @@ -3039,7 +3039,7 @@ namespace Google.Protobuf.Reflection { name_ = other.name_; inputType_ = other.inputType_; outputType_ = other.outputType_; - Options = other.options_ != null ? other.Options.Clone() : null; + options_ = other.options_ != null ? other.options_.Clone() : null; clientStreaming_ = other.clientStreaming_; serverStreaming_ = other.serverStreaming_; _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Api.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Api.cs index 4db1f633..e4a4a365 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/Api.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Api.cs @@ -93,7 +93,7 @@ namespace Google.Protobuf.WellKnownTypes { methods_ = other.methods_.Clone(); options_ = other.options_.Clone(); version_ = other.version_; - SourceContext = other.sourceContext_ != null ? other.SourceContext.Clone() : null; + sourceContext_ = other.sourceContext_ != null ? other.sourceContext_.Clone() : null; mixins_ = other.mixins_.Clone(); syntax_ = other.syntax_; _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Type.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Type.cs index 84310550..3e2fe541 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/Type.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Type.cs @@ -123,7 +123,7 @@ namespace Google.Protobuf.WellKnownTypes { fields_ = other.fields_.Clone(); oneofs_ = other.oneofs_.Clone(); options_ = other.options_.Clone(); - SourceContext = other.sourceContext_ != null ? other.SourceContext.Clone() : null; + sourceContext_ = other.sourceContext_ != null ? other.sourceContext_.Clone() : null; syntax_ = other.syntax_; _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } @@ -913,7 +913,7 @@ namespace Google.Protobuf.WellKnownTypes { name_ = other.name_; enumvalue_ = other.enumvalue_.Clone(); options_ = other.options_.Clone(); - SourceContext = other.sourceContext_ != null ? other.SourceContext.Clone() : null; + sourceContext_ = other.sourceContext_ != null ? other.sourceContext_.Clone() : null; syntax_ = other.syntax_; _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } @@ -1350,7 +1350,7 @@ namespace Google.Protobuf.WellKnownTypes { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Option(Option other) : this() { name_ = other.name_; - Value = other.value_ != null ? other.Value.Clone() : null; + value_ = other.value_ != null ? other.value_.Clone() : null; _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } diff --git a/java/README.md b/java/README.md index 0e0fba64..5e4fb8b4 100644 --- a/java/README.md +++ b/java/README.md @@ -1,17 +1,65 @@ -Protocol Buffers - Google's data interchange format -=================================================== - -[![Build Status](https://travis-ci.org/google/protobuf.svg?branch=master)](https://travis-ci.org/google/protobuf) +# Protocol Buffers - Google's data interchange format Copyright 2008 Google Inc. -This directory contains the Java Protocol Buffers runtime library. +https://developers.google.com/protocol-buffers/ + +## Use Java Protocol Buffers + +To use protobuf in Java, first obtain the protocol compiler (a.k.a., protoc, +see instructions in the toplevel [README.md](../README.md)) and use it to +generate Java code for your .proto files: + + $ protoc --java_out=${OUTPUT_DIR} path/to/your/proto/file + +Include the generated Java files in your project and add a dependency on the +protobuf Java runtime. If you are using Maven, use the following: + +```xml +<dependency> + <groupId>com.google.protobuf</groupId> + <artifactId>protobuf-java</artifactId> + <version>3.5.1</version> +</dependency> +``` + +Make sure the version number of the runtime matches (or is newer than) the +version number of the protoc. + +If you want to use features like protobuf JsonFormat, add a dependency on the +protobuf-java-util package: + +```xml +<dependency> + <groupId>com.google.protobuf</groupId> + <artifactId>protobuf-java-util</artifactId> + <version>3.5.1</version> +</dependency> +``` + +### Use Java Protocol Buffers on Android + +For Android users, it's recommended to use protobuf Java Lite runtime because +of its smaller code size. Java Lite runtime also works better with Proguard +because it doesn't rely on Java reflection and is optimized to allow as much +code stripping as possible. You can following these [instructions to use Java +Lite runtime](lite.md). + +### Use Java Protocol Buffers with Bazel + +Bazel has native build rules to work with protobuf. For Java, you can use the +`java_proto_library` rule for server and the `java_lite_proto_library` rule +for Android. Check out [our build files examples](../examples/BUILD) to learn +how to use them. + +## Build from Source -Installation - With Maven -========================= +Most users should follow the instructions above to use protobuf Java runtime. +If you are contributing code to protobuf or want to use a protobuf version +that hasn't been officially released yet, you can folllow the instructions +below to build protobuf from source code. -The Protocol Buffers build is managed using Maven. If you would -rather build without Maven, see below. +### Build from Source - With Maven 1) Install Apache Maven if you don't have it: @@ -45,20 +93,15 @@ rather build without Maven, see below. The .jar will be placed in the "target" directory. -The above instructions will install 3 maven artifacts: +The above instructions will install 2 maven artifacts: * protobuf-java: The core Java Protocol Buffers library. Most users only need this artifact. - * protobuf-lite: The lite version of core Java Protobuf Buffers library. It - is a subset of the core library and is used together with - the 'lite' code generator flag to reduce generated code size - for mobile. * protobuf-java-util: Utilities to work with protos. It contains JSON support as well as utilities to work with proto3 well-known types. -Installation - Without Maven -============================ +### Build from Source - Without Maven If you would rather not install Maven to build the library, you may follow these instructions instead. Note that these instructions skip @@ -83,8 +126,7 @@ library (without the util package). 4) Install the classes wherever you prefer. -Compatibility Notice -==================== +## Compatibility Notice * Protobuf minor version releases are backwards-compatible. If your code can build/run against the old version, it's expected to build/run against @@ -118,8 +160,7 @@ Compatibility Notice * Protobuf LITE runtime APIs are not stable yet. They are subject to change even in minor version releases. -Documentation -============= +## Documentation The complete documentation for Protocol Buffers is available via the web at: diff --git a/java/lite.md b/java/lite.md new file mode 100644 index 00000000..84a45ec5 --- /dev/null +++ b/java/lite.md @@ -0,0 +1,50 @@ +# Protocol Buffers - Google's data interchange format + +Copyright 2008 Google Inc. + +https://developers.google.com/protocol-buffers/ + +## Use Protobuf Java Lite Runtime + +Protobuf Java Lite runtime is separated from the main Java runtime because +it's designed/implemented with different constraints. In particular, Java +Lite runtime has a much smaller code size which makes it more suitable to +be used on Android. + +To use Java Lite runtime, you need to install protoc and the protoc plugin for +Java Lite runtime. You can obtain protoc following the instructions in the +toplevel [README.md](../README.md) file. For the protoc plugin, you can +download it from maven: + + https://repo1.maven.org/maven2/com/google/protobuf/protoc-gen-javalite/ + +Choose the version that works on your platform (e.g., on windows you can +download `protoc-gen-javalite-3.0.0-windows-x86_32.exe`), rename it to +protoc-gen-javalite (or protoc-gen-javalite.exe on windows) and place it +in a directory where it can be find in PATH. + +Once you have the protoc and protoc plugin, you can generate Java Lite code +for your .proto files: + + $ protoc --javalite_out=${OUTPUT_DIR} path/to/your/proto/file + +Include the generated Java files in your project and add a dependency on the +protobuf Java runtime. If you are using Maven, use the following: + +```xml +<dependency> + <groupId>com.google.protobuf</groupId> + <artifactId>protobuf-lite</artifactId> + <version>3.0.1</version> +</dependency> +``` + +Make sure the version number of the runtime matches (or is newer than) the +version number of the protoc plugin. The version number of the protoc doesn't +matter and any version >= 3.0.0 should work. + +### Use Protobuf Java Lite Runtime with Bazel + +Bazel has native build rules to work with protobuf. For Java Lite runtime, +you can use the `java_lite_proto_library` rule. Check out [our build files +examples](../examples/BUILD) to learn how to use it. diff --git a/java/lite/generate-sources-build.xml b/java/lite/generate-sources-build.xml deleted file mode 100644 index 89c21c13..00000000 --- a/java/lite/generate-sources-build.xml +++ /dev/null @@ -1,20 +0,0 @@ -<project name="generate-sources"> - <echo message="Running protoc ..."/> - <mkdir dir="${generated.sources.lite.dir}"/> - <exec executable="${protoc}"> - <arg value="--java_out=lite:${generated.sources.lite.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> diff --git a/java/lite/generate-test-sources-build.xml b/java/lite/generate-test-sources-build.xml deleted file mode 100644 index cdd1ee89..00000000 --- a/java/lite/generate-test-sources-build.xml +++ /dev/null @@ -1,43 +0,0 @@ -<project name="generate-test-sources"> - <mkdir dir="${generated.testsources.lite.dir}"/> - <exec executable="${protoc}"> - <arg value="--java_out=lite:${generated.testsources.lite.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> diff --git a/java/lite/pom.xml b/java/lite/pom.xml deleted file mode 100644 index c902f819..00000000 --- a/java/lite/pom.xml +++ /dev/null @@ -1,185 +0,0 @@ -<?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</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="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> - - <!-- Only compile a subset of the files --> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>build-helper-maven-plugin</artifactId> - <executions> - <execution> - <id>add-generated-sources</id> - <phase>generate-sources</phase> - <goals> - <goal>add-source</goal> - </goals> - <configuration> - <sources> - <source>${generated.sources.lite.dir}</source> - </sources> - </configuration> - </execution> - <execution> - <id>add-generated-test-sources</id> - <phase>generate-test-sources</phase> - <goals> - <goal>add-test-source</goal> - </goals> - <configuration> - <sources> - <source>${generated.testsources.lite.dir}</source> - </sources> - </configuration> - </execution> - </executions> - </plugin> - <plugin> - <artifactId>maven-compiler-plugin</artifactId> - <configuration> - <includes> - <include>**/AbstractMessageLite.java</include> - <include>**/AbstractParser.java</include> - <include>**/AbstractProtobufList.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>**/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>**/PrimitiveNonBoxingCollection.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>**/UnsafeByteOperations.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 c42cae11..f2284918 100644 --- a/java/pom.xml +++ b/java/pom.xml @@ -33,8 +33,6 @@ <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> - <generated.sources.lite.dir>${project.build.directory}/generated-sources-lite</generated.sources.lite.dir> - <generated.testsources.lite.dir>${project.build.directory}/generated-test-sources-lite</generated.testsources.lite.dir> </properties> <licenses> @@ -208,7 +206,6 @@ <modules> <module>core</module> - <!-- <module>lite</module> --> <module>util</module> </modules> diff --git a/src/google/protobuf/compiler/cpp/cpp_field.cc b/src/google/protobuf/compiler/cpp/cpp_field.cc index 33ffe574..0de20f84 100644 --- a/src/google/protobuf/compiler/cpp/cpp_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_field.cc @@ -117,8 +117,7 @@ FieldGeneratorMap::FieldGeneratorMap(const Descriptor* descriptor, SCCAnalyzer* scc_analyzer) : descriptor_(descriptor), options_(options), - field_generators_( - new std::unique_ptr<FieldGenerator>[descriptor->field_count()]) { + field_generators_(descriptor->field_count()) { // Construct all the FieldGenerators. for (int i = 0; i < descriptor->field_count(); i++) { field_generators_[i].reset( diff --git a/src/google/protobuf/compiler/cpp/cpp_field.h b/src/google/protobuf/compiler/cpp/cpp_field.h index 6cb466a8..8cdbe886 100644 --- a/src/google/protobuf/compiler/cpp/cpp_field.h +++ b/src/google/protobuf/compiler/cpp/cpp_field.h @@ -203,7 +203,7 @@ class FieldGeneratorMap { private: const Descriptor* descriptor_; const Options& options_; - std::unique_ptr<std::unique_ptr<FieldGenerator> []> field_generators_; + std::vector<std::unique_ptr<FieldGenerator>> field_generators_; static FieldGenerator* MakeGenerator(const FieldDescriptor* field, const Options& options, diff --git a/src/google/protobuf/compiler/csharp/csharp_message_field.cc b/src/google/protobuf/compiler/csharp/csharp_message_field.cc index 59b7edfb..cf1b4dbf 100644 --- a/src/google/protobuf/compiler/csharp/csharp_message_field.cc +++ b/src/google/protobuf/compiler/csharp/csharp_message_field.cc @@ -133,7 +133,7 @@ void MessageFieldGenerator::WriteToString(io::Printer* printer) { void MessageFieldGenerator::GenerateCloningCode(io::Printer* printer) { printer->Print(variables_, - "$property_name$ = other.$has_property_check$ ? other.$property_name$.Clone() : null;\n"); + "$name$_ = other.$has_property_check$ ? other.$name$_.Clone() : null;\n"); } void MessageFieldGenerator::GenerateFreezingCode(io::Printer* printer) { diff --git a/src/google/protobuf/compiler/java/java_field.cc b/src/google/protobuf/compiler/java/java_field.cc index d7319681..93de0229 100644 --- a/src/google/protobuf/compiler/java/java_field.cc +++ b/src/google/protobuf/compiler/java/java_field.cc @@ -211,8 +211,7 @@ template <> FieldGeneratorMap<ImmutableFieldGenerator>::FieldGeneratorMap( const Descriptor* descriptor, Context* context) : descriptor_(descriptor), - field_generators_(new std::unique_ptr< - ImmutableFieldGenerator>[descriptor->field_count()]) { + field_generators_(descriptor->field_count()) { // Construct all the FieldGenerators and assign them bit indices for their // bit fields. @@ -234,8 +233,7 @@ template <> FieldGeneratorMap<ImmutableFieldLiteGenerator>::FieldGeneratorMap( const Descriptor* descriptor, Context* context) : descriptor_(descriptor), - field_generators_(new std::unique_ptr< - ImmutableFieldLiteGenerator>[descriptor->field_count()]) { + field_generators_(descriptor->field_count()) { // Construct all the FieldGenerators and assign them bit indices for their // bit fields. int messageBitIndex = 0; diff --git a/src/google/protobuf/compiler/java/java_field.h b/src/google/protobuf/compiler/java/java_field.h index 04bbe24a..7275c099 100644 --- a/src/google/protobuf/compiler/java/java_field.h +++ b/src/google/protobuf/compiler/java/java_field.h @@ -138,7 +138,7 @@ class FieldGeneratorMap { const Descriptor* descriptor_; Context* context_; ClassNameResolver* name_resolver_; - std::unique_ptr<std::unique_ptr<FieldGeneratorType> []> field_generators_; + std::vector<std::unique_ptr<FieldGeneratorType>> field_generators_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldGeneratorMap); }; diff --git a/src/google/protobuf/compiler/java/java_file.cc b/src/google/protobuf/compiler/java/java_file.cc index 5ee04e5a..5583b779 100644 --- a/src/google/protobuf/compiler/java/java_file.cc +++ b/src/google/protobuf/compiler/java/java_file.cc @@ -186,10 +186,8 @@ FileGenerator::FileGenerator(const FileDescriptor* file, const Options& options, bool immutable_api) : file_(file), java_package_(FileJavaPackage(file, immutable_api)), - message_generators_( - new std::unique_ptr<MessageGenerator>[file->message_type_count()]), - extension_generators_( - new std::unique_ptr<ExtensionGenerator>[file->extension_count()]), + message_generators_(file->message_type_count()), + extension_generators_(file->extension_count()), context_(new Context(file, options)), name_resolver_(context_->GetNameResolver()), options_(options), @@ -225,6 +223,16 @@ bool FileGenerator::Validate(string* error) { "option to specify a different outer class name for the .proto file."); return false; } + // Print a warning if optimize_for = LITE_RUNTIME is used. + if (file_->options().optimize_for() == FileOptions::LITE_RUNTIME) { + GOOGLE_LOG(WARNING) + << "The optimize_for = LITE_RUNTIME option is no longer supported by " + << "protobuf Java code generator and may generate broken code. It " + << "will be ignored by protoc in the future and protoc will always " + << "generate full runtime code for Java. To use Java Lite runtime, " + << "users should use the Java Lite plugin instead. See:\n" + << " https://github.com/google/protobuf/blob/master/java/lite.md"; + } return true; } diff --git a/src/google/protobuf/compiler/java/java_file.h b/src/google/protobuf/compiler/java/java_file.h index 9ad7937c..78833a45 100644 --- a/src/google/protobuf/compiler/java/java_file.h +++ b/src/google/protobuf/compiler/java/java_file.h @@ -98,8 +98,8 @@ class FileGenerator { string java_package_; string classname_; - std::unique_ptr<std::unique_ptr<MessageGenerator> []> message_generators_; - std::unique_ptr<std::unique_ptr<ExtensionGenerator> []> extension_generators_; + std::vector<std::unique_ptr<MessageGenerator>> message_generators_; + std::vector<std::unique_ptr<ExtensionGenerator>> extension_generators_; std::unique_ptr<GeneratorFactory> generator_factory_; std::unique_ptr<Context> context_; ClassNameResolver* name_resolver_; diff --git a/src/google/protobuf/compiler/objectivec/objectivec_field.cc b/src/google/protobuf/compiler/objectivec/objectivec_field.cc index 67b026c3..f74599ba 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_field.cc +++ b/src/google/protobuf/compiler/objectivec/objectivec_field.cc @@ -410,10 +410,8 @@ bool RepeatedFieldGenerator::RuntimeUsesHasBit(void) const { FieldGeneratorMap::FieldGeneratorMap(const Descriptor* descriptor, const Options& options) : descriptor_(descriptor), - field_generators_( - new std::unique_ptr<FieldGenerator>[descriptor->field_count()]), - extension_generators_( - new std::unique_ptr<FieldGenerator>[descriptor->extension_count()]) { + field_generators_(descriptor->field_count()), + extension_generators_(descriptor->extension_count()) { // Construct all the FieldGenerators. for (int i = 0; i < descriptor->field_count(); i++) { field_generators_[i].reset( diff --git a/src/google/protobuf/compiler/objectivec/objectivec_field.h b/src/google/protobuf/compiler/objectivec/objectivec_field.h index 888cfefc..216034d0 100644 --- a/src/google/protobuf/compiler/objectivec/objectivec_field.h +++ b/src/google/protobuf/compiler/objectivec/objectivec_field.h @@ -182,8 +182,8 @@ class FieldGeneratorMap { private: const Descriptor* descriptor_; - std::unique_ptr<std::unique_ptr<FieldGenerator>[]> field_generators_; - std::unique_ptr<std::unique_ptr<FieldGenerator>[]> extension_generators_; + std::vector<std::unique_ptr<FieldGenerator>> field_generators_; + std::vector<std::unique_ptr<FieldGenerator>> extension_generators_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldGeneratorMap); }; |