Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8236539

Relative link tags in record javadoc don't resolve

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b28
    • Verification:
      Verified

      Backports

        Description

        From amber-dev:
        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

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                jjg Jonathan Gibbons
                Reporter:
                jjg Jonathan Gibbons
                Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: