From e13b66e920336b3d786159ccda1317b63a36c2e2 Mon Sep 17 00:00:00 2001 From: Sanne Grinovero Date: Tue, 6 Oct 2020 14:20:28 +0100 Subject: [PATCH] Use a Clener Substitution rather than reporting unsupported elements at runtime --- extensions/tika/runtime/pom.xml | 5 ++++ .../CleanerNotSupportedSubstitution.java | 29 +++++++++++++++++++ integration-tests/tika/pom.xml | 1 - 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 extensions/tika/runtime/src/main/java/io/quarkus/tika/graalvm/CleanerNotSupportedSubstitution.java diff --git a/extensions/tika/runtime/pom.xml b/extensions/tika/runtime/pom.xml index ca3b70f5d630c..8a2cd8d56be45 100644 --- a/extensions/tika/runtime/pom.xml +++ b/extensions/tika/runtime/pom.xml @@ -73,6 +73,11 @@ org.jboss.logging commons-logging-jboss-logging + + org.graalvm.nativeimage + svm + provided + diff --git a/extensions/tika/runtime/src/main/java/io/quarkus/tika/graalvm/CleanerNotSupportedSubstitution.java b/extensions/tika/runtime/src/main/java/io/quarkus/tika/graalvm/CleanerNotSupportedSubstitution.java new file mode 100644 index 0000000000000..f882e8676806c --- /dev/null +++ b/extensions/tika/runtime/src/main/java/io/quarkus/tika/graalvm/CleanerNotSupportedSubstitution.java @@ -0,0 +1,29 @@ +package io.quarkus.tika.graalvm; + +@com.oracle.svm.core.annotate.Substitute +@com.oracle.svm.core.annotate.TargetClass(className = "org.apache.poi.poifs.nio.CleanerUtil") +public final class CleanerNotSupportedSubstitution { + + /** + * true, if this platform supports unmapping mmapped files. + */ + public static final boolean UNMAP_SUPPORTED = false; + + /** + * if {@link #UNMAP_SUPPORTED} is {@code false}, this contains the reason + * why unmapping is not supported. + */ + public static final String UNMAP_NOT_SUPPORTED_REASON = "Not supported on GraalVM native-image"; + + private static final org.apache.poi.poifs.nio.CleanerUtil.BufferCleaner CLEANER = null; + + /** + * Reference to a BufferCleaner that does unmapping. + * + * @return {@code null} if not supported. + */ + public static org.apache.poi.poifs.nio.CleanerUtil.BufferCleaner getCleaner() { + return CLEANER; + } + +} diff --git a/integration-tests/tika/pom.xml b/integration-tests/tika/pom.xml index c0f0a220ab3dc..d14a12ce1fcdc 100644 --- a/integration-tests/tika/pom.xml +++ b/integration-tests/tika/pom.xml @@ -149,7 +149,6 @@ true true ${graalvmHome} - --report-unsupported-elements-at-runtime