-
Notifications
You must be signed in to change notification settings - Fork 884
JAVA-2799: Create GraalVM substitutions for Guava's UnsignedBytes #1443
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| /* | ||
| * 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.RecomputeFieldValue; | ||
| import com.oracle.svm.core.annotate.Substitute; | ||
| import com.oracle.svm.core.annotate.TargetClass; | ||
| import java.util.Comparator; | ||
|
|
||
| @TargetClass(UnsignedBytes.LexicographicalComparatorHolder.class) | ||
| final class LexicographicalComparatorHolderSubstitution { | ||
|
|
||
| @Alias | ||
| @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.FromAlias) | ||
| static Comparator<byte[]> 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<byte[]> getBestComparator() { | ||
| return UnsignedBytes.lexicographicalComparatorJavaImpl(); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| /* | ||
| * 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.Delete; | ||
| import com.oracle.svm.core.annotate.TargetClass; | ||
|
|
||
| @TargetClass(UnsignedBytes.LexicographicalComparatorHolder.UnsafeComparator.class) | ||
| @Delete | ||
| final class UnsafeComparatorSubstitution {} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -382,6 +382,11 @@ | |
| <artifactId>graal-sdk</artifactId> | ||
| <version>20.0.0</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.graalvm.nativeimage</groupId> | ||
| <artifactId>svm</artifactId> | ||
| <version>20.0.0</version> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it safe to hardcode the version of the graal here?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This lib is only required to gain access to the annotations needed to implement the substitution. So long as the Graal native build respects those annotations there shouldn't be an issue. I've tested this with a toolchain going back to 19.2.1 and it worked without issue so we should be fine. Note that Quarkus only supports 19.3.1 so even with 19.2.1 we'd be talking about users writing their own apps for Graal and not using Quarkus. |
||
| </dependency> | ||
| </dependencies> | ||
| </dependencyManagement> | ||
| <build> | ||
|
|
@@ -693,7 +698,7 @@ limitations under the License.]]></inlineHeader> | |
| <verbose>false</verbose> | ||
| <quiet>true</quiet> | ||
| <doclint>all,-missing</doclint> | ||
| <excludePackageNames>com.datastax.*.driver.internal*</excludePackageNames> | ||
| <excludePackageNames>com.datastax.*.driver.internal*,com.datastax.oss.driver.shaded.guava.common.primitives</excludePackageNames> | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Weirdly this was required... without this change Javadoc generation started failing the build: I'm not sure where the reference to that class is coming from; it isn't introduced by the new dependency added in this change and isn't in the shaded Guava JAR.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think Graal generates the substituted class inside driver-core own classes, i.e. in I think you can actually exclude everything that is shaded here, just in case we generate some more substitutions in the future: |
||
| <tags> | ||
| <!-- | ||
| For custom `leaks-private-api` tag (apparently dash separators are not handled | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.