Relative link tags in record javadoc don't resolve

Michael Hixson michael.hixson at gmail.com
Tue Dec 24 19:28:28 UTC 2019


Hello,

The javadoc tool in 14-ea+28-1366 doesn't resolve {@link} tags in
records unless the link target is qualified with its class name.  This
seems like a bug because it's different than the behavior for
non-record classes.

Take this code for example:

    package example;

    public class JavadocTest {
      /**
       * {@link #foo()}
       * {@link Bar}
       */
      public static class Foo {
        public void foo() {}
      }

      /**
       * {@link #bar()}
       * {@link Foo}
       */
      public record Bar() {
        public void bar() {}
      }
    }

The javadoc tool complains about both of the link tags in the "Bar"
record class.  It's fine with the similar-looking link tags in the
"Foo" non-record class.

    javadoc --enable-preview --release 14 -d jdoc
src/main/java/example/JavadocTest.java

    src\main\java\example\JavadocTest.java:13: error: reference not found
       * {@link #bar()}
                ^
    src\main\java\example\JavadocTest.java:14: error: reference not found
       * {@link Foo}
                ^

If I qualify the link tags in the record class, then javadoc is happy.

    package example;

    public class JavadocTest {
      /**
       * {@link #foo()}
       * {@link Bar}
       */
      public static class Foo {
        public void foo() {}
      }

      /**
       * {@link JavadocTest.Bar#bar()}
       * {@link JavadocTest.Foo}
       */
      public record Bar() {
        public void bar() {}
      }
    }

-Michael


More information about the amber-dev mailing list