Author: desruisseaux
Date: Tue Feb 3 14:27:03 2015
New Revision: 1656742
URL: http://svn.apache.org/r1656742
Log:
Make the JDK6 code compilable with the JDK8 compiler.
Modified:
sis/trunk/ (props changed)
sis/trunk/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/InlineTaglet.java
Propchange: sis/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Feb 3 14:27:03 2015
@@ -1,4 +1,4 @@
/sis/branches/Android:1430670-1480699
-/sis/branches/JDK6:1394364-1656726
-/sis/branches/JDK7:1394913-1656724
-/sis/branches/JDK8:1584960-1656723
+/sis/branches/JDK6:1394364-1656740
+/sis/branches/JDK7:1394913-1656738
+/sis/branches/JDK8:1584960-1656731
Modified:
sis/trunk/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/InlineTaglet.java
URL:
http://svn.apache.org/viewvc/sis/trunk/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/InlineTaglet.java?rev=1656742&r1=1656741&r2=1656742&view=diff
==============================================================================
---
sis/trunk/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/InlineTaglet.java
[UTF-8] (original)
+++
sis/trunk/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/InlineTaglet.java
[UTF-8] Tue Feb 3 14:27:03 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 (Exception e) { // ReflectiveOperationException on the
JDK7 branch
+ try {
+ configuration = ConfigurationImpl.class.newInstance();
+ } catch (Exception e2) { // ReflectiveOperationException on
the JDK7 branch
+ 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 {