Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Javadoc & <a href & URLs with anchors #1014

Open
jonpryor opened this issue Jul 18, 2022 · 0 comments
Open

Javadoc & <a href & URLs with anchors #1014

jonpryor opened this issue Jul 18, 2022 · 0 comments
Labels
bug Component does not function as intended javadoc Issues with consuming Java documentation formats

Comments

@jonpryor
Copy link
Member

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.

@jpobst jpobst added bug Component does not function as intended javadoc Issues with consuming Java documentation formats labels Jul 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Component does not function as intended javadoc Issues with consuming Java documentation formats
Projects
None yet
Development

No branches or pull requests

2 participants