Workaround for breaking change in OpenJDK 8 javadoc

This should only affect behavior when using the OpenJDK 8 version
of javadoc.

ConstructorDoc.name() is supposed to return the unqualified name for a constructor.
It is left ambiguous as to what this means for constructors of inner classes. e.g.

package foo;

class Bar {
  static class Baz {
    public Baz() {}
  }
}

For OpenJDK 7, the method returns "Bar.Baz" as the name of the constructor. i.e. it is
qualified with the name of the outer class, but not the package
For OpenJDK 8, the method returns "Baz" as the name of the constructor. i.e. it is not
qualified at all

In Android this affects both what doclava is willing to accept in
@link tags, but also the content of the API files like current.txt. This change
retains the old behavior under both OpenJDK 7 and OpenJDK 8. If later Android wants to
adopt the new semantics that can be done once OpenJDK 7 is no longer supported.

Bug: 18051133
Change-Id: Ic753a8d308e5d773cca13bd44ba3463481881779
diff --git a/src/com/google/doclava/Converter.java b/src/com/google/doclava/Converter.java
index e620bf3..79b7a2e 100644
--- a/src/com/google/doclava/Converter.java
+++ b/src/com/google/doclava/Converter.java
@@ -437,9 +437,23 @@
         return result;
       } else {
         ConstructorDoc m = (ConstructorDoc) o;
+        // Workaround for a JavaDoc behavior change introduced in OpenJDK 8 that breaks
+        // links in documentation and the content of API files like current.txt.
+        // http://b/18051133.
+        String name = m.name();
+        ClassDoc containingClass = m.containingClass();
+        if (containingClass.containingClass() != null) {
+          // This should detect the new behavior and be bypassed otherwise.
+          if (!name.contains(".")) {
+            // Constructors of inner classes do not contain the name of the enclosing class
+            // with OpenJDK 8. This simulates the old behavior:
+            name = containingClass.name();
+          }
+        }
+        // End of workaround.
         MethodInfo result =
-            new MethodInfo(m.getRawCommentText(), new ArrayList<TypeInfo>(Arrays.asList(Converter.convertTypes(m.typeParameters()))), m
-                .name(), m.signature(), Converter.obtainClass(m.containingClass()), Converter
+            new MethodInfo(m.getRawCommentText(), new ArrayList<TypeInfo>(Arrays.asList(Converter.convertTypes(m.typeParameters()))), 
+                name, m.signature(), Converter.obtainClass(m.containingClass()), Converter
                 .obtainClass(m.containingClass()), m.isPublic(), m.isProtected(), m
                 .isPackagePrivate(), m.isPrivate(), m.isFinal(), m.isStatic(), m.isSynthetic(),
                 false, m.isSynchronized(), m.isNative(), false, "constructor", m.flatSignature(),