From 53e363c0d0920c1acce90655c2b3e27271ec035a Mon Sep 17 00:00:00 2001 From: Andrew Wieteska Date: Thu, 16 Feb 2023 00:15:11 -0500 Subject: [PATCH 1/5] [DNM] try out Blackbird optimization for Jackson --- conjure-java-jackson-optimizations/build.gradle | 1 + .../optimizations/ObjectMapperOptimizations.java | 14 ++++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/conjure-java-jackson-optimizations/build.gradle b/conjure-java-jackson-optimizations/build.gradle index c1641e2e9..ede664d6d 100644 --- a/conjure-java-jackson-optimizations/build.gradle +++ b/conjure-java-jackson-optimizations/build.gradle @@ -4,4 +4,5 @@ apply plugin: 'com.palantir.revapi' dependencies { api "com.fasterxml.jackson.core:jackson-databind" implementation "com.fasterxml.jackson.module:jackson-module-afterburner" + implementation "com.fasterxml.jackson.module:jackson-module-blackbird" } diff --git a/conjure-java-jackson-optimizations/src/main/java/com/palantir/conjure/java/jackson/optimizations/ObjectMapperOptimizations.java b/conjure-java-jackson-optimizations/src/main/java/com/palantir/conjure/java/jackson/optimizations/ObjectMapperOptimizations.java index 21556e67e..9de5b7015 100644 --- a/conjure-java-jackson-optimizations/src/main/java/com/palantir/conjure/java/jackson/optimizations/ObjectMapperOptimizations.java +++ b/conjure-java-jackson-optimizations/src/main/java/com/palantir/conjure/java/jackson/optimizations/ObjectMapperOptimizations.java @@ -16,8 +16,9 @@ package com.palantir.conjure.java.jackson.optimizations; -import com.fasterxml.jackson.module.afterburner.AfterburnerModule; -import java.util.List; +import com.fasterxml.jackson.module.blackbird.*; + +import java.util.*; /** * Applies jackson optimization modules based on supported JVMs and best practices. @@ -33,21 +34,22 @@ public final class ObjectMapperOptimizations { System.getProperty("org.graalvm.nativeimage.imagecode") != null // This may be globally configured with a system property || readProperty( - "com.palantir.conjure.java.jackson.optimizations.disabled", shouldDisableByDefault()); + "com.palantir.conjure.java.jackson.optimizations.disabled", shouldDisableByDefault()); @SuppressWarnings("AfterburnerJavaIncompatibility") public static List createModules() { - return NO_OPTIMIZATIONS ? List.of() : List.of(new AfterburnerModule()); + return NO_OPTIMIZATIONS ? List.of() : List.of(new BlackbirdModule()); } - private ObjectMapperOptimizations() {} + private ObjectMapperOptimizations() { + } /** * We disable afterburner optimizations by default on java 16+ where internal access is * restricted by https://openjdk.java.net/jeps/396 and https://openjdk.java.net/jeps/403. */ private static boolean shouldDisableByDefault() { - return Runtime.version().feature() >= 16; + return false; } private static boolean readProperty(String property, boolean defaultValue) { From 6c51758c4fd60405878ecc756a02fc095e4d878c Mon Sep 17 00:00:00 2001 From: Andrew Wieteska Date: Fri, 24 Feb 2023 17:09:32 +0000 Subject: [PATCH 2/5] spotless --- .../jackson/optimizations/ObjectMapperOptimizations.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/conjure-java-jackson-optimizations/src/main/java/com/palantir/conjure/java/jackson/optimizations/ObjectMapperOptimizations.java b/conjure-java-jackson-optimizations/src/main/java/com/palantir/conjure/java/jackson/optimizations/ObjectMapperOptimizations.java index 9de5b7015..4ce4734d7 100644 --- a/conjure-java-jackson-optimizations/src/main/java/com/palantir/conjure/java/jackson/optimizations/ObjectMapperOptimizations.java +++ b/conjure-java-jackson-optimizations/src/main/java/com/palantir/conjure/java/jackson/optimizations/ObjectMapperOptimizations.java @@ -17,7 +17,6 @@ package com.palantir.conjure.java.jackson.optimizations; import com.fasterxml.jackson.module.blackbird.*; - import java.util.*; /** @@ -34,15 +33,14 @@ public final class ObjectMapperOptimizations { System.getProperty("org.graalvm.nativeimage.imagecode") != null // This may be globally configured with a system property || readProperty( - "com.palantir.conjure.java.jackson.optimizations.disabled", shouldDisableByDefault()); + "com.palantir.conjure.java.jackson.optimizations.disabled", shouldDisableByDefault()); @SuppressWarnings("AfterburnerJavaIncompatibility") public static List createModules() { return NO_OPTIMIZATIONS ? List.of() : List.of(new BlackbirdModule()); } - private ObjectMapperOptimizations() { - } + private ObjectMapperOptimizations() {} /** * We disable afterburner optimizations by default on java 16+ where internal access is From 520a10bf0b44fe1553bb892ff0c137f93d413e48 Mon Sep 17 00:00:00 2001 From: Andrew Wieteska Date: Fri, 24 Feb 2023 17:28:19 +0000 Subject: [PATCH 3/5] checkstyle --- .../java/jackson/optimizations/ObjectMapperOptimizations.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conjure-java-jackson-optimizations/src/main/java/com/palantir/conjure/java/jackson/optimizations/ObjectMapperOptimizations.java b/conjure-java-jackson-optimizations/src/main/java/com/palantir/conjure/java/jackson/optimizations/ObjectMapperOptimizations.java index 4ce4734d7..ed2b1f9cc 100644 --- a/conjure-java-jackson-optimizations/src/main/java/com/palantir/conjure/java/jackson/optimizations/ObjectMapperOptimizations.java +++ b/conjure-java-jackson-optimizations/src/main/java/com/palantir/conjure/java/jackson/optimizations/ObjectMapperOptimizations.java @@ -16,8 +16,8 @@ package com.palantir.conjure.java.jackson.optimizations; -import com.fasterxml.jackson.module.blackbird.*; -import java.util.*; +import com.fasterxml.jackson.module.blackbird.BlackbirdModule; +import java.util.List; /** * Applies jackson optimization modules based on supported JVMs and best practices. From 1d529e9653792d6c21d06ea4217f11ead9347023 Mon Sep 17 00:00:00 2001 From: Andrew Wieteska Date: Fri, 24 Feb 2023 17:35:11 +0000 Subject: [PATCH 4/5] unused dependency --- conjure-java-jackson-optimizations/build.gradle | 1 - 1 file changed, 1 deletion(-) diff --git a/conjure-java-jackson-optimizations/build.gradle b/conjure-java-jackson-optimizations/build.gradle index ede664d6d..f7183190e 100644 --- a/conjure-java-jackson-optimizations/build.gradle +++ b/conjure-java-jackson-optimizations/build.gradle @@ -3,6 +3,5 @@ apply plugin: 'com.palantir.revapi' dependencies { api "com.fasterxml.jackson.core:jackson-databind" - implementation "com.fasterxml.jackson.module:jackson-module-afterburner" implementation "com.fasterxml.jackson.module:jackson-module-blackbird" } From 3c70e3210548d63d3a1e14681dd6eb08d1f4903e Mon Sep 17 00:00:00 2001 From: Andrew Wieteska Date: Fri, 24 Feb 2023 17:35:11 +0000 Subject: [PATCH 5/5] unused dependency --- conjure-java-jackson-optimizations/build.gradle | 1 - versions.lock | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/conjure-java-jackson-optimizations/build.gradle b/conjure-java-jackson-optimizations/build.gradle index ede664d6d..f7183190e 100644 --- a/conjure-java-jackson-optimizations/build.gradle +++ b/conjure-java-jackson-optimizations/build.gradle @@ -3,6 +3,5 @@ apply plugin: 'com.palantir.revapi' dependencies { api "com.fasterxml.jackson.core:jackson-databind" - implementation "com.fasterxml.jackson.module:jackson-module-afterburner" implementation "com.fasterxml.jackson.module:jackson-module-blackbird" } diff --git a/versions.lock b/versions.lock index c00bca5e2..5a46b25a3 100644 --- a/versions.lock +++ b/versions.lock @@ -1,8 +1,8 @@ # Run ./gradlew --write-locks to regenerate this file com.fasterxml:classmate:1.5.1 (1 constraints: 9a122a13) com.fasterxml.jackson.core:jackson-annotations:2.14.2 (9 constraints: 3ab6ba5c) -com.fasterxml.jackson.core:jackson-core:2.14.2 (13 constraints: f7254e86) -com.fasterxml.jackson.core:jackson-databind:2.14.2 (20 constraints: c38ce552) +com.fasterxml.jackson.core:jackson-core:2.14.2 (13 constraints: f52446fa) +com.fasterxml.jackson.core:jackson-databind:2.14.2 (20 constraints: c18bcc8f) com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:2.14.2 (2 constraints: 2d20b805) com.fasterxml.jackson.dataformat:jackson-dataformat-smile:2.14.2 (1 constraints: 3905393b) com.fasterxml.jackson.datatype:jackson-datatype-guava:2.14.2 (1 constraints: 3905393b) @@ -11,7 +11,7 @@ com.fasterxml.jackson.datatype:jackson-datatype-joda:2.14.2 (1 constraints: 3905 com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.14.2 (1 constraints: 3905393b) com.fasterxml.jackson.jakarta.rs:jackson-jakarta-rs-base:2.14.2 (1 constraints: f51af942) com.fasterxml.jackson.jakarta.rs:jackson-jakarta-rs-cbor-provider:2.14.2 (1 constraints: 3905393b) -com.fasterxml.jackson.module:jackson-module-afterburner:2.14.2 (1 constraints: 3905393b) +com.fasterxml.jackson.module:jackson-module-blackbird:2.14.2 (1 constraints: 3905393b) com.fasterxml.jackson.module:jackson-module-jakarta-xmlbind-annotations:2.14.2 (2 constraints: e3308eb3) com.fasterxml.jackson.module:jackson-module-scala_2.12:2.14.2 (1 constraints: 3905393b) com.github.ben-manes.caffeine:caffeine:3.1.4 (3 constraints: e22362a2)