Author: desruisseaux Date: Tue Feb 3 14:07:53 2015 New Revision: 1656738 URL: http://svn.apache.org/r1656738 Log: Make the JDK7 branch compilable with JDK8.
Modified: sis/branches/JDK7/ (props changed) sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/InlineTaglet.java Propchange: sis/branches/JDK7/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Tue Feb 3 14:07:53 2015 @@ -1,4 +1,4 @@ /sis/branches/Android:1430670-1480699 /sis/branches/JDK6:1394913-1508480 -/sis/branches/JDK8:1584960-1656723 +/sis/branches/JDK8:1584960-1656731 /sis/trunk:1394364-1508466,1519089-1519674 Modified: sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/InlineTaglet.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/InlineTaglet.java?rev=1656738&r1=1656737&r2=1656738&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/InlineTaglet.java [UTF-8] (original) +++ sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/InlineTaglet.java [UTF-8] Tue Feb 3 14:07:53 2015 @@ -34,10 +34,31 @@ import com.sun.tools.doclets.formats.htm */ abstract class InlineTaglet implements Taglet { /** - * Returns the doclet configuration. + * The doclet configuration, created when first needed for reporting warnings. */ - private static synchronized Configuration getConfiguration() { - return ConfigurationImpl.getInstance(); + private static Configuration configuration; + + /** + * Returns the root document, or {@code null} if none. + */ + private static synchronized RootDoc getRootDoc() { + if (configuration == null) { + /* + * Try to invoke ConfigurationImpl.getInstance(), which exists on JDK6 and JDK7 but not on JDK8. + * If we fail, fallback on direct instantiation of ConfigurationImpl(), which is possible only + * in JDK8 (because the constructor is private on JDK6 and JDK7). + */ + try { + configuration = (Configuration) ConfigurationImpl.class.getMethod("getInstance").invoke(null); + } catch (ReflectiveOperationException e) { + try { + configuration = ConfigurationImpl.class.newInstance(); + } catch (ReflectiveOperationException e2) { + return null; // Allowed by this method contract. + } + } + } + return configuration.root; } /** @@ -138,7 +159,7 @@ abstract class InlineTaglet implements T * Prints a warning message. */ static void printWarning(final SourcePosition position, final String message) { - final RootDoc root = getConfiguration().root; + final RootDoc root = getRootDoc(); if (root != null) { root.printWarning(position, message); } else { @@ -150,7 +171,7 @@ abstract class InlineTaglet implements T * Prints an error message. */ static void printError(final SourcePosition position, final String message) { - final RootDoc root = getConfiguration().root; + final RootDoc root = getRootDoc(); if (root != null) { root.printError(position, message); } else {