diff --git a/.gitmodules b/.gitmodules index 35b419c520..b0bd09c398 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ -[submodule "realm/realm-library/src/main/cpp/object-store"] - path = realm/realm-library/src/main/cpp/object-store - url = https://github.com/realm/realm-object-store.git +[submodule "realm/realm-library/src/main/cpp/realm-core"] + path = realm/realm-library/src/main/cpp/realm-core + url = https://github.com/realm/realm-core.git diff --git a/CHANGELOG.md b/CHANGELOG.md index d3331ff7b6..00a0ed30c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,12 +1,13 @@ -## 10.2.1 (YYYY-MM-DD) - -### Breaking Changes -* None. +## 10.3.0 (YYYY-MM-DD) ### Enhancements * None. ### Fixes +* [RealmApp] Integrating a remote Sync changeset into the local Realm could result in an `Index out of range error`. +* Change notifications not firing when removing and adding an object with the same primary key within a transaction (Issue [#7098](https://github.com/realm/realm-java/issues/7098)). +* Race condition which would lead to "uncaught exception in notifier thread: N5realm15InvalidTableRefE: transaction_ended" and a crash when the source Realm was closed or invalidated at a very specific time during the first run of a collection notifier (Core issue [#3761](https://github.com/realm/realm-core/issues/3761), since v7.0.0). +* Deleting and recreating objects with embedded objects could fail (Core issue [#4240](https://github.com/realm/realm-core/pull/4240), since v10.0.0) * Added `@Nullable` annotation to input parameter in `RealmObject.isValid(item)` to avoid mismatch warnings from Kotlin code (Issue [#7216](https://github.com/realm/realm-java/issues/7216)). ### Compatibility @@ -15,7 +16,8 @@ * Realm Studio 10.0.0 or above is required to open Realms created by this version. ### Internal -* Updated to Object Store commit: fc790d558ddc0e25a50d6b27dadf617532a1bf44. +* Updated to Realm Core: 10.3.3 (Monorepo). +* Updated to Realm Core commit: 8af0f8d609491986b49f2c986e771d9dc445664d. ## 10.2.0 (2020-12-02) diff --git a/Dockerfile b/Dockerfile index 4265616585..c65e37b706 100644 --- a/Dockerfile +++ b/Dockerfile @@ -48,6 +48,7 @@ RUN DEBIAN_FRONTEND=noninteractive \ virt-manager \ wget \ zip \ + ninja-build \ && apt-get clean # Install the Android SDK @@ -69,7 +70,6 @@ RUN yes | sdkmanager --licenses # Please keep all sections in descending order! RUN yes | sdkmanager \ 'build-tools;29.0.3' \ - 'cmake;3.6.4111459' \ 'emulator' \ 'extras;android;m2repository' \ 'platforms;android-29' \ @@ -79,3 +79,10 @@ RUN yes | sdkmanager \ # Make the SDK universally writable RUN chmod -R a+rwX ${ANDROID_HOME} + +# Ensure a new enough version of CMake is available. +RUN cd /opt \ + && wget -nv https://cmake.org/files/v3.18/cmake-3.18.4-Linux-x86_64.tar.gz \ + && tar zxf cmake-3.18.4-Linux-x86_64.tar.gz + +ENV PATH "/opt/cmake-3.18.4-Linux-x86_64/bin:$PATH" diff --git a/Jenkinsfile b/Jenkinsfile index 89e788e797..f7f391cce4 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -75,14 +75,14 @@ try { // on an actual device. def useEmulator = false def emulatorImage = "" - def abiFilter = "" + def buildFlags = "" def instrumentationTestTarget = "connectedAndroidTest" def deviceSerial = "" if (!releaseBranches.contains(currentBranch)) { // Build development branch useEmulator = true emulatorImage = "system-images;android-29;default;x86" - abiFilter = "-PbuildTargetABIs=x86" + buildFlags = "-PbuildTargetABIs=x86 -PenableLTO=false -PbuildCore=false" instrumentationTestTarget = "connectedObjectServerDebugAndroidTest" deviceSerial = "emulator-5554" } else { @@ -91,6 +91,7 @@ try { // But still build all ABI's and run all types of tests. useEmulator = true emulatorImage = "system-images;android-29;default;x86" + buildFlags = "-PenableLTO=true -PbuildCore=true" instrumentationTestTarget = "connectedAndroidTest" deviceSerial = "emulator-5554" } @@ -151,12 +152,12 @@ try { // Need to go to ANDROID_HOME due to https://askubuntu.com/questions/1005944/emulator-avd-does-not-launch-the-virtual-device sh "cd \$ANDROID_HOME/tools && emulator -avd CIEmulator -no-boot-anim -no-window -wipe-data -noaudio -partition-size 4098 &" try { - runBuild(abiFilter, instrumentationTestTarget) + runBuild(buildFlags, instrumentationTestTarget) } finally { sh "adb emu kill" } } else { - runBuild(abiFilter, instrumentationTestTarget) + runBuild(buildFlags, instrumentationTestTarget) } // Release the library if needed @@ -214,17 +215,17 @@ try { } // Runs all build steps -def runBuild(abiFilter, instrumentationTestTarget) { +def runBuild(buildFlags, instrumentationTestTarget) { stage('Build') { sh "chmod +x gradlew" - sh "./gradlew assemble ${abiFilter} --stacktrace" + sh "./gradlew assemble ${buildFlags} --stacktrace" } stage('Tests') { parallel 'JVM' : { try { - sh "chmod +x gradlew && ./gradlew check ${abiFilter} --stacktrace" + sh "chmod +x gradlew && ./gradlew check ${buildFlags} --stacktrace" } finally { storeJunitResults 'realm/realm-annotations-processor/build/test-results/test/TEST-*.xml' storeJunitResults 'examples/unitTestExample/build/test-results/**/TEST-*.xml' @@ -241,7 +242,7 @@ def runBuild(abiFilter, instrumentationTestTarget) { }, 'Static code analysis' : { try { - gradle('realm', "spotbugsMain pmd checkstyle ${abiFilter}") + gradle('realm', "spotbugsMain pmd checkstyle ${buildFlags}") } finally { publishHTML(target: [ allowMissing: false, @@ -277,7 +278,7 @@ def runBuild(abiFilter, instrumentationTestTarget) { try { backgroundPid = startLogCatCollector() forwardAdbPorts() - gradle('realm', "${instrumentationTestTarget} ${abiFilter}") + gradle('realm', "${instrumentationTestTarget} ${buildFlags}") } finally { stopLogCatCollector(backgroundPid) storeJunitResults 'realm/realm-library/build/outputs/androidTest-results/connected/**/TEST-*.xml' @@ -295,7 +296,7 @@ def runBuild(abiFilter, instrumentationTestTarget) { } }, 'JavaDoc': { - sh "./gradlew javadoc ${abiFilter} --stacktrace" + sh "./gradlew javadoc ${buildFlags} --stacktrace" } } diff --git a/LICENSE b/LICENSE index 57a0e0b24a..e163ae2f84 100644 --- a/LICENSE +++ b/LICENSE @@ -1,8 +1,7 @@ TABLE OF CONTENTS 1. Apache License version 2.0 -2. Realm Components -3. Export Compliance +2. Export Compliance 1. ------------------------------------------------------------------------------- @@ -183,49 +182,6 @@ TABLE OF CONTENTS 2. ------------------------------------------------------------------------------- -REALM COMPONENTS - -This software contains components with separate copyright and license terms. -Your use of these components is subject to the terms and conditions of the -following licenses. - -For the Realm Platform Extensions component - - Realm Platform Extensions License - - Copyright (c) 2011-2017 Realm Inc All rights reserved - - Redistribution and use in binary form, with or without modification, is - permitted provided that the following conditions are met: - - 1. You agree not to attempt to decompile, disassemble, reverse engineer or - otherwise discover the source code from which the binary code was derived. - You may, however, access and obtain a separate license for most of the - source code from which this Software was created, at - http://realm.io/pricing/. - - 2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - 3. Neither the name of the copyright holder nor the names of its - contributors may be used to endorse or promote products derived from this - software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - -3. ------------------------------------------------------------------------------- - EXPORT COMPLIANCE You understand that the Software may contain cryptographic functions that may be diff --git a/README.md b/README.md index cfcfb0b61d..5c72db770b 100644 --- a/README.md +++ b/README.md @@ -70,34 +70,24 @@ In case you don't want to use the precompiled version, you can build Realm yours ### Prerequisites * Download the [**JDK 8**](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html) from Oracle and install it. - * The latest stable version of Android Studio. Currently [3.6.2](https://developer.android.com/studio/). - * Download & install the Android SDK **Build-Tools 28.0.3**, **Android Pie (API 28)** (for example through Android Studio’s **Android SDK Manager**). - * Install CMake from SDK manager in Android Studio ("SDK Tools" -> "CMake"). - * Install the NDK (currently r21) from the SDK Manager in Android Studio or using the [website](https://developer.android.com/ndk/downloads). If downloaded -You may unzip the file wherever you choose. For macOS, a suggested location is `~/Library`. The download will unzip as the directory `android-ndk-r21`. + * The latest stable version of Android Studio. Currently [4.1.1](https://developer.android.com/studio/). + * Download & install the Android SDK **Build-Tools 29.0.3**, **Android Pie (API 29)** (for example through Android Studio’s **Android SDK Manager**). + * Install CMake version 3.18.2 and build Ninja. + * Install the NDK (Side-by-side) **21.0.6113669** from the SDK Manager in Android Studio. Remember to check `☑ Show package details` in the manager to display all available versions. - * If you will be building with Android Studio, you will need to tell it to use the correct NDK. If you installed it using the SDK Manager, it will automatically be detected. Otherwise, you need to define the variable `ndk.dir` in `realm/local.properties` and assign it the full pathname of the directory that you unzipped above. Note that there is a `local.properites` in the root directory that is *not* the one that needs to be edited. + * Add the Android home environment variable to your profile: ``` - ndk.dir=/Users//Library/android-sdk/ndk/21.0.6113669 - - ``` - - * Add two environment variables to your profile (presuming you installed the NDK using the SDK Manager): - - ``` - export ANDROID_HOME=~/Library/android-sdk - export ANDROID_NDK_HOME=~/Library/android-sdk/ndk/21.0.6113669 + export ANDROID_HOME=~/Library/Android/sdk ``` - * If you are launching Android Studio from the macOS Finder, you should also run the following two commands: + * If you are launching Android Studio from the macOS Finder, you should also run the following command: ``` launchctl setenv ANDROID_HOME "$ANDROID_HOME" - launchctl setenv ANDROID_NDK_HOME "$ANDROID_NDK_HOME" ``` - * If you'd like to specify the location in which to store the archives of Realm Core, define the `REALM_CORE_DOWNLOAD_DIR` environment variable. It enables you to keep Core's archive when executing `git clean -xfd`. + * If you'd like to specify the location in which to store the archives of Realm Core, define the `REALM_CORE_DOWNLOAD_DIR` environment variable. It enables caching core release artifacts. ``` export REALM_CORE_DOWNLOAD_DIR=~/.realmCore @@ -113,7 +103,7 @@ It would be a good idea to add all of the symbol definitions (and their accompan * If you develop Realm Java with Android Studio, we recommend you to exclude some directories from indexing target by executing following steps on Android Studio. It really speeds up indexing phase after the build. - - Under `/realm/realm-library/`, select `build`, `.externalNativeBuild` and `distribution` folders in `Project` view. + - Under `/realm/realm-library/`, select `build`, `.cxx` and `distribution` folders in `Project` view. - Press `Command + Shift + A` to open `Find action` dialog. If you are not using default keymap nor using macOS, you can find your shortcut key in `Keymap` preference by searching `Find action`. - Search `Excluded` (not `Exclude`) action and select it. Selected folder icons should become orange (in default theme). - Restart Android Studio. @@ -151,22 +141,28 @@ The full build may take an hour or more, to complete. ### Building from source -It is possible to build Realm Java against a local checked out version of Realm Core. This is done by providing the following parameter when building: `-PcoreSourcePath=`. +It is possible to build Realm Java with the submodule version of Realm Core. This is done by providing the following parameter when building: `-PbuildCore=true`. -E.g in the case where the `realm-java` and `realm-core` repos are checked out next to each other you can build from source using: +``` +./gradlew assembleBase -PbuildCore=true +``` + +You can turn off interprocedural optimizations with the following parameter: `-PenableLTO=false`. ``` -git clone https://github.com/realm/realm-java.git -git clone https://github.com/realm/realm-core.git -cd realm-java/realm -./gradlew assembleBase -PcoreSourcePath=../../realm-core +./gradlew assembleBase -PenableLTO=false` ``` -Note: If the `realm-core` project has already been compiled for non-Android builds and CMake files have been generated, this might conflict with `realm-java` trying to build it. Cleanup the `realm-core` project by calling `git clean -xfd` inside it (beware that all unsaved changes will be lost). +Note: Building the `Base` variant would always build realm-core. + +Note: Interprocedural optimizations are enabled by default. -Note: Building from source with Realm Sync is not enabled yet. Only building the `Base` variant is supported. +Note: If you want to build from source inside Android Studio, you need to update the Gradle parameters by going into the Realm projects settings `Settings > Build, Execution, Deployment > Compiler > Command-line options` and add `-PbuildCore=true` or `-PenableLTO=false` to it. Alternatively you can add it into your `gradle.properties`: -Note: If you want to build from source inside Android Studio, you need to update the Gradle parameters by going into the Realm projects settings `Settings > Build, Execution, Deployment > Compiler > Command-line options` and add `-PcoreSourcePath=` to it. +``` +buildCore=true +enableLTO=false +``` Note: If building on OSX you might like to prevent Gatekeeper to block all NDK executables by disabling it: `sudo spctl --master-disable`. Remember to enable it afterwards: `sudo spctl --master-enable` diff --git a/build.gradle b/build.gradle index 09d29884d3..9d6773f79b 100644 --- a/build.gradle +++ b/build.gradle @@ -40,6 +40,9 @@ def copyProperties = { if (project.hasProperty('s3cfg')) { startParameter.projectProperties += [s3cfg: project.getProperty('s3cfg')] } + if (project.hasProperty('enableLTO')) { + startParameter.projectProperties += [enableLTO: project.getProperty('enableLTO')] + } } task assembleAnnotations(type:GradleBuild) { diff --git a/dependencies.list b/dependencies.list index 8265c6d795..10d689dce9 100644 --- a/dependencies.list +++ b/dependencies.list @@ -1,7 +1,6 @@ -# Realm Sync release used by Realm Java (This includes Realm Core) -# https://github.com/realm/realm-sync/releases -REALM_SYNC=10.1.4 -REALM_SYNC_SHA256=f838a27402c5b5243280102014defd844420abba66eb93c10334507d9c0fd513 +# Realm Core release used by Realm Java +# https://github.com/realm/realm-core/releases +REALM_CORE=10.3.3 # Version of MongoDB Realm used by integration tests # See https://github.com/realm/ci/packages/147854 for available versions @@ -18,6 +17,7 @@ gradle=6.5 ndkVersion=21.0.6113669 BUILD_INFO_EXTRACTOR_GRADLE=4.17.0 GRADLE_BINTRAY_PLUGIN=1.8.5 +CMAKE=3.18.4 # Bson dependency version BSON_DEPENDENCY=3.12.1 diff --git a/realm-transformer/build.gradle b/realm-transformer/build.gradle index 48fda83a40..aadd205d1a 100644 --- a/realm-transformer/build.gradle +++ b/realm-transformer/build.gradle @@ -26,7 +26,7 @@ version = file("${projectDir}/../version.txt").text.trim() def properties = new Properties() properties.load(new FileInputStream("${projectDir}/../dependencies.list")) -def syncVersion = properties.getProperty('REALM_SYNC') +def coreVersion = properties.getProperty('REALM_CORE') sourceCompatibility = '1.8' targetCompatibility = '1.8' @@ -67,7 +67,7 @@ import org.apache.tools.ant.filters.ReplaceTokens task generateVersionClass(type: Copy) { from 'src/main/templates/Version.java' into 'build/generated-src/main/java/io/realm/transformer' - filter(ReplaceTokens, tokens: [version: version, syncVersion: syncVersion]) + filter(ReplaceTokens, tokens: [version: version, coreVersion: coreVersion]) outputs.upToDateWhen { false } } diff --git a/realm-transformer/src/main/templates/Version.java b/realm-transformer/src/main/templates/Version.java index 9239f52d3e..9ea6a82503 100644 --- a/realm-transformer/src/main/templates/Version.java +++ b/realm-transformer/src/main/templates/Version.java @@ -2,5 +2,5 @@ public class Version { public static final String VERSION = "@version@"; - public static final String SYNC_VERSION = "@syncVersion@"; + public static final String SYNC_VERSION = "@coreVersion@"; } diff --git a/realm/realm-library/build.gradle b/realm/realm-library/build.gradle index bcdf975990..7aa16a995e 100644 --- a/realm/realm-library/build.gradle +++ b/realm/realm-library/build.gradle @@ -16,26 +16,8 @@ apply plugin: 'net.ltgt.errorprone' def properties = new Properties() properties.load(new FileInputStream("${projectDir}/../../dependencies.list")) -ext.coreVersion = properties.getProperty('REALM_SYNC') -// empty or comment out this to disable hash checking -ext.coreSha256Hash = properties.getProperty('REALM_SYNC_SHA256') -ext.forceDownloadCore = project.hasProperty('forceDownloadCore') ? project.getProperty('forceDownloadCore').toBoolean() : false - -// Set the core source code path. By setting this, the core will be built from source. And coreVersion will be read from -// core source code. -ext.coreSourcePath = project.hasProperty('coreSourcePath') ? file(project.getProperty('coreSourcePath')) : null -// The location of pre-compiled Realm Core/Sync archive. -ext.coreArchiveDir = System.getenv("REALM_CORE_DOWNLOAD_DIR") -if (!ext.coreArchiveDir) { - ext.coreArchiveDir = ".." -} -ext.coreArchiveFile = rootProject.file("${ext.coreArchiveDir}/realm-sync-android-${project.coreVersion}.tar.gz") -ext.coreDistributionDir = file("${projectDir}/distribution/realm-core/") -ext.coreDir = file("${project.coreDistributionDir.getAbsolutePath()}/core-${project.coreVersion}") ext.ccachePath = project.findProperty('ccachePath') ?: System.getenv('NDK_CCACHE') ext.lcachePath = project.findProperty('lcachePath') ?: System.getenv('NDK_LCACHE') -// Set to true to enable linking with debug core. -ext.enableDebugCore = project.hasProperty('enableDebugCore') ? project.getProperty('enableDebugCore') : true android { compileSdkVersion rootProject.compileSdkVersion @@ -50,17 +32,17 @@ android { multiDexEnabled true externalNativeBuild { cmake { - arguments "-DREALM_CORE_DIST_DIR:STRING=${project.coreDir.getAbsolutePath()}", - "-DENABLE_DEBUG_CORE=$project.enableDebugCore" if (project.ccachePath) arguments "-DNDK_CCACHE=$project.ccachePath" if (project.lcachePath) arguments "-DNDK_LCACHE=$project.lcachePath" - if (project.coreSourcePath) arguments "-DCORE_SOURCE_PATH=${project.coreSourcePath.getAbsolutePath()}" if (project.hasProperty('buildTargetABIs') && !project.getProperty('buildTargetABIs').trim().isEmpty()) { abiFilters(*project.getProperty('buildTargetABIs').trim().split('\\s*,\\s*')) } else { // "armeabi" and "mips" are no longer supported by the NDK abiFilters 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a' } + + arguments "-DREALM_JAVA_BUILD_CORE_FROM_SOURCE=${project.hasProperty('buildCore') && project.getProperty('buildCore').toBoolean()}" + arguments "-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=${!project.hasProperty('enableLTO') || project.getProperty('enableLTO').toBoolean()}" } } @@ -68,17 +50,18 @@ android { debug { javaCompileOptions { annotationProcessorOptions { - arguments += [ 'realm.suppressWarnings' : 'false' ] + arguments += ['realm.suppressWarnings': 'false'] } } } } } - ndkVersion = "21.0.6113669" + ndkVersion = '21.0.6113669' externalNativeBuild { cmake { + version = properties.getProperty('CMAKE') path 'src/main/cpp/CMakeLists.txt' } } @@ -92,6 +75,10 @@ android { } release { + externalNativeBuild { + cmake { + } + } // minifyEnabled = true; } } @@ -107,7 +94,7 @@ android { java.srcDirs += [/* FIXME 'src/syncIntegrationTest/java', */ 'src/syncIntegrationTest/kotlin', 'src/androidTestObjectServer/kotlin', 'src/syncTestUtils/java' - , 'src/syncTestUtils/kotlin'] + , 'src/syncTestUtils/kotlin'] assets.srcDirs += ['src/syncIntegrationTest/assets/'] } } @@ -153,15 +140,6 @@ android { proguardFiles 'proguard-rules-build-common.pro', 'proguard-rules-build-objectServer.pro' } } - - variantFilter { variant -> - def names = variant.flavors*.name - - // Ignore the objectServer flavour when building from core source. - if (coreSourcePath && names.contains("objectServer")) { - variant.ignore = true - } - } } @@ -474,111 +452,7 @@ artifacts { archives sourcesJar } - -def coreDownloaded = false - -task downloadCore() { - group = 'build setup' - description = 'Download the latest version of Realm Core' - def isHashCheckingEnabled = { - return project.hasProperty('coreSha256Hash') && !project.coreSha256Hash.empty - } - - def calcSha256Hash = { File targetFile -> - MessageDigest sha = MessageDigest.getInstance("SHA-256") - Formatter hexHash = new Formatter() - sha.digest(targetFile.bytes).each { b -> hexHash.format('%02x', b) } - return hexHash.toString() - } - - def shouldDownloadCore = { - if (coreSourcePath) { - println "shouldDownloadCore: skipping, using local Core at: ${coreSourcePath}." - return false - } - - if (!project.coreArchiveFile.exists()) { - return true - } - if (project.forceDownloadCore) { - return true - } - if (!isHashCheckingEnabled()) { - println "shouldDownloadCore: skipping hash check(empty \'coreSha256Hash\')." - return false - } - - def calculatedHash = calcSha256Hash(project.coreArchiveFile) - if (project.coreSha256Hash.equalsIgnoreCase(calculatedHash)) { - return false - } - - println "Existing archive hash mismatch (Expected: ${project.coreSha256Hash.toLowerCase()}" + - " but got ${calculatedHash.toLowerCase()}). Download new version." - return true - } - - doLast { - if (shouldDownloadCore()) { - download { - src "http://static.realm.io/downloads/sync/realm-sync-android-${project.coreVersion}.tar.gz" - dest project.coreArchiveFile - onlyIfNewer false - } - coreDownloaded = true - - if (isHashCheckingEnabled()) { - def calculatedHash = calcSha256Hash(project.coreArchiveFile) - if (!project.coreSha256Hash.equalsIgnoreCase(calculatedHash)) { - throw new GradleException("Invalid checksum for file '" + - "${project.coreArchiveFile.getName()}'. Expected " + - "${project.coreSha256Hash.toLowerCase()} but got " + - "${calculatedHash.toLowerCase()}.") - } - } else { - println 'Skipping hash check (empty \'coreSha256Hash\').' - } - } - } -} - -task deployCore(group: 'build setup', description: 'Deploy the latest version of Realm Core') { - dependsOn { - downloadCore - } - - // Build with the output from core source dir. No need to deploy anything. - onlyIf { - return !coreSourcePath - } - - outputs.upToDateWhen { - // Clean up the coreDir if it is newly downloaded - if (coreDownloaded) { - return false - } - - return project.coreDir.exists() - } - - doLast { - // Delete all files to avoid multiple copies of the same header file in Android Studio. - exec { - commandLine = [ - 'rm', - '-rf', - project.coreDistributionDir.getAbsolutePath() - ] - } - copy { - from tarTree(project.coreArchiveFile) - into project.coreDir - } - } -} - publishToMavenLocal.dependsOn assemble -preBuild.dependsOn deployCore if (project.hasProperty('dontCleanJniFiles')) { project.afterEvaluate { diff --git a/realm/realm-library/src/androidTest/java/io/realm/ManagedOrderedRealmCollectionTests.java b/realm/realm-library/src/androidTest/java/io/realm/ManagedOrderedRealmCollectionTests.java index 56b6c6970d..43f2bdab4a 100644 --- a/realm/realm-library/src/androidTest/java/io/realm/ManagedOrderedRealmCollectionTests.java +++ b/realm/realm-library/src/androidTest/java/io/realm/ManagedOrderedRealmCollectionTests.java @@ -18,6 +18,7 @@ import org.junit.After; import org.junit.Before; +import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; diff --git a/realm/realm-library/src/androidTest/java/io/realm/RealmJsonTests.java b/realm/realm-library/src/androidTest/java/io/realm/RealmJsonTests.java index 13d71fc6bc..081bc93911 100644 --- a/realm/realm-library/src/androidTest/java/io/realm/RealmJsonTests.java +++ b/realm/realm-library/src/androidTest/java/io/realm/RealmJsonTests.java @@ -20,9 +20,6 @@ import android.os.Build; import android.util.Base64; -import androidx.test.ext.junit.runners.AndroidJUnit4; -import androidx.test.platform.app.InstrumentationRegistry; - import org.bson.types.Decimal128; import org.bson.types.ObjectId; import org.json.JSONArray; @@ -30,6 +27,7 @@ import org.json.JSONObject; import org.junit.After; import org.junit.Before; +import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -49,6 +47,8 @@ import javax.annotation.Nullable; +import androidx.test.ext.junit.runners.AndroidJUnit4; +import androidx.test.platform.app.InstrumentationRegistry; import io.realm.entities.AllTypes; import io.realm.entities.AllTypesPrimaryKey; import io.realm.entities.AnnotationTypes; diff --git a/realm/realm-library/src/androidTest/java/io/realm/RealmResultsTests.java b/realm/realm-library/src/androidTest/java/io/realm/RealmResultsTests.java index b892f38fe9..9366c51dea 100644 --- a/realm/realm-library/src/androidTest/java/io/realm/RealmResultsTests.java +++ b/realm/realm-library/src/androidTest/java/io/realm/RealmResultsTests.java @@ -16,14 +16,12 @@ package io.realm; -import androidx.test.annotation.UiThreadTest; -import androidx.test.ext.junit.runners.AndroidJUnit4; - import org.bson.types.Decimal128; import org.bson.types.ObjectId; import org.json.JSONException; import org.junit.After; import org.junit.Before; +import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; @@ -42,6 +40,8 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; +import androidx.test.annotation.UiThreadTest; +import androidx.test.ext.junit.runners.AndroidJUnit4; import io.realm.entities.AllJavaTypes; import io.realm.entities.AllTypes; import io.realm.entities.CyclicType; diff --git a/realm/realm-library/src/androidTest/java/io/realm/RealmTests.java b/realm/realm-library/src/androidTest/java/io/realm/RealmTests.java index 8ee1772a6c..e2bd49ee12 100644 --- a/realm/realm-library/src/androidTest/java/io/realm/RealmTests.java +++ b/realm/realm-library/src/androidTest/java/io/realm/RealmTests.java @@ -21,11 +21,6 @@ import android.os.Looper; import android.os.SystemClock; -import androidx.test.annotation.UiThreadTest; -import androidx.test.ext.junit.runners.AndroidJUnit4; -import androidx.test.platform.app.InstrumentationRegistry; -import androidx.test.rule.UiThreadTestRule; - import junit.framework.AssertionFailedError; import org.bson.types.Decimal128; @@ -37,6 +32,7 @@ import org.junit.After; import org.junit.Assume; import org.junit.Before; +import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; @@ -70,6 +66,10 @@ import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicReference; +import androidx.test.annotation.UiThreadTest; +import androidx.test.ext.junit.runners.AndroidJUnit4; +import androidx.test.platform.app.InstrumentationRegistry; +import androidx.test.rule.UiThreadTestRule; import io.realm.entities.AllJavaTypes; import io.realm.entities.AllTypes; import io.realm.entities.AllTypesPrimaryKey; diff --git a/realm/realm-library/src/main/cpp/CMake/RealmCore.cmake b/realm/realm-library/src/main/cpp/CMake/RealmCore.cmake deleted file mode 100644 index 6014163b4f..0000000000 --- a/realm/realm-library/src/main/cpp/CMake/RealmCore.cmake +++ /dev/null @@ -1,130 +0,0 @@ -########################################################################### -# -# Copyright 2017 Realm Inc. -# -# 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. -# -########################################################################### -include(ExternalProject) - -function(build_existing_realm_core core_source_path) - if (CMAKE_BUILD_TYPE STREQUAL "Debug") - set(debug_lib_suffix "-dbg") - add_compile_options(-DREALM_DEBUG) - else() - add_compile_options(-DNDEBUG) - endif() - - # We mirror relevant flags from this script - # https://github.com/realm/realm-core/blob/master/tools/cross_compile.sh#L68 - ExternalProject_Add(realm-core - SOURCE_DIR ${core_source_path} - PREFIX ${core_source_path}/build-android-${ANDROID_ABI}-${CMAKE_BUILD_TYPE} - CMAKE_ARGS -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} - -DANDROID_ABI=${ANDROID_ABI} - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} - -DREALM_BUILD_LIB_ONLY=YES - -DREALM_ENABLE_ENCRYPTION=1 - INSTALL_COMMAND "" - LOG_CONFIGURE 1 - LOG_BUILD 1 - ) - - ExternalProject_Get_Property(realm-core SOURCE_DIR) - ExternalProject_Get_Property(realm-core BINARY_DIR) - - # Create directories that are included in INTERFACE_INCLUDE_DIRECTORIES, as CMake requires they exist at - # configure time, when they'd otherwise not be created until we download and extract core. - file(MAKE_DIRECTORY "${BINARY_DIR}/src") - - set(core_lib_file "${BINARY_DIR}/src/realm/librealm${debug_lib_suffix}.a") - add_library(lib_realm_core STATIC IMPORTED) - set_target_properties(lib_realm_core PROPERTIES IMPORTED_LOCATION ${core_lib_file} - IMPORTED_LINK_INTERFACE_LIBRARIES atomic - INTERFACE_INCLUDE_DIRECTORIES "${SOURCE_DIR}/src;${BINARY_DIR}/src") - - ExternalProject_Add_Step(realm-core ensure-libraries - DEPENDEES build - BYPRODUCTS ${core_lib_file} - ) - - add_dependencies(lib_realm_core realm-core) -endfunction() - -# Add the sync released as the library. -function(use_sync_release enable_sync sync_dist_path) - # Link to core/sync debug lib for debug build if it is debug build and linking with debug core is enabled. - if (CMAKE_BUILD_TYPE STREQUAL "Debug" AND ${ENABLE_DEBUG_CORE}) - set(debug_lib_suffix "-dbg") - add_compile_options(-DREALM_DEBUG) - else() - add_compile_options(-DNDEBUG) - endif() - - # Configure import realm core lib - set(core_lib_path ${sync_dist_path}/librealm-android-${ANDROID_ABI}${debug_lib_suffix}.a) - if (NOT EXISTS ${core_lib_path}) - if (ARMEABI) - set(core_lib_path ${sync_dist_path}/librealm-android-arm${debug_lib_suffix}.a) - elseif (ARMEABI_V7A) - set(core_lib_path ${sync_dist_path}/librealm-android-arm-v7a${debug_lib_suffix}.a) - elseif (ARM64_V8A) - set(core_lib_path ${sync_dist_path}/librealm-android-arm64${debug_lib_suffix}.a) - else() - message(FATAL_ERROR "Cannot find core lib file: ${core_lib_path}") - endif() - endif() - - add_library(lib_realm_core STATIC IMPORTED) - - # -latomic is not set by default for mips and armv5. - # See https://code.google.com/p/android/issues/detail?id=182094 - list(APPEND LIB_INCLUDE_DIRS "${sync_dist_path}/include") - list(APPEND LIB_INCLUDE_DIRS "${sync_dist_path}/include/realm") - set_target_properties(lib_realm_core PROPERTIES IMPORTED_LOCATION ${core_lib_path} - IMPORTED_LINK_INTERFACE_LIBRARIES atomic - INTERFACE_INCLUDE_DIRECTORIES "${LIB_INCLUDE_DIRS}") - - if (enable_sync) - # Sync static library - set(sync_lib_path ${sync_dist_path}/librealm-sync-android-${ANDROID_ABI}${debug_lib_suffix}.a) - # Workaround for old core's funny ABI nicknames - if (NOT EXISTS ${sync_lib_path}) - if (ARMEABI) - set(sync_lib_path ${sync_dist_path}/librealm-sync-android-arm${debug_lib_suffix}.a) - elseif (ARMEABI_V7A) - set(sync_lib_path ${sync_dist_path}/librealm-sync-android-arm-v7a${debug_lib_suffix}.a) - elseif (ARM64_V8A) - set(sync_lib_path ${sync_dist_path}/librealm-sync-android-arm64${debug_lib_suffix}.a) - else() - message(FATAL_ERROR "Cannot find sync lib file: ${sync_lib_path}") - endif() - endif() - add_library(lib_realm_sync STATIC IMPORTED) - set_target_properties(lib_realm_sync PROPERTIES IMPORTED_LOCATION ${sync_lib_path} - IMPORTED_LINK_INTERFACE_LIBRARIES lib_realm_core) - endif() - - set(REALM_CORE_INCLUDE_DIR "${sync_dist_path}/include") -endfunction() - -# Add core/sync libraries. Set the core_source_path to build core from source. -# FIXME: Build from sync source is not supported yet. -function(use_realm_core enable_sync sync_dist_path core_source_path) - if (core_source_path) - message("Building Realm Core from local source in ${core_source_path}.") - build_existing_realm_core(${core_source_path}) - else() - use_sync_release(${enable_sync} ${sync_dist_path}) - endif() -endfunction() diff --git a/realm/realm-library/src/main/cpp/CMakeLists.txt b/realm/realm-library/src/main/cpp/CMakeLists.txt index ebf8cd36a5..ea02abd736 100644 --- a/realm/realm-library/src/main/cpp/CMakeLists.txt +++ b/realm/realm-library/src/main/cpp/CMakeLists.txt @@ -15,11 +15,13 @@ # limitations under the License. # ########################################################################### -cmake_minimum_required(VERSION 3.6.0) +cmake_minimum_required(VERSION 3.15.0) +project(RealmJava) # loading dependencies properties file(STRINGS "${CMAKE_SOURCE_DIR}/../../../../../dependencies.list" DEPENDENCIES) foreach(LINE IN LISTS DEPENDENCIES) + string(REGEX MATCHALL "([^=]+)" KEY_VALUE "${LINE}") list(LENGTH KEY_VALUE matches_count) if(matches_count STREQUAL 2) @@ -36,8 +38,6 @@ FUNCTION(capitalizeFirstLetter var value) set(${var} "${value}" PARENT_SCOPE) ENDFUNCTION(capitalizeFirstLetter) -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake") - # find javah find_package(Java COMPONENTS Development) if (NOT Java_Development_FOUND) @@ -64,11 +64,11 @@ if(NDK_LCACHE) set(CMAKE_CXX_CREATE_SHARED_LIBRARY "${NDK_LCACHE} ${CMAKE_CXX_CREATE_SHARED_LIBRARY}") endif() -# Set flag build_SYNC +# Set flag REALM_ENABLE_SYNC if (REALM_FLAVOR STREQUAL base) - set(build_SYNC OFF) + set(REALM_ENABLE_SYNC OFF) else() - set(build_SYNC ON) + set(REALM_ENABLE_SYNC ON) endif() # Format strings used to represent build parameters: Variant and Type @@ -100,7 +100,7 @@ set(classes_LIST # /./ is the workaround for the problem that AS cannot find the jni headers. # See https://github.com/googlesamples/android-ndk/issues/319 set(jni_headers_PATH /./${PROJECT_BINARY_DIR}/jni_include) -if (build_SYNC) +if (REALM_ENABLE_SYNC) list(APPEND classes_LIST io.realm.mongodb.App io.realm.mongodb.ApiKeyAuthImpl @@ -131,32 +131,50 @@ create_javah(TARGET jni_headers DEPENDS ${classes_PATH} ) -include(RealmCore) -use_realm_core(${build_SYNC} "${REALM_CORE_DIST_DIR}" "${CORE_SOURCE_PATH}") +# Check if user defined download location +if(NOT DEFINED ENV{REALM_CORE_DOWNLOAD_DIR}) + set(REALM_CORE_DOWNLOAD_DIR ${CMAKE_BINARY_DIR}) +else() + set(REALM_CORE_DOWNLOAD_DIR $ENV{REALM_CORE_DOWNLOAD_DIR}) +endif() + +if(REALM_JAVA_BUILD_CORE_FROM_SOURCE OR NOT REALM_ENABLE_SYNC) + message(STATUS "Building Realm Core from source...") + + set(REALM_BUILD_LIB_ONLY ON) + add_subdirectory(realm-core EXCLUDE_FROM_ALL) +else() + message(STATUS "Using prebuilt Realm Core.") + + # CMAKE_INTERPROCEDURAL_OPTIMIZATION is not compatible with binary artifacts. + set(CMAKE_INTERPROCEDURAL_OPTIMIZATION OFF) + + execute_process(COMMAND "${CMAKE_COMMAND}" "-E" "environment") + set(core_filename "realm-${CMAKE_BUILD_TYPE}-v${DEP_REALM_CORE}-Android-${CMAKE_ANDROID_ARCH_ABI}-devel") + + # Use cached resources if possible + if(NOT EXISTS "${REALM_CORE_DOWNLOAD_DIR}/${core_filename}.tar.gz") + message(STATUS "Downloading ${core_filename}...") + file(DOWNLOAD "https://static.realm.io/downloads/core/${core_filename}.tar.gz" "${REALM_CORE_DOWNLOAD_DIR}/${core_filename}.tar.gz") + else() + file(TIMESTAMP "${REALM_CORE_DOWNLOAD_DIR}/${core_filename}.tar.gz" CORE_FILE_TIMESTAMP "%b %d %H:%M") + message(STATUS "Using cached filename: ${core_filename}.tar.gz : ${CORE_FILE_TIMESTAMP}") + endif() -# Download OpenSSL lib -# FIXME Read the openssl version from core when the core/sync release has that information. -set(openssl_VERSION "1.1.1b") -set(openssl_FILENAME "openssl.tgz") -set(openssl_URL "https://static.realm.io/downloads/openssl/${openssl_VERSION}/Android/${ANDROID_ABI}/${openssl_FILENAME}") + message(STATUS "Uncompressing realm-core...") + file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/${core_filename}") -message(STATUS "Downloading OpenSSL...") -file(DOWNLOAD "${openssl_URL}" "${PROJECT_BINARY_DIR}/${openssl_FILENAME}") + execute_process(COMMAND ${CMAKE_COMMAND} -E tar xfz "${REALM_CORE_DOWNLOAD_DIR}/${core_filename}.tar.gz" + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/${core_filename}") -message(STATUS "Uncompressing OpenSSL: ${PROJECT_BINARY_DIR}/${openssl_FILENAME}") -execute_process(COMMAND ${CMAKE_COMMAND} -E tar xfz "${openssl_FILENAME}" WORKING_DIRECTORY "${PROJECT_BINARY_DIR}") -message(STATUS "Importing OpenSSL...") -include(${PROJECT_BINARY_DIR}/lib/cmake/OpenSSL/OpenSSLConfig.cmake) -get_target_property(openssl_include_DIR OpenSSL::Crypto INTERFACE_INCLUDE_DIRECTORIES) -get_target_property(crypto_LIB OpenSSL::Crypto IMPORTED_LOCATION) -get_target_property(ssl_LIB OpenSSL::SSL IMPORTED_LOCATION) + include(${CMAKE_BINARY_DIR}/${core_filename}/lib/cmake/Realm/RealmConfig.cmake) +endif() # build application's shared lib include_directories( - ${CMAKE_SOURCE_DIR} - ${jni_headers_PATH} - ${CMAKE_SOURCE_DIR}/object-store/src - ${CMAKE_SOURCE_DIR}/object-store/external/json) + ${CMAKE_SOURCE_DIR} + ${jni_headers_PATH} +) # Hack the memmove bug on Samsung device. if (ARMEABI OR ARMEABI_V7A) @@ -176,10 +194,10 @@ set(WARNING_CXX_FLAGS "-Werror -Wall -Wextra -pedantic -Wmissing-declarations \ -Wno-missing-field-initializers -Wno-unevaluated-expression -Wno-unreachable-code \ -Wno-c99-extensions") set(REALM_COMMON_CXX_FLAGS "${REALM_COMMON_CXX_FLAGS} -DREALM_ANDROID -DREALM_HAVE_CONFIG -DPIC -fdata-sections -pthread -frtti -fvisibility=hidden -fsigned-char -fno-stack-protector -std=c++17") -if (build_SYNC) +if (REALM_ENABLE_SYNC) set(REALM_COMMON_CXX_FLAGS "${REALM_COMMON_CXX_FLAGS} -DREALM_ENABLE_SYNC=1") endif() -set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG -Oz") +set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG -O2") # -ggdb doesn't play well with -flto set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -glldb -g") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${REALM_COMMON_CXX_FLAGS} ${WARNING_CXX_FLAGS} ${ABI_CXX_FLAGS}") @@ -188,7 +206,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${REALM_COMMON_CXX_FLAGS} ${WARNING_CXX_ if (CMAKE_BUILD_TYPE STREQUAL "Release") set(REALM_LINKER_FLAGS "${REALM_LINKER_FLAGS} -Wl,-gc-sections") endif() -if (build_SYNC) +if (REALM_ENABLE_SYNC) set(REALM_LINKER_FLAGS "${REALM_LINKER_FLAGS} -lz") endif() set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${REALM_LINKER_FLAGS}") @@ -200,7 +218,7 @@ file(GLOB jni_SRC "jni_impl/android_logger.cpp" ) # Those source file are only needed for sync. -if (NOT build_SYNC) +if (NOT REALM_ENABLE_SYNC) list(REMOVE_ITEM jni_SRC ${CMAKE_CURRENT_SOURCE_DIR}/io_realm_mongodb_User.cpp ${CMAKE_CURRENT_SOURCE_DIR}/io_realm_mongodb_FunctionsImpl.cpp @@ -225,34 +243,10 @@ if (NOT build_SYNC) ) endif() -# Object Store source files -file(GLOB objectstore_SRC - "object-store/src/*.cpp" - "object-store/src/impl/*.cpp" - "object-store/src/impl/epoll/*.cpp" - "object-store/src/util/*.cpp" - "object-store/src/impl/epoll/*.cpp" - "object-store/src/util/android/*.cpp") - -# Sync needed Object Store files -if (build_SYNC) - file(GLOB objectstore_sync_SRC - "object-store/src/results.cpp" - "object-store/src/impl/results_notifier.cpp" - "object-store/src/sync/*.cpp" - "object-store/src/util/bson/*.cpp" - "object-store/src/sync/impl/*.cpp") -endif() - -add_library(realm-jni SHARED ${jni_SRC} ${objectstore_SRC} ${objectstore_sync_SRC}) +add_library(realm-jni SHARED ${jni_SRC}) +target_link_libraries(realm-jni log android Realm::ObjectStore) add_dependencies(realm-jni jni_headers) -if (build_SYNC) - target_link_libraries(realm-jni log android lib_realm_sync OpenSSL::SSL OpenSSL::Crypto) -else() - target_link_libraries(realm-jni log android lib_realm_core OpenSSL::Crypto) -endif() - # Strip the release so files and backup the unstripped versions if (CMAKE_BUILD_TYPE STREQUAL "Release") set(unstripped_SO_DIR diff --git a/realm/realm-library/src/main/cpp/io_realm_RealmQuery.cpp b/realm/realm-library/src/main/cpp/io_realm_RealmQuery.cpp index b2754775a9..dcd77ccaf2 100644 --- a/realm/realm-library/src/main/cpp/io_realm_RealmQuery.cpp +++ b/realm/realm-library/src/main/cpp/io_realm_RealmQuery.cpp @@ -16,8 +16,8 @@ #include "io_realm_RealmQuery.h" -#include -#include +#include +#include #include "util.hpp" diff --git a/realm/realm-library/src/main/cpp/io_realm_internal_OsCollectionChangeSet.cpp b/realm/realm-library/src/main/cpp/io_realm_internal_OsCollectionChangeSet.cpp index 7048bc12e6..eed33dec4d 100644 --- a/realm/realm-library/src/main/cpp/io_realm_internal_OsCollectionChangeSet.cpp +++ b/realm/realm-library/src/main/cpp/io_realm_internal_OsCollectionChangeSet.cpp @@ -16,7 +16,7 @@ #include "io_realm_internal_OsCollectionChangeSet.h" -#include +#include #include "util.hpp" diff --git a/realm/realm-library/src/main/cpp/io_realm_internal_OsList.cpp b/realm/realm-library/src/main/cpp/io_realm_internal_OsList.cpp index f2023f6563..e12b5fa6f1 100644 --- a/realm/realm-library/src/main/cpp/io_realm_internal_OsList.cpp +++ b/realm/realm-library/src/main/cpp/io_realm_internal_OsList.cpp @@ -16,9 +16,9 @@ #include "io_realm_internal_OsList.h" -#include -#include -#include +#include +#include +#include #include "observable_collection_wrapper.hpp" #include "java_accessor.hpp" diff --git a/realm/realm-library/src/main/cpp/io_realm_internal_OsObject.cpp b/realm/realm-library/src/main/cpp/io_realm_internal_OsObject.cpp index 699ebd3d85..8582f220f7 100644 --- a/realm/realm-library/src/main/cpp/io_realm_internal_OsObject.cpp +++ b/realm/realm-library/src/main/cpp/io_realm_internal_OsObject.cpp @@ -20,9 +20,9 @@ #include #endif -#include -#include -#include +#include +#include +#include #include "util.hpp" #include "java_class_global_def.hpp" diff --git a/realm/realm-library/src/main/cpp/io_realm_internal_OsObjectSchemaInfo.cpp b/realm/realm-library/src/main/cpp/io_realm_internal_OsObjectSchemaInfo.cpp index 5835ced274..d108b2da85 100644 --- a/realm/realm-library/src/main/cpp/io_realm_internal_OsObjectSchemaInfo.cpp +++ b/realm/realm-library/src/main/cpp/io_realm_internal_OsObjectSchemaInfo.cpp @@ -18,8 +18,8 @@ #include -#include -#include +#include +#include #include "java_accessor.hpp" #include "java_exception_def.hpp" diff --git a/realm/realm-library/src/main/cpp/io_realm_internal_OsObjectStore.cpp b/realm/realm-library/src/main/cpp/io_realm_internal_OsObjectStore.cpp index b2d3d3cd2c..f78ef4b89f 100644 --- a/realm/realm-library/src/main/cpp/io_realm_internal_OsObjectStore.cpp +++ b/realm/realm-library/src/main/cpp/io_realm_internal_OsObjectStore.cpp @@ -16,8 +16,8 @@ #include "io_realm_internal_OsObjectStore.h" -#include -#include +#include +#include #include "util.hpp" #include "jni_util/java_method.hpp" diff --git a/realm/realm-library/src/main/cpp/io_realm_internal_OsRealmConfig.cpp b/realm/realm-library/src/main/cpp/io_realm_internal_OsRealmConfig.cpp index 37993bacff..4e70ae27a3 100644 --- a/realm/realm-library/src/main/cpp/io_realm_internal_OsRealmConfig.cpp +++ b/realm/realm-library/src/main/cpp/io_realm_internal_OsRealmConfig.cpp @@ -16,17 +16,18 @@ #include "io_realm_internal_OsRealmConfig.h" -#include +#include #if REALM_ENABLE_SYNC -#include -#include -#include -#include +#include +#include +#include +#include #include #endif #include #include +#include #include "java_accessor.hpp" #include "util.hpp" diff --git a/realm/realm-library/src/main/cpp/io_realm_internal_OsResults.cpp b/realm/realm-library/src/main/cpp/io_realm_internal_OsResults.cpp index 8873d832e3..0515a14158 100644 --- a/realm/realm-library/src/main/cpp/io_realm_internal_OsResults.cpp +++ b/realm/realm-library/src/main/cpp/io_realm_internal_OsResults.cpp @@ -16,9 +16,9 @@ #include "io_realm_internal_OsResults.h" -#include -#include -#include +#include +#include +#include #include #include "java_class_global_def.hpp" diff --git a/realm/realm-library/src/main/cpp/io_realm_internal_OsSchemaInfo.cpp b/realm/realm-library/src/main/cpp/io_realm_internal_OsSchemaInfo.cpp index 8675e9e18a..5827402777 100644 --- a/realm/realm-library/src/main/cpp/io_realm_internal_OsSchemaInfo.cpp +++ b/realm/realm-library/src/main/cpp/io_realm_internal_OsSchemaInfo.cpp @@ -16,9 +16,9 @@ #include "io_realm_internal_OsSchemaInfo.h" -#include -#include -#include +#include +#include +#include #include "java_accessor.hpp" #include "java_exception_def.hpp" #include "util.hpp" diff --git a/realm/realm-library/src/main/cpp/io_realm_internal_OsSharedRealm.cpp b/realm/realm-library/src/main/cpp/io_realm_internal_OsSharedRealm.cpp index 7cac296a38..d44892858d 100644 --- a/realm/realm-library/src/main/cpp/io_realm_internal_OsSharedRealm.cpp +++ b/realm/realm-library/src/main/cpp/io_realm_internal_OsSharedRealm.cpp @@ -16,22 +16,23 @@ #include "io_realm_internal_OsSharedRealm.h" #if REALM_ENABLE_SYNC -#include "object-store/src/sync/sync_manager.hpp" -#include "object-store/src/sync/sync_config.hpp" -#include "object-store/src/sync/sync_session.hpp" -#include "object-store/src/results.hpp" +#include +#include +#include +#include +#include #include "observable_collection_wrapper.hpp" #endif #include -#include +#include #include "java_accessor.hpp" #include "java_binding_context.hpp" #include "java_exception_def.hpp" -#include "object_store.hpp" +#include #include "util.hpp" #include "jni_util/java_method.hpp" #include "jni_util/java_class.hpp" diff --git a/realm/realm-library/src/main/cpp/io_realm_internal_Property.cpp b/realm/realm-library/src/main/cpp/io_realm_internal_Property.cpp index ada73fef66..f76eab7ef1 100644 --- a/realm/realm-library/src/main/cpp/io_realm_internal_Property.cpp +++ b/realm/realm-library/src/main/cpp/io_realm_internal_Property.cpp @@ -16,8 +16,8 @@ #include "io_realm_internal_Property.h" -#include -#include +#include +#include #include "util.hpp" diff --git a/realm/realm-library/src/main/cpp/io_realm_internal_Table.cpp b/realm/realm-library/src/main/cpp/io_realm_internal_Table.cpp index 8acf09e59c..65cb0d36ac 100644 --- a/realm/realm-library/src/main/cpp/io_realm_internal_Table.cpp +++ b/realm/realm-library/src/main/cpp/io_realm_internal_Table.cpp @@ -22,7 +22,7 @@ #include "java_accessor.hpp" #include "java_exception_def.hpp" -#include "shared_realm.hpp" +#include #include "jni_util/java_exception_thrower.hpp" #include @@ -101,9 +101,20 @@ JNIEXPORT jlong JNICALL Java_io_realm_internal_Table_nativeAddColumnLink(JNIEnv* return 0; } try { - JStringAccessor name2(env, name); // throws + JStringAccessor name_accessor(env, name); // throws TableRef table = TBL_REF(nativeTableRefPtr); - return static_cast(table->add_column_link(DataType(colType), name2, *targetTableRef).value); + auto data_type = DataType(colType); + + if (REALM_UNLIKELY(!Table::is_link_type(ColumnType(data_type)))) + throw LogicError(LogicError::illegal_type); + + if (data_type == type_LinkList) { + return static_cast(table->add_column_list(*targetTableRef, name_accessor).value); + } + else { + REALM_ASSERT(data_type == type_Link); + return static_cast(table->add_column(*targetTableRef, name_accessor).value); + } } CATCH_STD() return 0; diff --git a/realm/realm-library/src/main/cpp/io_realm_internal_TableQuery.cpp b/realm/realm-library/src/main/cpp/io_realm_internal_TableQuery.cpp index f315099bb2..7bca0a4c02 100644 --- a/realm/realm-library/src/main/cpp/io_realm_internal_TableQuery.cpp +++ b/realm/realm-library/src/main/cpp/io_realm_internal_TableQuery.cpp @@ -20,9 +20,9 @@ #include #include -#include -#include -#include +#include +#include +#include #include "java_accessor.hpp" #include "java_class_global_def.hpp" diff --git a/realm/realm-library/src/main/cpp/io_realm_internal_core_IncludeDescriptor.cpp b/realm/realm-library/src/main/cpp/io_realm_internal_core_IncludeDescriptor.cpp index 010e8c8eef..4ab4a28049 100644 --- a/realm/realm-library/src/main/cpp/io_realm_internal_core_IncludeDescriptor.cpp +++ b/realm/realm-library/src/main/cpp/io_realm_internal_core_IncludeDescriptor.cpp @@ -18,11 +18,11 @@ #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "java_accessor.hpp" #include "java_query_descriptor.hpp" diff --git a/realm/realm-library/src/main/cpp/io_realm_internal_objectstore_OsApp.cpp b/realm/realm-library/src/main/cpp/io_realm_internal_objectstore_OsApp.cpp index b792f3a263..1899ddc9b9 100644 --- a/realm/realm-library/src/main/cpp/io_realm_internal_objectstore_OsApp.cpp +++ b/realm/realm-library/src/main/cpp/io_realm_internal_objectstore_OsApp.cpp @@ -21,9 +21,9 @@ #include "jni_util/java_method.hpp" #include "jni_util/jni_utils.hpp" -#include -#include -#include +#include +#include +#include #include diff --git a/realm/realm-library/src/main/cpp/io_realm_internal_objectstore_OsAppCredentials.cpp b/realm/realm-library/src/main/cpp/io_realm_internal_objectstore_OsAppCredentials.cpp index c40c1d88c1..394c97ebda 100644 --- a/realm/realm-library/src/main/cpp/io_realm_internal_objectstore_OsAppCredentials.cpp +++ b/realm/realm-library/src/main/cpp/io_realm_internal_objectstore_OsAppCredentials.cpp @@ -19,7 +19,7 @@ #include "util.hpp" #include -#include +#include using namespace realm; using namespace realm::app; diff --git a/realm/realm-library/src/main/cpp/io_realm_internal_objectstore_OsAsyncOpenTask.cpp b/realm/realm-library/src/main/cpp/io_realm_internal_objectstore_OsAsyncOpenTask.cpp index e69eae0b86..f125e32fa1 100644 --- a/realm/realm-library/src/main/cpp/io_realm_internal_objectstore_OsAsyncOpenTask.cpp +++ b/realm/realm-library/src/main/cpp/io_realm_internal_objectstore_OsAsyncOpenTask.cpp @@ -17,15 +17,14 @@ #include "io_realm_internal_objectstore_OsAsyncOpenTask.h" #include "util.hpp" -#include "thread_safe_reference.hpp" +#include #include "jni_util/java_method.hpp" #include "jni_util/java_class.hpp" #include "jni_util/jni_utils.hpp" -#include "object-store/src/sync/async_open_task.hpp" -#include "object-store/src/sync/sync_config.hpp" +#include +#include -#include -#include +#include #include using namespace realm; diff --git a/realm/realm-library/src/main/cpp/io_realm_internal_objectstore_OsMongoClient.cpp b/realm/realm-library/src/main/cpp/io_realm_internal_objectstore_OsMongoClient.cpp index dc5876a0cb..8c5576beb3 100644 --- a/realm/realm-library/src/main/cpp/io_realm_internal_objectstore_OsMongoClient.cpp +++ b/realm/realm-library/src/main/cpp/io_realm_internal_objectstore_OsMongoClient.cpp @@ -23,10 +23,10 @@ #include "jni_util/jni_utils.hpp" #include -#include -#include -#include -#include +#include +#include +#include +#include using namespace realm; using namespace realm::app; diff --git a/realm/realm-library/src/main/cpp/io_realm_internal_objectstore_OsMongoCollection.cpp b/realm/realm-library/src/main/cpp/io_realm_internal_objectstore_OsMongoCollection.cpp index e7597399ae..b171a7627a 100644 --- a/realm/realm-library/src/main/cpp/io_realm_internal_objectstore_OsMongoCollection.cpp +++ b/realm/realm-library/src/main/cpp/io_realm_internal_objectstore_OsMongoCollection.cpp @@ -22,12 +22,12 @@ #include "jni_util/java_method.hpp" #include "jni_util/jni_utils.hpp" #include "jni_util/bson_util.hpp" -#include "object-store/src/util/bson/bson.hpp" +#include #include -#include -#include -#include +#include +#include +#include #include using namespace realm; diff --git a/realm/realm-library/src/main/cpp/io_realm_internal_objectstore_OsMongoDatabase.cpp b/realm/realm-library/src/main/cpp/io_realm_internal_objectstore_OsMongoDatabase.cpp index 51626da135..645a21b828 100644 --- a/realm/realm-library/src/main/cpp/io_realm_internal_objectstore_OsMongoDatabase.cpp +++ b/realm/realm-library/src/main/cpp/io_realm_internal_objectstore_OsMongoDatabase.cpp @@ -23,10 +23,10 @@ #include "jni_util/jni_utils.hpp" #include -#include -#include -#include -#include +#include +#include +#include +#include using namespace realm; using namespace realm::app; diff --git a/realm/realm-library/src/main/cpp/io_realm_internal_objectstore_OsPush.cpp b/realm/realm-library/src/main/cpp/io_realm_internal_objectstore_OsPush.cpp index b718ebbd8e..5689d70b4a 100644 --- a/realm/realm-library/src/main/cpp/io_realm_internal_objectstore_OsPush.cpp +++ b/realm/realm-library/src/main/cpp/io_realm_internal_objectstore_OsPush.cpp @@ -23,7 +23,7 @@ #include "jni_util/jni_utils.hpp" #include -#include +#include #include using namespace realm; diff --git a/realm/realm-library/src/main/cpp/io_realm_internal_objectstore_OsSyncUser.cpp b/realm/realm-library/src/main/cpp/io_realm_internal_objectstore_OsSyncUser.cpp index 942f401717..0b332cfa2f 100644 --- a/realm/realm-library/src/main/cpp/io_realm_internal_objectstore_OsSyncUser.cpp +++ b/realm/realm-library/src/main/cpp/io_realm_internal_objectstore_OsSyncUser.cpp @@ -21,9 +21,9 @@ #include "jni_util/java_class.hpp" #include "java_network_transport.hpp" -#include +#include +#include #include -#include using namespace realm; using namespace realm::_impl; diff --git a/realm/realm-library/src/main/cpp/io_realm_internal_objectstore_OsWatchStream.cpp b/realm/realm-library/src/main/cpp/io_realm_internal_objectstore_OsWatchStream.cpp index 735175d84f..4609244092 100644 --- a/realm/realm-library/src/main/cpp/io_realm_internal_objectstore_OsWatchStream.cpp +++ b/realm/realm-library/src/main/cpp/io_realm_internal_objectstore_OsWatchStream.cpp @@ -19,7 +19,7 @@ #include "java_class_global_def.hpp" #include "jni_util/bson_util.hpp" -#include +#include using namespace realm; using namespace realm::app; diff --git a/realm/realm-library/src/main/cpp/io_realm_mongodb_ApiKeyAuthImpl.cpp b/realm/realm-library/src/main/cpp/io_realm_mongodb_ApiKeyAuthImpl.cpp index 4122558592..68790aa0bf 100644 --- a/realm/realm-library/src/main/cpp/io_realm_mongodb_ApiKeyAuthImpl.cpp +++ b/realm/realm-library/src/main/cpp/io_realm_mongodb_ApiKeyAuthImpl.cpp @@ -21,10 +21,9 @@ #include "util.hpp" #include "jni_util/java_method.hpp" #include "jni_util/jni_utils.hpp" -#include "object-store/src/sync/app.hpp" #include -#include +#include using namespace realm; using namespace realm::app; diff --git a/realm/realm-library/src/main/cpp/io_realm_mongodb_EmailPasswordAuthImpl.cpp b/realm/realm-library/src/main/cpp/io_realm_mongodb_EmailPasswordAuthImpl.cpp index c193355f0f..8af10fe2b5 100644 --- a/realm/realm-library/src/main/cpp/io_realm_mongodb_EmailPasswordAuthImpl.cpp +++ b/realm/realm-library/src/main/cpp/io_realm_mongodb_EmailPasswordAuthImpl.cpp @@ -22,7 +22,7 @@ #include "jni_util/jni_utils.hpp" #include "jni_util/bson_util.hpp" -#include +#include using namespace realm; using namespace realm::app; diff --git a/realm/realm-library/src/main/cpp/io_realm_mongodb_FunctionsImpl.cpp b/realm/realm-library/src/main/cpp/io_realm_mongodb_FunctionsImpl.cpp index 7d4ba9a834..c27de9d41d 100644 --- a/realm/realm-library/src/main/cpp/io_realm_mongodb_FunctionsImpl.cpp +++ b/realm/realm-library/src/main/cpp/io_realm_mongodb_FunctionsImpl.cpp @@ -19,7 +19,7 @@ #include "util.hpp" #include "jni_util/bson_util.hpp" #include "java_network_transport.hpp" -#include "object-store/src/sync/app.hpp" +#include using namespace realm; diff --git a/realm/realm-library/src/main/cpp/io_realm_mongodb_User.cpp b/realm/realm-library/src/main/cpp/io_realm_mongodb_User.cpp index 3729dbc756..95cd3618d4 100644 --- a/realm/realm-library/src/main/cpp/io_realm_mongodb_User.cpp +++ b/realm/realm-library/src/main/cpp/io_realm_mongodb_User.cpp @@ -21,7 +21,7 @@ #include "jni_util/java_method.hpp" #include "jni_util/jni_utils.hpp" -#include +#include #include using namespace realm; diff --git a/realm/realm-library/src/main/cpp/io_realm_mongodb_mongo_iterable_AggregateIterable.cpp b/realm/realm-library/src/main/cpp/io_realm_mongodb_mongo_iterable_AggregateIterable.cpp index cd9144e696..f33ef60a3f 100644 --- a/realm/realm-library/src/main/cpp/io_realm_mongodb_mongo_iterable_AggregateIterable.cpp +++ b/realm/realm-library/src/main/cpp/io_realm_mongodb_mongo_iterable_AggregateIterable.cpp @@ -22,10 +22,10 @@ #include "jni_util/java_method.hpp" #include "jni_util/jni_utils.hpp" #include "jni_util/bson_util.hpp" -#include "object-store/src/util/bson/bson.hpp" #include -#include +#include +#include #include #include diff --git a/realm/realm-library/src/main/cpp/io_realm_mongodb_mongo_iterable_FindIterable.cpp b/realm/realm-library/src/main/cpp/io_realm_mongodb_mongo_iterable_FindIterable.cpp index 1507682960..3fee3c8805 100644 --- a/realm/realm-library/src/main/cpp/io_realm_mongodb_mongo_iterable_FindIterable.cpp +++ b/realm/realm-library/src/main/cpp/io_realm_mongodb_mongo_iterable_FindIterable.cpp @@ -22,10 +22,10 @@ #include "jni_util/java_method.hpp" #include "jni_util/jni_utils.hpp" #include "jni_util/bson_util.hpp" -#include "object-store/src/util/bson/bson.hpp" #include -#include +#include +#include #include using namespace realm; diff --git a/realm/realm-library/src/main/cpp/io_realm_mongodb_sync_ClientResetRequiredError.cpp b/realm/realm-library/src/main/cpp/io_realm_mongodb_sync_ClientResetRequiredError.cpp index 9f55fddc7b..fc3b3b068e 100644 --- a/realm/realm-library/src/main/cpp/io_realm_mongodb_sync_ClientResetRequiredError.cpp +++ b/realm/realm-library/src/main/cpp/io_realm_mongodb_sync_ClientResetRequiredError.cpp @@ -16,8 +16,8 @@ #include -#include -#include +#include +#include #include "util.hpp" #include "io_realm_mongodb_sync_ClientResetRequiredError.h" diff --git a/realm/realm-library/src/main/cpp/io_realm_mongodb_sync_Sync.cpp b/realm/realm-library/src/main/cpp/io_realm_mongodb_sync_Sync.cpp index 8fb690f522..e0d325ada1 100644 --- a/realm/realm-library/src/main/cpp/io_realm_mongodb_sync_Sync.cpp +++ b/realm/realm-library/src/main/cpp/io_realm_mongodb_sync_Sync.cpp @@ -16,11 +16,12 @@ #include "io_realm_mongodb_sync_Sync.h" -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include "util.hpp" #include diff --git a/realm/realm-library/src/main/cpp/io_realm_mongodb_sync_SyncSession.cpp b/realm/realm-library/src/main/cpp/io_realm_mongodb_sync_SyncSession.cpp index 42a647e688..61c2931a7b 100644 --- a/realm/realm-library/src/main/cpp/io_realm_mongodb_sync_SyncSession.cpp +++ b/realm/realm-library/src/main/cpp/io_realm_mongodb_sync_SyncSession.cpp @@ -19,9 +19,9 @@ #include "io_realm_mongodb_sync_SyncSession.h" -#include "sync/app.hpp" -#include "sync/sync_manager.hpp" -#include "sync/sync_session.hpp" +#include +#include +#include #include "util.hpp" #include "java_class_global_def.hpp" diff --git a/realm/realm-library/src/main/cpp/java_accessor.hpp b/realm/realm-library/src/main/cpp/java_accessor.hpp index 0d29fab2f0..e402b423fd 100644 --- a/realm/realm-library/src/main/cpp/java_accessor.hpp +++ b/realm/realm-library/src/main/cpp/java_accessor.hpp @@ -28,8 +28,7 @@ #include #include -#include -#include +#include #include "java_class_global_def.hpp" #include "java_exception_def.hpp" diff --git a/realm/realm-library/src/main/cpp/java_binding_context.hpp b/realm/realm-library/src/main/cpp/java_binding_context.hpp index eeff8523b4..f8270c3f19 100644 --- a/realm/realm-library/src/main/cpp/java_binding_context.hpp +++ b/realm/realm-library/src/main/cpp/java_binding_context.hpp @@ -20,7 +20,7 @@ #include #include -#include "binding_context.hpp" +#include #include "jni_util/java_global_weak_ref.hpp" diff --git a/realm/realm-library/src/main/cpp/java_network_transport.hpp b/realm/realm-library/src/main/cpp/java_network_transport.hpp index 15aa315b05..e8722ab6cc 100644 --- a/realm/realm-library/src/main/cpp/java_network_transport.hpp +++ b/realm/realm-library/src/main/cpp/java_network_transport.hpp @@ -19,7 +19,7 @@ #include "java_accessor.hpp" #include "util.hpp" -#include "sync/generic_network_transport.hpp" +#include #include "jni_util/java_class.hpp" #include "jni_util/java_method.hpp" #include "jni_util/jni_utils.hpp" diff --git a/realm/realm-library/src/main/cpp/java_object_accessor.hpp b/realm/realm-library/src/main/cpp/java_object_accessor.hpp index cd761f607a..e038862ab2 100644 --- a/realm/realm-library/src/main/cpp/java_object_accessor.hpp +++ b/realm/realm-library/src/main/cpp/java_object_accessor.hpp @@ -25,8 +25,8 @@ #include "java_accessor.hpp" #include "java_class_global_def.hpp" -#include "object_accessor.hpp" -#include "object-store/src/property.hpp" +#include +#include #include #include @@ -43,10 +43,12 @@ using namespace realm::_impl; X(Date) \ X(ObjectId) \ X(Decimal) \ + X(Mixed) \ X(Binary) \ X(Object) \ X(List) \ X(PropertyList) \ + X(Dictionary) \ namespace realm { @@ -70,18 +72,20 @@ template constexpr T realm_max(T a, T b, Rest... rest) } template struct JavaValueTypeRepr; -template <> struct JavaValueTypeRepr { using Type = jlong; }; -template <> struct JavaValueTypeRepr { using Type = std::string; }; -template <> struct JavaValueTypeRepr { using Type = jboolean; }; -template <> struct JavaValueTypeRepr { using Type = jfloat; }; -template <> struct JavaValueTypeRepr { using Type = jdouble; }; -template <> struct JavaValueTypeRepr { using Type = Timestamp; }; -template <> struct JavaValueTypeRepr{ using Type = ObjectId; }; -template <> struct JavaValueTypeRepr { using Type = Decimal128; }; -template <> struct JavaValueTypeRepr { using Type = OwnedBinaryData; }; -template <> struct JavaValueTypeRepr { using Type = Obj*; }; -template <> struct JavaValueTypeRepr { using Type = std::vector; }; -template <> struct JavaValueTypeRepr { using Type = std::map; }; +template <> struct JavaValueTypeRepr { using Type = jlong; }; +template <> struct JavaValueTypeRepr { using Type = std::string; }; +template <> struct JavaValueTypeRepr { using Type = jboolean; }; +template <> struct JavaValueTypeRepr { using Type = jfloat; }; +template <> struct JavaValueTypeRepr { using Type = jdouble; }; +template <> struct JavaValueTypeRepr { using Type = Timestamp; }; +template <> struct JavaValueTypeRepr { using Type = ObjectId; }; +template <> struct JavaValueTypeRepr { using Type = Decimal128; }; +template <> struct JavaValueTypeRepr { using Type = Mixed; }; +template <> struct JavaValueTypeRepr { using Type = OwnedBinaryData; }; +template <> struct JavaValueTypeRepr { using Type = Obj*; }; +template <> struct JavaValueTypeRepr { using Type = std::vector; }; +template <> struct JavaValueTypeRepr { using Type = std::map; }; +template <> struct JavaValueTypeRepr { using Type = std::map; }; // Tagged union class representing all the values Java can send to Object Store struct JavaValue { @@ -212,6 +216,11 @@ struct JavaValue { return get_as(); } + auto& get_dictionary() const noexcept + { + return get_as(); + } + auto& get_property_list() const noexcept { return get_as(); @@ -233,6 +242,11 @@ struct JavaValue { return get_as(); } + auto& get_mixed() const noexcept + { + return get_as(); + } + auto& get_binary() const noexcept { return get_as(); @@ -286,6 +300,9 @@ struct JavaValue { return get_object_id().to_string(); case JavaValueType::Decimal: return get_decimal128().to_string(); + case JavaValueType::Mixed: + // TODO: Return actual string + return "Mixed"; case JavaValueType::Binary: ss << "Blob["; ss << get_binary().size(); @@ -370,25 +387,6 @@ class JavaContext { return util::none; } - // Invoke `fn` with each of the values from an enumerable type - template - void enumerate_list(JavaValue& value, Func&& fn) { - if (value.get_type() == JavaValueType::List) { - for (const auto& v : value.get_list()) { - fn(v); - } - } else { - throw std::logic_error("Type is not a list"); - } - } - - // Determine if `value` boxes the same List as `list` - bool is_same_list(List const& /*list*/, JavaValue const& /*value*/) - { - // Lists from Java are currently never the same as the ones found in Object Store. - return false; - } - // Convert from core types to the boxed type. These are currently not used as Proxy objects read // directly from the Row objects. This implementation is thus only here as a reminder of which // method signatures to add if needed. @@ -454,7 +452,46 @@ class JavaContext { Obj create_embedded_object(); -private: + // Determine if `value` boxes the same List as `list` + bool is_same_list(List const& /*list*/, JavaValue const& /*value*/) + { + // Lists from Java are currently never the same as the ones found in Object Store. + return false; + } + + bool is_same_dictionary(const object_store::Dictionary&, JavaValue const& /*value*/){ + //TODO: Implement with sets + return false; + } + + bool is_same_set(object_store::Set const&, JavaValue const& /*value*/){ + //TODO: Implement with sets + return false; + } + + template + void enumerate_collection(JavaValue& value, Func&& fn) { + if (value.get_type() == JavaValueType::List) { + for (const auto& v : value.get_list()) { + fn(v); + } + } else { + throw std::logic_error("Type is not a list"); + } + } + + template + void enumerate_dictionary(JavaValue& value, Func&& fn) { + if (value.get_type() == JavaValueType::Dictionary) { + for (const auto& v : value.get_dictionary()) { + fn(v.first, v.second); + } + } else { + throw std::logic_error("Type is not a dictionary"); + } + } + + private: JNIEnv* m_env; std::shared_ptr realm; Obj m_parent; @@ -528,6 +565,11 @@ inline Decimal128 JavaContext::unbox(JavaValue const& v, CreatePolicy, ObjKey) c return v.has_value() ? v.get_decimal128() : Decimal128(); } +template <> +inline Mixed JavaContext::unbox(JavaValue const& v, CreatePolicy, ObjKey) const +{ + return v.has_value() ? v.get_mixed() : Mixed(); +} template <> inline ObjectId JavaContext::unbox(JavaValue const& v, CreatePolicy, ObjKey) const @@ -571,12 +613,6 @@ inline util::Optional JavaContext::unbox(JavaValue const& v, CreatePolicy return v.has_value() ? util::make_optional(v.get_float()) : util::none; } -template <> -inline Mixed JavaContext::unbox(JavaValue const&, CreatePolicy, ObjKey) const -{ - REALM_TERMINATE("'Mixed' not supported"); -} - template <> inline util::Optional JavaContext::unbox(JavaValue const& v, CreatePolicy, ObjKey) const { @@ -589,6 +625,12 @@ inline util::Optional JavaContext::unbox(JavaValue const& v, CreatePoli return v.has_value() ? util::make_optional(v.get_decimal128()) : util::none; } +template <> +inline util::Optional JavaContext::unbox(JavaValue const& v, CreatePolicy, ObjKey) const +{ + return v.has_value() ? util::make_optional(v.get_mixed()) : util::none; +} + inline Obj JavaContext::create_embedded_object() { return m_parent.create_and_set_linked_object(m_property->column_key); } diff --git a/realm/realm-library/src/main/cpp/jni_util/bson_util.hpp b/realm/realm-library/src/main/cpp/jni_util/bson_util.hpp index eb5377d7a7..fb0d822903 100644 --- a/realm/realm-library/src/main/cpp/jni_util/bson_util.hpp +++ b/realm/realm-library/src/main/cpp/jni_util/bson_util.hpp @@ -18,7 +18,7 @@ #define REALM_BSON_UTIL_HPP #include -#include +#include namespace realm { namespace jni_util { diff --git a/realm/realm-library/src/main/cpp/jni_util/log.hpp b/realm/realm-library/src/main/cpp/jni_util/log.hpp index 3b694571d6..c38db7c94a 100644 --- a/realm/realm-library/src/main/cpp/jni_util/log.hpp +++ b/realm/realm-library/src/main/cpp/jni_util/log.hpp @@ -26,7 +26,7 @@ #include "io_realm_log_LogLevel.h" -#include "realm/util/logger.hpp" +#include namespace realm { diff --git a/realm/realm-library/src/main/cpp/object-store b/realm/realm-library/src/main/cpp/object-store deleted file mode 160000 index fc790d558d..0000000000 --- a/realm/realm-library/src/main/cpp/object-store +++ /dev/null @@ -1 +0,0 @@ -Subproject commit fc790d558ddc0e25a50d6b27dadf617532a1bf44 diff --git a/realm/realm-library/src/main/cpp/observable_collection_wrapper.hpp b/realm/realm-library/src/main/cpp/observable_collection_wrapper.hpp index 0f6ff53b76..e5f8ebf919 100644 --- a/realm/realm-library/src/main/cpp/observable_collection_wrapper.hpp +++ b/realm/realm-library/src/main/cpp/observable_collection_wrapper.hpp @@ -22,7 +22,7 @@ #include "jni_util/java_method.hpp" #include "jni_util/log.hpp" -#include +#include #include namespace realm { diff --git a/realm/realm-library/src/main/cpp/realm-core b/realm/realm-library/src/main/cpp/realm-core new file mode 160000 index 0000000000..8af0f8d609 --- /dev/null +++ b/realm/realm-library/src/main/cpp/realm-core @@ -0,0 +1 @@ +Subproject commit 8af0f8d609491986b49f2c986e771d9dc445664d diff --git a/realm/realm-library/src/main/cpp/util.cpp b/realm/realm-library/src/main/cpp/util.cpp index aa21cde659..c9fde94751 100644 --- a/realm/realm-library/src/main/cpp/util.cpp +++ b/realm/realm-library/src/main/cpp/util.cpp @@ -26,16 +26,16 @@ #include "util.hpp" #include "io_realm_internal_Util.h" #include "io_realm_internal_OsSharedRealm.h" -#include "shared_realm.hpp" -#include "results.hpp" -#include "list.hpp" -#include "java_exception_def.hpp" -#include "java_object_accessor.hpp" -#include "object.hpp" +#include +#include +#include +#include #if REALM_ENABLE_SYNC -#include "sync/app.hpp" +#include #endif +#include "java_exception_def.hpp" +#include "java_object_accessor.hpp" #include "jni_util/java_exception_thrower.hpp" using namespace std; diff --git a/tools/realm-cli.sh b/tools/realm-cli.sh index 91ccd0a71b..9fae79c022 100755 --- a/tools/realm-cli.sh +++ b/tools/realm-cli.sh @@ -127,6 +127,26 @@ java_clean(){ popd } +java_size(){ + pushd $REALM_JAVA_PATH/realm/ 1> /dev/null + ./gradlew assemble + cd realm-library/build/intermediates/cmake/ + + pushd baseRelease/obj 1> /dev/null + echo "Base" + find . -name "*.so" -print0 | xargs -0 stat -f '%z %N' + echo "-----------" + popd 1> /dev/null + + pushd objectServerRelease/obj 1> /dev/null + echo "Object server" + find . -name "*.so" -print0 | xargs -0 stat -f '%z %N' + echo "-----------" + popd 1> /dev/null + + popd 1> /dev/null +} + java_help(){ echo "Try with: @@ -135,6 +155,7 @@ build - builds realm-java test - runs the realm-java test suite check - runs realm-java spotbugs, checkstyle, pmd clean - cleans realm-java" +size - calculates and displays the JNI lib size } java(){ @@ -155,6 +176,9 @@ java(){ clean) java_clean ;; + size) + java_size + ;; *) java_help esac