Merge master@5406228 into git_qt-dev-plus-aosp.
am: f741650224

Change-Id: I407f4f7fa1c5deeb657cc1da8529e9ebd47ffa72
diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml
new file mode 100644
index 0000000..cea328d
--- /dev/null
+++ b/.bazelci/presubmit.yml
@@ -0,0 +1,23 @@
+---
+buildifier: true
+platforms:
+  ubuntu1404:
+    build_targets:
+    - "..."
+    test_targets:
+    - "..."
+  ubuntu1604:
+    build_targets:
+    - "..."
+    test_targets:
+    - "..."
+  macos:
+    build_targets:
+    - "..."
+    test_targets:
+    - "..."
+  windows:
+    build_targets:
+    - "..."
+    test_targets:
+    - "..."
diff --git a/.travis.yml b/.travis.yml
index b6ab995..04616f7 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -89,11 +89,12 @@
       - if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo ln -s -v -f $(which gcc-$GCC_VERSION) /usr/bin/gcc; fi
 
       script:
+      - bash .travis/check-sources.sh
       - bash grpc/build_grpc.sh
-      - cmake . 
-        -DCMAKE_BUILD_TYPE=$BUILD_TYPE 
-        -DFLATBUFFERS_BUILD_GRPCTEST=ON 
-        -DGRPC_INSTALL_PATH=$TRAVIS_BUILD_DIR/google/grpc/install 
+      - cmake .
+        -DCMAKE_BUILD_TYPE=$BUILD_TYPE
+        -DFLATBUFFERS_BUILD_GRPCTEST=ON
+        -DGRPC_INSTALL_PATH=$TRAVIS_BUILD_DIR/google/grpc/install
         -DPROTOBUF_DOWNLOAD_PATH=$TRAVIS_BUILD_DIR/google/grpc/third_party/protobuf
         -DFLATBUFFERS_CODE_SANITIZE=ON
       - cmake --build . -- -j${JOBS}
@@ -108,13 +109,13 @@
         matrix:
           - BUILD_TYPE=Debug
           - BUILD_TYPE=Release
-      
+
       script:
       - bash grpc/build_grpc.sh
       - cmake .
-        -DCMAKE_BUILD_TYPE=$BUILD_TYPE 
-        -DFLATBUFFERS_BUILD_GRPCTEST=ON 
-        -DGRPC_INSTALL_PATH=$TRAVIS_BUILD_DIR/google/grpc/install 
+        -DCMAKE_BUILD_TYPE=$BUILD_TYPE
+        -DFLATBUFFERS_BUILD_GRPCTEST=ON
+        -DGRPC_INSTALL_PATH=$TRAVIS_BUILD_DIR/google/grpc/install
         -DPROTOBUF_DOWNLOAD_PATH=$TRAVIS_BUILD_DIR/google/grpc/third_party/protobuf
         -DFLATBUFFERS_CODE_SANITIZE=ON
       - cmake --build . -- -j${JOBS}
@@ -168,6 +169,8 @@
         - gcc
 
       before_install:
+        # Output something every 10 minutes or Travis kills the job
+        - while sleep 540; do echo "=====[ $SECONDS seconds still running ]====="; done &
         - git clone https://github.com/urho3d/android-ndk.git $HOME/android-ndk-root
         - export ANDROID_NDK_HOME=$HOME/android-ndk-root
         # Setup environment for Linux build which is required to build the sample.
@@ -179,3 +182,5 @@
         - if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo ln -s -v -f $(which gcc-$GCC_VERSION) /usr/bin/gcc; fi
       script:
         - failed=0; for build_gradle in $(git ls-files | grep build.gradle); do ( cd "$(dirname "${build_gradle}")" && ./gradlew build ) || failed=1; done; exit $((failed))
+        # Kill the sleep loop
+        - kill %1
diff --git a/.travis/check-sources.sh b/.travis/check-sources.sh
new file mode 100644
index 0000000..3e6dbf1
--- /dev/null
+++ b/.travis/check-sources.sh
@@ -0,0 +1,33 @@
+#!/bin/bash
+#
+# Copyright 2018 Google Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+set -e
+
+if [ -n "$1" ]; then
+  scan_dir="$1"
+else
+  scan_dir="$( pwd )"
+fi
+
+py_checker="$0.py"
+
+echo "scan root directory = '$scan_dir'"
+python3 --version
+# Scan recursively and search all *.cpp and *.h files using regex patterns.
+# Assume that script running from a root of Flatbuffers working dir.
+python3 $py_checker "ascii" "$scan_dir/include" "\.h$"
+python3 $py_checker "ascii" "$scan_dir/src"     "\.cpp$"
+python3 $py_checker "ascii" "$scan_dir/tests"   "\.h$"
+python3 $py_checker "utf-8" "$scan_dir/tests"   "\.cpp$"
diff --git a/.travis/check-sources.sh.py b/.travis/check-sources.sh.py
new file mode 100644
index 0000000..5ad060c
--- /dev/null
+++ b/.travis/check-sources.sh.py
@@ -0,0 +1,36 @@
+import os
+import re
+import sys
+
+def check_encoding(encoding, scan_dir, regex_pattern):
+  fname = None
+  try:
+    assert encoding in ['ascii', 'utf-8'], "unexpected encoding"
+    cmp = re.compile(regex_pattern)
+    for root, dirs, files in os.walk(scan_dir):
+      fname = root
+      cmp_list = [f for f in files if cmp.search(f) is not None]
+      for f in cmp_list:
+        fname = os.path.join(root, f)
+        with open(fname, mode='rb') as test_file:
+          btext = test_file.read()
+        # check encoding
+        btext.decode(encoding=encoding, errors="strict")
+        if encoding == "utf-8" and btext.startswith(b'\xEF\xBB\xBF'):
+          raise ValueError("unexpected BOM in file")
+        # check strict CRLF line-ending
+        LF = btext.count(b'\r')
+        CRLF = btext.count(b'\r\n')
+        assert LF >= CRLF, "CRLF logic error"
+        if CRLF != LF:
+          raise ValueError("CRLF violation: found {} LF characters".format(LF - CRLF))
+  except Exception as err:
+    print("ERROR with [{}]: {}".format(fname, err))
+    return -1
+  else:
+    return 0
+
+if __name__ == "__main__":
+  # python check-sources.sh.py 'ascii' '.' '.*\.(cpp|h)$'
+  res = check_encoding(sys.argv[1], sys.argv[2], sys.argv[3])
+  sys.exit(0 if res == 0 else -1)
diff --git a/BUILD b/BUILD
index 105f72f..be30227 100644
--- a/BUILD
+++ b/BUILD
@@ -133,7 +133,6 @@
         "src/idl_parser.cpp",
         "src/reflection.cpp",
         "src/util.cpp",
-        "monster_test_generated.h",
         "tests/namespace_test/namespace_test1_generated.h",
         "tests/namespace_test/namespace_test2_generated.h",
         "tests/test.cpp",
@@ -162,6 +161,10 @@
         ":tests/union_vector/union_vector.fbs",
     ],
     includes = ["include/"],
+    deps = [
+        ":monster_extra_cc_fbs",
+        ":monster_test_cc_fbs",
+    ],
 )
 
 # Test bzl rules
@@ -175,3 +178,8 @@
         "tests/include_test/sub/include_test2.fbs",
     ],
 )
+
+flatbuffer_cc_library(
+    name = "monster_extra_cc_fbs",
+    srcs = ["tests/monster_extra.fbs"],
+)
diff --git a/CMake/DESCRIPTION.txt b/CMake/DESCRIPTION.txt
new file mode 100644
index 0000000..3698b03
--- /dev/null
+++ b/CMake/DESCRIPTION.txt
@@ -0,0 +1,4 @@
+FlatBuffers is a cross platform serialization library architected for
+maximum memory efficiency. It allows you to directly access serialized
+data without parsing/unpacking it first, while still having great 
+forwards/backwards compatibility.
diff --git a/CMake/PackageDebian.cmake b/CMake/PackageDebian.cmake
index 6653181..f587ff7 100644
--- a/CMake/PackageDebian.cmake
+++ b/CMake/PackageDebian.cmake
@@ -37,5 +37,3 @@
         "${CPACK_DEBIAN_PACKAGE_NAME}_${CPACK_DEBIAN_PACKAGE_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")
 
 endif(UNIX)
-
-INCLUDE(CPack)
diff --git a/CMake/PackageRedhat.cmake b/CMake/PackageRedhat.cmake
new file mode 100644
index 0000000..4545e72
--- /dev/null
+++ b/CMake/PackageRedhat.cmake
@@ -0,0 +1,34 @@
+if (UNIX)
+    set(CPACK_GENERATOR "RPM")
+    set(CPACK_SOURCE_TGZ "ON")
+
+    set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "FlatBuffers serialization library and schema compiler.")
+    
+    set(CPACK_RPM_PACKAGE_HOMEPAGE "https://github.com/google/flatbuffers")
+    set(CPACK_RPM_PACKAGE_MAINTAINER "Marc Butler <mockbutler@gmail.com>")
+
+    set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})
+    set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR})
+    set(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH})
+    set(CPACK_PACKAGE_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-${VERSION_COMMIT}")
+    set(CPACK_RPM_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION}")
+
+    set(CPACK_RPM_PACKAGE_NAME "flatbuffers")
+
+    # Assume this is not a cross complation build.
+    if(NOT CPACK_RPM_PACKAGE_ARCHITECTURE)
+        set(CPACK_RPM_PACKAGE_ARCHITECTURE "${CMAKE_SYSTEM_PROCESSOR}")
+    endif(NOT CPACK_RPM_PACKAGE_ARCHITECTURE)
+
+    set(CPACK_RPM_PACKAGE_VENDOR "Google, Inc.")
+    set(CPACK_RPM_PACKAGE_LICENSE "Apache 2.0")
+    set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/LICENSE.txt)
+    set(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_SOURCE_DIR}/CMake/DESCRIPTION.txt)
+
+    # This may reduce rpm compatiblity with very old systems.
+    set(CPACK_RPM_COMPRESSION_TYPE lzma)
+    
+    set(CPACK_RPM_PACKAGE_NAME "flatbuffers")
+    set(CPACK_PACKAGE_FILE_NAME
+        "${CPACK_RPM_PACKAGE_NAME}_${CPACK_RPM_PACKAGE_VERSION}_${CPACK_RPM_PACKAGE_ARCHITECTURE}")
+endif(UNIX)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f4e563a..9f640ac 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -23,6 +23,12 @@
 option(FLATBUFFERS_CODE_SANITIZE
       "Add '-fsanitize' flags to 'flattests' and 'flatc' targets."
       OFF)
+option(FLATBUFFERS_PACKAGE_REDHAT
+       "Build an rpm using the 'package' target."
+       OFF)
+option(FLATBUFFERS_PACKAGE_DEBIAN
+       "Build an deb using the 'package' target."
+       OFF)
 
 if(NOT FLATBUFFERS_BUILD_FLATC AND FLATBUFFERS_BUILD_TESTS)
     message(WARNING
@@ -152,6 +158,7 @@
 if(EXISTS "${CMAKE_TOOLCHAIN_FILE}")
   # do not apply any global settings if the toolchain
   # is being configured externally
+  message(STATUS "Using toolchain file: ${CMAKE_TOOLCHAIN_FILE}.")
 elseif(APPLE)
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++")
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -Werror -Wextra -Wno-unused-parameter")
@@ -185,6 +192,9 @@
   set(CMAKE_CXX_FLAGS
       "${CMAKE_CXX_FLAGS} -std=c++0x -Wall -pedantic -Werror -Wextra -Wno-unused-parameter")
   set(FLATBUFFERS_PRIVATE_CXX_FLAGS "-Wold-style-cast")
+  if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.8)
+    list(APPEND FLATBUFFERS_PRIVATE_CXX_FLAGS "-Wimplicit-fallthrough" "-Wextra-semi" "-Wc++98-compat-extra-semi" "-Werror=unused-private-field") # enable warning
+  endif()
   if(FLATBUFFERS_LIBCXX_WITH_CLANG)
     if(NOT "${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
       set(CMAKE_CXX_FLAGS
@@ -255,7 +265,7 @@
 if(FLATBUFFERS_BUILD_FLATC)
   add_executable(flatc ${FlatBuffers_Compiler_SRCS})
   target_compile_options(flatc PRIVATE "${FLATBUFFERS_PRIVATE_CXX_FLAGS}")
-  if(FLATBUFFERS_CODE_SANITIZE)
+  if(FLATBUFFERS_CODE_SANITIZE AND NOT WIN32)
     add_fsanitize_to_target(flatc ${FLATBUFFERS_CODE_SANITIZE})
   endif()
   if(NOT FLATBUFFERS_FLATC_EXECUTABLE)
@@ -313,12 +323,17 @@
   compile_flatbuffers_schema_to_cpp(tests/monster_test.fbs)
   include_directories(${CMAKE_CURRENT_BINARY_DIR}/tests)
   add_executable(flattests ${FlatBuffers_Tests_SRCS})
-  if(FLATBUFFERS_CODE_SANITIZE)
-    add_fsanitize_to_target(flattests ${FLATBUFFERS_CODE_SANITIZE})
-  endif()
   set_property(TARGET flattests
     PROPERTY COMPILE_DEFINITIONS FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE
     FLATBUFFERS_DEBUG_VERIFICATION_FAILURE=1)
+  if(FLATBUFFERS_CODE_SANITIZE)
+    if(WIN32)
+      target_compile_definitions(flattests PRIVATE FLATBUFFERS_MEMORY_LEAK_TRACKING)
+      message(STATUS "Sanitizer MSVC::_CrtDumpMemoryLeaks added to flattests")
+    else()
+      add_fsanitize_to_target(flattests ${FLATBUFFERS_CODE_SANITIZE})
+    endif()
+  endif()
 
   compile_flatbuffers_schema_to_cpp(samples/monster.fbs)
   include_directories(${CMAKE_CURRENT_BINARY_DIR}/samples)
@@ -384,7 +399,6 @@
     install(
       TARGETS flatc EXPORT FlatcTargets
       RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
-      CONFIGURATIONS Release
     )
 
     install(
@@ -392,7 +406,6 @@
       FILE FlatcTargets.cmake
       NAMESPACE flatbuffers::
       DESTINATION ${FB_CMAKE_DIR}
-      CONFIGURATIONS Release
     )
   endif()
 
@@ -436,6 +449,13 @@
 
 include(CMake/BuildFlatBuffers.cmake)
 
-if(FLATBUFFERS_PACKAGE_DEBIAN)
-    include(CMake/PackageDebian.cmake)
+if(UNIX)
+    # Use of CPack only supported on Linux systems.
+    if(FLATBUFFERS_PACKAGE_DEBIAN)
+        include(CMake/PackageDebian.cmake)
+    endif()
+    if (FLATBUFFERS_PACKAGE_REDHAT)
+        include(CMake/PackageRedhat.cmake)
+    endif()
+    include(CPack)
 endif()
diff --git a/METADATA b/METADATA
index 50d8642..abb1bc0 100644
--- a/METADATA
+++ b/METADATA
@@ -9,10 +9,10 @@
     type: GIT
     value: "https://github.com/google/flatbuffers.git"
   }
-  version: "63d51afd1196336a7d1f56a988091ef05deb1c62"
+  version: "1c7d91cc55a9deb05e7ea93ba10b5ab511d29238"
   last_upgrade_date {
     year: 2019
-    month: 1
-    day: 28
+    month: 3
+    day: 4
   }
 }
diff --git a/WORKSPACE b/WORKSPACE
index 148797e..be4a402 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -1,11 +1,15 @@
 workspace(name = "com_github_google_flatbuffers")
 
 load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
+
 http_archive(
     name = "io_bazel_rules_go",
-    urls = ["https://github.com/bazelbuild/rules_go/releases/download/0.13.0/rules_go-0.13.0.tar.gz"],
-    sha256 = "ba79c532ac400cefd1859cbc8a9829346aa69e3b99482cd5a54432092cbc3933",
+    sha256 = "492c3ac68ed9dcf527a07e6a1b2dcbf199c6bf8b35517951467ac32e421c06c1",
+    urls = ["https://github.com/bazelbuild/rules_go/releases/download/0.17.0/rules_go-0.17.0.tar.gz"],
 )
-load("@io_bazel_rules_go//go:def.bzl", "go_rules_dependencies", "go_register_toolchains")
+
+load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
+
 go_rules_dependencies()
+
 go_register_toolchains()
diff --git a/appveyor.yml b/appveyor.yml
index 2cd22e9..75a63c8 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -31,7 +31,7 @@
 
 before_build:
   - set MONSTER_EXTRA=%MONSTER_EXTRA%
-  - cmake -G"Visual Studio %CMAKE_VS_VERSION%"
+  - cmake -G"Visual Studio %CMAKE_VS_VERSION%" -DFLATBUFFERS_CODE_SANITIZE=1 .
   # This cuts down on a lot of noise generated by xamarin warnings.
   - del "C:\Program Files (x86)\MSBuild\14.0\Microsoft.Common.targets\ImportAfter\Xamarin.Common.targets"
 
@@ -92,6 +92,9 @@
   - "cd FlatBuffers.Test"
   - "msbuild.exe /property:Configuration=Release;OutputPath=tempcs /verbosity:minimal FlatBuffers.Test.csproj"
   - "tempcs\\FlatBuffers.Test.exe"
+  # Run tests with UNSAFE_BYTEBUFFER
+  - "msbuild.exe /property:Configuration=Release;UnsafeByteBuffer=true;OutputPath=tempcsUnsafe /verbosity:minimal FlatBuffers.Test.csproj"
+  - "tempcsUnsafe\\FlatBuffers.Test.exe"
   # TODO: add more languages.
   - "cd ..\\.."
 
diff --git a/dart/test/monster_test_my_game.example_generated.dart b/dart/test/monster_test_my_game.example_generated.dart
index d243b2d..49e2ec1 100644
--- a/dart/test/monster_test_my_game.example_generated.dart
+++ b/dart/test/monster_test_my_game.example_generated.dart
@@ -90,6 +90,88 @@
       new AnyTypeId.fromValue(const fb.Uint8Reader().read(bc, offset));
 }
 
+class AnyUniqueAliasesTypeId {
+  final int value;
+  const AnyUniqueAliasesTypeId._(this.value);
+
+  factory AnyUniqueAliasesTypeId.fromValue(int value) {
+    if (value == null) value = 0;
+    if (!values.containsKey(value)) {
+      throw new StateError('Invalid value $value for bit flag enum AnyUniqueAliasesTypeId');
+    }
+    return values[value];
+  }
+
+  static const int minValue = 0;
+  static const int maxValue = 3;
+  static bool containsValue(int value) => values.containsKey(value);
+
+  static const AnyUniqueAliasesTypeId NONE = const AnyUniqueAliasesTypeId._(0);
+  static const AnyUniqueAliasesTypeId M = const AnyUniqueAliasesTypeId._(1);
+  static const AnyUniqueAliasesTypeId T = const AnyUniqueAliasesTypeId._(2);
+  static const AnyUniqueAliasesTypeId M2 = const AnyUniqueAliasesTypeId._(3);
+  static get values => {0: NONE,1: M,2: T,3: M2,};
+
+  static const fb.Reader<AnyUniqueAliasesTypeId> reader = const _AnyUniqueAliasesTypeIdReader();
+
+  @override
+  String toString() {
+    return 'AnyUniqueAliasesTypeId{value: $value}';
+  }
+}
+
+class _AnyUniqueAliasesTypeIdReader extends fb.Reader<AnyUniqueAliasesTypeId> {
+  const _AnyUniqueAliasesTypeIdReader();
+
+  @override
+  int get size => 1;
+
+  @override
+  AnyUniqueAliasesTypeId read(fb.BufferContext bc, int offset) =>
+      new AnyUniqueAliasesTypeId.fromValue(const fb.Uint8Reader().read(bc, offset));
+}
+
+class AnyAmbiguousAliasesTypeId {
+  final int value;
+  const AnyAmbiguousAliasesTypeId._(this.value);
+
+  factory AnyAmbiguousAliasesTypeId.fromValue(int value) {
+    if (value == null) value = 0;
+    if (!values.containsKey(value)) {
+      throw new StateError('Invalid value $value for bit flag enum AnyAmbiguousAliasesTypeId');
+    }
+    return values[value];
+  }
+
+  static const int minValue = 0;
+  static const int maxValue = 3;
+  static bool containsValue(int value) => values.containsKey(value);
+
+  static const AnyAmbiguousAliasesTypeId NONE = const AnyAmbiguousAliasesTypeId._(0);
+  static const AnyAmbiguousAliasesTypeId M1 = const AnyAmbiguousAliasesTypeId._(1);
+  static const AnyAmbiguousAliasesTypeId M2 = const AnyAmbiguousAliasesTypeId._(2);
+  static const AnyAmbiguousAliasesTypeId M3 = const AnyAmbiguousAliasesTypeId._(3);
+  static get values => {0: NONE,1: M1,2: M2,3: M3,};
+
+  static const fb.Reader<AnyAmbiguousAliasesTypeId> reader = const _AnyAmbiguousAliasesTypeIdReader();
+
+  @override
+  String toString() {
+    return 'AnyAmbiguousAliasesTypeId{value: $value}';
+  }
+}
+
+class _AnyAmbiguousAliasesTypeIdReader extends fb.Reader<AnyAmbiguousAliasesTypeId> {
+  const _AnyAmbiguousAliasesTypeIdReader();
+
+  @override
+  int get size => 1;
+
+  @override
+  AnyAmbiguousAliasesTypeId read(fb.BufferContext bc, int offset) =>
+      new AnyAmbiguousAliasesTypeId.fromValue(const fb.Uint8Reader().read(bc, offset));
+}
+
 class Test {
   Test._(this._bc, this._bcOffset);
 
@@ -654,10 +736,29 @@
   List<int> get vectorOfCoOwningReferences => const fb.ListReader<int>(const fb.Uint64Reader()).vTableGet(_bc, _bcOffset, 84, null);
   int get nonOwningReference => const fb.Uint64Reader().vTableGet(_bc, _bcOffset, 86, 0);
   List<int> get vectorOfNonOwningReferences => const fb.ListReader<int>(const fb.Uint64Reader()).vTableGet(_bc, _bcOffset, 88, null);
+  AnyUniqueAliasesTypeId get anyUniqueType => new AnyUniqueAliasesTypeId.fromValue(const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 90, 0));
+  dynamic get anyUnique {
+    switch (anyUniqueType?.value) {
+      case 1: return M.reader.vTableGet(_bc, _bcOffset, 92, null);
+      case 2: return T.reader.vTableGet(_bc, _bcOffset, 92, null);
+      case 3: return M2.reader.vTableGet(_bc, _bcOffset, 92, null);
+      default: return null;
+    }
+  }
+  AnyAmbiguousAliasesTypeId get anyAmbiguousType => new AnyAmbiguousAliasesTypeId.fromValue(const fb.Uint8Reader().vTableGet(_bc, _bcOffset, 94, 0));
+  dynamic get anyAmbiguous {
+    switch (anyAmbiguousType?.value) {
+      case 1: return M1.reader.vTableGet(_bc, _bcOffset, 96, null);
+      case 2: return M2.reader.vTableGet(_bc, _bcOffset, 96, null);
+      case 3: return M3.reader.vTableGet(_bc, _bcOffset, 96, null);
+      default: return null;
+    }
+  }
+  List<Color> get vectorOfEnums => const fb.ListReader<Color>(Color.reader).vTableGet(_bc, _bcOffset, 98, null);
 
   @override
   String toString() {
-    return 'Monster{pos: $pos, mana: $mana, hp: $hp, name: $name, inventory: $inventory, color: $color, testType: $testType, test: $test, test4: $test4, testarrayofstring: $testarrayofstring, testarrayoftables: $testarrayoftables, enemy: $enemy, testnestedflatbuffer: $testnestedflatbuffer, testempty: $testempty, testbool: $testbool, testhashs32Fnv1: $testhashs32Fnv1, testhashu32Fnv1: $testhashu32Fnv1, testhashs64Fnv1: $testhashs64Fnv1, testhashu64Fnv1: $testhashu64Fnv1, testhashs32Fnv1a: $testhashs32Fnv1a, testhashu32Fnv1a: $testhashu32Fnv1a, testhashs64Fnv1a: $testhashs64Fnv1a, testhashu64Fnv1a: $testhashu64Fnv1a, testarrayofbools: $testarrayofbools, testf: $testf, testf2: $testf2, testf3: $testf3, testarrayofstring2: $testarrayofstring2, testarrayofsortedstruct: $testarrayofsortedstruct, flex: $flex, test5: $test5, vectorOfLongs: $vectorOfLongs, vectorOfDoubles: $vectorOfDoubles, parentNamespaceTest: $parentNamespaceTest, vectorOfReferrables: $vectorOfReferrables, singleWeakReference: $singleWeakReference, vectorOfWeakReferences: $vectorOfWeakReferences, vectorOfStrongReferrables: $vectorOfStrongReferrables, coOwningReference: $coOwningReference, vectorOfCoOwningReferences: $vectorOfCoOwningReferences, nonOwningReference: $nonOwningReference, vectorOfNonOwningReferences: $vectorOfNonOwningReferences}';
+    return 'Monster{pos: $pos, mana: $mana, hp: $hp, name: $name, inventory: $inventory, color: $color, testType: $testType, test: $test, test4: $test4, testarrayofstring: $testarrayofstring, testarrayoftables: $testarrayoftables, enemy: $enemy, testnestedflatbuffer: $testnestedflatbuffer, testempty: $testempty, testbool: $testbool, testhashs32Fnv1: $testhashs32Fnv1, testhashu32Fnv1: $testhashu32Fnv1, testhashs64Fnv1: $testhashs64Fnv1, testhashu64Fnv1: $testhashu64Fnv1, testhashs32Fnv1a: $testhashs32Fnv1a, testhashu32Fnv1a: $testhashu32Fnv1a, testhashs64Fnv1a: $testhashs64Fnv1a, testhashu64Fnv1a: $testhashu64Fnv1a, testarrayofbools: $testarrayofbools, testf: $testf, testf2: $testf2, testf3: $testf3, testarrayofstring2: $testarrayofstring2, testarrayofsortedstruct: $testarrayofsortedstruct, flex: $flex, test5: $test5, vectorOfLongs: $vectorOfLongs, vectorOfDoubles: $vectorOfDoubles, parentNamespaceTest: $parentNamespaceTest, vectorOfReferrables: $vectorOfReferrables, singleWeakReference: $singleWeakReference, vectorOfWeakReferences: $vectorOfWeakReferences, vectorOfStrongReferrables: $vectorOfStrongReferrables, coOwningReference: $coOwningReference, vectorOfCoOwningReferences: $vectorOfCoOwningReferences, nonOwningReference: $nonOwningReference, vectorOfNonOwningReferences: $vectorOfNonOwningReferences, anyUniqueType: $anyUniqueType, anyUnique: $anyUnique, anyAmbiguousType: $anyAmbiguousType, anyAmbiguous: $anyAmbiguous, vectorOfEnums: $vectorOfEnums}';
   }
 }
 
@@ -848,6 +949,26 @@
     fbBuilder.addOffset(42, offset);
     return fbBuilder.offset;
   }
+  int addAnyUniqueType(AnyUniqueAliasesTypeId anyUniqueType) {
+    fbBuilder.addUint8(43, anyUniqueType?.value);
+    return fbBuilder.offset;
+  }
+  int addAnyUniqueOffset(int offset) {
+    fbBuilder.addOffset(44, offset);
+    return fbBuilder.offset;
+  }
+  int addAnyAmbiguousType(AnyAmbiguousAliasesTypeId anyAmbiguousType) {
+    fbBuilder.addUint8(45, anyAmbiguousType?.value);
+    return fbBuilder.offset;
+  }
+  int addAnyAmbiguousOffset(int offset) {
+    fbBuilder.addOffset(46, offset);
+    return fbBuilder.offset;
+  }
+  int addVectorOfEnumsOffset(int offset) {
+    fbBuilder.addOffset(47, offset);
+    return fbBuilder.offset;
+  }
 
   int finish() {
     return fbBuilder.endTable();
@@ -897,6 +1018,11 @@
   final List<int> _vectorOfCoOwningReferences;
   final int _nonOwningReference;
   final List<int> _vectorOfNonOwningReferences;
+  final AnyUniqueAliasesTypeId _anyUniqueType;
+  final dynamic _anyUnique;
+  final AnyAmbiguousAliasesTypeId _anyAmbiguousType;
+  final dynamic _anyAmbiguous;
+  final List<Color> _vectorOfEnums;
 
   MonsterObjectBuilder({
     Vec3ObjectBuilder pos,
@@ -941,6 +1067,11 @@
     List<int> vectorOfCoOwningReferences,
     int nonOwningReference,
     List<int> vectorOfNonOwningReferences,
+    AnyUniqueAliasesTypeId anyUniqueType,
+    dynamic anyUnique,
+    AnyAmbiguousAliasesTypeId anyAmbiguousType,
+    dynamic anyAmbiguous,
+    List<Color> vectorOfEnums,
   })
       : _pos = pos,
         _mana = mana,
@@ -983,7 +1114,12 @@
         _coOwningReference = coOwningReference,
         _vectorOfCoOwningReferences = vectorOfCoOwningReferences,
         _nonOwningReference = nonOwningReference,
-        _vectorOfNonOwningReferences = vectorOfNonOwningReferences;
+        _vectorOfNonOwningReferences = vectorOfNonOwningReferences,
+        _anyUniqueType = anyUniqueType,
+        _anyUnique = anyUnique,
+        _anyAmbiguousType = anyAmbiguousType,
+        _anyAmbiguous = anyAmbiguous,
+        _vectorOfEnums = vectorOfEnums;
 
   /// Finish building, and store into the [fbBuilder].
   @override
@@ -1046,6 +1182,11 @@
     final int vectorOfNonOwningReferencesOffset = _vectorOfNonOwningReferences?.isNotEmpty == true
         ? fbBuilder.writeListUint64(_vectorOfNonOwningReferences)
         : null;
+    final int anyUniqueOffset = _anyUnique?.getOrCreateOffset(fbBuilder);
+    final int anyAmbiguousOffset = _anyAmbiguous?.getOrCreateOffset(fbBuilder);
+    final int vectorOfEnumsOffset = _vectorOfEnums?.isNotEmpty == true
+        ? fbBuilder.writeListInt8(_vectorOfEnums.map((f) => f.value))
+        : null;
 
     fbBuilder.startTable();
     if (_pos != null) {
@@ -1136,6 +1277,17 @@
     if (vectorOfNonOwningReferencesOffset != null) {
       fbBuilder.addOffset(42, vectorOfNonOwningReferencesOffset);
     }
+    fbBuilder.addUint8(43, _anyUniqueType?.value);
+    if (anyUniqueOffset != null) {
+      fbBuilder.addOffset(44, anyUniqueOffset);
+    }
+    fbBuilder.addUint8(45, _anyAmbiguousType?.value);
+    if (anyAmbiguousOffset != null) {
+      fbBuilder.addOffset(46, anyAmbiguousOffset);
+    }
+    if (vectorOfEnumsOffset != null) {
+      fbBuilder.addOffset(47, vectorOfEnumsOffset);
+    }
     return fbBuilder.endTable();
   }
 
diff --git a/docs/source/Compiler.md b/docs/source/Compiler.md
index 420019c..d7b44c8 100644
--- a/docs/source/Compiler.md
+++ b/docs/source/Compiler.md
@@ -72,6 +72,12 @@
     in quotes, no trailing commas in tables/vectors). By default, no quotes are
     required/generated, and trailing commas are allowed.
 
+-   `--allow-non-utf8` : Pass non-UTF-8 input through parser and emit nonstandard
+    \x escapes in JSON. (Default is to raise parse error on non-UTF-8 input.)
+
+-  `--natural-utf8` : Output strings with UTF-8 as human-readable strings. 
+     By default, UTF-8 characters are printed as \uXXXX escapes."
+
 -   `--defaults-json` : Output fields whose value is equal to the default value
     when writing JSON text.
 
@@ -91,23 +97,36 @@
 -   `--gen-mutable` : Generate additional non-const accessors for mutating
     FlatBuffers in-place.
 
-    `--gen-object-api` : Generate an additional object-based API. This API is
+-   `--gen-onefile` : Generate single output file for C# and Go.
+
+-   `--gen-name-strings` : Generate type name functions for C++.
+
+-   `--gen-object-api` : Generate an additional object-based API. This API is
     more convenient for object construction and mutation than the base API,
     at the cost of efficiency (object allocation). Recommended only to be used
     if other options are insufficient.
 
--   `--gen-compare` :  Generate operator== for object-based API types.
+-   `--gen-compare`  :  Generate operator== for object-based API types.
 
--   `--gen-onefile` :  Generate single output file (useful for C#)
+-   `--gen-nullable` : Add Clang _Nullable for C++ pointer. or @Nullable for Java.
 
--   `--gen-all`: Generate not just code for the current schema files, but
+-   `--gen-generated` : Add @Generated annotation for Java.
+
+-   `--gen-all` : Generate not just code for the current schema files, but
     for all files it includes as well. If the language uses a single file for
     output (by default the case for C++ and JS), all code will end up in
     this one file.
 
--   `--gen-generated`: Add @Generated annotation for Java
+-   `--cpp-ptr-type T` : Set object API pointer type (default std::unique_ptr)
 
--   `--no-js-exports` :  Removes Node.js style export lines (useful for JS)
+-   `--cpp-str-type T` : Set object API string type (default std::string)
+-   T::c_str() and T::length() must be supported.
+
+-   `--object-prefix` : Customise class prefix for C++ object-based API.
+
+-   `--object-suffix` : Customise class suffix for C++ object-based API.
+
+-   `--no-js-exports` : Removes Node.js style export lines (useful for JS)
 
 -   `--goog-js-export` :  Uses goog.exportsSymbol and goog.exportsProperty
     instead of Node.js style exporting.  Needed for compatibility with the
@@ -117,9 +136,16 @@
     instead of Node.js style exporting. Useful when integrating flatbuffers
     with modern Javascript projects.
 
+-   `--go-namespace` : Generate the overrided namespace in Golang.
+
+-   `--go-import` : Generate the overrided import for flatbuffers in Golang.
+     (default is "github.com/google/flatbuffers/go").
+
 -   `--raw-binary` : Allow binaries without a file_indentifier to be read.
     This may crash flatc given a mismatched schema.
 
+-   `--size-prefixed` : Input binaries are size prefixed buffers.
+
 -   `--proto`: Expect input files to be .proto files (protocol buffers).
     Output the corresponding .fbs file.
     Currently supports: `package`, `message`, `enum`, nested declarations,
@@ -127,6 +153,10 @@
     Does not support, but will skip without error: `option`, `service`,
     `extensions`, and most everything else.
 
+-   `--oneof-union` : Translate .proto oneofs to flatbuffer unions.
+
+-   `--grpc` : Generate GRPC interfaces for the specified languages.
+
 -   `--schema`: Serialize schemas instead of JSON (use with -b). This will
     output a binary version of the specified schema that itself corresponds
     to the reflection/reflection.fbs schema. Loading this binary file is the
@@ -138,12 +168,22 @@
     an evolution of. Gives errors if not. Useful to check if schema
     modifications don't break schema evolution rules.
 
+-   `--conform-includes PATH` : Include path for the schema given with 
+    `--conform PATH`.
+
 -   `--include-prefix PATH` : Prefix this path to any generated include
     statements.
 
 -   `--keep-prefix` : Keep original prefix of schema include statement.
 
+-   `--no-fb-impor` : Don't include flatbuffers import statement for TypeScript.
+
+-   `--no-ts-reexpor` : Don't re-export imported dependencies for TypeScript.
+
+-   `--short-name` : Use short function names for JS and TypeScript.
+
 -   `--reflect-types` : Add minimal type reflection to code generation.
+
 -   `--reflect-names` : Add minimal type/name reflection.
 
 -   `--root-type T` : Select or override the default root_type.
diff --git a/docs/source/CppUsage.md b/docs/source/CppUsage.md
index ad47a94..2808c49 100644
--- a/docs/source/CppUsage.md
+++ b/docs/source/CppUsage.md
@@ -88,6 +88,14 @@
 
 *Note: That we never stored a `mana` value, so it will return the default.*
 
+The following attributes are supported:
+
+-   `shared` (on a field): For string fields, this enables the usage of string
+    pooling (i.e. `CreateSharedString`) as default serialization behavior.
+
+    Specifically, `CreateXxxDirect` functions and `Pack` functions for object
+    based API (see below) will use `CreateSharedString` to create strings.
+
 ## Object based API.  {#flatbuffers_cpp_object_based_api}
 
 FlatBuffers is all about memory efficiency, which is why its base API is written
@@ -130,10 +138,10 @@
     verbatim in the class constructor initializer list for this member.
 
 -   `native_custom_alloc`:"custom_allocator" (on a table or struct): When using the
-    object-based API all generated NativeTables that  are allocated when unpacking 
-    your  flatbuffer will use "custom allocator". The allocator is also used by 
-    any std::vector that appears in a table defined with `native_custom_alloc`. 
-    This can be  used to provide allocation from a pool for example, for faster 
+    object-based API all generated NativeTables that  are allocated when unpacking
+    your  flatbuffer will use "custom allocator". The allocator is also used by
+    any std::vector that appears in a table defined with `native_custom_alloc`.
+    This can be  used to provide allocation from a pool for example, for faster
     unpacking when using the object-based API.
 
     Minimal Example:
@@ -151,8 +159,8 @@
       typedef T *pointer;
 
       template <class U>
-      struct rebind { 
-        typedef custom_allocator<U> other; 
+      struct rebind {
+        typedef custom_allocator<U> other;
       };
 
       pointer allocate(const std::size_t n) {
@@ -164,7 +172,7 @@
       }
 
       custom_allocator() throw() {}
-      template <class U> 
+      template <class U>
       custom_allocator(const custom_allocator<U>&) throw() {}
     };
 
@@ -208,12 +216,15 @@
 
 Finally, the following top-level attribute
 
--   native_include: "path" (at file level): Because the `native_type` attribute
+-   `native_include`: "path" (at file level): Because the `native_type` attribute
     can be used to introduce types that are unknown to flatbuffers, it may be
     necessary to include "external" header files in the generated code.  This
     attribute can be used to directly add an #include directive to the top of
     the generated code that includes the specified path directly.
 
+-   `force_align`: this attribute may not be respected in the object API,
+    depending on the aligned of the allocator used with `new`.
+
 # External references.
 
 An additional feature of the object API is the ability to allow you to load
@@ -499,43 +510,43 @@
 
 ## Depth limit of nested objects and stack-overflow control
 The parser of Flatbuffers schema or json-files is kind of recursive parser.
-To avoid stack-overflow problem the parser has a built-in limiter of 
-recursion depth. Number of nested declarations in a schema or number of 
+To avoid stack-overflow problem the parser has a built-in limiter of
+recursion depth. Number of nested declarations in a schema or number of
 nested json-objects is limited. By default, this depth limit set to `64`.
-It is possible to override this limit with `FLATBUFFERS_MAX_PARSING_DEPTH` 
-definition. This definition can be helpful for testing purposes or embedded 
-applications. For details see [build](@ref flatbuffers_guide_building) of 
+It is possible to override this limit with `FLATBUFFERS_MAX_PARSING_DEPTH`
+definition. This definition can be helpful for testing purposes or embedded
+applications. For details see [build](@ref flatbuffers_guide_building) of
 CMake-based projects.
 
 ## Dependence from C-locale {#flatbuffers_locale_cpp}
-The Flatbuffers [grammar](@ref flatbuffers grammar) uses ASCII 
+The Flatbuffers [grammar](@ref flatbuffers grammar) uses ASCII
 character set for identifiers, alphanumeric literals, reserved words.
 
-Internal implementation of the Flatbuffers depends from functions which 
+Internal implementation of the Flatbuffers depends from functions which
 depend from C-locale: `strtod()` or `strtof()`, for example.
-The library expects the dot `.` symbol as the separator of an integer 
+The library expects the dot `.` symbol as the separator of an integer
 part from the fractional part of a float number.
-Another separator symbols (`,` for example) will break the compatibility 
+Another separator symbols (`,` for example) will break the compatibility
 and may lead to an error while parsing a Flatbuffers schema or a json file.
 
-The Standard C locale is a global resource, there is only one locale for 
-the entire application. Some modern compilers and platforms have 
-locale-independent or locale-narrow functions `strtof_l`, `strtod_l`, 
-`strtoll_l`, `strtoull_l` to resolve this dependency. 
-These functions use specified locale rather than the global or per-thread 
-locale instead. They are part of POSIX-2008 but not part of the C/C++ 
+The Standard C locale is a global resource, there is only one locale for
+the entire application. Some modern compilers and platforms have
+locale-independent or locale-narrow functions `strtof_l`, `strtod_l`,
+`strtoll_l`, `strtoull_l` to resolve this dependency.
+These functions use specified locale rather than the global or per-thread
+locale instead. They are part of POSIX-2008 but not part of the C/C++
 standard library, therefore, may be missing on some platforms.
 
-The Flatbuffers library try to detect these functions at configuration and 
+The Flatbuffers library try to detect these functions at configuration and
 compile time:
 - `_MSC_VER >= 1900`: check MSVC2012 or higher for MSVC buid
 - `_XOPEN_SOURCE>=700`: check POSIX-2008 for GCC/Clang build
 - `check_cxx_symbol_exists(strtof_l stdlib.h)`: CMake check of `strtod_f`
 
-After detection, the definition `FLATBUFFERS_LOCALE_INDEPENDENT` will be 
+After detection, the definition `FLATBUFFERS_LOCALE_INDEPENDENT` will be
 set to `0` or `1`.
 
-It is possible to test the compatibility of the Flatbuffers library with 
+It is possible to test the compatibility of the Flatbuffers library with
 a specific locale using the environment variable `FLATBUFFERS_TEST_LOCALE`:
 ```sh
 >FLATBUFFERS_TEST_LOCALE="" ./flattests
diff --git a/docs/source/Schemas.md b/docs/source/Schemas.md
index 42551c6..66c800d 100644
--- a/docs/source/Schemas.md
+++ b/docs/source/Schemas.md
@@ -84,7 +84,7 @@
 
 ### Types
 
-Built-in scalar types are 
+Built-in scalar types are
 
 -   8 bit: `byte` (`int8`), `ubyte` (`uint8`), `bool`
 
@@ -321,6 +321,9 @@
     these structs to be aligned to that amount inside a buffer, IF that
     buffer is allocated with that alignment (which is not necessarily
     the case for buffers accessed directly inside a `FlatBufferBuilder`).
+    Note: currently not guaranteed to have an effect when used with
+    `--object-api`, since that may allocate objects at alignments less than
+    what you specify with `force_align`.
 -   `bit_flags` (on an enum): the values of this field indicate bits,
     meaning that any value N specified in the schema will end up
     representing 1<<N, or if you don't specify values at all, you'll get
@@ -404,26 +407,26 @@
 
 When parsing numbers, the parser is more flexible than JSON.
 A format of numeric literals is more close to the C/C++.
-According to the [grammar](@ref flatbuffers_grammar), it accepts the following 
+According to the [grammar](@ref flatbuffers_grammar), it accepts the following
 numerical literals:
 
 -   An integer literal can have any number of leading zero `0` digits.
-    Unlike C/C++, the parser ignores a leading zero, not interpreting it as the 
+    Unlike C/C++, the parser ignores a leading zero, not interpreting it as the
     beginning of the octal number.
     The numbers `[081, -00094]` are equal to `[81, -94]`  decimal integers.
 -   The parser accepts unsigned and signed hexadecimal integer numbers.
     For example: `[0x123, +0x45, -0x67]` are equal to `[291, 69, -103]` decimals.
 -   The format of float-point numbers is fully compatible with C/C++ format.
-    If a modern C++ compiler is used the parser accepts hexadecimal and special 
+    If a modern C++ compiler is used the parser accepts hexadecimal and special
     float-point literals as well:
     `[-1.0, 2., .3e0, 3.e4, 0x21.34p-5, -inf, nan]`.
     The exponent suffix of hexadecimal float-point number is mandatory.
-    
+
     Extended float-point support was tested with:
     - x64 Windows: `MSVC2015` and higher.
     - x64 Linux: `LLVM 6.0`, `GCC 4.9` and higher.
 
--   For compatibility with a JSON lint tool all numeric literals of scalar 
+-   For compatibility with a JSON lint tool all numeric literals of scalar
     fields can be wrapped to quoted string:
     `"1", "2.0", "0x48A", "0x0C.0Ep-1", "-inf", "true"`.
 
diff --git a/docs/source/Tutorial.md b/docs/source/Tutorial.md
index f2eaa2e..db3efa3 100644
--- a/docs/source/Tutorial.md
+++ b/docs/source/Tutorial.md
@@ -370,7 +370,7 @@
 
 <div class="language-cpp">
 ~~~{.cpp}
-  #include "monster_generate.h" // This was generated by `flatc`.
+  #include "monster_generated.h" // This was generated by `flatc`.
 
   using namespace MyGame::Sample; // Specified in the schema.
 ~~~
@@ -767,7 +767,7 @@
 
 
 
-  // The genearted ObjectBuilder classes offer an easier to use alternative
+  // The generated ObjectBuilder classes offer an easier to use alternative
   // at the cost of requiring some additional reference allocations. If memory
   // usage is critical, or if you'll be working with especially large messages
   // or tables, you should prefer using the generated Builder classes.
@@ -1238,7 +1238,7 @@
   final vec3Builder = new myGame.Vec3Builder(builder);
   vec3Builder.finish(4.0, 5.0, 6.0);
   vec3Builder.finish(1.0, 2.0, 3.0);
-  final int path = builder.endStructVector(2); // the lenght of the vector
+  final int path = builder.endStructVector(2); // the length of the vector
 
   // Otherwise, using the ObjectBuilder classes:
   // The dart implementation provides a simple interface for writing vectors
@@ -1520,7 +1520,7 @@
   // Create the monster using the `Monster::create` helper function. This
   // function accepts a `MonsterArgs` struct, which supplies all of the data
   // needed to build a `Monster`. To supply empty/default fields, just use the
-  // Rust built-in `Default::default()` function, as demononstrated below.
+  // Rust built-in `Default::default()` function, as demonstrated below.
   let orc = Monster::create(&mut builder, &MonsterArgs{
       pos: Some(&Vec3::new(1.0f32, 2.0f32, 3.0f32)),
       mana: 150,
@@ -1663,7 +1663,7 @@
 </div>
 <div class="language-c">
 ~~~{.c}
-  // Add union type and data simultanously.
+  // Add union type and data simultaneously.
   ns(Monster_equipped_Weapon_add(B, axe));
 ~~~
 </div>
@@ -1906,7 +1906,7 @@
 
 
 Now you can write the bytes to a file, send them over the network..
-**Make sure your file mode (or tranfer protocol) is set to BINARY, not text.**
+**Make sure your file mode (or transfer protocol) is set to BINARY, not text.**
 If you transfer a FlatBuffer in text mode, the buffer will be corrupted,
 which will lead to hard to find problems when you read the buffer.
 
@@ -2207,7 +2207,7 @@
 <div class="language-csharp">
 ~~~{.cs}
   // For C#, unlike most other languages support by FlatBuffers, most values (except for
-  // vectors and unions) are available as propreties instead of asccessor methods.
+  // vectors and unions) are available as properties instead of accessor methods.
   var hp = monster.Hp
   var mana = monster.Mana
   var name = monster.Name
@@ -2258,7 +2258,7 @@
 <div class="language-dart">
 ~~~{.dart}
   // For Dart, unlike other languages support by FlatBuffers, most values
-  // are available as propreties instead of asccessor methods.
+  // are available as properties instead of accessor methods.
   var hp = monster.hp;
   var mana = monster.mana;
   var name = monster.name;
diff --git a/grpc/src/compiler/java_generator.cc b/grpc/src/compiler/java_generator.cc
index 4ca3596..661c9ee 100644
--- a/grpc/src/compiler/java_generator.cc
+++ b/grpc/src/compiler/java_generator.cc
@@ -37,9 +37,6 @@
 #define XSTR(s) STR(s)
 #endif
 
-#ifndef FALLTHROUGH_INTENDED
-#define FALLTHROUGH_INTENDED
-#endif
 
 typedef grpc_generator::Printer Printer;
 typedef std::map<grpc::string, grpc::string> VARS;
@@ -479,7 +476,7 @@
       break;
     case BLOCKING_CLIENT_INTERFACE:
       interface = true;
-      FALLTHROUGH_INTENDED;  // fallthrough
+      FLATBUFFERS_FALLTHROUGH(); // fall thru
     case BLOCKING_CLIENT_IMPL:
       call_type = BLOCKING_CALL;
       stub_name += "BlockingStub";
@@ -487,7 +484,7 @@
       break;
     case FUTURE_CLIENT_INTERFACE:
       interface = true;
-      FALLTHROUGH_INTENDED;  // fallthrough
+      FLATBUFFERS_FALLTHROUGH(); // fall thru
     case FUTURE_CLIENT_IMPL:
       call_type = FUTURE_CALL;
       stub_name += "FutureStub";
diff --git a/grpc/tests/message_builder_test.cpp b/grpc/tests/message_builder_test.cpp
index d5ed8d9..36f5bc2 100644
--- a/grpc/tests/message_builder_test.cpp
+++ b/grpc/tests/message_builder_test.cpp
@@ -3,6 +3,10 @@
 #include "test_assert.h"
 #include "test_builder.h"
 
+using MyGame::Example::Vec3;
+using MyGame::Example::CreateStat;
+using MyGame::Example::Any_NONE;
+
 bool verify(flatbuffers::grpc::Message<Monster> &msg, const std::string &expected_name, Color color) {
   const Monster *monster = msg.GetRoot();
   return (monster->name()->str() == expected_name) && (monster->color() == color);
diff --git a/include/flatbuffers/base.h b/include/flatbuffers/base.h
index 3682055..a64a587 100644
--- a/include/flatbuffers/base.h
+++ b/include/flatbuffers/base.h
@@ -2,9 +2,18 @@
 #define FLATBUFFERS_BASE_H_
 
 // clang-format off
+
+// If activate should be declared and included first.
 #if defined(FLATBUFFERS_MEMORY_LEAK_TRACKING) && \
     defined(_MSC_VER) && defined(_DEBUG)
+  // The _CRTDBG_MAP_ALLOC inside <crtdbg.h> will replace
+  // calloc/free (etc) to its debug version using #define directives.
   #define _CRTDBG_MAP_ALLOC
+  #include <stdlib.h>
+  #include <crtdbg.h>
+  // Replace operator new by trace-enabled version.
+  #define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
+  #define new DEBUG_NEW
 #endif
 
 #if !defined(FLATBUFFERS_ASSERT)
@@ -23,13 +32,6 @@
 #include <cstdlib>
 #include <cstring>
 
-#if defined(FLATBUFFERS_MEMORY_LEAK_TRACKING) && \
-    defined(_MSC_VER) && defined(_DEBUG)
-  #include <crtdbg.h>
-  #define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
-  #define new DEBUG_NEW
-#endif
-
 #if defined(ARDUINO) && !defined(ARDUINOSTL_M_H)
   #include <utility.h>
 #else
@@ -68,6 +70,18 @@
 // Use the _MSC_VER and _MSVC_LANG definition instead of the __cplusplus  for compatibility.
 // The _MSVC_LANG macro reports the Standard version regardless of the '/Zc:__cplusplus' switch.
 
+#if defined(__GNUC__) && !defined(__clang__)
+  #define FLATBUFFERS_GCC (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
+#else
+  #define FLATBUFFERS_GCC 0
+#endif
+
+#if defined(__clang__)
+  #define FLATBUFFERS_CLANG (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
+#else
+  #define FLATBUFFERS_CLANG 0
+#endif
+
 /// @cond FLATBUFFERS_INTERNAL
 #if __cplusplus <= 199711L && \
     (!defined(_MSC_VER) || _MSC_VER < 1600) && \
@@ -104,7 +118,8 @@
 #endif // __s390x__
 #if !defined(FLATBUFFERS_LITTLEENDIAN)
   #if defined(__GNUC__) || defined(__clang__)
-    #ifdef __BIG_ENDIAN__
+    #if (defined(__BIG_ENDIAN__) || \
+         (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__))
       #define FLATBUFFERS_LITTLEENDIAN 0
     #else
       #define FLATBUFFERS_LITTLEENDIAN 1
@@ -233,13 +248,23 @@
   return !!t;
 }
 
-// Enable of std:c++17 or higher.
-#if (defined(__cplusplus) &&  (__cplusplus >= 201703L)) || \
-    (defined(_MSVC_LANG) &&  (_MSVC_LANG >= 201703L))
+// Enable C++ attribute [[]] if std:c++17 or higher.
+#if ((__cplusplus >= 201703L) \
+    || (defined(_MSVC_LANG) &&  (_MSVC_LANG >= 201703L)))
   // All attributes unknown to an implementation are ignored without causing an error.
-  #define FLATBUFFERS_ATTRIBUTE(attr) // [[attr]] - will be enabled in a future release
+  #define FLATBUFFERS_ATTRIBUTE(attr) [[attr]]
+
+  #define FLATBUFFERS_FALLTHROUGH() [[fallthrough]]
 #else
   #define FLATBUFFERS_ATTRIBUTE(attr)
+
+  #if FLATBUFFERS_CLANG >= 30800
+    #define FLATBUFFERS_FALLTHROUGH() [[clang::fallthrough]]
+  #elif FLATBUFFERS_GCC >= 70300
+    #define FLATBUFFERS_FALLTHROUGH() [[gnu::fallthrough]]
+  #else
+    #define FLATBUFFERS_FALLTHROUGH()
+  #endif
 #endif
 
 /// @endcond
@@ -338,6 +363,11 @@
   *reinterpret_cast<T *>(p) = EndianScalar(t);
 }
 
+template<typename T> struct Offset;
+template<typename T> __supress_ubsan__("alignment") void WriteScalar(void *p, Offset<T> t) {
+  *reinterpret_cast<uoffset_t *>(p) = EndianScalar(t.o);
+}
+
 // Computes how many bytes you'd have to pad to be able to write an
 // "scalar_size" scalar if the buffer had grown to "buf_size" (downwards in
 // memory).
diff --git a/include/flatbuffers/code_generators.h b/include/flatbuffers/code_generators.h
index df09ca0..c2ed707 100644
--- a/include/flatbuffers/code_generators.h
+++ b/include/flatbuffers/code_generators.h
@@ -132,7 +132,7 @@
 
 class FloatConstantGenerator {
  public:
-  virtual ~FloatConstantGenerator(){};
+  virtual ~FloatConstantGenerator() {}
   std::string GenFloatConstant(const FieldDef &field) const;
 
  private:
diff --git a/include/flatbuffers/flatbuffers.h b/include/flatbuffers/flatbuffers.h
index 3f7cbbe..a1a95f0 100644
--- a/include/flatbuffers/flatbuffers.h
+++ b/include/flatbuffers/flatbuffers.h
@@ -116,6 +116,7 @@
   VectorIterator(const uint8_t *data, uoffset_t i)
       : data_(data + IndirectHelper<T>::element_stride * i) {}
   VectorIterator(const VectorIterator &other) : data_(other.data_) {}
+  VectorIterator() : data_(nullptr) {}
 
   VectorIterator &operator=(const VectorIterator &other) {
     data_ = other.data_;
@@ -183,7 +184,7 @@
     return temp;
   }
 
-  VectorIterator operator-(const uoffset_t &offset) {
+  VectorIterator operator-(const uoffset_t &offset) const {
     return VectorIterator(data_ - offset * IndirectHelper<T>::element_stride,
                           0);
   }
@@ -197,6 +198,19 @@
   const uint8_t *data_;
 };
 
+template<typename Iterator> struct VectorReverseIterator :
+  public std::reverse_iterator<Iterator> {
+
+  explicit VectorReverseIterator(Iterator iter) : iter_(iter) {}
+
+  typename Iterator::value_type operator*() const { return *(iter_ - 1); }
+
+  typename Iterator::value_type operator->() const { return *(iter_ - 1); }
+
+ private:
+  Iterator iter_;
+};
+
 struct String;
 
 // This is used as a helper type for accessing vectors.
@@ -207,6 +221,8 @@
       iterator;
   typedef VectorIterator<T, typename IndirectHelper<T>::return_type>
       const_iterator;
+  typedef VectorReverseIterator<iterator> reverse_iterator;
+  typedef VectorReverseIterator<const_iterator> const_reverse_iterator;
 
   uoffset_t size() const { return EndianScalar(length_); }
 
@@ -253,6 +269,20 @@
   iterator end() { return iterator(Data(), size()); }
   const_iterator end() const { return const_iterator(Data(), size()); }
 
+  reverse_iterator rbegin() { return reverse_iterator(end()); }
+  const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); }
+
+  reverse_iterator rend() { return reverse_iterator(end()); }
+  const_reverse_iterator rend() const { return const_reverse_iterator(end()); }
+
+  const_iterator cbegin() const { return begin(); }
+
+  const_iterator cend() const { return end(); }
+
+  const_reverse_iterator crbegin() const { return rbegin(); }
+
+  const_reverse_iterator crend() const { return rend(); }
+
   // Change elements if you have a non-const pointer to this object.
   // Scalars only. See reflection.h, and the documentation.
   void Mutate(uoffset_t i, const T &val) {
@@ -360,7 +390,7 @@
 // Convenient helper function to get the length of any vector, regardless
 // of whether it is null or not (the field is not set).
 template<typename T> static inline size_t VectorLength(const Vector<T> *v) {
-  return v ? v->Length() : 0;
+  return v ? v->size() : 0;
 }
 
 // Lexicographically compare two strings (possibly containing nulls), and
@@ -373,12 +403,12 @@
 
 struct String : public Vector<char> {
   const char *c_str() const { return reinterpret_cast<const char *>(Data()); }
-  std::string str() const { return std::string(c_str(), Length()); }
+  std::string str() const { return std::string(c_str(), size()); }
 
   // clang-format off
   #ifdef FLATBUFFERS_HAS_STRING_VIEW
   flatbuffers::string_view string_view() const {
-    return flatbuffers::string_view(c_str(), Length());
+    return flatbuffers::string_view(c_str(), size());
   }
   #endif // FLATBUFFERS_HAS_STRING_VIEW
   // clang-format on
@@ -1310,7 +1340,7 @@
   /// @param[in] str A const pointer to a `String` struct to add to the buffer.
   /// @return Returns the offset in the buffer where the string starts
   Offset<String> CreateString(const String *str) {
-    return str ? CreateString(str->c_str(), str->Length()) : 0;
+    return str ? CreateString(str->c_str(), str->size()) : 0;
   }
 
   /// @brief Store a string in the buffer, which can contain any binary data.
@@ -1370,7 +1400,7 @@
   /// @param[in] str A const pointer to a `String` struct to add to the buffer.
   /// @return Returns the offset in the buffer where the string starts
   Offset<String> CreateSharedString(const String *str) {
-    return CreateSharedString(str->c_str(), str->Length());
+    return CreateSharedString(str->c_str(), str->size());
   }
 
   /// @cond FLATBUFFERS_INTERNAL
@@ -1947,13 +1977,9 @@
         depth_(0),
         max_depth_(_max_depth),
         num_tables_(0),
-        max_tables_(_max_tables)
-  // clang-format off
-    #ifdef FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE
-        , upper_bound_(0)
-    #endif
-        , check_alignment_(_check_alignment)
-  // clang-format on
+        max_tables_(_max_tables),
+        upper_bound_(0),
+        check_alignment_(_check_alignment)
   {
     FLATBUFFERS_ASSERT(size_ < FLATBUFFERS_MAX_BUFFER_SIZE);
   }
@@ -2144,17 +2170,22 @@
     return true;
   }
 
-  // clang-format off
-  #ifdef FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE
   // Returns the message size in bytes
   size_t GetComputedSize() const {
-    uintptr_t size = upper_bound_;
-    // Align the size to uoffset_t
-    size = (size - 1 + sizeof(uoffset_t)) & ~(sizeof(uoffset_t) - 1);
-    return (size > size_) ?  0 : size;
+    // clang-format off
+    #ifdef FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE
+      uintptr_t size = upper_bound_;
+      // Align the size to uoffset_t
+      size = (size - 1 + sizeof(uoffset_t)) & ~(sizeof(uoffset_t) - 1);
+      return (size > size_) ?  0 : size;
+    #else
+      // Must turn on FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE for this to work.
+      (void)upper_bound_;
+      FLATBUFFERS_ASSERT(false);
+      return 0;
+    #endif
+    // clang-format on
   }
-  #endif
-  // clang-format on
 
  private:
   const uint8_t *buf_;
@@ -2163,11 +2194,7 @@
   uoffset_t max_depth_;
   uoffset_t num_tables_;
   uoffset_t max_tables_;
-  // clang-format off
-  #ifdef FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE
-    mutable size_t upper_bound_;
-  #endif
-  // clang-format on
+  mutable size_t upper_bound_;
   bool check_alignment_;
 };
 
@@ -2441,10 +2468,10 @@
 // clang-format off
 #if defined(_MSC_VER)
   #define FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(alignment) \
-    __pragma(pack(1)); \
+    __pragma(pack(1)) \
     struct __declspec(align(alignment))
   #define FLATBUFFERS_STRUCT_END(name, size) \
-    __pragma(pack()); \
+    __pragma(pack()) \
     static_assert(sizeof(name) == size, "compiler breaks packing rules")
 #elif defined(__GNUC__) || defined(__clang__)
   #define FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(alignment) \
diff --git a/include/flatbuffers/flexbuffers.h b/include/flatbuffers/flexbuffers.h
index 51cae53..7cba5b7 100644
--- a/include/flatbuffers/flexbuffers.h
+++ b/include/flatbuffers/flexbuffers.h
@@ -153,7 +153,7 @@
   // constant, which here it isn't. Test if memcpy is still faster than
   // the conditionals in ReadSizedScalar. Can also use inline asm.
   // clang-format off
-  #ifdef _MSC_VER
+  #if defined(_MSC_VER) && (defined(_M_X64) || defined _M_IX86)
     uint64_t u = 0;
     __movsb(reinterpret_cast<uint8_t *>(&u),
             reinterpret_cast<const uint8_t *>(data), byte_width);
diff --git a/include/flatbuffers/idl.h b/include/flatbuffers/idl.h
index e48edb0..6b70f3a 100644
--- a/include/flatbuffers/idl.h
+++ b/include/flatbuffers/idl.h
@@ -258,6 +258,7 @@
       : deprecated(false),
         required(false),
         key(false),
+        shared(false),
         native_inline(false),
         flexbuffer(false),
         nested_flatbuffer(NULL),
@@ -273,6 +274,8 @@
                     // written in new data nor accessed in new code.
   bool required;    // Field must always be present.
   bool key;         // Field functions as a key for creating sorted vectors.
+  bool shared;  // Field will be using string pooling (i.e. CreateSharedString)
+                // as default serialization behavior if field is a string.
   bool native_inline;  // Field will be defined inline (instead of as a pointer)
                        // for native tables if field is a struct.
   bool flexbuffer;     // This field contains FlexBuffer data.
@@ -326,7 +329,7 @@
 
 struct EnumVal {
   EnumVal(const std::string &_name, int64_t _val) : name(_name), value(_val) {}
-  EnumVal() : value(0){};
+  EnumVal() : value(0) {}
 
   Offset<reflection::EnumVal> Serialize(FlatBufferBuilder *builder, const Parser &parser) const;
 
@@ -422,6 +425,7 @@
   std::string go_import;
   std::string go_namespace;
   bool reexport_ts_modules;
+  bool js_ts_short_names;
   bool protobuf_ascii_alike;
   bool size_prefixed;
   std::string root_type;
@@ -493,6 +497,7 @@
         binary_schema_builtins(false),
         skip_flatbuffers_import(false),
         reexport_ts_modules(true),
+        js_ts_short_names(false),
         protobuf_ascii_alike(false),
         size_prefixed(false),
         force_defaults(false),
@@ -608,6 +613,7 @@
     known_attributes_["deprecated"] = true;
     known_attributes_["required"] = true;
     known_attributes_["key"] = true;
+    known_attributes_["shared"] = true;
     known_attributes_["hash"] = true;
     known_attributes_["id"] = true;
     known_attributes_["force_align"] = true;
diff --git a/include/flatbuffers/minireflect.h b/include/flatbuffers/minireflect.h
index e3def08..fc0cc43 100644
--- a/include/flatbuffers/minireflect.h
+++ b/include/flatbuffers/minireflect.h
@@ -122,58 +122,58 @@
                          soffset_t vector_index, IterationVisitor *visitor) {
   switch (type) {
     case ET_UTYPE: {
-      auto tval = *reinterpret_cast<const uint8_t *>(val);
+      auto tval = ReadScalar<uint8_t>(val);
       visitor->UType(tval, EnumName(tval, type_table));
       break;
     }
     case ET_BOOL: {
-      visitor->Bool(*reinterpret_cast<const uint8_t *>(val) != 0);
+      visitor->Bool(ReadScalar<uint8_t>(val) != 0);
       break;
     }
     case ET_CHAR: {
-      auto tval = *reinterpret_cast<const int8_t *>(val);
+      auto tval = ReadScalar<int8_t>(val);
       visitor->Char(tval, EnumName(tval, type_table));
       break;
     }
     case ET_UCHAR: {
-      auto tval = *reinterpret_cast<const uint8_t *>(val);
+      auto tval = ReadScalar<uint8_t>(val);
       visitor->UChar(tval, EnumName(tval, type_table));
       break;
     }
     case ET_SHORT: {
-      auto tval = *reinterpret_cast<const int16_t *>(val);
+      auto tval = ReadScalar<int16_t>(val);
       visitor->Short(tval, EnumName(tval, type_table));
       break;
     }
     case ET_USHORT: {
-      auto tval = *reinterpret_cast<const uint16_t *>(val);
+      auto tval = ReadScalar<uint16_t>(val);
       visitor->UShort(tval, EnumName(tval, type_table));
       break;
     }
     case ET_INT: {
-      auto tval = *reinterpret_cast<const int32_t *>(val);
+      auto tval = ReadScalar<int32_t>(val);
       visitor->Int(tval, EnumName(tval, type_table));
       break;
     }
     case ET_UINT: {
-      auto tval = *reinterpret_cast<const uint32_t *>(val);
+      auto tval = ReadScalar<uint32_t>(val);
       visitor->UInt(tval, EnumName(tval, type_table));
       break;
     }
     case ET_LONG: {
-      visitor->Long(*reinterpret_cast<const int64_t *>(val));
+      visitor->Long(ReadScalar<int64_t>(val));
       break;
     }
     case ET_ULONG: {
-      visitor->ULong(*reinterpret_cast<const uint64_t *>(val));
+      visitor->ULong(ReadScalar<uint64_t>(val));
       break;
     }
     case ET_FLOAT: {
-      visitor->Float(*reinterpret_cast<const float *>(val));
+      visitor->Float(ReadScalar<float>(val));
       break;
     }
     case ET_DOUBLE: {
-      visitor->Double(*reinterpret_cast<const double *>(val));
+      visitor->Double(ReadScalar<double>(val));
       break;
     }
     case ET_STRING: {
diff --git a/include/flatbuffers/stl_emulation.h b/include/flatbuffers/stl_emulation.h
index 028cc6f..6f6e766 100644
--- a/include/flatbuffers/stl_emulation.h
+++ b/include/flatbuffers/stl_emulation.h
@@ -148,11 +148,15 @@
     template <typename T> using is_unsigned = std::tr1::is_unsigned<T>;
     // Android NDK doesn't have std::make_unsigned or std::tr1::make_unsigned.
     template<typename T> struct make_unsigned {
-      static_assert(is_unsigned<T>::value, "Specialization not impelented!");
+      static_assert(is_unsigned<T>::value, "Specialization not implemented!");
       using type = T;
     };
     template<> struct make_unsigned<char> { using type = unsigned char; };
-    template<> struct make_unsigned<int>  { using type = unsigned int;  };
+    template<> struct make_unsigned<short> { using type = unsigned short; };
+    template<> struct make_unsigned<int> { using type = unsigned int; };
+    template<> struct make_unsigned<long> { using type = unsigned long; };
+    template<>
+    struct make_unsigned<long long> { using type = unsigned long long; };
   #endif  // !FLATBUFFERS_CPP98_STL
 #else
   // MSVC 2010 doesn't support C++11 aliases.
diff --git a/include/flatbuffers/util.h b/include/flatbuffers/util.h
index 3bd8e97..275747b 100644
--- a/include/flatbuffers/util.h
+++ b/include/flatbuffers/util.h
@@ -130,6 +130,9 @@
 template<> inline std::string NumToString<unsigned char>(unsigned char t) {
   return NumToString(static_cast<int>(t));
 }
+template<> inline std::string NumToString<char>(char t) {
+  return NumToString(static_cast<int>(t));
+}
 #if defined(FLATBUFFERS_CPP98_STL)
 template<> inline std::string NumToString<long long>(long long t) {
   char buf[21];  // (log((1 << 63) - 1) / log(10)) + 2
@@ -272,7 +275,7 @@
 //
 // Return value (like strtoull and strtoll, but reject partial result):
 // - If successful, an integer value corresponding to the str is returned.
-// - If full string conversion can't be performed, ​0​ is returned.
+// - If full string conversion can't be performed, 0 is returned.
 // - If the converted value falls out of range of corresponding return type, a
 // range error occurs. In this case value MAX(T)/MIN(T) is returned.
 template<typename T>
@@ -316,7 +319,7 @@
 // Convert a string to an instance of T.
 // Return value (matched with StringToInteger64Impl and strtod):
 // - If successful, a numeric value corresponding to the str is returned.
-// - If full string conversion can't be performed, ​0​ is returned.
+// - If full string conversion can't be performed, 0 is returned.
 // - If the converted value falls out of range of corresponding return type, a
 // range error occurs. In this case value MAX(T)/MIN(T) is returned.
 template<typename T> inline bool StringToNumber(const char *s, T *val) {
diff --git a/java/com/google/flatbuffers/FlatBufferBuilder.java b/java/com/google/flatbuffers/FlatBufferBuilder.java
index 4a62f33..9f3ae20 100644
--- a/java/com/google/flatbuffers/FlatBufferBuilder.java
+++ b/java/com/google/flatbuffers/FlatBufferBuilder.java
@@ -65,6 +65,7 @@
      * @param initial_size The initial size of the internal buffer to use.
      * @param bb_factory The factory to be used for allocating the internal buffer
      * @param existing_bb The byte buffer to reuse.
+     * @param utf8 The Utf8 codec
      */
     public FlatBufferBuilder(int initial_size, ByteBufferFactory bb_factory,
                              ByteBuffer existing_bb, Utf8 utf8) {
@@ -76,10 +77,10 @@
         if (existing_bb != null) {
           bb = existing_bb;
           bb.clear();
+          bb.order(ByteOrder.LITTLE_ENDIAN);
         } else {
           bb = bb_factory.newByteBuffer(initial_size);
         }
-        bb.order(ByteOrder.LITTLE_ENDIAN);
         this.utf8 = utf8;
     }
 
@@ -89,7 +90,7 @@
     * @param initial_size The initial size of the internal buffer to use.
     */
     public FlatBufferBuilder(int initial_size) {
-        this(initial_size, new HeapByteBufferFactory(), null, Utf8.getDefault());
+        this(initial_size, HeapByteBufferFactory.INSTANCE, null, Utf8.getDefault());
     }
 
     /**
@@ -159,14 +160,15 @@
      * preserve the default behavior in the event that the user does not provide
      * their own implementation of this interface.
      */
-    public interface ByteBufferFactory {
+    public static abstract class ByteBufferFactory {
         /**
          * Create a `ByteBuffer` with a given capacity.
+         * The returned ByteBuf must have a ByteOrder.LITTLE_ENDIAN ByteOrder.
          *
          * @param capacity The size of the `ByteBuffer` to allocate.
          * @return Returns the new `ByteBuffer` that was allocated.
          */
-        ByteBuffer newByteBuffer(int capacity);
+        public abstract ByteBuffer newByteBuffer(int capacity);
 
         /**
          * Release a ByteBuffer. Current {@link FlatBufferBuilder}
@@ -177,7 +179,7 @@
          *
          * @param bb the buffer to release
          */
-        default void releaseByteBuffer(ByteBuffer bb) {
+        public void releaseByteBuffer(ByteBuffer bb) {
         }
     }
 
@@ -187,7 +189,10 @@
      *
      * Allocate memory for a new byte-array backed `ByteBuffer` array inside the JVM.
      */
-    public static final class HeapByteBufferFactory implements ByteBufferFactory {
+    public static final class HeapByteBufferFactory extends ByteBufferFactory {
+
+        public static final HeapByteBufferFactory INSTANCE = new HeapByteBufferFactory();
+
         @Override
         public ByteBuffer newByteBuffer(int capacity) {
             return ByteBuffer.allocate(capacity).order(ByteOrder.LITTLE_ENDIAN);
diff --git a/java/com/google/flatbuffers/Table.java b/java/com/google/flatbuffers/Table.java
index 703ce28..cedbb8e 100644
--- a/java/com/google/flatbuffers/Table.java
+++ b/java/com/google/flatbuffers/Table.java
@@ -37,6 +37,10 @@
   protected int bb_pos;
   /** The underlying ByteBuffer to hold the data of the Table. */
   protected ByteBuffer bb;
+  /** Used to hold the vtable position. */
+  protected int vtable_start;
+  /** Used to hold the vtable size. */
+  protected int vtable_size;
   Utf8 utf8 = Utf8.getDefault();
 
   /**
@@ -53,8 +57,7 @@
    * @return Returns an offset into the object, or `0` if the field is not present.
    */
   protected int __offset(int vtable_offset) {
-    int vtable = bb_pos - bb.getInt(bb_pos);
-    return vtable_offset < bb.getShort(vtable) ? bb.getShort(vtable + vtable_offset) : 0;
+    return vtable_offset < vtable_size ? bb.getShort(vtable_start + vtable_offset) : 0;
   }
 
   protected static int __offset(int vtable_offset, int offset, ByteBuffer bb) {
@@ -89,8 +92,7 @@
    */
   protected String __string(int offset) {
     offset += bb.getInt(offset);
-    ByteBuffer src = bb.duplicate().order(ByteOrder.LITTLE_ENDIAN);
-    int length = src.getInt(offset);
+    int length = bb.getInt(offset);
     return utf8.decodeUtf8(bb, offset + SIZEOF_INT, length);
   }
 
@@ -170,6 +172,8 @@
     offset += bb_pos;
     t.bb_pos = offset + bb.getInt(offset);
     t.bb = bb;
+    t.vtable_start = t.bb_pos - bb.getInt(t.bb_pos);
+    t.vtable_size = bb.getShort(t.vtable_start);
     return t;
   }
 
@@ -269,6 +273,8 @@
   public void __reset() {
     bb = null;
     bb_pos = 0;
+    vtable_start = 0;
+    vtable_size = 0;
   }
 }
 
diff --git a/lua/flatbuffers/builder.lua b/lua/flatbuffers/builder.lua
index 51f0797..2fb2220 100644
--- a/lua/flatbuffers/builder.lua
+++ b/lua/flatbuffers/builder.lua
@@ -34,7 +34,7 @@
     end
 
     for i, elem in ipairs(a) do
-        local x = VOffsetT:Unpack(b, i * VOffsetT.bytewidth)
+        local x = string.unpack(VOffsetT.packFmt, b, 1 + (i - 1) * VOffsetT.bytewidth)
         if x ~= 0 or elem ~= 0 then
             local y = objectStart - elem
             if x ~= y then
@@ -96,11 +96,13 @@
         i = i - 1
     end
 
+    i = #self.vtables
     while i >= 1 do
 
         local vt2Offset = self.vtables[i]
         local vt2Start = #self.bytes - vt2Offset
-        local vt2len = VOffsetT:Unpack(self.bytes, vt2Start)
+        local vt2lenstr = self.bytes:Slice(vt2Start, vt2Start+1)
+        local vt2Len = string.unpack(VOffsetT.packFmt, vt2lenstr, 1)
 
         local metadata = VtableMetadataFields * VOffsetT.bytewidth
         local vt2End = vt2Start + vt2Len
@@ -364,4 +366,4 @@
     self.bytes:Set(d, h)
 end
 
-return m
\ No newline at end of file
+return m
diff --git a/net/FlatBuffers/ByteBuffer.cs b/net/FlatBuffers/ByteBuffer.cs
index 1b2e1af..5e212dd 100644
--- a/net/FlatBuffers/ByteBuffer.cs
+++ b/net/FlatBuffers/ByteBuffer.cs
@@ -42,20 +42,24 @@
 using System.Runtime.InteropServices;
 using System.Text;
 
+#if ENABLE_SPAN_T
+using System.Buffers.Binary;
+#endif
+
 #if ENABLE_SPAN_T && !UNSAFE_BYTEBUFFER
 #error ENABLE_SPAN_T requires UNSAFE_BYTEBUFFER to also be defined
 #endif
 
 namespace FlatBuffers
 {
-    public abstract class ByteBufferAllocator : IDisposable
+    public abstract class ByteBufferAllocator
     {
-#if UNSAFE_BYTEBUFFER
-        public unsafe byte* Buffer
-        {
-            get;
-            protected set;
-        }
+#if ENABLE_SPAN_T
+        public abstract Span<byte> Span { get; }
+        public abstract ReadOnlySpan<byte> ReadOnlySpan { get; }
+        public abstract Memory<byte> Memory { get; }
+        public abstract ReadOnlyMemory<byte> ReadOnlyMemory { get; }
+
 #else
         public byte[] Buffer
         {
@@ -70,23 +74,17 @@
             protected set;
         }
 
-        public abstract void Dispose();
-
         public abstract void GrowFront(int newSize);
-
-#if !ENABLE_SPAN_T
-        public abstract byte[] ByteArray { get; }
-#endif
     }
 
-    public class ByteArrayAllocator : ByteBufferAllocator
+    public sealed class ByteArrayAllocator : ByteBufferAllocator
     {
         private byte[] _buffer;
 
         public ByteArrayAllocator(byte[] buffer)
         {
             _buffer = buffer;
-            InitPointer();
+            InitBuffer();
         }
 
         public override void GrowFront(int newSize)
@@ -101,63 +99,29 @@
             byte[] newBuffer = new byte[newSize];
             System.Buffer.BlockCopy(_buffer, 0, newBuffer, newSize - Length, Length);
             _buffer = newBuffer;
-            InitPointer();
+            InitBuffer();
         }
 
-        public override void Dispose()
-        {
-            GC.SuppressFinalize(this);
-#if UNSAFE_BYTEBUFFER
-            if (_handle.IsAllocated)
-            {
-                _handle.Free();
-            }
-#endif
-        }
-
-#if !ENABLE_SPAN_T
-        public override byte[] ByteArray
-        {
-            get { return _buffer; }
-        }
+#if ENABLE_SPAN_T
+        public override Span<byte> Span => _buffer;
+        public override ReadOnlySpan<byte> ReadOnlySpan => _buffer;
+        public override Memory<byte> Memory => _buffer;
+        public override ReadOnlyMemory<byte> ReadOnlyMemory => _buffer;
 #endif
 
-#if UNSAFE_BYTEBUFFER
-        private GCHandle _handle;
-
-        ~ByteArrayAllocator()
-        {
-            if (_handle.IsAllocated)
-            {
-                _handle.Free();
-            }
-        }
-#endif
-
-        private void InitPointer()
+        private void InitBuffer()
         {
             Length = _buffer.Length;
-#if UNSAFE_BYTEBUFFER
-            if (_handle.IsAllocated)
-            {
-                _handle.Free();
-            }
-            _handle = GCHandle.Alloc(_buffer, GCHandleType.Pinned);
-            unsafe
-            {
-                Buffer = (byte*)_handle.AddrOfPinnedObject().ToPointer();
-            }
-#else
+#if !ENABLE_SPAN_T
             Buffer = _buffer;
 #endif
         }
     }
 
-
     /// <summary>
     /// Class to mimic Java's ByteBuffer which is used heavily in Flatbuffers.
     /// </summary>
-    public class ByteBuffer : IDisposable
+    public class ByteBuffer
     {
         private ByteBufferAllocator _buffer;
         private int _pos;  // Must track start of the buffer.
@@ -178,15 +142,8 @@
             _pos = pos;
         }
 
-        public void Dispose()
+        public int Position
         {
-            if (_buffer != null)
-            {
-                _buffer.Dispose();
-            }
-        }
-
-        public int Position {
             get { return _pos; }
             set { _pos = value; }
         }
@@ -278,16 +235,10 @@
         // the buffer position and length.
 #if ENABLE_SPAN_T
         public T[] ToArray<T>(int pos, int len)
-            where T: struct
+            where T : struct
         {
-            unsafe
-            {
-                AssertOffsetAndLength(pos, len);
-                T[] arr = new T[len];
-                var typed = MemoryMarshal.Cast<byte, T>(new Span<byte>(_buffer.Buffer + pos, _buffer.Length));
-                typed.Slice(0, arr.Length).CopyTo(arr);
-                return arr;
-            }
+            AssertOffsetAndLength(pos, len);
+            return MemoryMarshal.Cast<byte, T>(_buffer.ReadOnlySpan.Slice(pos)).Slice(0, len).ToArray();
         }
 #else
         public T[] ToArray<T>(int pos, int len)
@@ -295,7 +246,7 @@
         {
             AssertOffsetAndLength(pos, len);
             T[] arr = new T[len];
-            Buffer.BlockCopy(_buffer.ByteArray, pos, arr, 0, ArraySize(arr));
+            Buffer.BlockCopy(_buffer.Buffer, pos, arr, 0, ArraySize(arr));
             return arr;
         }
 #endif
@@ -310,23 +261,30 @@
             return ToArray<byte>(0, Length);
         }
 
-
 #if ENABLE_SPAN_T
-        public unsafe Span<byte> ToSpan(int pos, int len)
+        public ReadOnlyMemory<byte> ToReadOnlyMemory(int pos, int len)
         {
-            return new Span<byte>(_buffer.Buffer, _buffer.Length).Slice(pos, len);
+            return _buffer.ReadOnlyMemory.Slice(pos, len);
+        }
+
+        public Memory<byte> ToMemory(int pos, int len)
+        {
+            return _buffer.Memory.Slice(pos, len);
+        }
+
+        public Span<byte> ToSpan(int pos, int len)
+        {
+            return _buffer.Span.Slice(pos, len);
         }
 #else
         public ArraySegment<byte> ToArraySegment(int pos, int len)
         {
-            return new ArraySegment<byte>(_buffer.ByteArray, pos, len);
+            return new ArraySegment<byte>(_buffer.Buffer, pos, len);
         }
-#endif
 
-#if !ENABLE_SPAN_T
         public MemoryStream ToMemoryStream(int pos, int len)
         {
-            return new MemoryStream(_buffer.ByteArray, pos, len);
+            return new MemoryStream(_buffer.Buffer, pos, len);
         }
 #endif
 
@@ -391,15 +349,15 @@
             {
                 for (int i = 0; i < count; i++)
                 {
-                  r |= (ulong)_buffer.Buffer[offset + i] << i * 8;
+                    r |= (ulong)_buffer.Buffer[offset + i] << i * 8;
                 }
             }
             else
             {
-              for (int i = 0; i < count; i++)
-              {
-                r |= (ulong)_buffer.Buffer[offset + count - 1 - i] << i * 8;
-              }
+                for (int i = 0; i < count; i++)
+                {
+                    r |= (ulong)_buffer.Buffer[offset + count - 1 - i] << i * 8;
+                }
             }
             return r;
         }
@@ -414,31 +372,26 @@
 #endif
         }
 
-#if UNSAFE_BYTEBUFFER
+#if ENABLE_SPAN_T
 
-        public unsafe void PutSbyte(int offset, sbyte value)
+        public void PutSbyte(int offset, sbyte value)
         {
             AssertOffsetAndLength(offset, sizeof(sbyte));
-            _buffer.Buffer[offset] = (byte)value;
+            _buffer.Span[offset] = (byte)value;
         }
 
-        public unsafe void PutByte(int offset, byte value)
+        public void PutByte(int offset, byte value)
         {
             AssertOffsetAndLength(offset, sizeof(byte));
-            _buffer.Buffer[offset] = value;
+            _buffer.Span[offset] = value;
         }
 
-        public unsafe void PutByte(int offset, byte value, int count)
+        public void PutByte(int offset, byte value, int count)
         {
             AssertOffsetAndLength(offset, sizeof(byte) * count);
-            for (var i = 0; i < count; ++i)
-                _buffer.Buffer[offset + i] = value;
-        }
-
-        // this method exists in order to conform with Java ByteBuffer standards
-        public void Put(int offset, byte value)
-        {
-            PutByte(offset, value);
+            Span<byte> span = _buffer.Span.Slice(offset, count);
+            for (var i = 0; i < span.Length; ++i)
+                span[i] = value;
         }
 #else
         public void PutSbyte(int offset, sbyte value)
@@ -459,13 +412,13 @@
             for (var i = 0; i < count; ++i)
                 _buffer.Buffer[offset + i] = value;
         }
+#endif
 
         // this method exists in order to conform with Java ByteBuffer standards
         public void Put(int offset, byte value)
         {
             PutByte(offset, value);
         }
-#endif
 
 #if ENABLE_SPAN_T
         public unsafe void PutStringUTF8(int offset, string value)
@@ -473,7 +426,10 @@
             AssertOffsetAndLength(offset, value.Length);
             fixed (char* s = value)
             {
-                Encoding.UTF8.GetBytes(s, value.Length, _buffer.Buffer + offset, Length - offset);
+                fixed (byte* buffer = &MemoryMarshal.GetReference(_buffer.Span))
+                {
+                    Encoding.UTF8.GetBytes(s, value.Length, buffer + offset, Length - offset);
+                }
             }
         }
 #else
@@ -481,7 +437,7 @@
         {
             AssertOffsetAndLength(offset, value.Length);
             Encoding.UTF8.GetBytes(value, 0, value.Length,
-                _buffer.ByteArray, offset);
+                _buffer.Buffer, offset);
         }
 #endif
 
@@ -495,10 +451,17 @@
         public unsafe void PutUshort(int offset, ushort value)
         {
             AssertOffsetAndLength(offset, sizeof(ushort));
-            byte* ptr = _buffer.Buffer;
-            *(ushort*)(ptr + offset) = BitConverter.IsLittleEndian
-                ? value
-                : ReverseBytes(value);
+#if ENABLE_SPAN_T
+            Span<byte> span = _buffer.Span.Slice(offset);
+            BinaryPrimitives.WriteUInt16LittleEndian(span, value);
+#else
+            fixed (byte* ptr = _buffer.Buffer)
+            {
+                *(ushort*)(ptr + offset) = BitConverter.IsLittleEndian
+                    ? value
+                    : ReverseBytes(value);
+            }
+#endif
         }
 
         public void PutInt(int offset, int value)
@@ -509,10 +472,17 @@
         public unsafe void PutUint(int offset, uint value)
         {
             AssertOffsetAndLength(offset, sizeof(uint));
-            byte* ptr = _buffer.Buffer;
-            *(uint*)(ptr + offset) = BitConverter.IsLittleEndian
-                ? value
-                : ReverseBytes(value);
+#if ENABLE_SPAN_T
+            Span<byte> span = _buffer.Span.Slice(offset);
+            BinaryPrimitives.WriteUInt32LittleEndian(span, value);
+#else
+            fixed (byte* ptr = _buffer.Buffer)
+            {
+                *(uint*)(ptr + offset) = BitConverter.IsLittleEndian
+                    ? value
+                    : ReverseBytes(value);
+            }
+#endif
         }
 
         public unsafe void PutLong(int offset, long value)
@@ -523,38 +493,56 @@
         public unsafe void PutUlong(int offset, ulong value)
         {
             AssertOffsetAndLength(offset, sizeof(ulong));
-            byte* ptr = _buffer.Buffer;
-            *(ulong*)(ptr + offset) = BitConverter.IsLittleEndian
-                ? value
-                : ReverseBytes(value);
+#if ENABLE_SPAN_T
+            Span<byte> span = _buffer.Span.Slice(offset);
+            BinaryPrimitives.WriteUInt64LittleEndian(span, value);
+#else
+            fixed (byte* ptr = _buffer.Buffer)
+            {
+                *(ulong*)(ptr + offset) = BitConverter.IsLittleEndian
+                    ? value
+                    : ReverseBytes(value);
+            }
+#endif
         }
 
         public unsafe void PutFloat(int offset, float value)
         {
             AssertOffsetAndLength(offset, sizeof(float));
-            byte* ptr = _buffer.Buffer;
-            if (BitConverter.IsLittleEndian)
+#if ENABLE_SPAN_T
+            fixed (byte* ptr = &MemoryMarshal.GetReference(_buffer.Span))
+#else
+            fixed (byte* ptr = _buffer.Buffer)
+#endif
             {
-                *(float*)(ptr + offset) = value;
-            }
-            else
-            {
-                *(uint*)(ptr + offset) = ReverseBytes(*(uint*)(&value));
+                if (BitConverter.IsLittleEndian)
+                {
+                    *(float*)(ptr + offset) = value;
+                }
+                else
+                {
+                    *(uint*)(ptr + offset) = ReverseBytes(*(uint*)(&value));
+                }
             }
         }
 
         public unsafe void PutDouble(int offset, double value)
         {
             AssertOffsetAndLength(offset, sizeof(double));
-            byte* ptr = _buffer.Buffer;
-            if (BitConverter.IsLittleEndian)
+#if ENABLE_SPAN_T
+            fixed (byte* ptr = &MemoryMarshal.GetReference(_buffer.Span))
+#else
+            fixed (byte* ptr = _buffer.Buffer)
+#endif
             {
-                *(double*)(ptr + offset) = value;
-
-            }
-            else
-            {
-                *(ulong*)(ptr + offset) = ReverseBytes(*(ulong*)(&value));
+                if (BitConverter.IsLittleEndian)
+                {
+                    *(double*)(ptr + offset) = value;
+                }
+                else
+                {
+                    *(ulong*)(ptr + offset) = ReverseBytes(*(ulong*)(&value));
+                }
             }
         }
 #else // !UNSAFE_BYTEBUFFER
@@ -613,17 +601,17 @@
 
 #endif // UNSAFE_BYTEBUFFER
 
-#if UNSAFE_BYTEBUFFER
-        public unsafe sbyte GetSbyte(int index)
+#if ENABLE_SPAN_T
+        public sbyte GetSbyte(int index)
         {
             AssertOffsetAndLength(index, sizeof(sbyte));
-            return (sbyte)_buffer.Buffer[index];
+            return (sbyte)_buffer.ReadOnlySpan[index];
         }
 
-        public unsafe byte Get(int index)
+        public byte Get(int index)
         {
             AssertOffsetAndLength(index, sizeof(byte));
-            return _buffer.Buffer[index];
+            return _buffer.ReadOnlySpan[index];
         }
 #else
         public sbyte GetSbyte(int index)
@@ -642,12 +630,15 @@
 #if ENABLE_SPAN_T
         public unsafe string GetStringUTF8(int startPos, int len)
         {
-            return Encoding.UTF8.GetString(_buffer.Buffer + startPos, len);
+            fixed (byte* buffer = &MemoryMarshal.GetReference(_buffer.ReadOnlySpan.Slice(startPos)))
+            {
+                return Encoding.UTF8.GetString(buffer, len);
+            }
         }
 #else
         public string GetStringUTF8(int startPos, int len)
         {
-            return Encoding.UTF8.GetString(_buffer.ByteArray, startPos, len);
+            return Encoding.UTF8.GetString(_buffer.Buffer, startPos, len);
         }
 #endif
 
@@ -661,12 +652,17 @@
         public unsafe ushort GetUshort(int offset)
         {
             AssertOffsetAndLength(offset, sizeof(ushort));
-            byte* ptr = _buffer.Buffer;
+#if ENABLE_SPAN_T
+            ReadOnlySpan<byte> span = _buffer.ReadOnlySpan.Slice(offset);
+            return BinaryPrimitives.ReadUInt16LittleEndian(span);
+#else
+            fixed (byte* ptr = _buffer.Buffer)
             {
                 return BitConverter.IsLittleEndian
                     ? *(ushort*)(ptr + offset)
                     : ReverseBytes(*(ushort*)(ptr + offset));
             }
+#endif
         }
 
         public int GetInt(int offset)
@@ -677,12 +673,17 @@
         public unsafe uint GetUint(int offset)
         {
             AssertOffsetAndLength(offset, sizeof(uint));
-            byte* ptr = _buffer.Buffer;
+#if ENABLE_SPAN_T
+            ReadOnlySpan<byte> span = _buffer.ReadOnlySpan.Slice(offset);
+            return BinaryPrimitives.ReadUInt32LittleEndian(span);
+#else
+            fixed (byte* ptr = _buffer.Buffer)
             {
                 return BitConverter.IsLittleEndian
                     ? *(uint*)(ptr + offset)
                     : ReverseBytes(*(uint*)(ptr + offset));
             }
+#endif
         }
 
         public long GetLong(int offset)
@@ -693,18 +694,27 @@
         public unsafe ulong GetUlong(int offset)
         {
             AssertOffsetAndLength(offset, sizeof(ulong));
-            byte* ptr = _buffer.Buffer;
+#if ENABLE_SPAN_T
+            ReadOnlySpan<byte> span = _buffer.ReadOnlySpan.Slice(offset);
+            return BinaryPrimitives.ReadUInt64LittleEndian(span);
+#else            
+            fixed (byte* ptr = _buffer.Buffer)
             {
                 return BitConverter.IsLittleEndian
                     ? *(ulong*)(ptr + offset)
                     : ReverseBytes(*(ulong*)(ptr + offset));
             }
+#endif
         }
 
         public unsafe float GetFloat(int offset)
         {
             AssertOffsetAndLength(offset, sizeof(float));
-            byte* ptr = _buffer.Buffer;
+#if ENABLE_SPAN_T
+            fixed (byte* ptr = &MemoryMarshal.GetReference(_buffer.ReadOnlySpan))
+#else
+            fixed (byte* ptr = _buffer.Buffer)
+#endif
             {
                 if (BitConverter.IsLittleEndian)
                 {
@@ -721,7 +731,11 @@
         public unsafe double GetDouble(int offset)
         {
             AssertOffsetAndLength(offset, sizeof(double));
-            byte* ptr = _buffer.Buffer;
+#if ENABLE_SPAN_T
+            fixed (byte* ptr = &MemoryMarshal.GetReference(_buffer.ReadOnlySpan))
+#else
+            fixed (byte* ptr = _buffer.Buffer)
+#endif
             {
                 if (BitConverter.IsLittleEndian)
                 {
@@ -758,7 +772,7 @@
 
         public long GetLong(int index)
         {
-           return (long)ReadLittleEndian(index, sizeof(long));
+            return (long)ReadLittleEndian(index, sizeof(long));
         }
 
         public ulong GetUlong(int index)
@@ -819,12 +833,9 @@
                 AssertOffsetAndLength(offset, numBytes);
                 // if we are LE, just do a block copy
 #if ENABLE_SPAN_T
-                unsafe
-                {
-                    MemoryMarshal.Cast<T, byte>(x).CopyTo(new Span<byte>(_buffer.Buffer, _buffer.Length).Slice(offset, numBytes));
-                }
+                MemoryMarshal.Cast<T, byte>(x).CopyTo(_buffer.Span.Slice(offset, numBytes));
 #else
-                Buffer.BlockCopy(x, 0, _buffer.ByteArray, offset, numBytes);
+                Buffer.BlockCopy(x, 0, _buffer.Buffer, offset, numBytes);
 #endif
             }
             else
@@ -841,7 +852,7 @@
         }
 
 #if ENABLE_SPAN_T
-        public unsafe int Put<T>(int offset, Span<T> x)
+        public int Put<T>(int offset, Span<T> x)
             where T : struct
         {
             if (x.Length == 0)
@@ -861,7 +872,7 @@
                 offset -= numBytes;
                 AssertOffsetAndLength(offset, numBytes);
                 // if we are LE, just do a block copy
-                MemoryMarshal.Cast<T, byte>(x).CopyTo(new Span<byte>(_buffer.Buffer, _buffer.Length).Slice(offset, numBytes));
+                MemoryMarshal.Cast<T, byte>(x).CopyTo(_buffer.Span.Slice(offset, numBytes));
             }
             else
             {
diff --git a/net/FlatBuffers/FlatBuffers.Core.csproj b/net/FlatBuffers/FlatBuffers.Core.csproj
new file mode 100644
index 0000000..4285dd7
--- /dev/null
+++ b/net/FlatBuffers/FlatBuffers.Core.csproj
@@ -0,0 +1,19 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+    <PropertyGroup>
+        <TargetFramework>netstandard2.0</TargetFramework>
+    </PropertyGroup>
+
+    <ItemGroup>
+      <Compile Remove="Properties\**" />
+    </ItemGroup>
+
+    <ItemGroup>
+      <EmbeddedResource Remove="Properties\**" />
+    </ItemGroup>
+
+    <ItemGroup>
+      <None Remove="Properties\**" />
+    </ItemGroup>
+
+</Project>
diff --git a/samples/monster_generated.h b/samples/monster_generated.h
index db79c2e..5286ffd 100644
--- a/samples/monster_generated.h
+++ b/samples/monster_generated.h
@@ -166,7 +166,7 @@
 
  public:
   Vec3() {
-    memset(this, 0, sizeof(Vec3));
+    memset(static_cast<void *>(this), 0, sizeof(Vec3));
   }
   Vec3(float _x, float _y, float _z)
       : x_(flatbuffers::EndianScalar(_x)),
diff --git a/src/flatc.cpp b/src/flatc.cpp
index d42a585..c5ec70e 100644
--- a/src/flatc.cpp
+++ b/src/flatc.cpp
@@ -98,38 +98,43 @@
     "  --gen-name-strings Generate type name functions for C++.\n"
     "  --gen-object-api   Generate an additional object-based API.\n"
     "  --gen-compare      Generate operator== for object-based API types.\n"
-    "  --cpp-ptr-type T   Set object API pointer type (default std::unique_ptr)\n"
-    "  --cpp-str-type T   Set object API string type (default std::string)\n"
-    "                     T::c_str() and T::length() must be supported\n"
     "  --gen-nullable     Add Clang _Nullable for C++ pointer. or @Nullable for Java\n"
     "  --gen-generated    Add @Generated annotation for Java\n"
+    "  --gen-all          Generate not just code for the current schema files,\n" 
+    "                     but for all files it includes as well.\n"
+    "                     If the language uses a single file for output (by default\n"
+    "                     the case for C++ and JS), all code will end up in this one\n"
+    "                     file.\n"
+    "  --cpp-ptr-type T   Set object API pointer type (default std::unique_ptr).\n"
+    "  --cpp-str-type T   Set object API string type (default std::string).\n"
+    "                     T::c_str() and T::length() must be supported.\n"
     "  --object-prefix    Customise class prefix for C++ object-based API.\n"
     "  --object-suffix    Customise class suffix for C++ object-based API.\n"
-    "                     Default value is \"T\"\n"
+    "                     Default value is \"T\".\n"
     "  --no-js-exports    Removes Node.js style export lines in JS.\n"
     "  --goog-js-export   Uses goog.exports* for closure compiler exporting in JS.\n"
     "  --es6-js-export    Uses ECMAScript 6 export style lines in JS.\n"
     "  --go-namespace     Generate the overrided namespace in Golang.\n"
-    "  --go-import        Generate the overrided import for flatbuffers in Golang.\n"
-    "                     (default is \"github.com/google/flatbuffers/go\")\n"
+    "  --go-import        Generate the overrided import for flatbuffers in Golang\n"
+    "                     (default is \"github.com/google/flatbuffers/go\").\n"
     "  --raw-binary       Allow binaries without file_indentifier to be read.\n"
     "                     This may crash flatc given a mismatched schema.\n"
     "  --size-prefixed    Input binaries are size prefixed buffers.\n"
     "  --proto            Input is a .proto, translate to .fbs.\n"
     "  --oneof-union      Translate .proto oneofs to flatbuffer unions.\n"
-    "  --grpc             Generate GRPC interfaces for the specified languages\n"
-    "  --schema           Serialize schemas instead of JSON (use with -b)\n"
+    "  --grpc             Generate GRPC interfaces for the specified languages.\n"
+    "  --schema           Serialize schemas instead of JSON (use with -b).\n"
     "  --bfbs-comments    Add doc comments to the binary schema files.\n"
     "  --bfbs-builtins    Add builtin attributes to the binary schema files.\n"
     "  --conform FILE     Specify a schema the following schemas should be\n"
     "                     an evolution of. Gives errors if not.\n"
-    "  --conform-includes Include path for the schema given with --conform\n"
-    "    PATH             \n"
+    "  --conform-includes Include path for the schema given with --conform PATH\n"
     "  --include-prefix   Prefix this path to any generated include statements.\n"
     "    PATH\n"
     "  --keep-prefix      Keep original prefix of schema include statement.\n"
     "  --no-fb-import     Don't include flatbuffers import statement for TypeScript.\n"
     "  --no-ts-reexport   Don't re-export imported dependencies for TypeScript.\n"
+    "  --short-names      Use short function names for JS and TypeScript.\n"
     "  --reflect-types    Add minimal type reflection to code generation.\n"
     "  --reflect-names    Add minimal type/name reflection.\n"
     "  --root-type T      Select or override the default root_type\n"
@@ -289,6 +294,8 @@
         opts.skip_flatbuffers_import = true;
       } else if (arg == "--no-ts-reexport") {
         opts.reexport_ts_modules = false;
+      } else if (arg == "--short-names") {
+        opts.js_ts_short_names = true;
       } else if (arg == "--reflect-types") {
         opts.mini_reflect = IDLOptions::kTypes;
       } else if (arg == "--reflect-names") {
diff --git a/src/idl_gen_cpp.cpp b/src/idl_gen_cpp.cpp
index 9884081..efbfe07 100644
--- a/src/idl_gen_cpp.cpp
+++ b/src/idl_gen_cpp.cpp
@@ -2083,9 +2083,14 @@
         if (!field.deprecated) {
           code_.SetValue("FIELD_NAME", Name(field));
           if (field.value.type.base_type == BASE_TYPE_STRING) {
+            if (!field.shared) {
+              code_.SetValue("CREATE_STRING", "CreateString");
+            } else {
+              code_.SetValue("CREATE_STRING", "CreateSharedString");
+            }
             code_ +=
                 "  auto {{FIELD_NAME}}__ = {{FIELD_NAME}} ? "
-                "_fbb.CreateString({{FIELD_NAME}}) : 0;";
+                "_fbb.{{CREATE_STRING}}({{FIELD_NAME}}) : 0;";
           } else if (field.value.type.base_type == BASE_TYPE_VECTOR) {
             code_ += "  auto {{FIELD_NAME}}__ = {{FIELD_NAME}} ? \\";
             const auto vtype = field.value.type.VectorType();
@@ -2164,7 +2169,7 @@
         break;
       }
     }
-  };
+  }
 
   std::string GenUnpackFieldStatement(const FieldDef &field,
                                       const FieldDef *union_field) {
@@ -2294,8 +2299,16 @@
     switch (field.value.type.base_type) {
       // String fields are of the form:
       //   _fbb.CreateString(_o->field)
+      // or
+      //   _fbb.CreateSharedString(_o->field)
       case BASE_TYPE_STRING: {
-        code += "_fbb.CreateString(" + value + ")";
+        if (!field.shared) {
+          code += "_fbb.CreateString(";
+        } else {
+          code += "_fbb.CreateSharedString(";
+        }
+        code += value;
+        code.push_back(')');
 
         // For optional fields, check to see if there actually is any data
         // in _o->field before attempting to access it. If there isn't,
@@ -2604,7 +2617,7 @@
 
     // Generate a default constructor.
     code_ += "  {{STRUCT_NAME}}() {";
-    code_ += "    memset(this, 0, sizeof({{STRUCT_NAME}}));";
+    code_ += "    memset(static_cast<void *>(this), 0, sizeof({{STRUCT_NAME}}));";
     code_ += "  }";
 
     // Generate a constructor that takes all fields as arguments.
diff --git a/src/idl_gen_dart.cpp b/src/idl_gen_dart.cpp
index 854649f..fb7e0bd 100644
--- a/src/idl_gen_dart.cpp
+++ b/src/idl_gen_dart.cpp
@@ -55,7 +55,7 @@
 
   DartGenerator(const Parser &parser, const std::string &path,
                 const std::string &file_name)
-      : BaseGenerator(parser, path, file_name, "", "."){};
+      : BaseGenerator(parser, path, file_name, "", ".") {}
   // Iterate through all definitions we haven't generate code for (enums,
   // structs, and tables) and output them to a single file.
   bool generate() {
diff --git a/src/idl_gen_general.cpp b/src/idl_gen_general.cpp
index 7c34ee2..5fa9b18 100644
--- a/src/idl_gen_general.cpp
+++ b/src/idl_gen_general.cpp
@@ -95,7 +95,7 @@
         "",
         "import java.nio.*;\nimport java.lang.*;\nimport "
         "java.util.*;\nimport com.google.flatbuffers.*;\n",
-        "\n@SuppressWarnings(\"unused\")",
+        "\n@SuppressWarnings(\"unused\")\n",
         "\n@javax.annotation.Generated(value=\"flatc\")\n",
         {
             "/**",
@@ -306,7 +306,7 @@
       case BASE_TYPE_UNION:
         // Unions in C# use a generic Table-derived type for better type safety
         if (lang_.language == IDLOptions::kCSharp) return "TTable";
-        // fall through
+        FLATBUFFERS_FALLTHROUGH();  // else fall thru
       default: return "Table";
     }
   }
@@ -327,7 +327,7 @@
       case BASE_TYPE_UINT: return Type(BASE_TYPE_LONG);
       case BASE_TYPE_VECTOR:
         if (vectorelem) return DestinationType(type.VectorType(), vectorelem);
-        // else fall thru
+        FLATBUFFERS_FALLTHROUGH(); // else fall thru
       default: return type;
     }
   }
@@ -371,7 +371,7 @@
       case BASE_TYPE_UINT: return " & 0xFFFFFFFFL";
       case BASE_TYPE_VECTOR:
         if (vectorelem) return DestinationMask(type.VectorType(), vectorelem);
-        // else fall thru
+        FLATBUFFERS_FALLTHROUGH(); // else fall thru
       default: return "";
     }
   }
@@ -874,7 +874,15 @@
     // accessor object. This is to allow object reuse.
     code += "  public void __init(int _i, ByteBuffer _bb) ";
     code += "{ " + lang_.accessor_prefix + "bb_pos = _i; ";
-    code += lang_.accessor_prefix + "bb = _bb; }\n";
+    code += lang_.accessor_prefix + "bb = _bb; ";
+    if (!struct_def.fixed && lang_.language == IDLOptions::kJava) {
+      code += lang_.accessor_prefix + "vtable_start = " + lang_.accessor_prefix + "bb_pos - ";
+      code += lang_.accessor_prefix + "bb." + FunctionStart('G') + "etInt(";
+      code += lang_.accessor_prefix + "bb_pos); " + lang_.accessor_prefix + "vtable_size = ";
+      code += lang_.accessor_prefix + "bb." + FunctionStart('G') + "etShort(";
+      code += lang_.accessor_prefix + "vtable_start); ";
+    }
+    code += "}\n";
     code +=
         "  public " + struct_def.name + " __assign(int _i, ByteBuffer _bb) ";
     code += "{ __init(_i, _bb); return this; }\n\n";
@@ -1035,6 +1043,8 @@
                           ? index
                           : lang_.accessor_prefix + "__indirect(" + index + ")";
               code += ", " + lang_.accessor_prefix + "bb";
+            } else if (vectortype.base_type == BASE_TYPE_UNION) {
+              code += index + " - bb_pos";
             } else {
               code += index;
             }
diff --git a/src/idl_gen_grpc.cpp b/src/idl_gen_grpc.cpp
index 06ed765..d682a55 100644
--- a/src/idl_gen_grpc.cpp
+++ b/src/idl_gen_grpc.cpp
@@ -113,12 +113,12 @@
 
   int method_count() const {
     return static_cast<int>(service_->calls.vec.size());
-  };
+  }
 
   std::unique_ptr<const grpc_generator::Method> method(int i) const {
     return std::unique_ptr<const grpc_generator::Method>(
         new FlatBufMethod(service_->calls.vec[i]));
-  };
+  }
 
  private:
   const ServiceDef *service_;
@@ -235,7 +235,7 @@
 
   int service_count() const {
     return static_cast<int>(parser_.services_.vec.size());
-  };
+  }
 
   std::unique_ptr<const grpc_generator::Service> service(int i) const {
     return std::unique_ptr<const grpc_generator::Service>(
diff --git a/src/idl_gen_js_ts.cpp b/src/idl_gen_js_ts.cpp
index a2d40a4..ff248fc 100644
--- a/src/idl_gen_js_ts.cpp
+++ b/src/idl_gen_js_ts.cpp
@@ -77,9 +77,9 @@
       reexport_map;
 
   JsTsGenerator(const Parser &parser, const std::string &path,
-              const std::string &file_name)
+                const std::string &file_name)
       : BaseGenerator(parser, path, file_name, "", "."),
-        lang_(GetJsLangParams(parser_.opts.lang)){};
+        lang_(GetJsLangParams(parser_.opts.lang)) {}
   // Iterate through all definitions we haven't generate code for (enums,
   // structs, and tables) and output them to a single file.
   bool generate() {
@@ -105,10 +105,10 @@
 
     if (lang_.language == IDLOptions::kJs && !exports_code.empty() &&
         !parser_.opts.skip_js_exports) {
-        if( parser_.opts.use_ES6_js_export_format )
-            code += "// Exports for ECMAScript6 Modules\n";
-        else
-            code += "// Exports for Node.js and RequireJS\n";
+      if (parser_.opts.use_ES6_js_export_format)
+        code += "// Exports for ECMAScript6 Modules\n";
+      else
+        code += "// Exports for Node.js and RequireJS\n";
       code += exports_code;
     }
 
@@ -225,7 +225,7 @@
           code += "var ";
           if (parser_.opts.use_goog_js_export_format) {
             exports += "goog.exportSymbol('" + *it + "', " + *it + ");\n";
-          } else if( parser_.opts.use_ES6_js_export_format){
+          } else if (parser_.opts.use_ES6_js_export_format) {
             exports += "export {" + *it + "};\n";
           } else {
             exports += "this." + *it + " = " + *it + ";\n";
@@ -548,7 +548,9 @@
                                   const std::string &file) {
     const auto basename =
         flatbuffers::StripPath(flatbuffers::StripExtension(file));
-    if (basename == file_name_ || parser_.opts.generate_all) { return typeName; }
+    if (basename == file_name_ || parser_.opts.generate_all) {
+      return typeName;
+    }
     return GenFileNamespacePrefix(file) + "." + typeName;
   }
 
@@ -695,11 +697,11 @@
                         GenTypeAnnotation(kParam, object_name + "=", "obj") +
                         GenTypeAnnotation(kReturns, object_name, "", false));
       if (lang_.language == IDLOptions::kTs) {
-        code += "static getRootAs" + struct_def.name;
+        code += "static getRoot" + Verbose(struct_def, "As");
         code += "(bb:flatbuffers.ByteBuffer, obj?:" + object_name +
                 "):" + object_name + " {\n";
       } else {
-        code += object_name + ".getRootAs" + struct_def.name;
+        code += object_name + ".getRoot" + Verbose(struct_def, "As");
         code += " = function(bb, obj) {\n";
       }
       code += "  return (obj || new " + object_name;
@@ -763,6 +765,10 @@
                 GenPrefixedTypeName(GenTypeName(field.value.type, false, true),
                                     field.value.type.enum_def->file) +
                 " {\n";
+
+            if (!parser_.opts.generate_all) {
+              imported_files.insert(field.value.type.enum_def->file);
+            }
           } else {
             code += "):" + GenTypeName(field.value.type, false, true) + " {\n";
           }
@@ -876,7 +882,7 @@
                 code += prefix + ", obj?:" + vectortypename;
 
                 if (!parser_.opts.generate_all) {
-                    imported_files.insert(vectortype.struct_def->file);
+                  imported_files.insert(vectortype.struct_def->file);
                 }
               } else if (vectortype.base_type == BASE_TYPE_STRING) {
                 code += prefix + "):string\n";
@@ -1083,12 +1089,12 @@
                                                 "", false));
 
       if (lang_.language == IDLOptions::kTs) {
-        code +=
-            "static create" + struct_def.name + "(builder:flatbuffers.Builder";
+        code += "static create" + Verbose(struct_def) +
+                "(builder:flatbuffers.Builder";
         code += arguments + "):flatbuffers.Offset {\n";
       } else {
-        code +=
-            object_name + ".create" + struct_def.name + " = function(builder";
+        code += object_name + ".create" + Verbose(struct_def);
+        code += " = function(builder";
         code += arguments + ") {\n";
       }
 
@@ -1100,10 +1106,10 @@
                                                 "builder", false));
 
       if (lang_.language == IDLOptions::kTs) {
-        code += "static start" + struct_def.name;
-        code += "(builder:flatbuffers.Builder) {\n";
+        code += "static start" + Verbose(struct_def) +
+                "(builder:flatbuffers.Builder) {\n";
       } else {
-        code += object_name + ".start" + struct_def.name;
+        code += object_name + ".start" + Verbose(struct_def);
         code += " = function(builder) {\n";
       }
 
@@ -1127,8 +1133,8 @@
 
         if (lang_.language == IDLOptions::kTs) {
           code += "static add" + MakeCamel(field.name);
-          code += "(builder:flatbuffers.Builder, " + argname + ":" + GetArgType(field) +
-                  ") {\n";
+          code += "(builder:flatbuffers.Builder, " + argname + ":" +
+                  GetArgType(field) + ") {\n";
         } else {
           code += object_name + ".add" + MakeCamel(field.name);
           code += " = function(builder, " + argname + ") {\n";
@@ -1213,10 +1219,10 @@
               GenTypeAnnotation(kReturns, "flatbuffers.Offset", "", false));
 
       if (lang_.language == IDLOptions::kTs) {
-        code += "static end" + struct_def.name;
+        code += "static end" + Verbose(struct_def);
         code += "(builder:flatbuffers.Builder):flatbuffers.Offset {\n";
       } else {
-        code += object_name + ".end" + struct_def.name;
+        code += object_name + ".end" + Verbose(struct_def);
         code += " = function(builder) {\n";
       }
 
@@ -1242,11 +1248,11 @@
                                   false));
 
         if (lang_.language == IDLOptions::kTs) {
-          code += "static finish" + struct_def.name + "Buffer";
+          code += "static finish" + Verbose(struct_def) + "Buffer";
           code +=
               "(builder:flatbuffers.Builder, offset:flatbuffers.Offset) {\n";
         } else {
-          code += object_name + ".finish" + struct_def.name + "Buffer";
+          code += object_name + ".finish" + Verbose(struct_def) + "Buffer";
           code += " = function(builder, offset) {\n";
         }
 
@@ -1258,38 +1264,77 @@
         code += "};\n\n";
       }
 
-      if (lang_.language == IDLOptions::kTs) {
-          // Generate a convenient CreateX function
-          code += "static create" + struct_def.name + "(builder:flatbuffers.Builder";
-          for (auto it = struct_def.fields.vec.begin();
-               it != struct_def.fields.vec.end(); ++it) {
-            const auto &field = **it;
-            if (field.deprecated)
-              continue;
+      // Generate a convenient CreateX function
+      if (lang_.language == IDLOptions::kJs) {
+        std::string paramDoc =
+            GenTypeAnnotation(kParam, "flatbuffers.Builder", "builder");
+        for (auto it = struct_def.fields.vec.begin();
+             it != struct_def.fields.vec.end(); ++it) {
+          const auto &field = **it;
+          if (field.deprecated)
+            continue;
+          paramDoc +=
+              GenTypeAnnotation(kParam, GetArgType(field), GetArgName(field));
+        }
+        paramDoc +=
+            GenTypeAnnotation(kReturns, "flatbuffers.Offset", "", false);
 
-            code += ", " + GetArgName(field) + ":" + GetArgType(field);
-          }
-
-          code += "):flatbuffers.Offset {\n";
-          code += "  " + struct_def.name + ".start" + struct_def.name + "(builder);\n";
-
-          for (auto it = struct_def.fields.vec.begin();
-               it != struct_def.fields.vec.end(); ++it) {
-              const auto &field = **it;
-              if (field.deprecated)
-                continue;
-
-              code += "  " + struct_def.name + ".add" + MakeCamel(field.name) +"(";
-              code += "builder, " + GetArgName(field) + ");\n";
-          }
-
-          code += "  return " + struct_def.name + ".end" + struct_def.name + "(builder);\n";
-          code += "}\n";
+        GenDocComment(code_ptr, paramDoc);
       }
+
+      if (lang_.language == IDLOptions::kTs) {
+        code += "static create" + Verbose(struct_def);
+        code += "(builder:flatbuffers.Builder";
+      } else {
+        code += object_name + ".create" + Verbose(struct_def);
+        code += " = function(builder";
+      }
+      for (auto it = struct_def.fields.vec.begin();
+           it != struct_def.fields.vec.end(); ++it) {
+        const auto &field = **it;
+        if (field.deprecated)
+          continue;
+
+        if (lang_.language == IDLOptions::kTs) {
+          code += ", " + GetArgName(field) + ":" + GetArgType(field);
+        } else {
+          code += ", " + GetArgName(field);
+        }
+      }
+
+      if (lang_.language == IDLOptions::kTs) {
+        code += "):flatbuffers.Offset {\n";
+        code += "  " + struct_def.name + ".start" + Verbose(struct_def) +
+                "(builder);\n";
+      } else {
+        code += ") {\n";
+        code += "  " + object_name + ".start" + Verbose(struct_def) +
+                "(builder);\n";
+      }
+
+      std::string methodPrefix =
+          lang_.language == IDLOptions::kTs ? struct_def.name : object_name;
+      for (auto it = struct_def.fields.vec.begin();
+           it != struct_def.fields.vec.end(); ++it) {
+        const auto &field = **it;
+        if (field.deprecated)
+          continue;
+
+        code += "  " + methodPrefix + ".add" + MakeCamel(field.name) + "(";
+        code += "builder, " + GetArgName(field) + ");\n";
+      }
+
+      code += "  return " + methodPrefix + ".end" + Verbose(struct_def) +
+              "(builder);\n";
+      code += "}\n";
+      if (lang_.language == IDLOptions::kJs)
+        code += "\n";
     }
 
     if (lang_.language == IDLOptions::kTs) {
-      if (!object_namespace.empty()) { code += "}\n"; }
+      if (!object_namespace.empty()) {
+        code += "}\n";
+      }
       code += "}\n";
     }
   }
@@ -1302,22 +1347,28 @@
   }
 
   static std::string GetArgName(const FieldDef &field) {
-      auto argname = MakeCamel(field.name, false);
-      if (!IsScalar(field.value.type.base_type)) { argname += "Offset"; }
+    auto argname = MakeCamel(field.name, false);
+    if (!IsScalar(field.value.type.base_type)) { argname += "Offset"; }
 
-      return argname;
+    return argname;
+  }
+
+  std::string Verbose(const StructDef &struct_def,
+                      const char* prefix = "")
+  {
+    return parser_.opts.js_ts_short_names ? "" : prefix + struct_def.name;
   }
 };
 }  // namespace jsts
 
 bool GenerateJSTS(const Parser &parser, const std::string &path,
-                const std::string &file_name) {
+                  const std::string &file_name) {
   jsts::JsTsGenerator generator(parser, path, file_name);
   return generator.generate();
 }
 
 std::string JSTSMakeRule(const Parser &parser, const std::string &path,
-                       const std::string &file_name) {
+                         const std::string &file_name) {
   FLATBUFFERS_ASSERT(parser.opts.lang <= IDLOptions::kMAX);
   const auto &lang = GetJsLangParams(parser.opts.lang);
 
diff --git a/src/idl_gen_php.cpp b/src/idl_gen_php.cpp
index ae56754..3c6747e 100644
--- a/src/idl_gen_php.cpp
+++ b/src/idl_gen_php.cpp
@@ -31,7 +31,7 @@
  public:
   PhpGenerator(const Parser &parser, const std::string &path,
                const std::string &file_name)
-      : BaseGenerator(parser, path, file_name, "\\", "\\"){};
+      : BaseGenerator(parser, path, file_name, "\\", "\\") {}
   bool generate() {
     if (!GenerateEnums()) return false;
     if (!GenerateStructs()) return false;
@@ -828,7 +828,7 @@
     for (auto it = enum_def.vals.vec.begin(); it != enum_def.vals.vec.end();
          ++it) {
       auto &ev = **it;
-      code += Indent + Indent + "\"" + ev.name + "\",\n";
+      code += Indent + Indent + enum_def.name + "::" + ev.name + "=>" + "\"" + ev.name + "\",\n";
     }
 
     code += Indent + ");\n\n";
diff --git a/src/idl_gen_rust.cpp b/src/idl_gen_rust.cpp
index b530137..fd6a066 100644
--- a/src/idl_gen_rust.cpp
+++ b/src/idl_gen_rust.cpp
@@ -130,6 +130,7 @@
       case ftUnionKey:
       case ftUnionValue: {
         FLATBUFFERS_ASSERT(false && "vectors of unions are unsupported");
+        break;
       }
       default: {
         FLATBUFFERS_ASSERT(false && "vector of vectors are unsupported");
@@ -298,6 +299,11 @@
 
     assert(!cur_name_space_);
 
+    // Generate imports for the global scope in case no namespace is used
+    // in the schema file.
+    GenNamespaceImports(0);
+    code_ += "";
+
     // Generate all code in their namespaces, once, because Rust does not
     // permit re-opening modules.
     //
@@ -1325,8 +1331,8 @@
 
         code_ += "  #[inline]";
         code_ += "  #[allow(non_snake_case)]";
-        code_ += "  pub fn {{FIELD_NAME}}_as_{{U_ELEMENT_NAME}}(&'a self) -> "
-                 "Option<{{U_ELEMENT_TABLE_TYPE}}> {";
+        code_ += "  pub fn {{FIELD_NAME}}_as_{{U_ELEMENT_NAME}}(&self) -> "
+                 "Option<{{U_ELEMENT_TABLE_TYPE}}<'a>> {";
         code_ += "    if self.{{FIELD_NAME}}_type() == {{U_ELEMENT_ENUM_TYPE}} {";
         code_ += "      self.{{FIELD_NAME}}().map(|u| "
                  "{{U_ELEMENT_TABLE_TYPE}}::init_from_table(u))";
@@ -1740,6 +1746,18 @@
     code_ += "";
   }
 
+  void GenNamespaceImports(const int white_spaces) {
+      std::string indent = std::string(white_spaces, ' ');
+      code_ += indent + "#![allow(dead_code)]";
+      code_ += indent + "#![allow(unused_imports)]";
+      code_ += "";
+      code_ += indent + "use std::mem;";
+      code_ += indent + "use std::cmp::Ordering;";
+      code_ += "";
+      code_ += indent + "extern crate flatbuffers;";
+      code_ += indent + "use self::flatbuffers::EndianScalar;";
+  }
+
   // Set up the correct namespace. This opens a namespace if the current
   // namespace is different from the target namespace. This function
   // closes and opens the namespaces only as necessary.
@@ -1774,14 +1792,8 @@
     // in the previous example, E, then F, then G are opened
     for (auto j = common_prefix_size; j != new_size; ++j) {
       code_ += "pub mod " + MakeSnakeCase(ns->components[j]) + " {";
-      code_ += "  #![allow(dead_code)]";
-      code_ += "  #![allow(unused_imports)]";
-      code_ += "";
-      code_ += "  use std::mem;";
-      code_ += "  use std::cmp::Ordering;";
-      code_ += "";
-      code_ += "  extern crate flatbuffers;";
-      code_ += "  use self::flatbuffers::EndianScalar;";
+      // Generate local namespace imports.
+      GenNamespaceImports(2);
     }
     if (new_size != common_prefix_size) { code_ += ""; }
 
diff --git a/src/idl_gen_text.cpp b/src/idl_gen_text.cpp
index c129488..fb75a79 100644
--- a/src/idl_gen_text.cpp
+++ b/src/idl_gen_text.cpp
@@ -119,7 +119,7 @@
       break;
     case BASE_TYPE_STRING: {
       auto s = reinterpret_cast<const String *>(val);
-      if (!EscapeString(s->c_str(), s->Length(), _text, opts.allow_non_utf8,
+      if (!EscapeString(s->c_str(), s->size(), _text, opts.allow_non_utf8,
                         opts.natural_utf8)) {
         return false;
       }
diff --git a/src/idl_parser.cpp b/src/idl_parser.cpp
index 698c9ab..3a8165f 100644
--- a/src/idl_parser.cpp
+++ b/src/idl_parser.cpp
@@ -94,7 +94,7 @@
 void DeserializeDoc( std::vector<std::string> &doc,
                      const Vector<Offset<String>> *documentation) {
   if (documentation == nullptr) return;
-  for (uoffset_t index = 0; index < documentation->Length(); index++)
+  for (uoffset_t index = 0; index < documentation->size(); index++)
     doc.push_back(documentation->Get(index)->str());
 }
 
@@ -411,10 +411,8 @@
           }
           cursor_ += 2;
           break;
-        } else {
-          // fall thru
         }
-        FLATBUFFERS_ATTRIBUTE(fallthrough);
+        FLATBUFFERS_FALLTHROUGH(); // else fall thru
       default:
         const auto has_sign = (c == '+') || (c == '-');
         // '-'/'+' and following identifier - can be a predefined constant like:
@@ -430,7 +428,7 @@
 
         auto dot_lvl = (c == '.') ? 0 : 1;  // dot_lvl==0 <=> exactly one '.' seen
         if (!dot_lvl && !is_digit(*cursor_)) return NoError(); // enum?
-        // Parser accepts hexadecimal-floating-literal (see C++ 5.13.4).
+        // Parser accepts hexadecimal-floating-literal (see C++ 5.13.4).
         if (is_digit(c) || has_sign || !dot_lvl) {
           const auto start = cursor_ - 1;
           auto start_digits = !is_digit(c) ? cursor_ : cursor_ - 1;
@@ -769,6 +767,9 @@
         return Error("'key' field must be string or scalar type");
     }
   }
+  field->shared = field->attributes.Lookup("shared") != nullptr;
+  if (field->shared && field->value.type.base_type != BASE_TYPE_STRING)
+    return Error("shared can only be defined on strings");
 
   auto field_native_custom_alloc =
       field->attributes.Lookup("native_custom_alloc");
@@ -779,7 +780,7 @@
 
   field->native_inline = field->attributes.Lookup("native_inline") != nullptr;
   if (field->native_inline && !IsStruct(field->value.type))
-    return Error("native_inline can only be defined on structs'");
+    return Error("native_inline can only be defined on structs");
 
   auto nested = field->attributes.Lookup("nested_flatbuffer");
   if (nested) {
@@ -1215,8 +1216,15 @@
     nested_parser.uses_flexbuffers_ = uses_flexbuffers_;
 
     // Parse JSON substring into new flatbuffer builder using nested_parser
-    if (!nested_parser.Parse(substring.c_str(), nullptr, nullptr)) {
-      ECHECK(Error(nested_parser.error_));
+    bool ok = nested_parser.Parse(substring.c_str(), nullptr, nullptr);
+
+    // Clean nested_parser to avoid deleting the elements in
+    // the SymbolTables on destruction
+    nested_parser.enums_.dict.clear();
+    nested_parser.enums_.vec.clear();
+
+    if (!ok) {
+      ECHECK(Error(nested_parser.error_)); 
     }
     // Force alignment for nested flatbuffer
     builder_.ForceVectorAlignment(nested_parser.builder_.GetSize(), sizeof(uint8_t),
@@ -1225,11 +1233,6 @@
     auto off = builder_.CreateVector(nested_parser.builder_.GetBufferPointer(),
                                      nested_parser.builder_.GetSize());
     val.constant = NumToString(off.o);
-
-    // Clean nested_parser before destruction to avoid deleting the elements in
-    // the SymbolTables
-    nested_parser.enums_.dict.clear();
-    nested_parser.enums_.vec.clear();
   }
   return NoError();
 }
@@ -2755,8 +2758,8 @@
   predecl = false;
   sortbysize = attributes.Lookup("original_order") == nullptr && !fixed;
   std::vector<uoffset_t> indexes =
-    std::vector<uoffset_t>(object->fields()->Length());
-  for (uoffset_t i = 0; i < object->fields()->Length(); i++)
+    std::vector<uoffset_t>(object->fields()->size());
+  for (uoffset_t i = 0; i < object->fields()->size(); i++)
     indexes[object->fields()->Get(i)->id()] = i;
   for (size_t i = 0; i < indexes.size(); i++) {
     auto field = object->fields()->Get(indexes[i]);
diff --git a/src/reflection.cpp b/src/reflection.cpp
index 61c1ba7..89ce783 100644
--- a/src/reflection.cpp
+++ b/src/reflection.cpp
@@ -299,13 +299,13 @@
 void SetString(const reflection::Schema &schema, const std::string &val,
                const String *str, std::vector<uint8_t> *flatbuf,
                const reflection::Object *root_table) {
-  auto delta = static_cast<int>(val.size()) - static_cast<int>(str->Length());
+  auto delta = static_cast<int>(val.size()) - static_cast<int>(str->size());
   auto str_start = static_cast<uoffset_t>(
       reinterpret_cast<const uint8_t *>(str) - vector_data(*flatbuf));
   auto start = str_start + static_cast<uoffset_t>(sizeof(uoffset_t));
   if (delta) {
     // Clear the old string, since we don't want parts of it remaining.
-    memset(vector_data(*flatbuf) + start, 0, str->Length());
+    memset(vector_data(*flatbuf) + start, 0, str->size());
     // Different size, we must expand (or contract).
     ResizeContext(schema, start, delta, flatbuf, root_table);
     // Set the new length.
@@ -431,7 +431,7 @@
               break;
             }
           }
-          // FALL-THRU
+          FLATBUFFERS_FALLTHROUGH(); // fall thru
           default: {  // Scalars and structs.
             auto element_size = GetTypeSize(element_base_type);
             if (elemobjectdef && elemobjectdef->is_struct())
@@ -466,7 +466,7 @@
           break;
         }
       }
-      // ELSE FALL-THRU
+      FLATBUFFERS_FALLTHROUGH(); // fall thru
       case reflection::Union:
       case reflection::String:
       case reflection::Vector:
diff --git a/tests/FlatBuffers.Benchmarks/FlatBufferBuilderBenchmark.cs b/tests/FlatBuffers.Benchmarks/FlatBufferBuilderBenchmark.cs
new file mode 100644
index 0000000..1df5ac3
--- /dev/null
+++ b/tests/FlatBuffers.Benchmarks/FlatBufferBuilderBenchmark.cs
@@ -0,0 +1,101 @@
+/*
+ * Copyright 2014 Google Inc. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using BenchmarkDotNet.Attributes;
+using MyGame.Example;
+
+namespace FlatBuffers.Benchmarks
+{
+    //[EtwProfiler] - needs elevated privileges
+    [MemoryDiagnoser]
+    public class FlatBufferBuilderBenchmark
+    {
+        private const int NumberOfRows = 10_000;
+
+        [Benchmark]
+        public void BuildNestedMonster()
+        {
+            const string nestedMonsterName = "NestedMonsterName";
+            const short nestedMonsterHp = 600;
+            const short nestedMonsterMana = 1024;
+
+            for (int i = 0; i < NumberOfRows; i++)
+            {
+                // Create nested buffer as a Monster type
+                var fbb1 = new FlatBufferBuilder(16);
+                var str1 = fbb1.CreateString(nestedMonsterName);
+                Monster.StartMonster(fbb1);
+                Monster.AddName(fbb1, str1);
+                Monster.AddHp(fbb1, nestedMonsterHp);
+                Monster.AddMana(fbb1, nestedMonsterMana);
+                var monster1 = Monster.EndMonster(fbb1);
+                Monster.FinishMonsterBuffer(fbb1, monster1);
+                var fbb1Bytes = fbb1.SizedByteArray();
+                fbb1 = null;
+
+                // Create a Monster which has the first buffer as a nested buffer
+                var fbb2 = new FlatBufferBuilder(16);
+                var str2 = fbb2.CreateString("My Monster");
+                var nestedBuffer = Monster.CreateTestnestedflatbufferVector(fbb2, fbb1Bytes);
+                Monster.StartMonster(fbb2);
+                Monster.AddName(fbb2, str2);
+                Monster.AddHp(fbb2, 50);
+                Monster.AddMana(fbb2, 32);
+                Monster.AddTestnestedflatbuffer(fbb2, nestedBuffer);
+                var monster = Monster.EndMonster(fbb2);
+                Monster.FinishMonsterBuffer(fbb2, monster);
+            }
+        }
+
+        [Benchmark]
+        public void BuildMonster()
+        {
+            for (int i = 0; i < NumberOfRows; i++)
+            {
+                var builder = new FlatBufferBuilder(16);
+                var str1 = builder.CreateString("MonsterName");
+                Monster.StartMonster(builder);
+                Monster.AddName(builder, str1);
+                Monster.AddHp(builder, 600);
+                Monster.AddMana(builder, 1024);
+                Monster.AddColor(builder, Color.Blue);
+                Monster.AddTestbool(builder, true);
+                Monster.AddTestf(builder, 0.3f);
+                Monster.AddTestf2(builder, 0.2f);
+                Monster.AddTestf3(builder, 0.1f);
+
+                var monster1 = Monster.EndMonster(builder);
+                Monster.FinishMonsterBuffer(builder, monster1);
+            }
+        }
+
+        [Benchmark]
+        public void TestTables()
+        {
+            FlatBufferBuilder builder = new FlatBufferBuilder(1024 * 1024 * 32);
+            for (int x = 0; x < 500000; ++x)
+            {
+                var offset = builder.CreateString("T");
+                builder.StartObject(4);
+                builder.AddDouble(3.2);
+                builder.AddDouble(4.2);
+                builder.AddDouble(5.2);
+                builder.AddOffset(offset.Value);
+                builder.EndObject();
+            }
+        }
+    }
+}
diff --git a/tests/FlatBuffers.Benchmarks/FlatBuffers.Benchmarks.csproj b/tests/FlatBuffers.Benchmarks/FlatBuffers.Benchmarks.csproj
new file mode 100644
index 0000000..b900384
--- /dev/null
+++ b/tests/FlatBuffers.Benchmarks/FlatBuffers.Benchmarks.csproj
@@ -0,0 +1,21 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <OutputType>Exe</OutputType>
+    <TargetFramework>netcoreapp2.1</TargetFramework>
+    <LangVersion>latest</LangVersion>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <DefineConstants>$(DefineConstants);UNSAFE_BYTEBUFFER;BYTEBUFFER_NO_BOUNDS_CHECK;ENABLE_SPAN_T</DefineConstants>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <PackageReference Include="BenchmarkDotNet" Version="0.11.3" />
+    <PackageReference Include="BenchmarkDotNet.Diagnostics.Windows" Version="0.11.3" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <Compile Include="..\..\net\FlatBuffers\*.cs" Link="FlatBuffers\%(FileName).cs" />
+    <Compile Include="..\MyGame\**\*.cs" Link="MyGame\Example\%(FileName).cs" />
+  </ItemGroup>
+
+</Project>
diff --git a/tests/FlatBuffers.Benchmarks/Program.cs b/tests/FlatBuffers.Benchmarks/Program.cs
new file mode 100644
index 0000000..9e63b4b
--- /dev/null
+++ b/tests/FlatBuffers.Benchmarks/Program.cs
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2014 Google Inc. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using BenchmarkDotNet.Running;
+
+namespace FlatBuffers.Benchmarks
+{
+    public static class Program
+    {
+        public static void Main(string[] args)
+        {
+            BenchmarkSwitcher
+                .FromAssembly(typeof(Program).Assembly)
+                .Run(args);
+        }
+    }
+}
\ No newline at end of file
diff --git a/tests/FlatBuffers.Test/FlatBuffers.Test.csproj b/tests/FlatBuffers.Test/FlatBuffers.Test.csproj
index 7510f9d..bbba231 100644
--- a/tests/FlatBuffers.Test/FlatBuffers.Test.csproj
+++ b/tests/FlatBuffers.Test/FlatBuffers.Test.csproj
@@ -31,6 +31,10 @@
   <PropertyGroup>
     <StartupObject />
   </PropertyGroup>
+  <PropertyGroup Condition="'$(UnsafeByteBuffer)' == 'true'">
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+    <DefineConstants>$(DefineConstants);UNSAFE_BYTEBUFFER</DefineConstants>
+  </PropertyGroup>
   <ItemGroup>
     <Reference Include="System" />
     <Reference Include="System.Core">
diff --git a/tests/FlatBuffers.Test/FlatBuffersExampleTests.cs b/tests/FlatBuffers.Test/FlatBuffersExampleTests.cs
index 1a8a081..a670b19 100644
--- a/tests/FlatBuffers.Test/FlatBuffersExampleTests.cs
+++ b/tests/FlatBuffers.Test/FlatBuffersExampleTests.cs
@@ -258,7 +258,7 @@
             }
             else
             {
-                Assert.IsTrue(monster.GetTestarrayofboolsBytes().Length == 0);
+                Assert.IsTrue(monster.GetTestarrayofboolsBytes().Length != 0);
             }
 #else
             var nameBytes = monster.GetNameBytes().Value;
diff --git a/tests/JavaTest.bat b/tests/JavaTest.bat
index aa72613..921815a 100644
--- a/tests/JavaTest.bat
+++ b/tests/JavaTest.bat
@@ -17,5 +17,5 @@
 
 set batch_file_dir=%~d0%~p0
 
-javac -g -classpath %batch_file_dir%\..\java;%batch_file_dir%;%batch_file_dir%\namespace_test JavaTest.java
-java -classpath %batch_file_dir%\..\java;%batch_file_dir%;%batch_file_dir%\namespace_test JavaTest
+javac -g -classpath %batch_file_dir%\..\java;%batch_file_dir%;%batch_file_dir%\namespace_test;%batch_file_dir%\union_vector JavaTest.java
+java -classpath %batch_file_dir%\..\java;%batch_file_dir%;%batch_file_dir%\namespace_test;%batch_file_dir%\union_vector JavaTest
diff --git a/tests/JavaTest.java b/tests/JavaTest.java
index 7d96f06..1a9b701 100644
--- a/tests/JavaTest.java
+++ b/tests/JavaTest.java
@@ -73,6 +73,8 @@
 
         TestSizedInputStream();
 
+        TestVectorOfUnions();
+
         System.out.println("FlatBuffers test: completed successfully");
     }
 
@@ -232,7 +234,7 @@
     }
 
     static void TestByteBufferFactory() {
-        final class MappedByteBufferFactory implements FlatBufferBuilder.ByteBufferFactory {
+        final class MappedByteBufferFactory extends FlatBufferBuilder.ByteBufferFactory {
             @Override
             public ByteBuffer newByteBuffer(int capacity) {
                 ByteBuffer bb;
@@ -415,6 +417,40 @@
         TestEq(pos.x(), 1.0f);
     }
 
+    static void TestVectorOfUnions() {
+        final FlatBufferBuilder fbb = new FlatBufferBuilder();
+
+        final int swordAttackDamage = 1;
+
+        final int[] characterVector = new int[] {
+            Attacker.createAttacker(fbb, swordAttackDamage),
+        };
+
+        final byte[] characterTypeVector = new byte[]{
+            Character.MuLan,
+        };
+
+        Movie.finishMovieBuffer(
+            fbb,
+            Movie.createMovie(
+                fbb,
+                (byte)0,
+                (byte)0,
+                Movie.createCharactersTypeVector(fbb, characterTypeVector),
+                Movie.createCharactersVector(fbb, characterVector)
+            )
+        );
+
+        final Movie movie = Movie.getRootAsMovie(fbb.dataBuffer());
+
+        TestEq(movie.charactersTypeLength(), characterTypeVector.length);
+        TestEq(movie.charactersLength(), characterVector.length);
+
+        TestEq(movie.charactersType(0), characterTypeVector[0]);
+
+        TestEq(((Attacker)movie.characters(new Attacker(), 0)).swordAttackDamage(), swordAttackDamage);
+    }
+
     static <T> void TestEq(T a, T b) {
         if (!a.equals(b)) {
             System.out.println("" + a.getClass().getName() + " " + b.getClass().getName());
diff --git a/tests/JavaTest.sh b/tests/JavaTest.sh
index a5a049e..58d8442 100755
--- a/tests/JavaTest.sh
+++ b/tests/JavaTest.sh
@@ -36,7 +36,7 @@
     exit 1
 fi
 
-javac -d "${targetdir}" -classpath "${testdir}/../java:${testdir}:${testdir}/namespace_test" "${testdir}/JavaTest.java"
+javac -d "${targetdir}" -classpath "${testdir}/../java:${testdir}:${testdir}/namespace_test:${testdir}/union_vector" "${testdir}/JavaTest.java"
 
 (cd "${testdir}" && java -classpath "${targetdir}" JavaTest )
 
diff --git a/tests/MyGame/Example/Ability.java b/tests/MyGame/Example/Ability.java
index 0bd614c..5e1c90e 100644
--- a/tests/MyGame/Example/Ability.java
+++ b/tests/MyGame/Example/Ability.java
@@ -7,7 +7,8 @@
 import java.util.*;
 import com.google.flatbuffers.*;
 
-@SuppressWarnings("unused")public final class Ability extends Struct {
+@SuppressWarnings("unused")
+public final class Ability extends Struct {
   public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; }
   public Ability __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
 
diff --git a/tests/MyGame/Example/Any.php b/tests/MyGame/Example/Any.php
index da69176..929caaf 100644
--- a/tests/MyGame/Example/Any.php
+++ b/tests/MyGame/Example/Any.php
@@ -11,10 +11,10 @@
     const MyGame_Example2_Monster = 3;
 
     private static $names = array(
-        "NONE",
-        "Monster",
-        "TestSimpleTableWithEnum",
-        "MyGame_Example2_Monster",
+        Any::NONE=>"NONE",
+        Any::Monster=>"Monster",
+        Any::TestSimpleTableWithEnum=>"TestSimpleTableWithEnum",
+        Any::MyGame_Example2_Monster=>"MyGame_Example2_Monster",
     );
 
     public static function Name($e)
diff --git a/tests/MyGame/Example/AnyAmbiguousAliases.php b/tests/MyGame/Example/AnyAmbiguousAliases.php
index 8d82462..13d318a 100644
--- a/tests/MyGame/Example/AnyAmbiguousAliases.php
+++ b/tests/MyGame/Example/AnyAmbiguousAliases.php
@@ -11,10 +11,10 @@
     const M3 = 3;
 
     private static $names = array(
-        "NONE",
-        "M1",
-        "M2",
-        "M3",
+        AnyAmbiguousAliases::NONE=>"NONE",
+        AnyAmbiguousAliases::M1=>"M1",
+        AnyAmbiguousAliases::M2=>"M2",
+        AnyAmbiguousAliases::M3=>"M3",
     );
 
     public static function Name($e)
diff --git a/tests/MyGame/Example/AnyUniqueAliases.php b/tests/MyGame/Example/AnyUniqueAliases.php
index 5d51f82..fe551cc 100644
--- a/tests/MyGame/Example/AnyUniqueAliases.php
+++ b/tests/MyGame/Example/AnyUniqueAliases.php
@@ -11,10 +11,10 @@
     const M2 = 3;
 
     private static $names = array(
-        "NONE",
-        "M",
-        "T",
-        "M2",
+        AnyUniqueAliases::NONE=>"NONE",
+        AnyUniqueAliases::M=>"M",
+        AnyUniqueAliases::T=>"T",
+        AnyUniqueAliases::M2=>"M2",
     );
 
     public static function Name($e)
diff --git a/tests/MyGame/Example/Color.php b/tests/MyGame/Example/Color.php
index 70c7bfd..d89529e 100644
--- a/tests/MyGame/Example/Color.php
+++ b/tests/MyGame/Example/Color.php
@@ -10,9 +10,9 @@
     const Blue = 8;
 
     private static $names = array(
-        "Red",
-        "Green",
-        "Blue",
+        Color::Red=>"Red",
+        Color::Green=>"Green",
+        Color::Blue=>"Blue",
     );
 
     public static function Name($e)
diff --git a/tests/MyGame/Example/Monster.java b/tests/MyGame/Example/Monster.java
index 6feddb3..848f9a7 100644
--- a/tests/MyGame/Example/Monster.java
+++ b/tests/MyGame/Example/Monster.java
@@ -7,14 +7,15 @@
 import java.util.*;
 import com.google.flatbuffers.*;
 
-@SuppressWarnings("unused")/**
+@SuppressWarnings("unused")
+/**
  * an example documentation comment: monster object
  */
 public final class Monster extends Table {
   public static Monster getRootAsMonster(ByteBuffer _bb) { return getRootAsMonster(_bb, new Monster()); }
   public static Monster getRootAsMonster(ByteBuffer _bb, Monster obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
   public static boolean MonsterBufferHasIdentifier(ByteBuffer _bb) { return __has_identifier(_bb, "MONS"); }
-  public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; }
+  public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; vtable_start = bb_pos - bb.getInt(bb_pos); vtable_size = bb.getShort(vtable_start); }
   public Monster __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
 
   public Vec3 pos() { return pos(new Vec3()); }
diff --git a/tests/MyGame/Example/Referrable.java b/tests/MyGame/Example/Referrable.java
index e164256..6a11745 100644
--- a/tests/MyGame/Example/Referrable.java
+++ b/tests/MyGame/Example/Referrable.java
@@ -7,10 +7,11 @@
 import java.util.*;
 import com.google.flatbuffers.*;
 
-@SuppressWarnings("unused")public final class Referrable extends Table {
+@SuppressWarnings("unused")
+public final class Referrable extends Table {
   public static Referrable getRootAsReferrable(ByteBuffer _bb) { return getRootAsReferrable(_bb, new Referrable()); }
   public static Referrable getRootAsReferrable(ByteBuffer _bb, Referrable obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
-  public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; }
+  public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; vtable_start = bb_pos - bb.getInt(bb_pos); vtable_size = bb.getShort(vtable_start); }
   public Referrable __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
 
   public long id() { int o = __offset(4); return o != 0 ? bb.getLong(o + bb_pos) : 0L; }
diff --git a/tests/MyGame/Example/Stat.java b/tests/MyGame/Example/Stat.java
index 8f48036..c995eb1 100644
--- a/tests/MyGame/Example/Stat.java
+++ b/tests/MyGame/Example/Stat.java
@@ -7,10 +7,11 @@
 import java.util.*;
 import com.google.flatbuffers.*;
 
-@SuppressWarnings("unused")public final class Stat extends Table {
+@SuppressWarnings("unused")
+public final class Stat extends Table {
   public static Stat getRootAsStat(ByteBuffer _bb) { return getRootAsStat(_bb, new Stat()); }
   public static Stat getRootAsStat(ByteBuffer _bb, Stat obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
-  public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; }
+  public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; vtable_start = bb_pos - bb.getInt(bb_pos); vtable_size = bb.getShort(vtable_start); }
   public Stat __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
 
   public String id() { int o = __offset(4); return o != 0 ? __string(o + bb_pos) : null; }
diff --git a/tests/MyGame/Example/Test.java b/tests/MyGame/Example/Test.java
index 34b095a..f584c46 100644
--- a/tests/MyGame/Example/Test.java
+++ b/tests/MyGame/Example/Test.java
@@ -7,7 +7,8 @@
 import java.util.*;
 import com.google.flatbuffers.*;
 
-@SuppressWarnings("unused")public final class Test extends Struct {
+@SuppressWarnings("unused")
+public final class Test extends Struct {
   public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; }
   public Test __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
 
diff --git a/tests/MyGame/Example/TestSimpleTableWithEnum.java b/tests/MyGame/Example/TestSimpleTableWithEnum.java
index 545c0ad..974e44e 100644
--- a/tests/MyGame/Example/TestSimpleTableWithEnum.java
+++ b/tests/MyGame/Example/TestSimpleTableWithEnum.java
@@ -7,10 +7,11 @@
 import java.util.*;
 import com.google.flatbuffers.*;
 
-@SuppressWarnings("unused")final class TestSimpleTableWithEnum extends Table {
+@SuppressWarnings("unused")
+final class TestSimpleTableWithEnum extends Table {
   public static TestSimpleTableWithEnum getRootAsTestSimpleTableWithEnum(ByteBuffer _bb) { return getRootAsTestSimpleTableWithEnum(_bb, new TestSimpleTableWithEnum()); }
   public static TestSimpleTableWithEnum getRootAsTestSimpleTableWithEnum(ByteBuffer _bb, TestSimpleTableWithEnum obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
-  public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; }
+  public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; vtable_start = bb_pos - bb.getInt(bb_pos); vtable_size = bb.getShort(vtable_start); }
   public TestSimpleTableWithEnum __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
 
   public byte color() { int o = __offset(4); return o != 0 ? bb.get(o + bb_pos) : 2; }
diff --git a/tests/MyGame/Example/TypeAliases.java b/tests/MyGame/Example/TypeAliases.java
index 497d776..cccb722 100644
--- a/tests/MyGame/Example/TypeAliases.java
+++ b/tests/MyGame/Example/TypeAliases.java
@@ -7,10 +7,11 @@
 import java.util.*;
 import com.google.flatbuffers.*;
 
-@SuppressWarnings("unused")public final class TypeAliases extends Table {
+@SuppressWarnings("unused")
+public final class TypeAliases extends Table {
   public static TypeAliases getRootAsTypeAliases(ByteBuffer _bb) { return getRootAsTypeAliases(_bb, new TypeAliases()); }
   public static TypeAliases getRootAsTypeAliases(ByteBuffer _bb, TypeAliases obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
-  public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; }
+  public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; vtable_start = bb_pos - bb.getInt(bb_pos); vtable_size = bb.getShort(vtable_start); }
   public TypeAliases __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
 
   public byte i8() { int o = __offset(4); return o != 0 ? bb.get(o + bb_pos) : 0; }
diff --git a/tests/MyGame/Example/Vec3.cs b/tests/MyGame/Example/Vec3.cs
index e1669f9..b0f95a0 100644
--- a/tests/MyGame/Example/Vec3.cs
+++ b/tests/MyGame/Example/Vec3.cs
@@ -28,7 +28,7 @@
   public Test Test3 { get { return (new Test()).__assign(__p.bb_pos + 26, __p.bb); } }
 
   public static Offset<Vec3> CreateVec3(FlatBufferBuilder builder, float X, float Y, float Z, double Test1, Color Test2, short test3_A, sbyte test3_B) {
-    builder.Prep(16, 32);
+    builder.Prep(8, 32);
     builder.Pad(2);
     builder.Prep(2, 4);
     builder.Pad(1);
diff --git a/tests/MyGame/Example/Vec3.go b/tests/MyGame/Example/Vec3.go
index 658bac7..520b9cc 100644
--- a/tests/MyGame/Example/Vec3.go
+++ b/tests/MyGame/Example/Vec3.go
@@ -63,7 +63,7 @@
 }
 
 func CreateVec3(builder *flatbuffers.Builder, x float32, y float32, z float32, test1 float64, test2 int8, test3_a int16, test3_b int8) flatbuffers.UOffsetT {
-	builder.Prep(16, 32)
+	builder.Prep(8, 32)
 	builder.Pad(2)
 	builder.Prep(2, 4)
 	builder.Pad(1)
diff --git a/tests/MyGame/Example/Vec3.java b/tests/MyGame/Example/Vec3.java
index ecd65c7..2e43f05 100644
--- a/tests/MyGame/Example/Vec3.java
+++ b/tests/MyGame/Example/Vec3.java
@@ -7,7 +7,8 @@
 import java.util.*;
 import com.google.flatbuffers.*;
 
-@SuppressWarnings("unused")public final class Vec3 extends Struct {
+@SuppressWarnings("unused")
+public final class Vec3 extends Struct {
   public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; }
   public Vec3 __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
 
@@ -25,7 +26,7 @@
   public Test test3(Test obj) { return obj.__assign(bb_pos + 26, bb); }
 
   public static int createVec3(FlatBufferBuilder builder, float x, float y, float z, double test1, byte test2, short test3_a, byte test3_b) {
-    builder.prep(16, 32);
+    builder.prep(8, 32);
     builder.pad(2);
     builder.prep(2, 4);
     builder.pad(1);
diff --git a/tests/MyGame/Example/Vec3.lua b/tests/MyGame/Example/Vec3.lua
index ff7d13c..85e02d7 100644
--- a/tests/MyGame/Example/Vec3.lua
+++ b/tests/MyGame/Example/Vec3.lua
@@ -35,7 +35,7 @@
     return obj
 end
 function Vec3.CreateVec3(builder, x, y, z, test1, test2, test3_a, test3_b)
-    builder:Prep(16, 32)
+    builder:Prep(8, 32)
     builder:Pad(2)
     builder:Prep(2, 4)
     builder:Pad(1)
diff --git a/tests/MyGame/Example/Vec3.php b/tests/MyGame/Example/Vec3.php
index ab1a827..288c183 100644
--- a/tests/MyGame/Example/Vec3.php
+++ b/tests/MyGame/Example/Vec3.php
@@ -78,7 +78,7 @@
      */
     public static function createVec3(FlatBufferBuilder $builder, $x, $y, $z, $test1, $test2, $test3_a, $test3_b)
     {
-        $builder->prep(16, 32);
+        $builder->prep(8, 32);
         $builder->pad(2);
         $builder->prep(2, 4);
         $builder->pad(1);
diff --git a/tests/MyGame/Example/Vec3.py b/tests/MyGame/Example/Vec3.py
index a354773..20399ed 100644
--- a/tests/MyGame/Example/Vec3.py
+++ b/tests/MyGame/Example/Vec3.py
@@ -28,7 +28,7 @@
 
 
 def CreateVec3(builder, x, y, z, test1, test2, test3_a, test3_b):
-    builder.Prep(16, 32)
+    builder.Prep(8, 32)
     builder.Pad(2)
     builder.Prep(2, 4)
     builder.Pad(1)
diff --git a/tests/MyGame/Example2/Monster.java b/tests/MyGame/Example2/Monster.java
index 433d4c5..f65e7d4 100644
--- a/tests/MyGame/Example2/Monster.java
+++ b/tests/MyGame/Example2/Monster.java
@@ -7,10 +7,11 @@
 import java.util.*;
 import com.google.flatbuffers.*;
 
-@SuppressWarnings("unused")public final class Monster extends Table {
+@SuppressWarnings("unused")
+public final class Monster extends Table {
   public static Monster getRootAsMonster(ByteBuffer _bb) { return getRootAsMonster(_bb, new Monster()); }
   public static Monster getRootAsMonster(ByteBuffer _bb, Monster obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
-  public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; }
+  public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; vtable_start = bb_pos - bb.getInt(bb_pos); vtable_size = bb.getShort(vtable_start); }
   public Monster __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
 
 
diff --git a/tests/MyGame/InParentNamespace.java b/tests/MyGame/InParentNamespace.java
index f933fb9..42784b7 100644
--- a/tests/MyGame/InParentNamespace.java
+++ b/tests/MyGame/InParentNamespace.java
@@ -7,10 +7,11 @@
 import java.util.*;
 import com.google.flatbuffers.*;
 
-@SuppressWarnings("unused")public final class InParentNamespace extends Table {
+@SuppressWarnings("unused")
+public final class InParentNamespace extends Table {
   public static InParentNamespace getRootAsInParentNamespace(ByteBuffer _bb) { return getRootAsInParentNamespace(_bb, new InParentNamespace()); }
   public static InParentNamespace getRootAsInParentNamespace(ByteBuffer _bb, InParentNamespace obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
-  public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; }
+  public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; vtable_start = bb_pos - bb.getInt(bb_pos); vtable_size = bb.getShort(vtable_start); }
   public InParentNamespace __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
 
 
diff --git a/tests/MyGame/MonsterExtra.java b/tests/MyGame/MonsterExtra.java
index 6070efd..fecfadd 100644
--- a/tests/MyGame/MonsterExtra.java
+++ b/tests/MyGame/MonsterExtra.java
@@ -7,10 +7,11 @@
 import java.util.*;
 import com.google.flatbuffers.*;
 
-@SuppressWarnings("unused")public final class MonsterExtra extends Table {
+@SuppressWarnings("unused")
+public final class MonsterExtra extends Table {
   public static MonsterExtra getRootAsMonsterExtra(ByteBuffer _bb) { return getRootAsMonsterExtra(_bb, new MonsterExtra()); }
   public static MonsterExtra getRootAsMonsterExtra(ByteBuffer _bb, MonsterExtra obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
-  public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; }
+  public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; vtable_start = bb_pos - bb.getInt(bb_pos); vtable_size = bb.getShort(vtable_start); }
   public MonsterExtra __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
 
   public float testfNan() { int o = __offset(4); return o != 0 ? bb.getFloat(o + bb_pos) : Float.NaN; }
diff --git a/tests/generate_code.bat b/tests/generate_code.bat
index fed9c76..fd33551 100644
--- a/tests/generate_code.bat
+++ b/tests/generate_code.bat
@@ -17,7 +17,7 @@
 
 ..\%buildtype%\flatc.exe --cpp --java --csharp --go --binary --python --lobster --lua --js --rust --ts --php --grpc --gen-mutable --reflect-names --gen-object-api --gen-compare --no-includes --cpp-ptr-type flatbuffers::unique_ptr --no-fb-import -I include_test monster_test.fbs monsterdata_test.json || goto FAIL
 ..\%buildtype%\flatc.exe --cpp --java --csharp --go --binary --python --lobster --lua --js --rust --ts --php --gen-mutable --reflect-names --no-fb-import --cpp-ptr-type flatbuffers::unique_ptr  -o namespace_test namespace_test/namespace_test1.fbs namespace_test/namespace_test2.fbs || goto FAIL
-..\%buildtype%\flatc.exe --cpp --js --ts --php --gen-mutable --reflect-names --gen-object-api --gen-compare --cpp-ptr-type flatbuffers::unique_ptr -o union_vector ./union_vector/union_vector.fbs || goto FAIL
+..\%buildtype%\flatc.exe --cpp --java --js --ts --php --gen-mutable --reflect-names --gen-object-api --gen-compare --cpp-ptr-type flatbuffers::unique_ptr -o union_vector ./union_vector/union_vector.fbs || goto FAIL
 ..\%buildtype%\flatc.exe -b --schema --bfbs-comments --bfbs-builtins -I include_test monster_test.fbs || goto FAIL
 ..\%buildtype%\flatc.exe --jsonschema --schema -I include_test monster_test.fbs || goto FAIL
 
diff --git a/tests/generate_code.sh b/tests/generate_code.sh
index 499e31a..5d6b7ce 100755
--- a/tests/generate_code.sh
+++ b/tests/generate_code.sh
@@ -17,7 +17,7 @@
 
 ../flatc --cpp --java --csharp --dart --go --binary --lobster --lua --python --js --ts --php --rust --grpc --gen-mutable --reflect-names --gen-object-api --gen-compare --no-includes --cpp-ptr-type flatbuffers::unique_ptr  --no-fb-import -I include_test monster_test.fbs monsterdata_test.json
 ../flatc --cpp --java --csharp --dart --go --binary --lobster --lua --python --js --ts --php --rust --gen-mutable --reflect-names --no-fb-import --cpp-ptr-type flatbuffers::unique_ptr  -o namespace_test namespace_test/namespace_test1.fbs namespace_test/namespace_test2.fbs
-../flatc --cpp --js --ts --php --gen-mutable --reflect-names --gen-object-api --gen-compare --cpp-ptr-type flatbuffers::unique_ptr -o union_vector ./union_vector/union_vector.fbs
+../flatc --cpp --java --js --ts --php --gen-mutable --reflect-names --gen-object-api --gen-compare --cpp-ptr-type flatbuffers::unique_ptr -o union_vector ./union_vector/union_vector.fbs
 ../flatc -b --schema --bfbs-comments --bfbs-builtins -I include_test monster_test.fbs
 ../flatc --jsonschema --schema -I include_test monster_test.fbs
 ../flatc --cpp --java --csharp --python --gen-mutable --reflect-names --gen-object-api --gen-compare --no-includes monster_extra.fbs || goto FAIL
diff --git a/tests/javatest.bin b/tests/javatest.bin
index 15bea5f..804dbba 100644
--- a/tests/javatest.bin
+++ b/tests/javatest.bin
Binary files differ
diff --git a/tests/monster_test.bfbs b/tests/monster_test.bfbs
index f96b9fd..fefdd2c 100644
--- a/tests/monster_test.bfbs
+++ b/tests/monster_test.bfbs
Binary files differ
diff --git a/tests/monster_test.fbs b/tests/monster_test.fbs
index 6db7a5b..d571853 100644
--- a/tests/monster_test.fbs
+++ b/tests/monster_test.fbs
@@ -27,7 +27,7 @@
   color: Color = Green;
 }
 
-struct Vec3 (force_align: 16) {
+struct Vec3 (force_align: 8) {
   x:float;
   y:float;
   z:float;
diff --git a/tests/monster_test_generated.h b/tests/monster_test_generated.h
index ac8babb..f8c82f5 100644
--- a/tests/monster_test_generated.h
+++ b/tests/monster_test_generated.h
@@ -516,7 +516,7 @@
 
  public:
   Test() {
-    memset(this, 0, sizeof(Test));
+    memset(static_cast<void *>(this), 0, sizeof(Test));
   }
   Test(int16_t _a, int8_t _b)
       : a_(flatbuffers::EndianScalar(_a)),
@@ -545,7 +545,7 @@
       (lhs.b() == rhs.b());
 }
 
-FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(16) Vec3 FLATBUFFERS_FINAL_CLASS {
+FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(8) Vec3 FLATBUFFERS_FINAL_CLASS {
  private:
   float x_;
   float y_;
@@ -559,7 +559,7 @@
 
  public:
   Vec3() {
-    memset(this, 0, sizeof(Vec3));
+    memset(static_cast<void *>(this), 0, sizeof(Vec3));
   }
   Vec3(float _x, float _y, float _z, double _test1, Color _test2, const Test &_test3)
       : x_(flatbuffers::EndianScalar(_x)),
@@ -631,7 +631,7 @@
 
  public:
   Ability() {
-    memset(this, 0, sizeof(Ability));
+    memset(static_cast<void *>(this), 0, sizeof(Ability));
   }
   Ability(uint32_t _id, uint32_t _distance)
       : id_(flatbuffers::EndianScalar(_id)),
diff --git a/tests/monster_test_generated.js b/tests/monster_test_generated.js
index 7b73f4b..730bb21 100644
--- a/tests/monster_test_generated.js
+++ b/tests/monster_test_generated.js
@@ -115,6 +115,15 @@
 };
 
 /**
+ * @param {flatbuffers.Builder} builder
+ * @returns {flatbuffers.Offset}
+ */
+MyGame.InParentNamespace.createInParentNamespace = function(builder) {
+  MyGame.InParentNamespace.startInParentNamespace(builder);
+  return MyGame.InParentNamespace.endInParentNamespace(builder);
+}
+
+/**
  * @constructor
  */
 MyGame.Example2.Monster = function() {
@@ -166,6 +175,15 @@
 };
 
 /**
+ * @param {flatbuffers.Builder} builder
+ * @returns {flatbuffers.Offset}
+ */
+MyGame.Example2.Monster.createMonster = function(builder) {
+  MyGame.Example2.Monster.startMonster(builder);
+  return MyGame.Example2.Monster.endMonster(builder);
+}
+
+/**
  * @constructor
  */
 MyGame.Example.Test = function() {
@@ -332,6 +350,17 @@
 };
 
 /**
+ * @param {flatbuffers.Builder} builder
+ * @param {MyGame.Example.Color} color
+ * @returns {flatbuffers.Offset}
+ */
+MyGame.Example.TestSimpleTableWithEnum.createTestSimpleTableWithEnum = function(builder, color) {
+  MyGame.Example.TestSimpleTableWithEnum.startTestSimpleTableWithEnum(builder);
+  MyGame.Example.TestSimpleTableWithEnum.addColor(builder, color);
+  return MyGame.Example.TestSimpleTableWithEnum.endTestSimpleTableWithEnum(builder);
+}
+
+/**
  * @constructor
  */
 MyGame.Example.Vec3 = function() {
@@ -487,7 +516,7 @@
  * @returns {flatbuffers.Offset}
  */
 MyGame.Example.Vec3.createVec3 = function(builder, x, y, z, test1, test2, test3_a, test3_b) {
-  builder.prep(16, 32);
+  builder.prep(8, 32);
   builder.pad(2);
   builder.prep(2, 4);
   builder.pad(1);
@@ -717,6 +746,21 @@
 };
 
 /**
+ * @param {flatbuffers.Builder} builder
+ * @param {flatbuffers.Offset} idOffset
+ * @param {flatbuffers.Long} val
+ * @param {number} count
+ * @returns {flatbuffers.Offset}
+ */
+MyGame.Example.Stat.createStat = function(builder, idOffset, val, count) {
+  MyGame.Example.Stat.startStat(builder);
+  MyGame.Example.Stat.addId(builder, idOffset);
+  MyGame.Example.Stat.addVal(builder, val);
+  MyGame.Example.Stat.addCount(builder, count);
+  return MyGame.Example.Stat.endStat(builder);
+}
+
+/**
  * @constructor
  */
 MyGame.Example.Referrable = function() {
@@ -799,6 +843,17 @@
 };
 
 /**
+ * @param {flatbuffers.Builder} builder
+ * @param {flatbuffers.Long} id
+ * @returns {flatbuffers.Offset}
+ */
+MyGame.Example.Referrable.createReferrable = function(builder, id) {
+  MyGame.Example.Referrable.startReferrable(builder);
+  MyGame.Example.Referrable.addId(builder, id);
+  return MyGame.Example.Referrable.endReferrable(builder);
+}
+
+/**
  * an example documentation comment: monster object
  *
  * @constructor
@@ -2504,6 +2559,109 @@
 };
 
 /**
+ * @param {flatbuffers.Builder} builder
+ * @param {flatbuffers.Offset} posOffset
+ * @param {number} mana
+ * @param {number} hp
+ * @param {flatbuffers.Offset} nameOffset
+ * @param {flatbuffers.Offset} inventoryOffset
+ * @param {MyGame.Example.Color} color
+ * @param {MyGame.Example.Any} testType
+ * @param {flatbuffers.Offset} testOffset
+ * @param {flatbuffers.Offset} test4Offset
+ * @param {flatbuffers.Offset} testarrayofstringOffset
+ * @param {flatbuffers.Offset} testarrayoftablesOffset
+ * @param {flatbuffers.Offset} enemyOffset
+ * @param {flatbuffers.Offset} testnestedflatbufferOffset
+ * @param {flatbuffers.Offset} testemptyOffset
+ * @param {boolean} testbool
+ * @param {number} testhashs32Fnv1
+ * @param {number} testhashu32Fnv1
+ * @param {flatbuffers.Long} testhashs64Fnv1
+ * @param {flatbuffers.Long} testhashu64Fnv1
+ * @param {number} testhashs32Fnv1a
+ * @param {number} testhashu32Fnv1a
+ * @param {flatbuffers.Long} testhashs64Fnv1a
+ * @param {flatbuffers.Long} testhashu64Fnv1a
+ * @param {flatbuffers.Offset} testarrayofboolsOffset
+ * @param {number} testf
+ * @param {number} testf2
+ * @param {number} testf3
+ * @param {flatbuffers.Offset} testarrayofstring2Offset
+ * @param {flatbuffers.Offset} testarrayofsortedstructOffset
+ * @param {flatbuffers.Offset} flexOffset
+ * @param {flatbuffers.Offset} test5Offset
+ * @param {flatbuffers.Offset} vectorOfLongsOffset
+ * @param {flatbuffers.Offset} vectorOfDoublesOffset
+ * @param {flatbuffers.Offset} parentNamespaceTestOffset
+ * @param {flatbuffers.Offset} vectorOfReferrablesOffset
+ * @param {flatbuffers.Long} singleWeakReference
+ * @param {flatbuffers.Offset} vectorOfWeakReferencesOffset
+ * @param {flatbuffers.Offset} vectorOfStrongReferrablesOffset
+ * @param {flatbuffers.Long} coOwningReference
+ * @param {flatbuffers.Offset} vectorOfCoOwningReferencesOffset
+ * @param {flatbuffers.Long} nonOwningReference
+ * @param {flatbuffers.Offset} vectorOfNonOwningReferencesOffset
+ * @param {MyGame.Example.AnyUniqueAliases} anyUniqueType
+ * @param {flatbuffers.Offset} anyUniqueOffset
+ * @param {MyGame.Example.AnyAmbiguousAliases} anyAmbiguousType
+ * @param {flatbuffers.Offset} anyAmbiguousOffset
+ * @param {flatbuffers.Offset} vectorOfEnumsOffset
+ * @returns {flatbuffers.Offset}
+ */
+MyGame.Example.Monster.createMonster = function(builder, posOffset, mana, hp, nameOffset, inventoryOffset, color, testType, testOffset, test4Offset, testarrayofstringOffset, testarrayoftablesOffset, enemyOffset, testnestedflatbufferOffset, testemptyOffset, testbool, testhashs32Fnv1, testhashu32Fnv1, testhashs64Fnv1, testhashu64Fnv1, testhashs32Fnv1a, testhashu32Fnv1a, testhashs64Fnv1a, testhashu64Fnv1a, testarrayofboolsOffset, testf, testf2, testf3, testarrayofstring2Offset, testarrayofsortedstructOffset, flexOffset, test5Offset, vectorOfLongsOffset, vectorOfDoublesOffset, parentNamespaceTestOffset, vectorOfReferrablesOffset, singleWeakReference, vectorOfWeakReferencesOffset, vectorOfStrongReferrablesOffset, coOwningReference, vectorOfCoOwningReferencesOffset, nonOwningReference, vectorOfNonOwningReferencesOffset, anyUniqueType, anyUniqueOffset, anyAmbiguousType, anyAmbiguousOffset, vectorOfEnumsOffset) {
+  MyGame.Example.Monster.startMonster(builder);
+  MyGame.Example.Monster.addPos(builder, posOffset);
+  MyGame.Example.Monster.addMana(builder, mana);
+  MyGame.Example.Monster.addHp(builder, hp);
+  MyGame.Example.Monster.addName(builder, nameOffset);
+  MyGame.Example.Monster.addInventory(builder, inventoryOffset);
+  MyGame.Example.Monster.addColor(builder, color);
+  MyGame.Example.Monster.addTestType(builder, testType);
+  MyGame.Example.Monster.addTest(builder, testOffset);
+  MyGame.Example.Monster.addTest4(builder, test4Offset);
+  MyGame.Example.Monster.addTestarrayofstring(builder, testarrayofstringOffset);
+  MyGame.Example.Monster.addTestarrayoftables(builder, testarrayoftablesOffset);
+  MyGame.Example.Monster.addEnemy(builder, enemyOffset);
+  MyGame.Example.Monster.addTestnestedflatbuffer(builder, testnestedflatbufferOffset);
+  MyGame.Example.Monster.addTestempty(builder, testemptyOffset);
+  MyGame.Example.Monster.addTestbool(builder, testbool);
+  MyGame.Example.Monster.addTesthashs32Fnv1(builder, testhashs32Fnv1);
+  MyGame.Example.Monster.addTesthashu32Fnv1(builder, testhashu32Fnv1);
+  MyGame.Example.Monster.addTesthashs64Fnv1(builder, testhashs64Fnv1);
+  MyGame.Example.Monster.addTesthashu64Fnv1(builder, testhashu64Fnv1);
+  MyGame.Example.Monster.addTesthashs32Fnv1a(builder, testhashs32Fnv1a);
+  MyGame.Example.Monster.addTesthashu32Fnv1a(builder, testhashu32Fnv1a);
+  MyGame.Example.Monster.addTesthashs64Fnv1a(builder, testhashs64Fnv1a);
+  MyGame.Example.Monster.addTesthashu64Fnv1a(builder, testhashu64Fnv1a);
+  MyGame.Example.Monster.addTestarrayofbools(builder, testarrayofboolsOffset);
+  MyGame.Example.Monster.addTestf(builder, testf);
+  MyGame.Example.Monster.addTestf2(builder, testf2);
+  MyGame.Example.Monster.addTestf3(builder, testf3);
+  MyGame.Example.Monster.addTestarrayofstring2(builder, testarrayofstring2Offset);
+  MyGame.Example.Monster.addTestarrayofsortedstruct(builder, testarrayofsortedstructOffset);
+  MyGame.Example.Monster.addFlex(builder, flexOffset);
+  MyGame.Example.Monster.addTest5(builder, test5Offset);
+  MyGame.Example.Monster.addVectorOfLongs(builder, vectorOfLongsOffset);
+  MyGame.Example.Monster.addVectorOfDoubles(builder, vectorOfDoublesOffset);
+  MyGame.Example.Monster.addParentNamespaceTest(builder, parentNamespaceTestOffset);
+  MyGame.Example.Monster.addVectorOfReferrables(builder, vectorOfReferrablesOffset);
+  MyGame.Example.Monster.addSingleWeakReference(builder, singleWeakReference);
+  MyGame.Example.Monster.addVectorOfWeakReferences(builder, vectorOfWeakReferencesOffset);
+  MyGame.Example.Monster.addVectorOfStrongReferrables(builder, vectorOfStrongReferrablesOffset);
+  MyGame.Example.Monster.addCoOwningReference(builder, coOwningReference);
+  MyGame.Example.Monster.addVectorOfCoOwningReferences(builder, vectorOfCoOwningReferencesOffset);
+  MyGame.Example.Monster.addNonOwningReference(builder, nonOwningReference);
+  MyGame.Example.Monster.addVectorOfNonOwningReferences(builder, vectorOfNonOwningReferencesOffset);
+  MyGame.Example.Monster.addAnyUniqueType(builder, anyUniqueType);
+  MyGame.Example.Monster.addAnyUnique(builder, anyUniqueOffset);
+  MyGame.Example.Monster.addAnyAmbiguousType(builder, anyAmbiguousType);
+  MyGame.Example.Monster.addAnyAmbiguous(builder, anyAmbiguousOffset);
+  MyGame.Example.Monster.addVectorOfEnums(builder, vectorOfEnumsOffset);
+  return MyGame.Example.Monster.endMonster(builder);
+}
+
+/**
  * @constructor
  */
 MyGame.Example.TypeAliases = function() {
@@ -2972,5 +3130,38 @@
   return offset;
 };
 
+/**
+ * @param {flatbuffers.Builder} builder
+ * @param {number} i8
+ * @param {number} u8
+ * @param {number} i16
+ * @param {number} u16
+ * @param {number} i32
+ * @param {number} u32
+ * @param {flatbuffers.Long} i64
+ * @param {flatbuffers.Long} u64
+ * @param {number} f32
+ * @param {number} f64
+ * @param {flatbuffers.Offset} v8Offset
+ * @param {flatbuffers.Offset} vf64Offset
+ * @returns {flatbuffers.Offset}
+ */
+MyGame.Example.TypeAliases.createTypeAliases = function(builder, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, v8Offset, vf64Offset) {
+  MyGame.Example.TypeAliases.startTypeAliases(builder);
+  MyGame.Example.TypeAliases.addI8(builder, i8);
+  MyGame.Example.TypeAliases.addU8(builder, u8);
+  MyGame.Example.TypeAliases.addI16(builder, i16);
+  MyGame.Example.TypeAliases.addU16(builder, u16);
+  MyGame.Example.TypeAliases.addI32(builder, i32);
+  MyGame.Example.TypeAliases.addU32(builder, u32);
+  MyGame.Example.TypeAliases.addI64(builder, i64);
+  MyGame.Example.TypeAliases.addU64(builder, u64);
+  MyGame.Example.TypeAliases.addF32(builder, f32);
+  MyGame.Example.TypeAliases.addF64(builder, f64);
+  MyGame.Example.TypeAliases.addV8(builder, v8Offset);
+  MyGame.Example.TypeAliases.addVf64(builder, vf64Offset);
+  return MyGame.Example.TypeAliases.endTypeAliases(builder);
+}
+
 // Exports for Node.js and RequireJS
 this.MyGame = MyGame;
diff --git a/tests/monster_test_generated.lobster b/tests/monster_test_generated.lobster
index ab1cabb..bda8b6a 100644
--- a/tests/monster_test_generated.lobster
+++ b/tests/monster_test_generated.lobster
@@ -118,7 +118,7 @@
         MyGame_Example_Test{ buf_, pos_ + 26 }
 
 def CreateVec3(b_:flatbuffers_builder, x:float, y:float, z:float, test1:float, test2:int, test3_a:int, test3_b:int):
-    b_.Prep(16, 32)
+    b_.Prep(8, 32)
     b_.Pad(2)
     b_.Prep(2, 4)
     b_.Pad(1)
diff --git a/tests/monster_test_generated.rs b/tests/monster_test_generated.rs
index 5743391..a538eae 100644
--- a/tests/monster_test_generated.rs
+++ b/tests/monster_test_generated.rs
@@ -1,6 +1,15 @@
 // automatically generated by the FlatBuffers compiler, do not modify
 
 
+#![allow(dead_code)]
+#![allow(unused_imports)]
+
+use std::mem;
+use std::cmp::Ordering;
+
+extern crate flatbuffers;
+use self::flatbuffers::EndianScalar;
+
 pub mod my_game {
   #![allow(dead_code)]
   #![allow(unused_imports)]
@@ -491,8 +500,8 @@
   }
 }
 
-// struct Vec3, aligned to 16
-#[repr(C, align(16))]
+// struct Vec3, aligned to 8
+#[repr(C, align(8))]
 #[derive(Clone, Copy, Debug, PartialEq)]
 pub struct Vec3 {
   x_: f32,
@@ -1250,7 +1259,7 @@
   }
   #[inline]
   #[allow(non_snake_case)]
-  pub fn test_as_monster(&'a self) -> Option<Monster> {
+  pub fn test_as_monster(&self) -> Option<Monster<'a>> {
     if self.test_type() == Any::Monster {
       self.test().map(|u| Monster::init_from_table(u))
     } else {
@@ -1260,7 +1269,7 @@
 
   #[inline]
   #[allow(non_snake_case)]
-  pub fn test_as_test_simple_table_with_enum(&'a self) -> Option<TestSimpleTableWithEnum> {
+  pub fn test_as_test_simple_table_with_enum(&self) -> Option<TestSimpleTableWithEnum<'a>> {
     if self.test_type() == Any::TestSimpleTableWithEnum {
       self.test().map(|u| TestSimpleTableWithEnum::init_from_table(u))
     } else {
@@ -1270,7 +1279,7 @@
 
   #[inline]
   #[allow(non_snake_case)]
-  pub fn test_as_my_game_example_2_monster(&'a self) -> Option<super::example_2::Monster> {
+  pub fn test_as_my_game_example_2_monster(&self) -> Option<super::example_2::Monster<'a>> {
     if self.test_type() == Any::MyGame_Example2_Monster {
       self.test().map(|u| super::example_2::Monster::init_from_table(u))
     } else {
@@ -1280,7 +1289,7 @@
 
   #[inline]
   #[allow(non_snake_case)]
-  pub fn any_unique_as_m(&'a self) -> Option<Monster> {
+  pub fn any_unique_as_m(&self) -> Option<Monster<'a>> {
     if self.any_unique_type() == AnyUniqueAliases::M {
       self.any_unique().map(|u| Monster::init_from_table(u))
     } else {
@@ -1290,7 +1299,7 @@
 
   #[inline]
   #[allow(non_snake_case)]
-  pub fn any_unique_as_t(&'a self) -> Option<TestSimpleTableWithEnum> {
+  pub fn any_unique_as_t(&self) -> Option<TestSimpleTableWithEnum<'a>> {
     if self.any_unique_type() == AnyUniqueAliases::T {
       self.any_unique().map(|u| TestSimpleTableWithEnum::init_from_table(u))
     } else {
@@ -1300,7 +1309,7 @@
 
   #[inline]
   #[allow(non_snake_case)]
-  pub fn any_unique_as_m2(&'a self) -> Option<super::example_2::Monster> {
+  pub fn any_unique_as_m2(&self) -> Option<super::example_2::Monster<'a>> {
     if self.any_unique_type() == AnyUniqueAliases::M2 {
       self.any_unique().map(|u| super::example_2::Monster::init_from_table(u))
     } else {
@@ -1310,7 +1319,7 @@
 
   #[inline]
   #[allow(non_snake_case)]
-  pub fn any_ambiguous_as_m1(&'a self) -> Option<Monster> {
+  pub fn any_ambiguous_as_m1(&self) -> Option<Monster<'a>> {
     if self.any_ambiguous_type() == AnyAmbiguousAliases::M1 {
       self.any_ambiguous().map(|u| Monster::init_from_table(u))
     } else {
@@ -1320,7 +1329,7 @@
 
   #[inline]
   #[allow(non_snake_case)]
-  pub fn any_ambiguous_as_m2(&'a self) -> Option<Monster> {
+  pub fn any_ambiguous_as_m2(&self) -> Option<Monster<'a>> {
     if self.any_ambiguous_type() == AnyAmbiguousAliases::M2 {
       self.any_ambiguous().map(|u| Monster::init_from_table(u))
     } else {
@@ -1330,7 +1339,7 @@
 
   #[inline]
   #[allow(non_snake_case)]
-  pub fn any_ambiguous_as_m3(&'a self) -> Option<Monster> {
+  pub fn any_ambiguous_as_m3(&self) -> Option<Monster<'a>> {
     if self.any_ambiguous_type() == AnyAmbiguousAliases::M3 {
       self.any_ambiguous().map(|u| Monster::init_from_table(u))
     } else {
diff --git a/tests/monster_test_generated.ts b/tests/monster_test_generated.ts
index d0f9aa2..89cf6f1 100644
--- a/tests/monster_test_generated.ts
+++ b/tests/monster_test_generated.ts
@@ -453,7 +453,7 @@
  * @returns flatbuffers.Offset
  */
 static createVec3(builder:flatbuffers.Builder, x: number, y: number, z: number, test1: number, test2: MyGame.Example.Color, test3_a: number, test3_b: number):flatbuffers.Offset {
-  builder.prep(16, 32);
+  builder.prep(8, 32);
   builder.pad(2);
   builder.prep(2, 4);
   builder.pad(1);
diff --git a/tests/monsterdata_python_wire.mon b/tests/monsterdata_python_wire.mon
index 55e37bf..e41384a 100644
--- a/tests/monsterdata_python_wire.mon
+++ b/tests/monsterdata_python_wire.mon
Binary files differ
diff --git a/tests/monsterdata_test.mon b/tests/monsterdata_test.mon
index 3f83972..ba6cf27 100644
--- a/tests/monsterdata_test.mon
+++ b/tests/monsterdata_test.mon
Binary files differ
diff --git a/tests/namespace_test/NamespaceA/NamespaceB/EnumInNestedNS.php b/tests/namespace_test/NamespaceA/NamespaceB/EnumInNestedNS.php
index d51cb41..bcb22b7 100644
--- a/tests/namespace_test/NamespaceA/NamespaceB/EnumInNestedNS.php
+++ b/tests/namespace_test/NamespaceA/NamespaceB/EnumInNestedNS.php
@@ -10,9 +10,9 @@
     const C = 2;
 
     private static $names = array(
-        "A",
-        "B",
-        "C",
+        EnumInNestedNS::A=>"A",
+        EnumInNestedNS::B=>"B",
+        EnumInNestedNS::C=>"C",
     );
 
     public static function Name($e)
diff --git a/tests/namespace_test/NamespaceA/NamespaceB/StructInNestedNS.java b/tests/namespace_test/NamespaceA/NamespaceB/StructInNestedNS.java
index 883913b..42d47c1 100644
--- a/tests/namespace_test/NamespaceA/NamespaceB/StructInNestedNS.java
+++ b/tests/namespace_test/NamespaceA/NamespaceB/StructInNestedNS.java
@@ -7,7 +7,8 @@
 import java.util.*;
 import com.google.flatbuffers.*;
 
-@SuppressWarnings("unused")public final class StructInNestedNS extends Struct {
+@SuppressWarnings("unused")
+public final class StructInNestedNS extends Struct {
   public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; }
   public StructInNestedNS __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
 
diff --git a/tests/namespace_test/NamespaceA/NamespaceB/TableInNestedNS.java b/tests/namespace_test/NamespaceA/NamespaceB/TableInNestedNS.java
index bdd3f3a..f3216c1 100644
--- a/tests/namespace_test/NamespaceA/NamespaceB/TableInNestedNS.java
+++ b/tests/namespace_test/NamespaceA/NamespaceB/TableInNestedNS.java
@@ -7,10 +7,11 @@
 import java.util.*;
 import com.google.flatbuffers.*;
 
-@SuppressWarnings("unused")public final class TableInNestedNS extends Table {
+@SuppressWarnings("unused")
+public final class TableInNestedNS extends Table {
   public static TableInNestedNS getRootAsTableInNestedNS(ByteBuffer _bb) { return getRootAsTableInNestedNS(_bb, new TableInNestedNS()); }
   public static TableInNestedNS getRootAsTableInNestedNS(ByteBuffer _bb, TableInNestedNS obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
-  public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; }
+  public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; vtable_start = bb_pos - bb.getInt(bb_pos); vtable_size = bb.getShort(vtable_start); }
   public TableInNestedNS __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
 
   public int foo() { int o = __offset(4); return o != 0 ? bb.getInt(o + bb_pos) : 0; }
diff --git a/tests/namespace_test/NamespaceA/SecondTableInA.java b/tests/namespace_test/NamespaceA/SecondTableInA.java
index 542fbb4..8386446 100644
--- a/tests/namespace_test/NamespaceA/SecondTableInA.java
+++ b/tests/namespace_test/NamespaceA/SecondTableInA.java
@@ -7,10 +7,11 @@
 import java.util.*;
 import com.google.flatbuffers.*;
 
-@SuppressWarnings("unused")public final class SecondTableInA extends Table {
+@SuppressWarnings("unused")
+public final class SecondTableInA extends Table {
   public static SecondTableInA getRootAsSecondTableInA(ByteBuffer _bb) { return getRootAsSecondTableInA(_bb, new SecondTableInA()); }
   public static SecondTableInA getRootAsSecondTableInA(ByteBuffer _bb, SecondTableInA obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
-  public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; }
+  public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; vtable_start = bb_pos - bb.getInt(bb_pos); vtable_size = bb.getShort(vtable_start); }
   public SecondTableInA __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
 
   public NamespaceC.TableInC referToC() { return referToC(new NamespaceC.TableInC()); }
diff --git a/tests/namespace_test/NamespaceA/TableInFirstNS.java b/tests/namespace_test/NamespaceA/TableInFirstNS.java
index 09f6677..396d0b4 100644
--- a/tests/namespace_test/NamespaceA/TableInFirstNS.java
+++ b/tests/namespace_test/NamespaceA/TableInFirstNS.java
@@ -7,10 +7,11 @@
 import java.util.*;
 import com.google.flatbuffers.*;
 
-@SuppressWarnings("unused")public final class TableInFirstNS extends Table {
+@SuppressWarnings("unused")
+public final class TableInFirstNS extends Table {
   public static TableInFirstNS getRootAsTableInFirstNS(ByteBuffer _bb) { return getRootAsTableInFirstNS(_bb, new TableInFirstNS()); }
   public static TableInFirstNS getRootAsTableInFirstNS(ByteBuffer _bb, TableInFirstNS obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
-  public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; }
+  public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; vtable_start = bb_pos - bb.getInt(bb_pos); vtable_size = bb.getShort(vtable_start); }
   public TableInFirstNS __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
 
   public NamespaceA.NamespaceB.TableInNestedNS fooTable() { return fooTable(new NamespaceA.NamespaceB.TableInNestedNS()); }
diff --git a/tests/namespace_test/NamespaceC/TableInC.java b/tests/namespace_test/NamespaceC/TableInC.java
index 8a3a2a4..80d6a12 100644
--- a/tests/namespace_test/NamespaceC/TableInC.java
+++ b/tests/namespace_test/NamespaceC/TableInC.java
@@ -7,10 +7,11 @@
 import java.util.*;
 import com.google.flatbuffers.*;
 
-@SuppressWarnings("unused")public final class TableInC extends Table {
+@SuppressWarnings("unused")
+public final class TableInC extends Table {
   public static TableInC getRootAsTableInC(ByteBuffer _bb) { return getRootAsTableInC(_bb, new TableInC()); }
   public static TableInC getRootAsTableInC(ByteBuffer _bb, TableInC obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
-  public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; }
+  public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; vtable_start = bb_pos - bb.getInt(bb_pos); vtable_size = bb.getShort(vtable_start); }
   public TableInC __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
 
   public NamespaceA.TableInFirstNS referToA1() { return referToA1(new NamespaceA.TableInFirstNS()); }
diff --git a/tests/namespace_test/namespace_test1_generated.h b/tests/namespace_test/namespace_test1_generated.h
index 3f964b0..d26bf43 100644
--- a/tests/namespace_test/namespace_test1_generated.h
+++ b/tests/namespace_test/namespace_test1_generated.h
@@ -57,7 +57,7 @@
 
  public:
   StructInNestedNS() {
-    memset(this, 0, sizeof(StructInNestedNS));
+    memset(static_cast<void *>(this), 0, sizeof(StructInNestedNS));
   }
   StructInNestedNS(int32_t _a, int32_t _b)
       : a_(flatbuffers::EndianScalar(_a)),
diff --git a/tests/namespace_test/namespace_test1_generated.js b/tests/namespace_test/namespace_test1_generated.js
index c7a3561..d318f22 100644
--- a/tests/namespace_test/namespace_test1_generated.js
+++ b/tests/namespace_test/namespace_test1_generated.js
@@ -104,6 +104,17 @@
 };
 
 /**
+ * @param {flatbuffers.Builder} builder
+ * @param {number} foo
+ * @returns {flatbuffers.Offset}
+ */
+NamespaceA.NamespaceB.TableInNestedNS.createTableInNestedNS = function(builder, foo) {
+  NamespaceA.NamespaceB.TableInNestedNS.startTableInNestedNS(builder);
+  NamespaceA.NamespaceB.TableInNestedNS.addFoo(builder, foo);
+  return NamespaceA.NamespaceB.TableInNestedNS.endTableInNestedNS(builder);
+}
+
+/**
  * @constructor
  */
 NamespaceA.NamespaceB.StructInNestedNS = function() {
diff --git a/tests/namespace_test/namespace_test1_generated.rs b/tests/namespace_test/namespace_test1_generated.rs
index a2abf8f..7fb6c97 100644
--- a/tests/namespace_test/namespace_test1_generated.rs
+++ b/tests/namespace_test/namespace_test1_generated.rs
@@ -1,6 +1,15 @@
 // automatically generated by the FlatBuffers compiler, do not modify
 
 
+#![allow(dead_code)]
+#![allow(unused_imports)]
+
+use std::mem;
+use std::cmp::Ordering;
+
+extern crate flatbuffers;
+use self::flatbuffers::EndianScalar;
+
 pub mod namespace_a {
   #![allow(dead_code)]
   #![allow(unused_imports)]
diff --git a/tests/namespace_test/namespace_test2_generated.js b/tests/namespace_test/namespace_test2_generated.js
index 25db73f..a06e05e 100644
--- a/tests/namespace_test/namespace_test2_generated.js
+++ b/tests/namespace_test/namespace_test2_generated.js
@@ -135,6 +135,21 @@
 };
 
 /**
+ * @param {flatbuffers.Builder} builder
+ * @param {flatbuffers.Offset} fooTableOffset
+ * @param {NS8755221360535654258.NamespaceA.NamespaceB.EnumInNestedNS} fooEnum
+ * @param {flatbuffers.Offset} fooStructOffset
+ * @returns {flatbuffers.Offset}
+ */
+NamespaceA.TableInFirstNS.createTableInFirstNS = function(builder, fooTableOffset, fooEnum, fooStructOffset) {
+  NamespaceA.TableInFirstNS.startTableInFirstNS(builder);
+  NamespaceA.TableInFirstNS.addFooTable(builder, fooTableOffset);
+  NamespaceA.TableInFirstNS.addFooEnum(builder, fooEnum);
+  NamespaceA.TableInFirstNS.addFooStruct(builder, fooStructOffset);
+  return NamespaceA.TableInFirstNS.endTableInFirstNS(builder);
+}
+
+/**
  * @constructor
  */
 NamespaceC.TableInC = function() {
@@ -220,6 +235,19 @@
 };
 
 /**
+ * @param {flatbuffers.Builder} builder
+ * @param {flatbuffers.Offset} referToA1Offset
+ * @param {flatbuffers.Offset} referToA2Offset
+ * @returns {flatbuffers.Offset}
+ */
+NamespaceC.TableInC.createTableInC = function(builder, referToA1Offset, referToA2Offset) {
+  NamespaceC.TableInC.startTableInC(builder);
+  NamespaceC.TableInC.addReferToA1(builder, referToA1Offset);
+  NamespaceC.TableInC.addReferToA2(builder, referToA2Offset);
+  return NamespaceC.TableInC.endTableInC(builder);
+}
+
+/**
  * @constructor
  */
 NamespaceA.SecondTableInA = function() {
@@ -287,6 +315,17 @@
   return offset;
 };
 
+/**
+ * @param {flatbuffers.Builder} builder
+ * @param {flatbuffers.Offset} referToCOffset
+ * @returns {flatbuffers.Offset}
+ */
+NamespaceA.SecondTableInA.createSecondTableInA = function(builder, referToCOffset) {
+  NamespaceA.SecondTableInA.startSecondTableInA(builder);
+  NamespaceA.SecondTableInA.addReferToC(builder, referToCOffset);
+  return NamespaceA.SecondTableInA.endSecondTableInA(builder);
+}
+
 // Exports for Node.js and RequireJS
 this.NamespaceA = NamespaceA;
 this.NamespaceC = NamespaceC;
diff --git a/tests/namespace_test/namespace_test2_generated.rs b/tests/namespace_test/namespace_test2_generated.rs
index ac78936..c2e7021 100644
--- a/tests/namespace_test/namespace_test2_generated.rs
+++ b/tests/namespace_test/namespace_test2_generated.rs
@@ -1,6 +1,15 @@
 // automatically generated by the FlatBuffers compiler, do not modify
 
 
+#![allow(dead_code)]
+#![allow(unused_imports)]
+
+use std::mem;
+use std::cmp::Ordering;
+
+extern crate flatbuffers;
+use self::flatbuffers::EndianScalar;
+
 pub mod namespace_a {
   #![allow(dead_code)]
   #![allow(unused_imports)]
diff --git a/tests/py_test.py b/tests/py_test.py
index 54f0446..76dabcb 100644
--- a/tests/py_test.py
+++ b/tests/py_test.py
@@ -90,7 +90,7 @@
     if sizePrefix:
         size = util.GetSizePrefix(buf, offset)
         # taken from the size of monsterdata_python_wire.mon, minus 4
-        asserter(size == 348)
+        asserter(size == 340)
         buf, offset = util.RemoveSizePrefix(buf, offset)
     monster = MyGame.Example.Monster.Monster.GetRootAsMonster(buf, offset)
 
diff --git a/tests/rust_usage_test/tests/integration_test.rs b/tests/rust_usage_test/tests/integration_test.rs
index b9e44d8..f4db4ff 100644
--- a/tests/rust_usage_test/tests/integration_test.rs
+++ b/tests/rust_usage_test/tests/integration_test.rs
@@ -656,8 +656,8 @@
     }
 
     #[test]
-    fn struct_vec3_is_aligned_to_16() {
-        assert_eq!(16, ::std::mem::align_of::<my_game::example::Vec3>());
+    fn struct_vec3_is_aligned_to_8() {
+        assert_eq!(8, ::std::mem::align_of::<my_game::example::Vec3>());
     }
 
     #[test]
diff --git a/tests/test.cpp b/tests/test.cpp
index 7448466..003f825 100644
--- a/tests/test.cpp
+++ b/tests/test.cpp
@@ -1,4 +1,4 @@
-/*
+/*
  * Copyright 2014 Google Inc. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -210,18 +210,22 @@
   flatbuffers::Verifier verifier(flatbuf, length);
   TEST_EQ(VerifyMonsterBuffer(verifier), true);
 
-  std::vector<uint8_t> test_buff;
-  test_buff.resize(length * 2);
-  std::memcpy(&test_buff[0], flatbuf, length);
-  std::memcpy(&test_buff[length], flatbuf, length);
+  // clang-format off
+  #ifdef FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE
+    std::vector<uint8_t> test_buff;
+    test_buff.resize(length * 2);
+    std::memcpy(&test_buff[0], flatbuf, length);
+    std::memcpy(&test_buff[length], flatbuf, length);
 
-  flatbuffers::Verifier verifier1(&test_buff[0], length);
-  TEST_EQ(VerifyMonsterBuffer(verifier1), true);
-  TEST_EQ(verifier1.GetComputedSize(), length);
+    flatbuffers::Verifier verifier1(&test_buff[0], length);
+    TEST_EQ(VerifyMonsterBuffer(verifier1), true);
+    TEST_EQ(verifier1.GetComputedSize(), length);
 
-  flatbuffers::Verifier verifier2(&test_buff[length], length);
-  TEST_EQ(VerifyMonsterBuffer(verifier2), true);
-  TEST_EQ(verifier2.GetComputedSize(), length);
+    flatbuffers::Verifier verifier2(&test_buff[length], length);
+    TEST_EQ(VerifyMonsterBuffer(verifier2), true);
+    TEST_EQ(verifier2.GetComputedSize(), length);
+  #endif
+  // clang-format on
 
   TEST_EQ(strcmp(MonsterIdentifier(), "MONS"), 0);
   TEST_EQ(MonsterBufferHasIdentifier(flatbuf), true);
@@ -255,6 +259,24 @@
     TEST_EQ(*it, inv_data[indx]);
   }
 
+  for (auto it = inventory->cbegin(); it != inventory->cend(); ++it) {
+    auto indx = it - inventory->cbegin();
+    TEST_EQ(*it, inv_vec.at(indx));  // Use bounds-check.
+    TEST_EQ(*it, inv_data[indx]);
+  }
+
+  for (auto it = inventory->rbegin(); it != inventory->rend(); ++it) {
+    auto indx = inventory->rend() - it;
+    TEST_EQ(*it, inv_vec.at(indx));  // Use bounds-check.
+    TEST_EQ(*it, inv_data[indx]);
+  }
+
+  for (auto it = inventory->crbegin(); it != inventory->crend(); ++it) {
+    auto indx = inventory->crend() - it;
+    TEST_EQ(*it, inv_vec.at(indx));  // Use bounds-check.
+    TEST_EQ(*it, inv_data[indx]);
+  }
+
   TEST_EQ(monster->color(), Color_Blue);
 
   // Example of accessing a union:
@@ -265,7 +287,7 @@
 
   // Example of accessing a vector of strings:
   auto vecofstrings = monster->testarrayofstring();
-  TEST_EQ(vecofstrings->Length(), 4U);
+  TEST_EQ(vecofstrings->size(), 4U);
   TEST_EQ_STR(vecofstrings->Get(0)->c_str(), "bob");
   TEST_EQ_STR(vecofstrings->Get(1)->c_str(), "fred");
   if (pooled) {
@@ -276,14 +298,14 @@
 
   auto vecofstrings2 = monster->testarrayofstring2();
   if (vecofstrings2) {
-    TEST_EQ(vecofstrings2->Length(), 2U);
+    TEST_EQ(vecofstrings2->size(), 2U);
     TEST_EQ_STR(vecofstrings2->Get(0)->c_str(), "jane");
     TEST_EQ_STR(vecofstrings2->Get(1)->c_str(), "mary");
   }
 
   // Example of accessing a vector of tables:
   auto vecoftables = monster->testarrayoftables();
-  TEST_EQ(vecoftables->Length(), 3U);
+  TEST_EQ(vecoftables->size(), 3U);
   for (auto it = vecoftables->begin(); it != vecoftables->end(); ++it)
     TEST_EQ(strlen(it->name()->c_str()) >= 4, true);
   TEST_EQ_STR(vecoftables->Get(0)->name()->c_str(), "Barney");
@@ -1218,7 +1240,7 @@
   TestError_(src, error_substr, false, file, line, func);
 }
 
-#ifdef WIN32
+#ifdef _WIN32
 #  define TestError(src, ...) \
     TestError_(src, __VA_ARGS__, __FILE__, __LINE__, __FUNCTION__)
 #else
@@ -1974,6 +1996,26 @@
           true);
 }
 
+void InvalidNestedFlatbufferTest() {
+  // First, load and parse FlatBuffer schema (.fbs)
+  std::string schemafile;
+  TEST_EQ(flatbuffers::LoadFile((test_data_path + "monster_test.fbs").c_str(),
+                                false, &schemafile),
+          true);
+  auto include_test_path =
+      flatbuffers::ConCatPathFileName(test_data_path, "include_test");
+  const char *include_directories[] = { test_data_path.c_str(),
+                                        include_test_path.c_str(), nullptr };
+  flatbuffers::Parser parser1;
+  TEST_EQ(parser1.Parse(schemafile.c_str(), include_directories), true);
+
+  // "color" inside nested flatbuffer contains invalid enum value
+  TEST_EQ(parser1.Parse("{ name: \"Bender\", testnestedflatbuffer: { name: "
+                        "\"Leela\", color: \"nonexistent\"}}"),
+          false);
+  // Check that Parser is destroyed correctly after parsing invalid json
+}
+
 void UnionVectorTest() {
   // load FlatBuffer fbs schema.
   // TODO: load a JSON file with such a vector when JSON support is ready.
@@ -2445,13 +2487,6 @@
 
 int FlatBufferTests() {
   // clang-format off
-  #if defined(FLATBUFFERS_MEMORY_LEAK_TRACKING) && \
-      defined(_MSC_VER) && defined(_DEBUG)
-    _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF
-      // For more thorough checking:
-      //| _CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_DELAY_FREE_MEM_DF
-    );
-  #endif
 
   // Run our various test suites:
 
@@ -2509,6 +2544,7 @@
   InvalidUTF8Test();
   UnknownFieldsTest();
   ParseUnionTest();
+  InvalidNestedFlatbufferTest();
   ConformTest();
   ParseProtoBufAsciiTest();
   TypeAliasesTest();
@@ -2545,9 +2581,8 @@
 
   if (!testing_fails) {
     TEST_OUTPUT_LINE("ALL TESTS PASSED");
-    return 0;
   } else {
     TEST_OUTPUT_LINE("%d FAILED TESTS", testing_fails);
-    return 1;
   }
+  return CloseTestEngine();
 }
diff --git a/tests/test_assert.cpp b/tests/test_assert.cpp
index 056ef23..804663c 100644
--- a/tests/test_assert.cpp
+++ b/tests/test_assert.cpp
@@ -1,6 +1,7 @@
-#include <assert.h>
 #include "test_assert.h"
 
+#include <assert.h>
+
 #ifdef _MSC_VER
 #  include <crtdbg.h>
 #endif
@@ -27,13 +28,9 @@
   if (strcmp(expval, val) != 0) { TestFail(expval, val, exp, file, line); }
 }
 
-#ifdef _MSC_VER
-// Without this hook function the message box not suppressed.
-int msvc_no_dialog_box_on_assert(int rpt_type, char *msg, int *ret_val) {
-  (void)ret_val;
-  TEST_OUTPUT_LINE("TEST ASSERTED: %d: %s", rpt_type, msg);
-  return 1;
-}
+#if defined(FLATBUFFERS_MEMORY_LEAK_TRACKING) && defined(_MSC_VER) && \
+    defined(_DEBUG)
+#define FLATBUFFERS_MEMORY_LEAK_TRACKING_MSVC
 #endif
 
 void InitTestEngine(TestFailEventListener listener) {
@@ -46,14 +43,37 @@
   // clang-format off
 
   #ifdef _MSC_VER
-    // Suppress pop-up message box on assertion (MSVC2010, MSVC2012).
-    // This message box hangs CI-test on the hour until timeout expired.
-    // Default mode is file, file is stderr.
+    // Send all reports to STDOUT.
+    // CrtDebug reports to _CRT_WARN channel.
+    _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
+    _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDOUT);
+    // The assert from <assert.h> reports to _CRT_ERROR channel
+    _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
+    _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDOUT);
+    // Internal CRT assert channel?
     _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
-    _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
-    _CrtSetReportHook(msvc_no_dialog_box_on_assert);
+    _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDOUT);
+  #endif
+
+  #if defined(FLATBUFFERS_MEMORY_LEAK_TRACKING_MSVC)
+    // For more thorough checking:
+    // _CRTDBG_DELAY_FREE_MEM_DF | _CRTDBG_CHECK_ALWAYS_DF
+    auto flags = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
+    _CrtSetDbgFlag(flags | _CRTDBG_ALLOC_MEM_DF);
   #endif
   // clang-format on
 
   fail_listener_ = listener;
 }
+
+int CloseTestEngine(bool force_report) {
+  if (!testing_fails || force_report) {
+  #if defined(FLATBUFFERS_MEMORY_LEAK_TRACKING_MSVC)
+      auto flags = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
+      flags &= ~_CRTDBG_DELAY_FREE_MEM_DF;
+      flags |= _CRTDBG_LEAK_CHECK_DF;
+      _CrtSetDbgFlag(flags);
+  #endif
+  }
+  return (0 != testing_fails);
+}
diff --git a/tests/test_assert.h b/tests/test_assert.h
index 9a01c95..883586b 100644
--- a/tests/test_assert.h
+++ b/tests/test_assert.h
@@ -1,6 +1,7 @@
 #ifndef TEST_ASSERT_H
 #define TEST_ASSERT_H
 
+#include "flatbuffers/base.h"
 #include "flatbuffers/util.h"
 
 // clang-format off
@@ -20,7 +21,7 @@
 #define TEST_NOTNULL(exp) TestEq(exp == NULL, false, #exp, __FILE__, __LINE__)
 #define TEST_EQ_STR(exp, val) TestEqStr(exp, val, #exp, __FILE__, __LINE__)
 
-#ifdef WIN32
+#ifdef _WIN32
   #define TEST_ASSERT_FUNC(exp) TestEq(exp, true, #exp, __FILE__, __LINE__, __FUNCTION__)
   #define TEST_EQ_FUNC(exp, val) TestEq(exp, val, #exp, __FILE__, __LINE__, __FUNCTION__)
 #else
@@ -42,6 +43,12 @@
 // listener - this function will be notified on each TestFail call.
 void InitTestEngine(TestFailEventListener listener = nullptr);
 
+// Release all test-engine resources.
+// Prints or schedule a debug report if all test passed.
+// Returns 0 if all tests passed or 1 otherwise.
+// Memory leak report: FLATBUFFERS_MEMORY_LEAK_TRACKING && _MSC_VER && _DEBUG.
+int CloseTestEngine(bool force_report = false);
+
 // Write captured state to a log and terminate test run.
 void TestFail(const char *expval, const char *val, const char *exp,
               const char *file, int line, const char *func = 0);
diff --git a/tests/test_builder.h b/tests/test_builder.h
index fe8bea9..1e2fa0a 100644
--- a/tests/test_builder.h
+++ b/tests/test_builder.h
@@ -7,7 +7,9 @@
 #include "flatbuffers/flatbuffers.h"
 #include "test_assert.h"
 
-using namespace MyGame::Example;
+using MyGame::Example::Color;
+using MyGame::Example::Monster;
+
 namespace flatbuffers {
 namespace grpc {
 class MessageBuilder;
diff --git a/tests/union_vector/Attacker.java b/tests/union_vector/Attacker.java
index d9a9bf3..ae84a4a 100644
--- a/tests/union_vector/Attacker.java
+++ b/tests/union_vector/Attacker.java
@@ -9,10 +9,11 @@
 public final class Attacker extends Table {
   public static Attacker getRootAsAttacker(ByteBuffer _bb) { return getRootAsAttacker(_bb, new Attacker()); }
   public static Attacker getRootAsAttacker(ByteBuffer _bb, Attacker obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
-  public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; }
+  public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; vtable_start = bb_pos - bb.getInt(bb_pos); vtable_size = bb.getShort(vtable_start); }
   public Attacker __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
 
   public int swordAttackDamage() { int o = __offset(4); return o != 0 ? bb.getInt(o + bb_pos) : 0; }
+  public boolean mutateSwordAttackDamage(int sword_attack_damage) { int o = __offset(4); if (o != 0) { bb.putInt(o + bb_pos, sword_attack_damage); return true; } else { return false; } }
 
   public static int createAttacker(FlatBufferBuilder builder,
       int sword_attack_damage) {
diff --git a/tests/union_vector/BookReader.java b/tests/union_vector/BookReader.java
index e23f82c..1cb516e 100644
--- a/tests/union_vector/BookReader.java
+++ b/tests/union_vector/BookReader.java
@@ -11,6 +11,7 @@
   public BookReader __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
 
   public int booksRead() { return bb.getInt(bb_pos + 0); }
+  public void mutateBooksRead(int books_read) { bb.putInt(bb_pos + 0, books_read); }
 
   public static int createBookReader(FlatBufferBuilder builder, int booksRead) {
     builder.prep(4, 4);
diff --git a/tests/union_vector/Character.php b/tests/union_vector/Character.php
index bf73c36..755958b 100644
--- a/tests/union_vector/Character.php
+++ b/tests/union_vector/Character.php
@@ -12,13 +12,13 @@
     const Unused = 6;
 
     private static $names = array(
-        "NONE",
-        "MuLan",
-        "Rapunzel",
-        "Belle",
-        "BookFan",
-        "Other",
-        "Unused",
+        Character::NONE=>"NONE",
+        Character::MuLan=>"MuLan",
+        Character::Rapunzel=>"Rapunzel",
+        Character::Belle=>"Belle",
+        Character::BookFan=>"BookFan",
+        Character::Other=>"Other",
+        Character::Unused=>"Unused",
     );
 
     public static function Name($e)
diff --git a/tests/union_vector/Movie.java b/tests/union_vector/Movie.java
index 8e214b9..75791d3 100644
--- a/tests/union_vector/Movie.java
+++ b/tests/union_vector/Movie.java
@@ -10,16 +10,18 @@
   public static Movie getRootAsMovie(ByteBuffer _bb) { return getRootAsMovie(_bb, new Movie()); }
   public static Movie getRootAsMovie(ByteBuffer _bb, Movie obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
   public static boolean MovieBufferHasIdentifier(ByteBuffer _bb) { return __has_identifier(_bb, "MOVI"); }
-  public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; }
+  public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; vtable_start = bb_pos - bb.getInt(bb_pos); vtable_size = bb.getShort(vtable_start); }
   public Movie __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
 
   public byte mainCharacterType() { int o = __offset(4); return o != 0 ? bb.get(o + bb_pos) : 0; }
+  public boolean mutateMainCharacterType(byte main_character_type) { int o = __offset(4); if (o != 0) { bb.put(o + bb_pos, main_character_type); return true; } else { return false; } }
   public Table mainCharacter(Table obj) { int o = __offset(6); return o != 0 ? __union(obj, o) : null; }
   public byte charactersType(int j) { int o = __offset(8); return o != 0 ? bb.get(__vector(o) + j * 1) : 0; }
   public int charactersTypeLength() { int o = __offset(8); return o != 0 ? __vector_len(o) : 0; }
   public ByteBuffer charactersTypeAsByteBuffer() { return __vector_as_bytebuffer(8, 1); }
   public ByteBuffer charactersTypeInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 8, 1); }
-  public Table characters(Table obj, int j) { int o = __offset(10); return o != 0 ? __union(obj, __vector(o) + j * 4) : null; }
+  public boolean mutateCharactersType(int j, byte characters_type) { int o = __offset(8); if (o != 0) { bb.put(__vector(o) + j * 1, characters_type); return true; } else { return false; } }
+  public Table characters(Table obj, int j) { int o = __offset(10); return o != 0 ? __union(obj, __vector(o) + j * 4 - bb_pos) : null; }
   public int charactersLength() { int o = __offset(10); return o != 0 ? __vector_len(o) : 0; }
 
   public static int createMovie(FlatBufferBuilder builder,
diff --git a/tests/union_vector/Rapunzel.java b/tests/union_vector/Rapunzel.java
index 7c059f4..7cc6679 100644
--- a/tests/union_vector/Rapunzel.java
+++ b/tests/union_vector/Rapunzel.java
@@ -11,6 +11,7 @@
   public Rapunzel __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
 
   public int hairLength() { return bb.getInt(bb_pos + 0); }
+  public void mutateHairLength(int hair_length) { bb.putInt(bb_pos + 0, hair_length); }
 
   public static int createRapunzel(FlatBufferBuilder builder, int hairLength) {
     builder.prep(4, 4);
diff --git a/tests/union_vector/union_vector_generated.h b/tests/union_vector/union_vector_generated.h
index f085bbc..8629d4e 100644
--- a/tests/union_vector/union_vector_generated.h
+++ b/tests/union_vector/union_vector_generated.h
@@ -189,7 +189,7 @@
 
  public:
   Rapunzel() {
-    memset(this, 0, sizeof(Rapunzel));
+    memset(static_cast<void *>(this), 0, sizeof(Rapunzel));
   }
   Rapunzel(int32_t _hair_length)
       : hair_length_(flatbuffers::EndianScalar(_hair_length)) {
@@ -214,7 +214,7 @@
 
  public:
   BookReader() {
-    memset(this, 0, sizeof(BookReader));
+    memset(static_cast<void *>(this), 0, sizeof(BookReader));
   }
   BookReader(int32_t _books_read)
       : books_read_(flatbuffers::EndianScalar(_books_read)) {
diff --git a/tests/union_vector/union_vector_generated.js b/tests/union_vector/union_vector_generated.js
index b208e9c..5c1a579 100644
--- a/tests/union_vector/union_vector_generated.js
+++ b/tests/union_vector/union_vector_generated.js
@@ -96,6 +96,17 @@
 };
 
 /**
+ * @param {flatbuffers.Builder} builder
+ * @param {number} swordAttackDamage
+ * @returns {flatbuffers.Offset}
+ */
+Attacker.createAttacker = function(builder, swordAttackDamage) {
+  Attacker.startAttacker(builder);
+  Attacker.addSwordAttackDamage(builder, swordAttackDamage);
+  return Attacker.endAttacker(builder);
+}
+
+/**
  * @constructor
  */
 function Rapunzel() {
@@ -429,6 +440,23 @@
   builder.finish(offset, 'MOVI');
 };
 
+/**
+ * @param {flatbuffers.Builder} builder
+ * @param {Character} mainCharacterType
+ * @param {flatbuffers.Offset} mainCharacterOffset
+ * @param {flatbuffers.Offset} charactersTypeOffset
+ * @param {flatbuffers.Offset} charactersOffset
+ * @returns {flatbuffers.Offset}
+ */
+Movie.createMovie = function(builder, mainCharacterType, mainCharacterOffset, charactersTypeOffset, charactersOffset) {
+  Movie.startMovie(builder);
+  Movie.addMainCharacterType(builder, mainCharacterType);
+  Movie.addMainCharacter(builder, mainCharacterOffset);
+  Movie.addCharactersType(builder, charactersTypeOffset);
+  Movie.addCharacters(builder, charactersOffset);
+  return Movie.endMovie(builder);
+}
+
 // Exports for Node.js and RequireJS
 this.Character = Character;
 this.Attacker = Attacker;