java.interop icon indicating copy to clipboard operation
java.interop copied to clipboard

Javadoc & `<a href` & URLs with anchors

Open jonpryor opened this issue 3 years ago • 0 comments

Context: https://github.com/xamarin/android-api-docs/pull/33/files#diff-870423d17697a5761223c510ac816e5f181e5eee8d209b712b60fb8d64636d9eR248

While reviewing xamarin/android-api-docs#33, ran across the following Javadoc imports which don't look "right", involving HTTP anchors.

Consider this Javadoc fragment from java/lang/invoke/MethodHandleInfo.java, which contains a URL with an anchor MethodHandleInfo.html#refkinds:

public /* partial */ interface MethodHandleInfo {
    /**
     * Returns the descriptive name of the given reference kind,
     * as defined in the <a href="MethodHandleInfo.html#refkinds">table above</a>.
     * The conventional prefix "REF_" is omitted.
     * @param referenceKind an integer code for a kind of reference used to access a class member
     * @return a mixed-case string such as {@code "getField"}
     * @exception IllegalArgumentException if the argument is not a valid
     *            <a href="MethodHandleInfo.html#refkinds">reference kind number</a>
     */
    public static String referenceKindToString(int referenceKind) {
        if (!MethodHandleNatives.refKindIsValid(referenceKind))
            throw newIllegalArgumentException("invalid reference kind", referenceKind);
        return MethodHandleNatives.refKindName((byte)referenceKind);
    }
}

Importing the above Javadoc results in the <summary/>:

        <summary>Returns the descriptive name of the given reference kind,
            as defined in the "MethodHandleInfo.</summary>

Note that <a href="MethodHandleInfo.html#refkinds"> is converted into "MethodHandleInfo: the leading " is preserved, while the extension .html and anchor #refkinds is lost.

Or consider java/lang/ClassLoader.java:

public /* partial */ class ClassLoader {
    /**
     * Returns the class with the given <a href="#name">binary name</a> if this
     * loader has been recorded by the Java virtual machine as an initiating
     * loader of a class with that <a href="#name">binary name</a>.  Otherwise
     * <tt>null</tt> is returned.
     *
     * @param  name
     *         The <a href="#name">binary name</a> of the class
     *
     * @return  The <tt>Class</tt> object, or <tt>null</tt> if the class has
     *          not been loaded
     *
     * @since  1.1
     */
    protected final Class<?> findLoadedClass(String name) {
        ClassLoader loader;
        if (this == BootClassLoader.getInstance())
            loader = null;
        else
            loader = this;
        return VMClassLoader.findLoadedClass(loader, name);
    }
}

This is imported as:

        <param name="name">The "#name"&gt;binary name of the class</param>
        <summary>Returns the class with the given "#name"&gt;binary name if this
            loader has been recorded by the Java virtual machine as an initiating
            loader of a class with that "#name"&gt;binary name.</summary>

The commonality between these two issues appears to be in dealing with URL anchors, #anchor.

jonpryor avatar Jul 18 '22 18:07 jonpryor