Author: desruisseaux
Date: Tue Feb 3 14:19:01 2015
New Revision: 1656740
URL: http://svn.apache.org/r1656740
Log:
Make the JDK6 branch compilable with the JDK7 and JDK8 compilers.
Modified:
sis/branches/JDK6/ (props changed)
sis/branches/JDK6/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/InlineTaglet.java
Propchange: sis/branches/JDK6/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Feb 3 14:19:01 2015
@@ -1,4 +1,4 @@
/sis/branches/Android:1430670-1480699
-/sis/branches/JDK7:1394913-1656724
-/sis/branches/JDK8:1584960-1656723
+/sis/branches/JDK7:1394913-1656738
+/sis/branches/JDK8:1584960-1656731
/sis/trunk:1394364-1508466,1519089-1519674
Modified:
sis/branches/JDK6/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/InlineTaglet.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/InlineTaglet.java?rev=1656740&r1=1656739&r2=1656740&view=diff
==============================================================================
---
sis/branches/JDK6/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/InlineTaglet.java
[UTF-8] (original)
+++
sis/branches/JDK6/core/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/InlineTaglet.java
[UTF-8] Tue Feb 3 14:19:01 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 {