From 0fff3eae52dd162eb0f3a55646d459b5a3590987 Mon Sep 17 00:00:00 2001 From: Bret McGuire Date: Tue, 19 May 2020 13:44:43 -0500 Subject: [PATCH 1/3] Bits necessary to move Graal substitution for Guava's UnsignedBytes into driver core --- core/pom.xml | 4 ++ .../UnsignedBytesSubstitutions.java | 42 +++++++++++++++++++ pom.xml | 7 +++- 3 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 core/src/main/java/com/datastax/oss/driver/shaded/guava/common/primitives/UnsignedBytesSubstitutions.java diff --git a/core/pom.xml b/core/pom.xml index 47858cd2427..c9803a00c97 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -132,6 +132,10 @@ graal-sdk provided + + org.graalvm.nativeimage + svm + ch.qos.logback logback-classic diff --git a/core/src/main/java/com/datastax/oss/driver/shaded/guava/common/primitives/UnsignedBytesSubstitutions.java b/core/src/main/java/com/datastax/oss/driver/shaded/guava/common/primitives/UnsignedBytesSubstitutions.java new file mode 100644 index 00000000000..c99b873c684 --- /dev/null +++ b/core/src/main/java/com/datastax/oss/driver/shaded/guava/common/primitives/UnsignedBytesSubstitutions.java @@ -0,0 +1,42 @@ +/* + * Copyright DataStax, 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. + */ +package com.datastax.oss.driver.shaded.guava.common.primitives; + +import com.oracle.svm.core.annotate.Alias; +import com.oracle.svm.core.annotate.Delete; +import com.oracle.svm.core.annotate.RecomputeFieldValue; +import com.oracle.svm.core.annotate.Substitute; +import com.oracle.svm.core.annotate.TargetClass; +import java.util.Comparator; + +@TargetClass(UnsignedBytes.LexicographicalComparatorHolder.UnsafeComparator.class) +@Delete +final class UnsafeComparatorSubstitutions {} + +@TargetClass(UnsignedBytes.LexicographicalComparatorHolder.class) +final class LexicographicalComparatorHolderSubstitutions { + + @Alias + @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.FromAlias) + static Comparator BEST_COMPARATOR = UnsignedBytes.lexicographicalComparatorJavaImpl(); + + /* All known cases should be covered by the field substitution above... keeping this only + * for sake of completeness */ + @Substitute + static Comparator getBestComparator() { + return UnsignedBytes.lexicographicalComparatorJavaImpl(); + } +} diff --git a/pom.xml b/pom.xml index ffbaa5e93d8..3e07ec120ea 100644 --- a/pom.xml +++ b/pom.xml @@ -382,6 +382,11 @@ graal-sdk 20.0.0 + + org.graalvm.nativeimage + svm + 20.0.0 + @@ -693,7 +698,7 @@ limitations under the License.]]> false true all,-missing - com.datastax.*.driver.internal* + com.datastax.*.driver.internal*,com.datastax.oss.driver.shaded.guava.common.primitives