Upgrade the build requirement from Java 10 to Java 11 (but keep the result executable on Java 8).
This upgrade allows us to remove a hack for javadoc generation under Java 10.
diff --git a/core/sis-build-helper/src/main/java/org/apache/sis/internal/doclet/Doclet.java b/core/sis-build-helper/src/main/java/org/apache/sis/internal/doclet/Doclet.java
index dce22e1..7fa4ec8 100644
--- a/core/sis-build-helper/src/main/java/org/apache/sis/internal/doclet/Doclet.java
+++ b/core/sis-build-helper/src/main/java/org/apache/sis/internal/doclet/Doclet.java
@@ -20,6 +20,7 @@
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
+import java.util.function.Supplier;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.io.File;
@@ -34,7 +35,6 @@
import jdk.javadoc.doclet.Doclet.Option;
import jdk.javadoc.doclet.DocletEnvironment;
import jdk.javadoc.doclet.StandardDoclet;
-import com.sun.source.util.DocTrees;
/**
@@ -58,7 +58,7 @@
* @since 0.5
* @module
*/
-public final class Doclet extends StandardDoclet {
+public final class Doclet extends StandardDoclet implements Supplier<Reporter> {
/**
* The name of the SIS-specific stylesheet file.
*/
@@ -71,25 +71,8 @@
/**
* Where to report warnings, or {@code null} if unknown.
- *
- * @todo make package-private after {@link #workaround8201817} has been removed.
*/
- public Reporter reporter;
-
- /**
- * Utility methods for locating the path of elements, or {@code null} if unknown.
- *
- * @todo make package-private after {@link #workaround8201817} has been removed.
- */
- public DocTrees trees;
-
- /**
- * Temporary Workaround for https://bugs.openjdk.java.net/browse/JDK-8201817
- *
- * @deprecated to be removed after we upgraded Apache SIS build requirement to JDK 11.
- */
- @Deprecated
- public static Doclet workaround8201817;
+ private Reporter reporter;
/**
* Invoked by the Javadoc tools for instantiating the custom doclet.
@@ -107,7 +90,18 @@
public void init(final Locale locale, final Reporter reporter) {
super.init(locale, reporter);
this.reporter = reporter;
- workaround8201817 = this;
+ }
+
+ /**
+ * Returns the {@link Reporter} associated to this doclet environment.
+ * This method is hack for giving that information to the taglets. We have to use a standard Java interfaces
+ * because the class loader of this {@code Doclet} will not be the same than the {@link Taglet} class loader.
+ *
+ * @return implementation-dependent information to give to taglets.
+ */
+ @Override
+ public Reporter get() {
+ return reporter;
}
/**
@@ -156,7 +150,6 @@
*/
@Override
public boolean run(final DocletEnvironment environment) {
- trees = environment.getDocTrees();
final boolean success = super.run(environment);
if (success && outputDirectory != null) try {
final Path output = Paths.get(outputDirectory);
diff --git a/core/sis-build-helper/src/main/java/org/apache/sis/internal/doclet/Taglet.java b/core/sis-build-helper/src/main/java/org/apache/sis/internal/doclet/Taglet.java
index b55fafe..b7be2cf 100644
--- a/core/sis-build-helper/src/main/java/org/apache/sis/internal/doclet/Taglet.java
+++ b/core/sis-build-helper/src/main/java/org/apache/sis/internal/doclet/Taglet.java
@@ -25,11 +25,13 @@
import javax.lang.model.element.Element;
import jdk.javadoc.doclet.DocletEnvironment;
import jdk.javadoc.doclet.Reporter;
+import jdk.javadoc.doclet.Doclet;
import com.sun.source.util.DocTrees;
import com.sun.source.util.TreePath;
import com.sun.source.doctree.DocTree;
import com.sun.source.doctree.TextTree;
import com.sun.source.doctree.UnknownInlineTagTree;
+import java.util.function.Supplier;
/**
@@ -70,24 +72,9 @@
* @param doclet the doclet that instantiated this taglet.
*/
@Override
- public void init(final DocletEnvironment env, final jdk.javadoc.doclet.Doclet doclet) {
- if (doclet instanceof Doclet) {
- reporter = ((Doclet) doclet).reporter;
- trees = ((Doclet) doclet).trees;
- } else {
- // Temporary workaround for https://bugs.openjdk.java.net/browse/JDK-8201817
- StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE).walk(stream ->
- stream.filter(frame -> frame.getClassName().equals("org.apache.sis.internal.doclet.Doclet"))
- .map(frame -> frame.getDeclaringClass()).findFirst()).ifPresent(docletClass -> {
- try {
- Object instance = docletClass.getDeclaredField("workaround8201817").get(null);
- reporter = (Reporter) docletClass.getDeclaredField("reporter").get(instance);
- trees = (DocTrees) docletClass.getDeclaredField("trees").get(instance);
- } catch (ReflectiveOperationException e) {
- printError("Unsupported doclet implementation. Caused by: " + e);
- }
- });
- }
+ public void init(final DocletEnvironment env, final Doclet doclet) {
+ reporter = (Reporter) ((Supplier<?>) doclet).get();
+ trees = env.getDocTrees();
}
/**
diff --git a/pom.xml b/pom.xml
index 1790ea7..3c80bc9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
Maven 2 project configuration file
http://maven.apache.org/maven2/
- Apache SIS build requires Java 10 or higher, but compiled files can be executed on Java 8.
+ Apache SIS build requires Java 11 or higher, but compiled files can be executed on Java 8.
Setting the SIS_DATA environment variable before build is optional but recommended.
Build development snapshot: mvn clean install
@@ -624,7 +624,7 @@
<configuration>
<rules>
<requireJavaVersion>
- <version>10</version>
+ <version>11</version>
</requireJavaVersion>
</rules>
</configuration>
@@ -920,8 +920,6 @@
<!-- Custom taglets, some of them implemented in Java. -->
<tags>
- <tag><placement>t</placement> <name>goal</name> <head>Maven goal:</head></tag>
- <tag><placement>t</placement> <name>phase</name> <head>Maven phase:</head></tag>
<tag><placement>X</placement> <name>category</name> <head>Category:</head></tag>
<tag><placement>a</placement> <name>todo</name> <head>TODO:</head></tag>
</tags>