8232438: Remove ?is-external=true from external links

Reviewed-by: prappo
This commit is contained in:
Hannes Wallnöfer 2020-02-24 16:42:22 +01:00
parent ccdde49728
commit bb7344d919
13 changed files with 62 additions and 78 deletions
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util
test/langtools/jdk/javadoc/doclet

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -26,11 +26,10 @@
package jdk.javadoc.internal.doclets.toolkit.util;
/**
* Abstraction for simple relative URIs, consisting of a path,
* an optional query, and an optional fragment. DocLink objects can
* be created by the constructors below or from a DocPath using the
* convenience methods, {@link DocPath#fragment fragment} and
* {@link DocPath#query query}.
* Abstraction for simple relative URIs, consisting of a path and an
* optional fragment. DocLink objects can be created by the constructors
* below or from a DocPath using the convenience
* {@link DocPath#fragment fragment} method.
*
* <p><b>This is NOT part of any supported API.
* If you write code that depends on this, you do so at your own risk.
@ -40,7 +39,6 @@ package jdk.javadoc.internal.doclets.toolkit.util;
*/
public class DocLink {
final DocPath path;
final String query;
final String fragment;
/**
@ -49,7 +47,7 @@ public class DocLink {
* @return the DocLink
*/
public static DocLink fragment(String fragment) {
return new DocLink((DocPath) null, (String) null, fragment);
return new DocLink((DocPath) null, fragment);
}
/**
@ -57,31 +55,28 @@ public class DocLink {
* @param path the path
*/
public DocLink(DocPath path) {
this(path, null, null);
this(path, null);
}
/**
* Creates a DocLink representing the URI {@code path?query#fragment}.
* Creates a DocLink representing the URI {@code path#fragment}.
* Any of the component parts may be null.
* @param path the path
* @param query the query
* @param fragment the fragment
*/
public DocLink(DocPath path, String query, String fragment) {
public DocLink(DocPath path, String fragment) {
this.path = path;
this.query = query;
this.fragment = fragment;
}
/**
* Creates a DocLink representing the URI {@code path?query#fragment}.
* Creates a DocLink representing the URI {@code path#fragment}.
* Any of the component parts may be null.
* @param path the path
* @param query the query
* @param fragment the fragment
*/
public DocLink(String path, String query, String fragment) {
this(DocPath.create(path), query, fragment);
public DocLink(String path, String fragment) {
this(DocPath.create(path), fragment);
}
/**
@ -101,10 +96,10 @@ public class DocLink {
DocPath newPath = base.relativize(path);
// avoid generating an empty link by using the basename of the path if necessary
if (newPath.isEmpty() && isEmpty(query) && isEmpty(fragment)) {
if (newPath.isEmpty() && isEmpty(fragment)) {
newPath = path.basename();
}
return new DocLink(newPath, query, fragment);
return new DocLink(newPath, fragment);
}
// return true if the path begins <letters>://
@ -121,21 +116,19 @@ public class DocLink {
}
/**
* Returns the link in the form "path?query#fragment", omitting any empty
* Returns the link in the form "path#fragment", omitting any empty
* components.
* @return the string
*/
@Override
public String toString() {
// common fast path
if (path != null && isEmpty(query) && isEmpty(fragment))
if (path != null && isEmpty(fragment))
return path.getPath();
StringBuilder sb = new StringBuilder();
if (path != null)
sb.append(path.getPath());
if (!isEmpty(query))
sb.append("?").append(query);
if (!isEmpty(fragment))
sb.append("#").append(fragment);
return sb.toString();

@ -210,16 +210,7 @@ public class DocPath {
* @return the link
*/
public DocLink fragment(String fragment) {
return new DocLink(path, null, fragment);
}
/**
* Creates a DocLink formed from this path and a query string.
* @param query the query string
* @return the link
*/
public DocLink query(String query) {
return new DocLink(path, query, null);
return new DocLink(path, fragment);
}
/**

@ -190,7 +190,7 @@ public class Extern {
DocPath p = fnd.relative ?
relativepath.resolve(fnd.path).resolve(filename) :
fnd.path.resolve(filename);
return new DocLink(p, "is-external=true", memberName);
return new DocLink(p, memberName);
}
/**

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -54,15 +54,15 @@ public class TestClassCrossReferences extends JavadocTester {
checkExit(Exit.OK);
checkOutput("C.html", true,
"<a href=\"" + uri + "java/math/package-summary.html?is-external=true\" class=\"externalLink\">"
"<a href=\"" + uri + "java/math/package-summary.html\" class=\"externalLink\">"
+ "<code>Link to math package</code></a>",
"<a href=\"" + uri + "javax/swing/text/AbstractDocument.AttributeContext.html?is-external=true\" "
"<a href=\"" + uri + "javax/swing/text/AbstractDocument.AttributeContext.html\" "
+ "title=\"class or interface in javax.swing.text\" class=\"externalLink\"><code>Link to AttributeContext innerclass</code></a>",
"<a href=\"" + uri + "java/math/BigDecimal.html?is-external=true\" "
"<a href=\"" + uri + "java/math/BigDecimal.html\" "
+ "title=\"class or interface in java.math\" class=\"externalLink\"><code>Link to external class BigDecimal</code></a>",
"<a href=\"" + uri + "java/math/BigInteger.html?is-external=true#gcd(java.math.BigInteger)\" "
"<a href=\"" + uri + "java/math/BigInteger.html#gcd(java.math.BigInteger)\" "
+ "title=\"class or interface in java.math\" class=\"externalLink\"><code>Link to external member gcd</code></a>",
"<a href=\"" + uri + "javax/tools/SimpleJavaFileObject.html?is-external=true#uri\" "
"<a href=\"" + uri + "javax/tools/SimpleJavaFileObject.html#uri\" "
+ "title=\"class or interface in javax.tools\" class=\"externalLink\"><code>Link to external member URI</code></a>",
"<dl>\n"
+ "<dt><span class=\"overrideSpecifyLabel\">Overrides:</span></dt>\n"

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -55,10 +55,10 @@ public class TestDocRootInlineTag extends JavadocTester {
checkExit(Exit.OK);
checkOutput("TestDocRootTag.html", true,
"<a href=\"" + uri + "/java/io/File.html?is-external=true\" "
"<a href=\"" + uri + "/java/io/File.html\" "
+ "title=\"class or interface in java.io\" class=\"externalLink\"><code>File</code></a>",
"<a href=\"./index-all.html\">index</a>",
"<a href=\"" + uri + "/java/io/File.html?is-external=true\" "
"<a href=\"" + uri + "/java/io/File.html\" "
+ "title=\"class or interface in java.io\" class=\"externalLink\"><code>Second File Link</code></a>",
"The value of @docRoot is \"./\"");

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -54,14 +54,14 @@ public class TestExternalOverridenMethod extends JavadocTester {
checkOutput("pkg/XReader.html", true,
"<dt><span class=\"overrideSpecifyLabel\">Overrides:</span></dt>\n"
+ "<dd><code><a href=\"" + uri + "/java/io/FilterReader.html?is-external=true#read()\" "
+ "<dd><code><a href=\"" + uri + "/java/io/FilterReader.html#read()\" "
+ "title=\"class or interface in java.io\" class=\"externalLink\">read</a></code>&nbsp;in class&nbsp;<code>"
+ "<a href=\"" + uri + "/java/io/FilterReader.html?is-external=true\" "
+ "<a href=\"" + uri + "/java/io/FilterReader.html\" "
+ "title=\"class or interface in java.io\" class=\"externalLink\">FilterReader</a></code></dd>",
"<dt><span class=\"overrideSpecifyLabel\">Specified by:</span></dt>\n"
+ "<dd><code><a href=\"" + uri + "/java/io/DataInput.html?is-external=true#readInt()\" "
+ "<dd><code><a href=\"" + uri + "/java/io/DataInput.html#readInt()\" "
+ "title=\"class or interface in java.io\" class=\"externalLink\">readInt</a></code>&nbsp;in interface&nbsp;<code>"
+ "<a href=\"" + uri + "/java/io/DataInput.html?is-external=true\" "
+ "<a href=\"" + uri + "/java/io/DataInput.html\" "
+ "title=\"class or interface in java.io\" class=\"externalLink\">DataInput</a></code></dd>"
);
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -52,7 +52,7 @@ public class TestHref extends JavadocTester {
checkOutput("pkg/C1.html", true,
//External link.
"href=\"http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html?is-external=true#wait(long,int)\"",
"href=\"http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html#wait(long,int)\"",
//Member summary table link.
"href=\"#method(int,int,java.util.ArrayList)\"",
//Anchor test.

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -71,7 +71,7 @@ public class TestLinkOption extends JavadocTester {
checkExit(Exit.OK);
checkOutput("pkg/C.html", true,
"<a href=\"" + url + "java/lang/String.html?is-external=true\" "
"<a href=\"" + url + "java/lang/String.html\" "
+ "title=\"class or interface in java.lang\" class=\"externalLink\"><code>Link to String Class</code></a>",
//Make sure the parameters are formatted properly when the -link option is used.
"(int&nbsp;p1,\n"
@ -79,18 +79,18 @@ public class TestLinkOption extends JavadocTester {
+ "int&nbsp;p3)",
"(int&nbsp;p1,\n"
+ "int&nbsp;p2,\n"
+ "<a href=\"" + url + "java/lang/Object.html?is-external=true\" title=\"class or interface in java.lang\" class=\"externalLink\">"
+ "<a href=\"" + url + "java/lang/Object.html\" title=\"class or interface in java.lang\" class=\"externalLink\">"
+ "Object</a>&nbsp;p3)");
checkOutput("pkg/B.html", true,
"<div class=\"block\">A method with html tag the method "
+ "<a href=\"" + url + "java/lang/ClassLoader.html?is-external=true#getSystemClassLoader()\""
+ "<a href=\"" + url + "java/lang/ClassLoader.html#getSystemClassLoader()\""
+ " title=\"class or interface in java.lang\" class=\"externalLink\"><code><b>getSystemClassLoader()</b>"
+ "</code></a> as the parent class loader.</div>",
"<div class=\"block\">is equivalent to invoking <code>"
+ "<a href=\"#createTempFile(java.lang.String,java.lang.String,java.io.File)\">"
+ "<code>createTempFile(prefix,&nbsp;suffix,&nbsp;null)</code></a></code>.</div>",
"<a href=\"" + url + "java/lang/String.html?is-external=true\" "
"<a href=\"" + url + "java/lang/String.html\" "
+ "title=\"class or interface in java.lang\" class=\"externalLink\">Link-Plain to String Class</a>",
"<code><b>getSystemClassLoader()</b></code>",
"<code>createTempFile(prefix,&nbsp;suffix,&nbsp;null)</code>",
@ -107,7 +107,7 @@ public class TestLinkOption extends JavadocTester {
checkOutput("mylib/lang/StringBuilderChild.html", true,
"<pre>public abstract class <span class=\"typeNameLabel\">StringBuilderChild</span>\n"
+ "extends <a href=\"" + url + "java/lang/Object.html?is-external=true\" "
+ "extends <a href=\"" + url + "java/lang/Object.html\" "
+ "title=\"class or interface in java.lang\" class=\"externalLink\">Object</a></pre>"
);
@ -121,7 +121,7 @@ public class TestLinkOption extends JavadocTester {
"pkg2");
checkExit(Exit.OK);
checkOutput("pkg2/C2.html", true,
"This is a link to <a href=\"../../" + out1 + "/pkg/C.html?is-external=true\" " +
"This is a link to <a href=\"../../" + out1 + "/pkg/C.html\" " +
"title=\"class or interface in pkg\" class=\"externalLink\"><code>Class C</code></a>."
);
@ -150,10 +150,10 @@ public class TestLinkOption extends JavadocTester {
+ "extends java.lang.Object</pre>\n"
+ "<div class=\"block\">Test links.\n"
+ " <br>\n"
+ " <a href=\"../../out2/pkg2/C2.html?is-external=true\" "
+ " <a href=\"../../out2/pkg2/C2.html\" "
+ "title=\"class or interface in pkg2\" class=\"externalLink\"><code>link to pkg2.C2</code></a>\n"
+ " <br>\n"
+ " <a href=\"../../out1/mylib/lang/StringBuilderChild.html?is-external=true\" "
+ " <a href=\"../../out1/mylib/lang/StringBuilderChild.html\" "
+ "title=\"class or interface in mylib.lang\" class=\"externalLink\">"
+ "<code>link to mylib.lang.StringBuilderChild</code></a>.</div>\n"
);
@ -171,10 +171,10 @@ public class TestLinkOption extends JavadocTester {
+ "extends java.lang.Object</pre>\n"
+ "<div class=\"block\">Test links.\n"
+ " <br>\n"
+ " <a href=\"../../copy/out2/pkg2/C2.html?is-external=true\" "
+ " <a href=\"../../copy/out2/pkg2/C2.html\" "
+ "title=\"class or interface in pkg2\" class=\"externalLink\"><code>link to pkg2.C2</code></a>\n"
+ " <br>\n"
+ " <a href=\"../../copy/out1/mylib/lang/StringBuilderChild.html?is-external=true\" "
+ " <a href=\"../../copy/out1/mylib/lang/StringBuilderChild.html\" "
+ "title=\"class or interface in mylib.lang\" class=\"externalLink\">"
+ "<code>link to mylib.lang.StringBuilderChild</code></a>.</div>\n"
);

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -103,7 +103,7 @@ public class TestLinkOptionWithAutomaticModule extends JavadocTester {
"p");
checkExit(Exit.OK);
checkOutput("p/MyClass.html", true,
"extends <a href=\"http://myWebsite/lib/LibClass.html?is-external=true\" "
"extends <a href=\"http://myWebsite/lib/LibClass.html\" "
+ "title=\"class or interface in lib\" class=\"externalLink\">LibClass</a>");
}
@ -127,7 +127,7 @@ public class TestLinkOptionWithAutomaticModule extends JavadocTester {
"--module", "my.module");
checkExit(Exit.OK);
checkOutput("my.module/p/MyClass.html", true,
"extends <a href=\"http://myWebsite/lib/LibClass.html?is-external=true\" "
"extends <a href=\"http://myWebsite/lib/LibClass.html\" "
+ "title=\"class or interface in lib\" class=\"externalLink\">LibClass</a>");
}
@ -151,7 +151,7 @@ public class TestLinkOptionWithAutomaticModule extends JavadocTester {
"--module", "my.module");
checkExit(Exit.OK);
checkOutput("my.module/p/MyClass.html", true,
"extends <a href=\"http://myWebsite/lib/LibClass.html?is-external=true\" "
"extends <a href=\"http://myWebsite/lib/LibClass.html\" "
+ "title=\"class or interface in lib\" class=\"externalLink\">LibClass</a>");
}
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -76,7 +76,7 @@ public class TestLinkOptionWithModule extends JavadocTester {
checkExit(Exit.OK);
checkOutput("com.ex2/com/ex2/B.html", true,
"<a href=\"../../../../out1a/com.ex1/com/ex1/A.html?is-external=true\" "
"<a href=\"../../../../out1a/com.ex1/com/ex1/A.html\" "
+ "title=\"class or interface in com.ex1\" class=\"externalLink\">A</a>");
}
@ -95,7 +95,7 @@ public class TestLinkOptionWithModule extends JavadocTester {
checkExit(Exit.OK);
checkOutput("com/ex2/B.html", true,
"<a href=\"../../../out2a/com/ex1/A.html?is-external=true\" title=\"class or interface in com.ex1\" "
"<a href=\"../../../out2a/com/ex1/A.html\" title=\"class or interface in com.ex1\" "
+ "class=\"externalLink\">A</a>");
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -122,10 +122,10 @@ public class TestRedirectLinks extends JavadocTester {
"pkg");
checkExit(Exit.OK);
checkOutput("pkg/B.html", true,
"<a href=\"" + apiURL + "/java.base/java/lang/String.html?is-external=true\" "
"<a href=\"" + apiURL + "/java.base/java/lang/String.html\" "
+ "title=\"class or interface in java.lang\" class=\"externalLink\">Link-Plain to String Class</a>");
checkOutput("pkg/C.html", true,
"<a href=\"" + apiURL + "/java.base/java/lang/Object.html?is-external=true\" "
"<a href=\"" + apiURL + "/java.base/java/lang/Object.html\" "
+ "title=\"class or interface in java.lang\" class=\"externalLink\">Object</a>");
}
@ -216,10 +216,10 @@ public class TestRedirectLinks extends JavadocTester {
checkOutput(Output.OUT, true,
"javadoc: warning - URL " + oldURL + "/element-list was redirected to " + newURL + "/element-list");
checkOutput("mC/p5/C5.html", true,
"extends <a href=\"" + oldURL + "/mA/p1/C1.html?is-external=true\" " +
"extends <a href=\"" + oldURL + "/mA/p1/C1.html\" " +
"title=\"class or interface in p1\" class=\"externalLink\">C1</a>");
checkOutput("mC/p6/C6.html", true,
"<a href=\"" + oldURL + "/mB/p4/C4.html?is-external=true\" " +
"<a href=\"" + oldURL + "/mB/p4/C4.html\" " +
"title=\"class or interface in p4\" class=\"externalLink\">C4</a>");
} finally {
if (oldServer != null) {

@ -1246,13 +1246,13 @@ public class TestModules extends JavadocTester {
void checkLinkOffline() {
checkOutput("moduleB/testpkg3mdlB/package-summary.html", true,
"<a href=\"https://docs.oracle.com/javase/9/docs/api/java.base/java/lang/String.html?is-external=true\" "
"<a href=\"https://docs.oracle.com/javase/9/docs/api/java.base/java/lang/String.html\" "
+ "title=\"class or interface in java.lang\" class=\"externalLink\"><code>Link to String Class</code></a>");
checkOutput("moduleB/testpkg3mdlB/package-summary.html", true,
"<a href=\"https://docs.oracle.com/javase/9/docs/api/java.base/java/lang/package-summary.html?is-external=true\" "
"<a href=\"https://docs.oracle.com/javase/9/docs/api/java.base/java/lang/package-summary.html\" "
+ "class=\"externalLink\"><code>Link to java.lang package</code></a>");
checkOutput("moduleB/testpkg3mdlB/package-summary.html", true,
"<a href=\"https://docs.oracle.com/javase/9/docs/api/java.base/module-summary.html?is-external=true\" "
"<a href=\"https://docs.oracle.com/javase/9/docs/api/java.base/module-summary.html\" "
+ "class=\"externalLink\"><code>Link to java.base module</code></a>");
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -56,7 +56,7 @@ public class TestTitleInHref extends JavadocTester {
//Test to make sure that the title shows up in an interface link.
"<a href=\"Interface.html\" title=\"interface in pkg\">",
//Test to make sure that the title shows up in cross link shows up
"<a href=\"" + uri + "/java/io/File.html?is-external=true\" "
"<a href=\"" + uri + "/java/io/File.html\" "
+ "title=\"class or interface in java.io\" class=\"externalLink\">"
+ "<code>This is a cross link to class File</code></a>");
}