Przeglądaj źródła

Merge branch '3.6.x' into merge-3-6-x

Adam Cozzette 7 lat temu
rodzic
commit
82d3d7d250
59 zmienionych plików z 628 dodań i 93 usunięć
  1. 88 0
      CHANGES.txt
  2. 1 1
      Protobuf.podspec
  3. 6 0
      appveyor.yml
  4. 1 1
      configure.ac
  5. 1 1
      csharp/Google.Protobuf.Tools.nuspec
  6. 1 1
      csharp/src/Google.Protobuf/Google.Protobuf.csproj
  7. 0 4
      csharp/src/Google.Protobuf/Reflection/ReflectionUtil.cs
  8. 1 1
      java/core/pom.xml
  9. 1 1
      java/pom.xml
  10. 1 1
      java/util/pom.xml
  11. 11 4
      js/map.js
  12. 39 1
      js/maps_test.js
  13. 1 1
      js/package.json
  14. 32 0
      js/testbinary.proto
  15. 14 0
      kokoro/release/linux/build_artifacts.sh
  16. 16 0
      kokoro/release/linux/prepare_build.sh
  17. 8 0
      kokoro/release/linux/release.cfg
  18. 15 0
      kokoro/release/linux/ruby/ruby_build.sh
  19. 8 0
      kokoro/release/linux/ruby/ruby_build_environment.sh
  20. 19 0
      kokoro/release/macos/build_artifacts.sh
  21. 8 0
      kokoro/release/macos/release.cfg
  22. 15 0
      kokoro/release/macos/ruby/ruby_build.sh
  23. 57 0
      kokoro/release/macos/ruby/ruby_build_environment.sh
  24. 23 0
      kokoro/release/protoc/macos/build.sh
  25. 8 0
      kokoro/release/protoc/macos/release.cfg
  26. 27 0
      kokoro/release/protoc/windows/build.bat
  27. 8 0
      kokoro/release/protoc/windows/release.cfg
  28. 19 3
      php/ext/google/protobuf/package.xml
  29. 1 1
      php/ext/google/protobuf/protobuf.h
  30. 14 0
      php/src/Google/Protobuf/Internal/Descriptor.php
  31. 2 0
      php/src/Google/Protobuf/Internal/DescriptorPool.php
  32. 14 0
      php/src/Google/Protobuf/Internal/EnumDescriptor.php
  33. 28 4
      php/src/Google/Protobuf/Internal/GPBUtil.php
  34. 24 1
      php/src/Google/Protobuf/Internal/MapField.php
  35. 22 1
      php/src/Google/Protobuf/Internal/RepeatedField.php
  36. 33 16
      php/tests/compatibility_test.sh
  37. 1 1
      post_process_dist.sh
  38. 1 1
      protoc-artifacts/pom.xml
  39. 1 1
      python/google/protobuf/__init__.py
  40. 2 4
      python/setup.py
  41. 3 1
      ruby/ext/google/protobuf_c/extconf.rb
  42. 1 1
      ruby/google-protobuf.gemspec
  43. 3 3
      src/Makefile.am
  44. 2 2
      src/google/protobuf/any.pb.h
  45. 2 2
      src/google/protobuf/api.pb.h
  46. 5 1
      src/google/protobuf/compiler/js/js_generator.cc
  47. 2 2
      src/google/protobuf/compiler/plugin.pb.h
  48. 6 8
      src/google/protobuf/descriptor.cc
  49. 2 2
      src/google/protobuf/descriptor.pb.h
  50. 2 2
      src/google/protobuf/duration.pb.h
  51. 2 2
      src/google/protobuf/empty.pb.h
  52. 2 2
      src/google/protobuf/field_mask.pb.h
  53. 9 0
      src/google/protobuf/generated_message_util.h
  54. 2 2
      src/google/protobuf/source_context.pb.h
  55. 2 2
      src/google/protobuf/struct.pb.h
  56. 5 5
      src/google/protobuf/stubs/common.h
  57. 2 2
      src/google/protobuf/timestamp.pb.h
  58. 2 2
      src/google/protobuf/type.pb.h
  59. 2 2
      src/google/protobuf/wrappers.pb.h

+ 88 - 0
CHANGES.txt

@@ -1,3 +1,91 @@
+2018-06-01 version 3.6.0 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
+
+  C++
+  * Starting from this release, we now require C++11. For those we cannot yet
+    upgrade to C++11, we will try to keep the 3.5.x branch updated with
+    critical bug fixes only. If you have any concerns about this, please
+    comment on issue #2780.
+  * Moved to C++11 types like std::atomic and std::unique_ptr and away from our
+    old custom-built equivalents.
+  * Added support for repeated message fields in lite protos using implicit
+    weak fields. This is an experimental feature that allows the linker to
+    strip out more unused messages than previously was possible.
+  * Fixed SourceCodeInfo for interpreted options and extension range options.
+  * Fixed always_print_enums_as_ints option for JSON serialization.
+  * Added support for ignoring unknown enum values when parsing JSON.
+  * Create std::string in Arena memory.
+  * Fixed ValidateDateTime to correctly check the day.
+  * Fixed bug in ZeroCopyStreamByteSink.
+  * Various other cleanups and fixes.
+
+  Java
+  * Dropped support for Java 6.
+  * Added a UTF-8 decoder that uses Unsafe to directly decode a byte buffer.
+  * Added deprecation annotations to generated code for deprecated oneof
+    fields.
+  * Fixed map field serialization in DynamicMessage.
+  * Cleanup and documentation for Java Lite runtime.
+  * Various other fixes and cleanups
+  * Fixed unboxed arraylists to handle an edge case
+  * Improved performance for copying between unboxed arraylists
+  * Fixed lite protobuf to avoid Java compiler warnings
+  * Improved test coverage for lite runtime
+  * Performance improvements for lite runtime
+
+  Python
+  * Fixed bytes/string map key incompatibility between C++ and pure-Python
+    implementations (issue #4029)
+  * Added __init__.py files to compiler and util subpackages
+  * Use /MT for all Windows versions
+  * Fixed an issue affecting the Python-C++ implementation when used with
+    Cython (issue #2896)
+  * Various text format fixes
+  * Various fixes to resolve behavior differences between the pure-Python and
+    Python-C++ implementations
+
+  PHP
+  * Added php_metadata_namespace to control the file path of generated metadata
+    file.
+  * Changed generated classes of nested message/enum. E.g., Foo.Bar, which
+    previously generates Foo_Bar, now generates Foo/Bar
+  * Added array constructor. When creating a message, users can pass a php
+    array whose content is field name to value pairs into constructor. The
+    created message will be initialized according to the array. Note that
+    message field should use a message value instead of a sub-array.
+  * Various bug fixes.
+
+  Objective-C
+  * We removed some helper class methods from GPBDictionary to shrink the size
+    of the library, the functionary is still there, but you may need to do some
+    specific +alloc / -init… methods instead.
+  * Minor improvements in the performance of object field getters/setters by
+    avoiding some memory management overhead.
+  * Fix a memory leak during the raising of some errors.
+  * Make header importing completely order independent.
+  * Small code improvements for things the undefined behaviors compiler option
+    was flagging.
+
+  Ruby
+  * Added ruby_package file option to control the module of generated class.
+  * Various bug fixes.
+
+  Javascript
+  * Allow setting string to int64 field.
+
+  Csharp
+  * Unknown fields are now parsed and then sent back on the wire. They can be
+    discarded at parse time via a CodedInputStream option.
+  * Movement towards working with .NET 3.5 and Unity
+  * Expression trees are no longer used
+  * AOT generics issues in Unity/il2cpp have a workaround (see this commit for
+    details)
+  * Floating point values are now compared bitwise (affects NaN value
+    comparisons)
+  * The default size limit when parsing is now 2GB rather than 64MB
+  * MessageParser now supports parsing from a slice of a byte array
+  * JSON list parsing now accepts null values where the underlying proto
+    representation does
+
 2017-12-20 version 3.5.1 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
   Planned Future Changes
   * Make C++ implementation C++11 only: we plan to require C++11 to build

+ 1 - 1
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.5.2'
+  s.version  = '3.6.0'
   s.summary  = 'Protocol Buffers v.3 runtime library for Objective-C.'
   s.homepage = 'https://github.com/google/protobuf'
   s.license  = '3-Clause BSD License'

+ 6 - 0
appveyor.yml

@@ -16,6 +16,12 @@ environment:
       BUILD_DLL: ON
       UNICODE: ON
 
+    - platform: Win64
+      language: cpp
+      image: Visual Studio 2017
+      BUILD_DLL: OFF
+      UNICODE: ON
+
     - platform: Win64
       language: csharp
       image: Visual Studio 2017

+ 1 - 1
configure.ac

@@ -17,7 +17,7 @@ AC_PREREQ(2.59)
 # In the SVN trunk, the version should always be the next anticipated release
 # version with the "-pre" suffix.  (We used to use "-SNAPSHOT" but this pushed
 # the size of one file name in the dist tarfile over the 99-char limit.)
-AC_INIT([Protocol Buffers],[3.5.2],[protobuf@googlegroups.com],[protobuf])
+AC_INIT([Protocol Buffers],[3.6.0],[protobuf@googlegroups.com],[protobuf])
 
 AM_MAINTAINER_MODE([enable])
 

+ 1 - 1
csharp/Google.Protobuf.Tools.nuspec

@@ -5,7 +5,7 @@
     <title>Google Protocol Buffers tools</title>
     <summary>Tools for Protocol Buffers - Google's data interchange format.</summary>
     <description>See project site for more info.</description>
-    <version>3.5.2</version>
+    <version>3.6.0</version>
     <authors>Google Inc.</authors>
     <owners>protobuf-packages</owners>
     <licenseUrl>https://github.com/google/protobuf/blob/master/LICENSE</licenseUrl>

+ 1 - 1
csharp/src/Google.Protobuf/Google.Protobuf.csproj

@@ -4,7 +4,7 @@
     <Description>C# runtime library for Protocol Buffers - Google's data interchange format.</Description>
     <Copyright>Copyright 2015, Google Inc.</Copyright>
     <AssemblyTitle>Google Protocol Buffers</AssemblyTitle>
-    <VersionPrefix>3.5.2</VersionPrefix>
+    <VersionPrefix>3.6.0</VersionPrefix>
     <Authors>Google Inc.</Authors>
     <TargetFrameworks>netstandard1.0;net45</TargetFrameworks>
     <GenerateDocumentationFile>true</GenerateDocumentationFile>

+ 0 - 4
csharp/src/Google.Protobuf/Reflection/ReflectionUtil.cs

@@ -34,10 +34,6 @@ using Google.Protobuf.Compatibility;
 using System;
 using System.Reflection;
 
-#if NET35
-using Google.Protobuf.Compatibility;
-#endif
-
 namespace Google.Protobuf.Reflection
 {
     /// <summary>

+ 1 - 1
java/core/pom.xml

@@ -6,7 +6,7 @@
   <parent>
     <groupId>com.google.protobuf</groupId>
     <artifactId>protobuf-parent</artifactId>
-    <version>3.5.2</version>
+    <version>3.6.0</version>
   </parent>
 
   <artifactId>protobuf-java</artifactId>

+ 1 - 1
java/pom.xml

@@ -11,7 +11,7 @@
 
   <groupId>com.google.protobuf</groupId>
   <artifactId>protobuf-parent</artifactId>
-  <version>3.5.2</version>
+  <version>3.6.0</version>
   <packaging>pom</packaging>
 
   <name>Protocol Buffers [Parent]</name>

+ 1 - 1
java/util/pom.xml

@@ -6,7 +6,7 @@
   <parent>
     <groupId>com.google.protobuf</groupId>
     <artifactId>protobuf-parent</artifactId>
-    <version>3.5.2</version>
+    <version>3.6.0</version>
   </parent>
 
   <artifactId>protobuf-java-util</artifactId>

+ 11 - 4
js/map.js

@@ -443,7 +443,8 @@ jspb.Map.prototype.serializeBinary = function(
 /**
  * Read one key/value message from the given BinaryReader. Compatible as the
  * `reader` callback parameter to jspb.BinaryReader.readMessage, to be called
- * when a key/value pair submessage is encountered.
+ * when a key/value pair submessage is encountered. If the Key is undefined,
+ * we should default it to 0.
  * @template K, V
  * @param {!jspb.Map} map
  * @param {!jspb.BinaryReader} reader
@@ -457,12 +458,17 @@ jspb.Map.prototype.serializeBinary = function(
  *    readMessage, in which case the second callback arg form is used.
  *
  * @param {?function(V,!jspb.BinaryReader)=} opt_valueReaderCallback
- *    The BinaryReader parsing callback for type V, if V is a message type.
+ *    The BinaryReader parsing callback for type V, if V is a message type
+ *
+ * @param {K=} opt_defaultKey
+ *    The default value for the type of map keys. Accepting map
+ *    entries with unset keys is required for maps to be backwards compatible
+ *    with the repeated message representation described here: goo.gl/zuoLAC
  *
  */
 jspb.Map.deserializeBinary = function(map, reader, keyReaderFn, valueReaderFn,
-                                      opt_valueReaderCallback) {
-  var key = undefined;
+                                      opt_valueReaderCallback, opt_defaultKey) {
+  var key = opt_defaultKey;
   var value = undefined;
 
   while (reader.nextField()) {
@@ -470,6 +476,7 @@ jspb.Map.deserializeBinary = function(map, reader, keyReaderFn, valueReaderFn,
       break;
     }
     var field = reader.getFieldNumber();
+
     if (field == 1) {
       // Key.
       key = keyReaderFn.call(reader);

+ 39 - 1
js/maps_test.js

@@ -35,6 +35,11 @@ goog.require('goog.userAgent');
 goog.require('proto.jspb.test.MapValueEnum');
 goog.require('proto.jspb.test.MapValueMessage');
 goog.require('proto.jspb.test.TestMapFields');
+goog.require('proto.jspb.test.TestMapFieldsOptionalKeys');
+goog.require('proto.jspb.test.MapEntryOptionalKeysStringKey');
+goog.require('proto.jspb.test.MapEntryOptionalKeysInt32Key');
+goog.require('proto.jspb.test.MapEntryOptionalKeysInt64Key');
+goog.require('proto.jspb.test.MapEntryOptionalKeysBoolKey');
 
 // CommonJS-LoadFromFile: test_pb proto.jspb.test
 goog.require('proto.jspb.test.MapValueMessageNoBinary');
@@ -76,7 +81,7 @@ function toArray(iter) {
  * Helper: generate test methods for this TestMapFields class.
  * @param {?} msgInfo
  * @param {?} submessageCtor
- * @param {!string} suffix
+ * @param {string} suffix
  */
 function makeTests(msgInfo, submessageCtor, suffix) {
   /**
@@ -260,6 +265,39 @@ function makeTests(msgInfo, submessageCtor, suffix) {
       var decoded = msgInfo.deserializeBinary(serialized);
       checkMapFields(decoded);
     });
+    /**
+     * Tests deserialization of undefined map keys go to default values in binary format.
+     */
+    it('testMapDeserializationForUndefinedKeys', function() {
+      var testMessageOptionalKeys = new proto.jspb.test.TestMapFieldsOptionalKeys();
+      var mapEntryStringKey = new proto.jspb.test.MapEntryOptionalKeysStringKey();
+      mapEntryStringKey.setValue("a");
+      testMessageOptionalKeys.setMapStringString(mapEntryStringKey);
+      var mapEntryInt32Key = new proto.jspb.test.MapEntryOptionalKeysInt32Key();
+      mapEntryInt32Key.setValue("b");
+      testMessageOptionalKeys.setMapInt32String(mapEntryInt32Key);
+      var mapEntryInt64Key = new proto.jspb.test.MapEntryOptionalKeysInt64Key();
+      mapEntryInt64Key.setValue("c");
+      testMessageOptionalKeys.setMapInt64String(mapEntryInt64Key);
+      var mapEntryBoolKey = new proto.jspb.test.MapEntryOptionalKeysBoolKey();
+      mapEntryBoolKey.setValue("d");
+      testMessageOptionalKeys.setMapBoolString(mapEntryBoolKey);
+      var deserializedMessage = msgInfo.deserializeBinary(
+        testMessageOptionalKeys.serializeBinary()
+       );
+      checkMapEquals(deserializedMessage.getMapStringStringMap(), [
+        ['', 'a']
+      ]);
+      checkMapEquals(deserializedMessage.getMapInt32StringMap(), [
+        [0, 'b']
+      ]);
+      checkMapEquals(deserializedMessage.getMapInt64StringMap(), [
+        [0, 'c']
+      ]);
+      checkMapEquals(deserializedMessage.getMapBoolStringMap(), [
+        [false, 'd']
+      ]);
+    });
   }
 
 

+ 1 - 1
js/package.json

@@ -1,6 +1,6 @@
 {
   "name": "google-protobuf",
-  "version": "3.5.2",
+  "version": "3.6.0",
   "description": "Protocol Buffers for JavaScript",
   "main": "google-protobuf.js",
   "files": [

+ 32 - 0
js/testbinary.proto

@@ -201,6 +201,38 @@ message TestMapFields {
   map<string, TestMapFields> map_string_testmapfields = 12;
 }
 
+// These proto are 'mock map' entries to test the above map deserializing with
+// undefined keys. Make sure TestMapFieldsOptionalKeys is written to be
+// deserialized by TestMapFields
+message MapEntryOptionalKeysStringKey {
+  optional string key = 1;
+  optional string value = 2;
+}
+
+message MapEntryOptionalKeysInt32Key {
+  optional int32 key = 1;
+  optional string value = 2;
+}
+
+message MapEntryOptionalKeysInt64Key {
+  optional int64 key = 1;
+  optional string value = 2;
+}
+
+message MapEntryOptionalKeysBoolKey {
+  optional bool key = 1;
+  optional string value = 2;
+}
+
+message TestMapFieldsOptionalKeys {
+  optional MapEntryOptionalKeysStringKey map_string_string = 1;
+  optional MapEntryOptionalKeysInt32Key map_int32_string= 8;
+  optional MapEntryOptionalKeysInt64Key map_int64_string = 9;
+  optional MapEntryOptionalKeysBoolKey map_bool_string = 10;
+}
+
+// End mock-map entries
+
 enum MapValueEnum {
   MAP_VALUE_FOO = 0;
   MAP_VALUE_BAR = 1;

+ 14 - 0
kokoro/release/linux/build_artifacts.sh

@@ -0,0 +1,14 @@
+#!/bin/bash
+
+set -ex
+
+# change to repo root
+cd $(dirname $0)/../../..
+
+source kokoro/release/linux/prepare_build.sh
+
+# ruby environment
+source kokoro/release/linux/ruby/ruby_build_environment.sh
+
+# build artifacts
+bash kokoro/release/linux/ruby/ruby_build.sh

+ 16 - 0
kokoro/release/linux/prepare_build.sh

@@ -0,0 +1,16 @@
+#!/bin/bash
+
+# Move docker's storage location to scratch disk so we don't run out of space.
+echo 'DOCKER_OPTS="${DOCKER_OPTS} --graph=/tmpfs/docker"' | sudo tee --append /etc/default/docker
+# Use container registry mirror for pulling docker images (should make downloads faster)
+# See https://cloud.google.com/container-registry/docs/using-dockerhub-mirroring
+echo 'DOCKER_OPTS="${DOCKER_OPTS} --registry-mirror=https://mirror.gcr.io"' | sudo tee --append /etc/default/docker
+sudo service docker restart
+
+# Download Docker images from DockerHub
+export DOCKERHUB_ORGANIZATION=grpctesting
+
+# All artifacts come here
+mkdir artifacts
+export ARTIFACT_DIR=$(pwd)/artifacts
+

+ 8 - 0
kokoro/release/linux/release.cfg

@@ -0,0 +1,8 @@
+# Configuration for Linux release builds
+build_file: "protobuf/kokoro/release/linux/build_artifacts.sh"
+
+action {
+  define_artifacts {
+    regex: "github/protobuf/artifacts/**"
+  }
+}

+ 15 - 0
kokoro/release/linux/ruby/ruby_build.sh

@@ -0,0 +1,15 @@
+#!/bin/bash
+
+# Build protoc
+if test ! -e src/protoc; then
+  ./autogen.sh
+  ./configure
+  make -j4
+fi
+
+umask 0022
+pushd ruby
+bundle install && bundle exec rake gem:native
+ls pkg
+mv pkg/* $ARTIFACT_DIR
+popd

+ 8 - 0
kokoro/release/linux/ruby/ruby_build_environment.sh

@@ -0,0 +1,8 @@
+#!/bin/bash
+
+set +ex
+[[ -s /etc/profile.d/rvm.sh ]] && . /etc/profile.d/rvm.sh
+set -e  # rvm commands are very verbose
+rvm --default use ruby-2.4.1
+gem install bundler --update
+set -ex

+ 19 - 0
kokoro/release/macos/build_artifacts.sh

@@ -0,0 +1,19 @@
+#!/bin/bash
+
+set -ex
+
+# change to repo root
+cd $(dirname $0)/../../..
+
+# all artifacts come here
+mkdir artifacts
+export ARTIFACT_DIR=$(pwd)/artifacts
+
+# ruby environment
+bash kokoro/release/macos/ruby/ruby_build_environment.sh
+
+gem install rubygems-update
+update_rubygems
+
+# build artifacts
+bash kokoro/release/macos/ruby/ruby_build.sh

+ 8 - 0
kokoro/release/macos/release.cfg

@@ -0,0 +1,8 @@
+# Configuration for Mac OSX release builds
+build_file: "protobuf/kokoro/release/macos/build_artifacts.sh"
+
+action {
+  define_artifacts {
+    regex: "github/protobuf/artifacts/**"
+  }
+}

+ 15 - 0
kokoro/release/macos/ruby/ruby_build.sh

@@ -0,0 +1,15 @@
+#!/bin/bash
+
+# Build protoc
+if test ! -e src/protoc; then
+  ./autogen.sh
+  ./configure
+  make -j4
+fi
+
+umask 0022
+pushd ruby
+bundle install && bundle exec rake gem:native
+ls pkg
+mv pkg/* $ARTIFACT_DIR
+popd

+ 57 - 0
kokoro/release/macos/ruby/ruby_build_environment.sh

@@ -0,0 +1,57 @@
+#!/bin/bash
+
+set -ex
+
+set +ex  # rvm script is very verbose and exits with errorcode
+source $HOME/.rvm/scripts/rvm
+set -e  # rvm commands are very verbose
+time rvm install 2.5.0
+rvm use 2.5.0 --default
+gem install rake-compiler --no-ri --no-doc
+gem install bundler --no-ri --no-doc
+rvm osx-ssl-certs status all
+rvm osx-ssl-certs update all
+set -ex
+
+rm -rf ~/.rake-compiler
+
+CROSS_RUBY=$(mktemp tmpfile.XXXXXXXX)
+
+curl https://raw.githubusercontent.com/rake-compiler/rake-compiler/v1.0.3/tasks/bin/cross-ruby.rake > "$CROSS_RUBY"
+
+# See https://github.com/grpc/grpc/issues/12161 for verconf.h patch details
+patch "$CROSS_RUBY" << EOF
+--- cross-ruby.rake	2018-04-10 11:32:16.000000000 -0700
++++ patched	2018-04-10 11:40:25.000000000 -0700
+@@ -133,8 +133,10 @@
+     "--host=#{MINGW_HOST}",
+     "--target=#{MINGW_TARGET}",
+     "--build=#{RUBY_BUILD}",
+-    '--enable-shared',
++    '--enable-static',
++    '--disable-shared',
+     '--disable-install-doc',
++    '--without-gmp',
+     '--with-ext='
+   ]
+ 
+@@ -151,6 +153,7 @@
+ # make
+ file "#{USER_HOME}/builds/#{MINGW_HOST}/#{RUBY_CC_VERSION}/ruby.exe" => ["#{USER_HOME}/builds/#{MINGW_HOST}/#{RUBY_CC_VERSION}/Makefile"] do |t|
+   chdir File.dirname(t.prerequisites.first) do
++    sh "test -s verconf.h || rm -f verconf.h"  # if verconf.h has size 0, make sure it gets re-built by make
+     sh MAKE
+   end
+ end
+EOF
+
+MAKE="make -j8"
+
+for v in 2.5.0 2.4.0 2.3.0 2.2.2 2.1.6 2.0.0-p645 ; do
+  ccache -c
+  rake -f "$CROSS_RUBY" cross-ruby VERSION="$v" HOST=x86_64-darwin11 MAKE="$MAKE"
+done
+
+sed 's/x86_64-darwin-11/universal-darwin/' ~/.rake-compiler/config.yml > "$CROSS_RUBY"
+mv "$CROSS_RUBY" ~/.rake-compiler/config.yml
+

+ 23 - 0
kokoro/release/protoc/macos/build.sh

@@ -0,0 +1,23 @@
+#!/bin/bash
+
+set -x
+CXXFLAGS_COMMON="-DNDEBUG -mmacosx-version-min=10.9"
+
+cd github/protobuf
+./autogen.sh
+
+mkdir build32 && cd build32
+export CXXFLAGS="$CXXFLAGS_COMMON -m32"
+../configure --disable-shared
+make -j4
+file src/protoc
+otool -L src/protoc | grep dylib
+cd ..
+
+mkdir build64 && cd build64
+export CXXFLAGS="$CXXFLAGS_COMMON -m64"
+../configure --disable-shared
+make -j4
+file src/protoc
+otool -L src/protoc | grep dylib
+cd ..

+ 8 - 0
kokoro/release/protoc/macos/release.cfg

@@ -0,0 +1,8 @@
+# Configuration for Mac OSX protoc release builds
+build_file: "protobuf/kokoro/release/protoc/macos/build.sh"
+
+action {
+  define_artifacts {
+    regex: "**/protoc"
+  }
+}

+ 27 - 0
kokoro/release/protoc/windows/build.bat

@@ -0,0 +1,27 @@
+set PATH=C:\Program Files (x86)\MSBuild\14.0\bin\;%PATH%
+set generator32=Visual Studio 14
+set generator64=Visual Studio 14 Win64
+set vcplatform32=win32
+set vcplatform64=x64
+set configuration=Release
+
+echo Building protoc
+cd github\protobuf
+
+mkdir build32
+cd build32
+cmake -G "%generator32%" -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_BUILD_SHARED_LIBS=OFF -Dprotobuf_UNICODE=ON ../cmake
+msbuild protobuf.sln /p:Platform=%vcplatform32% || goto error
+cd ..
+
+mkdir build64
+cd build64
+cmake -G "%generator64%" -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_BUILD_SHARED_LIBS=OFF -Dprotobuf_UNICODE=ON ../cmake
+msbuild protobuf.sln /p:Platform=%vcplatform64% || goto error
+cd ..
+
+goto :EOF
+
+:error
+echo Failed!
+exit /b %ERRORLEVEL%

+ 8 - 0
kokoro/release/protoc/windows/release.cfg

@@ -0,0 +1,8 @@
+# Configuration for Windows protoc release builds
+build_file: "protobuf/kokoro/release/protoc/windows/build.bat"
+
+action {
+  define_artifacts {
+    regex: "**/protoc.exe"
+  }
+}

+ 19 - 3
php/ext/google/protobuf/package.xml

@@ -10,11 +10,11 @@
   <email>protobuf-opensource@google.com</email>
   <active>yes</active>
  </lead>
- <date>2018-03-06</date>
+ <date>2018-06-06</date>
  <time>11:02:07</time>
  <version>
-  <release>3.5.2</release>
-  <api>3.5.2</api>
+  <release>3.6.0</release>
+  <api>3.6.0</api>
  </version>
  <stability>
   <release>stable</release>
@@ -229,6 +229,22 @@ GA release.
    <time>11:02:07</time>
    <license uri="https://opensource.org/licenses/BSD-3-Clause">3-Clause BSD License</license>
    <notes>
+G  A release.
+   </notes>
+  </release>
+  <release>
+   <version>
+    <release>3.6.0</release>
+    <api>3.6.0</api>
+   </version>
+   <stability>
+    <release>stable</release>
+    <api>stable</api>
+   </stability>
+   <date>2018-06-06</date>
+   <time>11:02:07</time>
+   <license uri="https://opensource.org/licenses/BSD-3-Clause">3-Clause BSD License</license>
+   <notes>
 G  A release.
    </notes>
   </release>

+ 1 - 1
php/ext/google/protobuf/protobuf.h

@@ -37,7 +37,7 @@
 #include "upb.h"
 
 #define PHP_PROTOBUF_EXTNAME "protobuf"
-#define PHP_PROTOBUF_VERSION "3.5.2"
+#define PHP_PROTOBUF_VERSION "3.6.0"
 
 #define MAX_LENGTH_OF_INT64 20
 #define SIZEOF_INT64 8

+ 14 - 0
php/src/Google/Protobuf/Internal/Descriptor.php

@@ -44,6 +44,7 @@ class Descriptor
     private $nested_type = [];
     private $enum_type = [];
     private $klass;
+    private $legacy_klass;
     private $options;
     private $oneof_decl = [];
 
@@ -151,6 +152,16 @@ class Descriptor
         return $this->klass;
     }
 
+    public function setLegacyClass($klass)
+    {
+        $this->legacy_klass = $klass;
+    }
+
+    public function getLegacyClass()
+    {
+        return $this->legacy_klass;
+    }
+
     public function setOptions($options)
     {
         $this->options = $options;
@@ -167,16 +178,19 @@ class Descriptor
 
         $message_name_without_package  = "";
         $classname = "";
+        $legacy_classname = "";
         $fullname = "";
         GPBUtil::getFullClassName(
             $proto,
             $containing,
             $file_proto,
             $message_name_without_package,
+            $legacy_classname,
             $classname,
             $fullname);
         $desc->setFullName($fullname);
         $desc->setClass($classname);
+        $desc->setLegacyClass($legacy_classname);
         $desc->setOptions($proto->getOptions());
 
         foreach ($proto->getField() as $field_proto) {

+ 2 - 0
php/src/Google/Protobuf/Internal/DescriptorPool.php

@@ -92,6 +92,7 @@ class DescriptorPool
         $this->proto_to_class[$descriptor->getFullName()] =
             $descriptor->getClass();
         $this->class_to_desc[$descriptor->getClass()] = $descriptor;
+        $this->class_to_desc[$descriptor->getLegacyClass()] = $descriptor;
         foreach ($descriptor->getNestedType() as $nested_type) {
             $this->addDescriptor($nested_type);
         }
@@ -105,6 +106,7 @@ class DescriptorPool
         $this->proto_to_class[$descriptor->getFullName()] =
             $descriptor->getClass();
         $this->class_to_enum_desc[$descriptor->getClass()] = $descriptor;
+        $this->class_to_enum_desc[$descriptor->getLegacyClass()] = $descriptor;
     }
 
     public function getDescriptorByClassName($klass)

+ 14 - 0
php/src/Google/Protobuf/Internal/EnumDescriptor.php

@@ -9,6 +9,7 @@ class EnumDescriptor
     use HasPublicDescriptorTrait;
 
     private $klass;
+    private $legacy_klass;
     private $full_name;
     private $value;
     private $name_to_value;
@@ -66,12 +67,23 @@ class EnumDescriptor
         return $this->klass;
     }
 
+    public function setLegacyClass($klass)
+    {
+        $this->legacy_klass = $klass;
+    }
+
+    public function getLegacyClass()
+    {
+        return $this->legacy_klass;
+    }
+
     public static function buildFromProto($proto, $file_proto, $containing)
     {
         $desc = new EnumDescriptor();
 
         $enum_name_without_package  = "";
         $classname = "";
+        $legacy_classname = "";
         $fullname = "";
         GPBUtil::getFullClassName(
             $proto,
@@ -79,9 +91,11 @@ class EnumDescriptor
             $file_proto,
             $enum_name_without_package,
             $classname,
+            $legacy_classname,
             $fullname);
         $desc->setFullName($fullname);
         $desc->setClass($classname);
+        $desc->setLegacyClass($legacy_classname);
         $values = $proto->getValue();
         foreach ($values as $value) {
             $desc->addValue($value->getNumber(), $value);

+ 28 - 4
php/src/Google/Protobuf/Internal/GPBUtil.php

@@ -215,9 +215,10 @@ class GPBUtil
                     "Expect repeated field of different type.");
             }
             if ($var->getType() === GPBType::MESSAGE &&
-                $var->getClass() !== $klass) {
+                $var->getClass() !== $klass &&
+                $var->getLegacyClass() !== $klass) {
                 throw new \Exception(
-                    "Expect repeated field of different message.");
+                    "Expect repeated field of " . $klass . ".");
             }
             return $var;
         }
@@ -242,9 +243,10 @@ class GPBUtil
                 throw new \Exception("Expect map field of value type.");
             }
             if ($var->getValueType() === GPBType::MESSAGE &&
-                $var->getValueClass() !== $klass) {
+                $var->getValueClass() !== $klass &&
+                $var->getLegacyValueClass() !== $klass) {
                 throw new \Exception(
-                    "Expect map field of different value message.");
+                    "Expect map field of " . $klass . ".");
             }
             return $var;
         }
@@ -299,6 +301,17 @@ class GPBUtil
         return "";
     }
 
+    public static function getLegacyClassNameWithoutPackage(
+        $name,
+        $file_proto)
+    {
+        $parts = explode('.', $name);
+        foreach ($parts as $i => $part) {
+            $parts[$i] = static::getClassNamePrefix($parts[$i], $file_proto) . $parts[$i];
+        }
+        return implode('\\', $parts);
+    }
+
     public static function getClassNameWithoutPackage(
         $name,
         $file_proto)
@@ -316,6 +329,7 @@ class GPBUtil
         $file_proto,
         &$message_name_without_package,
         &$classname,
+        &$legacy_classname,
         &$fullname)
     {
         // Full name needs to start with '.'.
@@ -334,21 +348,28 @@ class GPBUtil
 
         $class_name_without_package =
             static::getClassNameWithoutPackage($message_name_without_package, $file_proto);
+        $legacy_class_name_without_package =
+            static::getLegacyClassNameWithoutPackage(
+                $message_name_without_package, $file_proto);
 
         $option = $file_proto->getOptions();
         if (!is_null($option) && $option->hasPhpNamespace()) {
             $namespace = $option->getPhpNamespace();
             if ($namespace !== "") {
                 $classname = $namespace . "\\" . $class_name_without_package;
+                $legacy_classname =
+                    $namespace . "\\" . $legacy_class_name_without_package;
                 return;
             } else {
                 $classname = $class_name_without_package;
+                $legacy_classname = $legacy_class_name_without_package;
                 return;
             }
         }
 
         if ($package === "") {
             $classname = $class_name_without_package;
+            $legacy_classname = $legacy_class_name_without_package;
         } else {
             $parts = array_map('ucwords', explode('.', $package));
             foreach ($parts as $i => $part) {
@@ -358,6 +379,9 @@ class GPBUtil
                 implode('\\', $parts) .
                 "\\".self::getClassNamePrefix($class_name_without_package,$file_proto).
                 $class_name_without_package;
+            $legacy_classname =
+                implode('\\', array_map('ucwords', explode('.', $package))).
+                "\\".$legacy_class_name_without_package;
         }
     }
 

+ 24 - 1
php/src/Google/Protobuf/Internal/MapField.php

@@ -58,7 +58,11 @@ class MapField implements \ArrayAccess, \IteratorAggregate, \Countable
     /**
      * @ignore
      */
-    private $value_klass;
+    private $klass;
+    /**
+     * @ignore
+     */
+    private $legacy_klass;
 
     /**
      * Constructs an instance of MapField.
@@ -75,6 +79,17 @@ class MapField implements \ArrayAccess, \IteratorAggregate, \Countable
         $this->key_type = $key_type;
         $this->value_type = $value_type;
         $this->klass = $klass;
+
+        if ($this->value_type == GPBType::MESSAGE) {
+            $pool = DescriptorPool::getGeneratedPool();
+            $desc = $pool->getDescriptorByClassName($klass);
+            if ($desc == NULL) {
+                new $klass;  // No msg class instance has been created before.
+                $desc = $pool->getDescriptorByClassName($klass);
+            }
+            $this->klass = $desc->getClass();
+            $this->legacy_klass = $desc->getLegacyClass();
+        }
     }
 
     /**
@@ -101,6 +116,14 @@ class MapField implements \ArrayAccess, \IteratorAggregate, \Countable
         return $this->klass;
     }
 
+    /**
+     * @ignore
+     */
+    public function getLegacyValueClass()
+    {
+        return $this->legacy_klass;
+    }
+
     /**
      * Return the element at the given key.
      *

+ 22 - 1
php/src/Google/Protobuf/Internal/RepeatedField.php

@@ -59,6 +59,10 @@ class RepeatedField implements \ArrayAccess, \IteratorAggregate, \Countable
      * @ignore
      */
     private $klass;
+    /**
+     * @ignore
+     */
+    private $legacy_klass;
 
     /**
      * Constructs an instance of RepeatedField.
@@ -71,7 +75,16 @@ class RepeatedField implements \ArrayAccess, \IteratorAggregate, \Countable
     {
         $this->container = [];
         $this->type = $type;
-        $this->klass = $klass;
+        if ($this->type == GPBType::MESSAGE) {
+            $pool = DescriptorPool::getGeneratedPool();
+            $desc = $pool->getDescriptorByClassName($klass);
+            if ($desc == NULL) {
+                new $klass;  // No msg class instance has been created before.
+                $desc = $pool->getDescriptorByClassName($klass);
+            }
+            $this->klass = $desc->getClass();
+            $this->legacy_klass = $desc->getLegacyClass();
+        }
     }
 
     /**
@@ -90,6 +103,14 @@ class RepeatedField implements \ArrayAccess, \IteratorAggregate, \Countable
         return $this->klass;
     }
 
+    /**
+     * @ignore
+     */
+    public function getLegacyClass()
+    {
+        return $this->legacy_klass;
+    }
+
     /**
      * Return the element at the given index.
      *

+ 33 - 16
php/tests/compatibility_test.sh

@@ -2,12 +2,14 @@
 
 function use_php() {
   VERSION=$1
-  PHP=`which php`
-  PHP_CONFIG=`which php-config`
-  PHPIZE=`which phpize`
-  ln -sfn "/usr/local/php-${VERSION}/bin/php" $PHP
-  ln -sfn "/usr/local/php-${VERSION}/bin/php-config" $PHP_CONFIG
-  ln -sfn "/usr/local/php-${VERSION}/bin/phpize" $PHPIZE
+
+  OLD_PATH=$PATH
+  OLD_CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH
+  OLD_C_INCLUDE_PATH=$C_INCLUDE_PATH
+
+  export PATH=/usr/local/php-${VERSION}/bin:$OLD_PATH
+  export CPLUS_INCLUDE_PATH=/usr/local/php-${VERSION}/include/php/main:/usr/local/php-${VERSION}/include/php/:$OLD_CPLUS_INCLUDE_PATH
+  export C_INCLUDE_PATH=/usr/local/php-${VERSION}/include/php/main:/usr/local/php-${VERSION}/include/php/:$OLD_C_INCLUDE_PATH
 }
 
 function generate_proto() {
@@ -18,7 +20,22 @@ function generate_proto() {
   mkdir generated
 
   $PROTOC1 --php_out=generated proto/test_include.proto
-  $PROTOC2 --php_out=generated proto/test.proto proto/test_no_namespace.proto proto/test_prefix.proto
+  $PROTOC2 --php_out=generated                 \
+    proto/test.proto                           \
+    proto/test_no_namespace.proto              \
+    proto/test_prefix.proto                    \
+    proto/test_php_namespace.proto             \
+    proto/test_empty_php_namespace.proto       \
+    proto/test_reserved_enum_lower.proto       \
+    proto/test_reserved_enum_upper.proto       \
+    proto/test_reserved_enum_value_lower.proto \
+    proto/test_reserved_enum_value_upper.proto \
+    proto/test_reserved_message_lower.proto    \
+    proto/test_reserved_message_upper.proto    \
+    proto/test_service.proto                   \
+    proto/test_service_namespace.proto         \
+    proto/test_descriptors.proto
+
   pushd ../../src
   $PROTOC2 --php_out=../php/tests/generated -I../php/tests -I. ../php/tests/proto/test_import_descriptor_proto.proto
   popd
@@ -52,9 +69,9 @@ cd $(dirname $0)
 
 # The old version of protobuf that we are testing compatibility against.
 case "$1" in
-  ""|3.3.0)
-    OLD_VERSION=3.3.0
-    OLD_VERSION_PROTOC=http://repo1.maven.org/maven2/com/google/protobuf/protoc/3.3.0/protoc-3.3.0-linux-x86_64.exe
+  ""|3.5.0)
+    OLD_VERSION=3.5.0
+    OLD_VERSION_PROTOC=http://repo1.maven.org/maven2/com/google/protobuf/protoc/$OLD_VERSION/protoc-$OLD_VERSION-linux-x86_64.exe
     ;;
   *)
     echo "[ERROR]: Unknown version number: $1"
@@ -81,7 +98,7 @@ git checkout v$OLD_VERSION
 popd
 
 # Build and copy the new runtime
-use_php 5.5
+use_php 7.1
 pushd ../ext/google/protobuf
 make clean || true
 phpize && ./configure && make
@@ -99,12 +116,12 @@ chmod +x old_protoc
 NEW_PROTOC=`pwd`/../../src/protoc
 OLD_PROTOC=`pwd`/old_protoc
 cd protobuf/php
-cp -r /usr/local/vendor-5.5 vendor
-wget https://phar.phpunit.de/phpunit-4.8.0.phar -O /usr/bin/phpunit
+composer install
 
 # Remove implementation detail tests.
 tests=( array_test.php encode_decode_test.php generated_class_test.php map_field_test.php well_known_test.php )
 sed -i.bak '/php_implementation_test.php/d' phpunit.xml
+sed -i.bak '/generated_phpdoc_test.php/d' phpunit.xml
 for t in "${tests[@]}"
 do
   remove_error_test tests/$t
@@ -118,7 +135,7 @@ cd tests
 generate_proto $OLD_PROTOC $OLD_PROTOC
 ./test.sh
 pushd ..
-phpunit
+./vendor/bin/phpunit
 popd
 
 # Test A.2:
@@ -127,7 +144,7 @@ popd
 generate_proto $NEW_PROTOC $OLD_PROTOC
 ./test.sh
 pushd ..
-phpunit
+./vendor/bin/phpunit
 popd
 
 # Test A.3:
@@ -136,5 +153,5 @@ popd
 generate_proto $OLD_PROTOC $NEW_PROTOC
 ./test.sh
 pushd ..
-phpunit
+./vendor/bin/phpunit
 popd

+ 1 - 1
post_process_dist.sh

@@ -27,7 +27,7 @@ fi
 
 set -ex
 
-LANGUAGES="cpp csharp java javanano js objectivec python ruby php all"
+LANGUAGES="cpp csharp java js objectivec python ruby php all"
 BASENAME=`basename $1 .tar.gz`
 VERSION=${BASENAME:9}
 

+ 1 - 1
protoc-artifacts/pom.xml

@@ -10,7 +10,7 @@
   </parent>
   <groupId>com.google.protobuf</groupId>
   <artifactId>protoc</artifactId>
-  <version>3.5.2</version>
+  <version>3.6.0</version>
   <packaging>pom</packaging>
   <name>Protobuf Compiler</name>
   <description>

+ 1 - 1
python/google/protobuf/__init__.py

@@ -30,7 +30,7 @@
 
 # Copyright 2007 Google Inc. All Rights Reserved.
 
-__version__ = '3.5.2'
+__version__ = '3.6.0'
 
 if __name__ != '__main__':
   try:

+ 2 - 4
python/setup.py

@@ -204,11 +204,9 @@ if __name__ == '__main__':
 
     v, _, _ = platform.mac_ver()
     if v:
-      v = float('.'.join(v.split('.')[:2]))
-      if v >= 10.12:
-        extra_compile_args.append('-std=c++11')
+      extra_compile_args.append('-std=c++11')
     elif os.getenv('KOKORO_BUILD_NUMBER') or os.getenv('KOKORO_BUILD_ID'):
-        extra_compile_args.append('-std=c++11')
+      extra_compile_args.append('-std=c++11')
 
     if warnings_as_errors in sys.argv:
       extra_compile_args.append('-Werror')

+ 3 - 1
ruby/ext/google/protobuf_c/extconf.rb

@@ -2,7 +2,9 @@
 
 require 'mkmf'
 
-$CFLAGS += " -std=c99 -O3 -DNDEBUG"
+unless RUBY_PLATFORM =~ /mswin|mingw/
+  $CFLAGS += " -std=c99 -O3 -DNDEBUG"
+end
 
 
 if RUBY_PLATFORM =~ /linux/

+ 1 - 1
ruby/google-protobuf.gemspec

@@ -1,6 +1,6 @@
 Gem::Specification.new do |s|
   s.name        = "google-protobuf"
-  s.version     = "3.5.2"
+  s.version     = "3.6.0"
   s.licenses    = ["BSD-3-Clause"]
   s.summary     = "Protocol Buffers"
   s.description = "Protocol Buffers are Google's data interchange format."

+ 3 - 3
src/Makefile.am

@@ -164,7 +164,7 @@ nobase_include_HEADERS =                                         \
 lib_LTLIBRARIES = libprotobuf-lite.la libprotobuf.la libprotoc.la
 
 libprotobuf_lite_la_LIBADD = $(PTHREAD_LIBS)
-libprotobuf_lite_la_LDFLAGS = -version-info 15:1:0 -export-dynamic -no-undefined
+libprotobuf_lite_la_LDFLAGS = -version-info 16:0:0 -export-dynamic -no-undefined
 if HAVE_LD_VERSION_SCRIPT
 libprotobuf_lite_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libprotobuf-lite.map
 EXTRA_libprotobuf_lite_la_DEPENDENCIES = libprotobuf-lite.map
@@ -210,7 +210,7 @@ libprotobuf_lite_la_SOURCES =                                  \
   google/protobuf/io/zero_copy_stream_impl_lite.cc
 
 libprotobuf_la_LIBADD = $(PTHREAD_LIBS)
-libprotobuf_la_LDFLAGS = -version-info 15:1:0 -export-dynamic -no-undefined
+libprotobuf_la_LDFLAGS = -version-info 16:0:0 -export-dynamic -no-undefined
 if HAVE_LD_VERSION_SCRIPT
 libprotobuf_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libprotobuf.map
 EXTRA_libprotobuf_la_DEPENDENCIES = libprotobuf.map
@@ -301,7 +301,7 @@ libprotobuf_la_SOURCES =                                       \
 nodist_libprotobuf_la_SOURCES = $(nodist_libprotobuf_lite_la_SOURCES)
 
 libprotoc_la_LIBADD = $(PTHREAD_LIBS) libprotobuf.la
-libprotoc_la_LDFLAGS = -version-info 15:1:0 -export-dynamic -no-undefined
+libprotoc_la_LDFLAGS = -version-info 16:0:0 -export-dynamic -no-undefined
 if HAVE_LD_VERSION_SCRIPT
 libprotoc_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libprotoc.map
 EXTRA_libprotoc_la_DEPENDENCIES = libprotoc.map

+ 2 - 2
src/google/protobuf/any.pb.h

@@ -8,12 +8,12 @@
 
 #include <google/protobuf/stubs/common.h>
 
-#if GOOGLE_PROTOBUF_VERSION < 3005000
+#if GOOGLE_PROTOBUF_VERSION < 3006000
 #error This file was generated by a newer version of protoc which is
 #error incompatible with your Protocol Buffer headers.  Please update
 #error your headers.
 #endif
-#if 3005001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
+#if 3006000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
 #error This file was generated by an older version of protoc which is
 #error incompatible with your Protocol Buffer headers.  Please
 #error regenerate this file with a newer version of protoc.

+ 2 - 2
src/google/protobuf/api.pb.h

@@ -8,12 +8,12 @@
 
 #include <google/protobuf/stubs/common.h>
 
-#if GOOGLE_PROTOBUF_VERSION < 3005000
+#if GOOGLE_PROTOBUF_VERSION < 3006000
 #error This file was generated by a newer version of protoc which is
 #error incompatible with your Protocol Buffer headers.  Please update
 #error your headers.
 #endif
-#if 3005001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
+#if 3006000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
 #error This file was generated by an older version of protoc which is
 #error incompatible with your Protocol Buffer headers.  Please
 #error regenerate this file with a newer version of protoc.

+ 5 - 1
src/google/protobuf/compiler/js/js_generator.cc

@@ -2962,8 +2962,12 @@ void Generator::GenerateClassDeserializeBinaryField(
     if (value_field->type() == FieldDescriptor::TYPE_MESSAGE) {
       printer->Print(", $messageType$.deserializeBinaryFromReader",
           "messageType", GetMessagePath(options, value_field->message_type()));
+    } else {
+      printer->Print(", null");
     }
-
+    printer->Print(", $defaultKey$",
+          "defaultKey", JSFieldDefault(key_field)
+    );
     printer->Print(");\n");
     printer->Print("         });\n");
   } else {

+ 2 - 2
src/google/protobuf/compiler/plugin.pb.h

@@ -8,12 +8,12 @@
 
 #include <google/protobuf/stubs/common.h>
 
-#if GOOGLE_PROTOBUF_VERSION < 3005000
+#if GOOGLE_PROTOBUF_VERSION < 3006000
 #error This file was generated by a newer version of protoc which is
 #error incompatible with your Protocol Buffer headers.  Please update
 #error your headers.
 #endif
-#if 3005001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
+#if 3006000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
 #error This file was generated by an older version of protoc which is
 #error incompatible with your Protocol Buffer headers.  Please
 #error regenerate this file with a newer version of protoc.

+ 6 - 8
src/google/protobuf/descriptor.cc

@@ -775,10 +775,10 @@ class FileDescriptorTables {
 
   SymbolsByParentMap symbols_by_parent_;
   mutable FieldsByNameMap fields_by_lowercase_name_;
-  mutable FieldsByNameMap* fields_by_lowercase_name_tmp_;
+  std::unique_ptr<FieldsByNameMap> fields_by_lowercase_name_tmp_;
   mutable GoogleOnceDynamic fields_by_lowercase_name_once_;
   mutable FieldsByNameMap fields_by_camelcase_name_;
-  mutable FieldsByNameMap* fields_by_camelcase_name_tmp_;
+  std::unique_ptr<FieldsByNameMap> fields_by_camelcase_name_tmp_;
   mutable GoogleOnceDynamic fields_by_camelcase_name_once_;
   FieldsByNumberMap fields_by_number_;  // Not including extensions.
   EnumValuesByNumberMap enum_values_by_number_;
@@ -1146,10 +1146,8 @@ bool DescriptorPool::Tables::AddFile(const FileDescriptor* file) {
 
 void FileDescriptorTables::FinalizeTables() {
   // Clean up the temporary maps used by AddFieldByStylizedNames().
-  delete fields_by_lowercase_name_tmp_;
-  fields_by_lowercase_name_tmp_ = NULL;
-  delete fields_by_camelcase_name_tmp_;
-  fields_by_camelcase_name_tmp_ = NULL;
+  fields_by_lowercase_name_tmp_ = nullptr;
+  fields_by_camelcase_name_tmp_ = nullptr;
 }
 
 void FileDescriptorTables::AddFieldByStylizedNames(
@@ -1164,7 +1162,7 @@ void FileDescriptorTables::AddFieldByStylizedNames(
   // entries from fields_by_number_.
 
   PointerStringPair lowercase_key(parent, field->lowercase_name().c_str());
-  if (!InsertIfNotPresent(fields_by_lowercase_name_tmp_, lowercase_key,
+  if (!InsertIfNotPresent(fields_by_lowercase_name_tmp_.get(), lowercase_key,
                           field)) {
     InsertIfNotPresent(
         &fields_by_lowercase_name_, lowercase_key,
@@ -1172,7 +1170,7 @@ void FileDescriptorTables::AddFieldByStylizedNames(
   }
 
   PointerStringPair camelcase_key(parent, field->camelcase_name().c_str());
-  if (!InsertIfNotPresent(fields_by_camelcase_name_tmp_, camelcase_key,
+  if (!InsertIfNotPresent(fields_by_camelcase_name_tmp_.get(), camelcase_key,
                           field)) {
     InsertIfNotPresent(
         &fields_by_camelcase_name_, camelcase_key,

+ 2 - 2
src/google/protobuf/descriptor.pb.h

@@ -8,12 +8,12 @@
 
 #include <google/protobuf/stubs/common.h>
 
-#if GOOGLE_PROTOBUF_VERSION < 3005000
+#if GOOGLE_PROTOBUF_VERSION < 3006000
 #error This file was generated by a newer version of protoc which is
 #error incompatible with your Protocol Buffer headers.  Please update
 #error your headers.
 #endif
-#if 3005001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
+#if 3006000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
 #error This file was generated by an older version of protoc which is
 #error incompatible with your Protocol Buffer headers.  Please
 #error regenerate this file with a newer version of protoc.

+ 2 - 2
src/google/protobuf/duration.pb.h

@@ -8,12 +8,12 @@
 
 #include <google/protobuf/stubs/common.h>
 
-#if GOOGLE_PROTOBUF_VERSION < 3005000
+#if GOOGLE_PROTOBUF_VERSION < 3006000
 #error This file was generated by a newer version of protoc which is
 #error incompatible with your Protocol Buffer headers.  Please update
 #error your headers.
 #endif
-#if 3005001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
+#if 3006000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
 #error This file was generated by an older version of protoc which is
 #error incompatible with your Protocol Buffer headers.  Please
 #error regenerate this file with a newer version of protoc.

+ 2 - 2
src/google/protobuf/empty.pb.h

@@ -8,12 +8,12 @@
 
 #include <google/protobuf/stubs/common.h>
 
-#if GOOGLE_PROTOBUF_VERSION < 3005000
+#if GOOGLE_PROTOBUF_VERSION < 3006000
 #error This file was generated by a newer version of protoc which is
 #error incompatible with your Protocol Buffer headers.  Please update
 #error your headers.
 #endif
-#if 3005001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
+#if 3006000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
 #error This file was generated by an older version of protoc which is
 #error incompatible with your Protocol Buffer headers.  Please
 #error regenerate this file with a newer version of protoc.

+ 2 - 2
src/google/protobuf/field_mask.pb.h

@@ -8,12 +8,12 @@
 
 #include <google/protobuf/stubs/common.h>
 
-#if GOOGLE_PROTOBUF_VERSION < 3005000
+#if GOOGLE_PROTOBUF_VERSION < 3006000
 #error This file was generated by a newer version of protoc which is
 #error incompatible with your Protocol Buffer headers.  Please update
 #error your headers.
 #endif
-#if 3005001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
+#if 3006000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
 #error This file was generated by an older version of protoc which is
 #error incompatible with your Protocol Buffer headers.  Please
 #error regenerate this file with a newer version of protoc.

+ 9 - 0
src/google/protobuf/generated_message_util.h

@@ -335,7 +335,16 @@ struct LIBPROTOBUF_EXPORT SCCInfoBase {
     kRunning = 1,
     kUninitialized = -1,  // initial state
   };
+#ifndef _MSC_VER
   std::atomic<int> visit_status;
+#else
+  // MSVC doesnt make std::atomic constant initialized. This union trick
+  // makes it so.
+  union {
+    int visit_status_to_make_linker_init;
+    std::atomic<int> visit_status;
+  };
+#endif
   int num_deps;
   void (*init_func)();
   // This is followed by an array  of num_deps

+ 2 - 2
src/google/protobuf/source_context.pb.h

@@ -8,12 +8,12 @@
 
 #include <google/protobuf/stubs/common.h>
 
-#if GOOGLE_PROTOBUF_VERSION < 3005000
+#if GOOGLE_PROTOBUF_VERSION < 3006000
 #error This file was generated by a newer version of protoc which is
 #error incompatible with your Protocol Buffer headers.  Please update
 #error your headers.
 #endif
-#if 3005001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
+#if 3006000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
 #error This file was generated by an older version of protoc which is
 #error incompatible with your Protocol Buffer headers.  Please
 #error regenerate this file with a newer version of protoc.

+ 2 - 2
src/google/protobuf/struct.pb.h

@@ -8,12 +8,12 @@
 
 #include <google/protobuf/stubs/common.h>
 
-#if GOOGLE_PROTOBUF_VERSION < 3005000
+#if GOOGLE_PROTOBUF_VERSION < 3006000
 #error This file was generated by a newer version of protoc which is
 #error incompatible with your Protocol Buffer headers.  Please update
 #error your headers.
 #endif
-#if 3005001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
+#if 3006000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
 #error This file was generated by an older version of protoc which is
 #error incompatible with your Protocol Buffer headers.  Please
 #error regenerate this file with a newer version of protoc.

+ 5 - 5
src/google/protobuf/stubs/common.h

@@ -101,27 +101,27 @@ namespace internal {
 
 // The current version, represented as a single integer to make comparison
 // easier:  major * 10^6 + minor * 10^3 + micro
-#define GOOGLE_PROTOBUF_VERSION 3005001
+#define GOOGLE_PROTOBUF_VERSION 3006000
 
 // A suffix string for alpha, beta or rc releases. Empty for stable releases.
 #define GOOGLE_PROTOBUF_VERSION_SUFFIX ""
 
 // The minimum library version which works with the current version of the
 // headers.
-#define GOOGLE_PROTOBUF_MIN_LIBRARY_VERSION 3005000
+#define GOOGLE_PROTOBUF_MIN_LIBRARY_VERSION 3006000
 
 // The minimum header version which works with the current version of
 // the library.  This constant should only be used by protoc's C++ code
 // generator.
-static const int kMinHeaderVersionForLibrary = 3005000;
+static const int kMinHeaderVersionForLibrary = 3006000;
 
 // The minimum protoc version which works with the current version of the
 // headers.
-#define GOOGLE_PROTOBUF_MIN_PROTOC_VERSION 3005000
+#define GOOGLE_PROTOBUF_MIN_PROTOC_VERSION 3006000
 
 // The minimum header version which works with the current version of
 // protoc.  This constant should only be used in VerifyVersion().
-static const int kMinHeaderVersionForProtoc = 3005000;
+static const int kMinHeaderVersionForProtoc = 3006000;
 
 // Verifies that the headers and libraries are compatible.  Use the macro
 // below to call this.

+ 2 - 2
src/google/protobuf/timestamp.pb.h

@@ -8,12 +8,12 @@
 
 #include <google/protobuf/stubs/common.h>
 
-#if GOOGLE_PROTOBUF_VERSION < 3005000
+#if GOOGLE_PROTOBUF_VERSION < 3006000
 #error This file was generated by a newer version of protoc which is
 #error incompatible with your Protocol Buffer headers.  Please update
 #error your headers.
 #endif
-#if 3005001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
+#if 3006000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
 #error This file was generated by an older version of protoc which is
 #error incompatible with your Protocol Buffer headers.  Please
 #error regenerate this file with a newer version of protoc.

+ 2 - 2
src/google/protobuf/type.pb.h

@@ -8,12 +8,12 @@
 
 #include <google/protobuf/stubs/common.h>
 
-#if GOOGLE_PROTOBUF_VERSION < 3005000
+#if GOOGLE_PROTOBUF_VERSION < 3006000
 #error This file was generated by a newer version of protoc which is
 #error incompatible with your Protocol Buffer headers.  Please update
 #error your headers.
 #endif
-#if 3005001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
+#if 3006000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
 #error This file was generated by an older version of protoc which is
 #error incompatible with your Protocol Buffer headers.  Please
 #error regenerate this file with a newer version of protoc.

+ 2 - 2
src/google/protobuf/wrappers.pb.h

@@ -8,12 +8,12 @@
 
 #include <google/protobuf/stubs/common.h>
 
-#if GOOGLE_PROTOBUF_VERSION < 3005000
+#if GOOGLE_PROTOBUF_VERSION < 3006000
 #error This file was generated by a newer version of protoc which is
 #error incompatible with your Protocol Buffer headers.  Please update
 #error your headers.
 #endif
-#if 3005001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
+#if 3006000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
 #error This file was generated by an older version of protoc which is
 #error incompatible with your Protocol Buffer headers.  Please
 #error regenerate this file with a newer version of protoc.