mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 02:54:35 +02:00
8042829: [javadoc] index-file output is not sorted correctly
8043062: JDK 9 platform and compiler upgrade failed on Solaris-sparcv9 with Javadoc.gmk:360: recipe for target docs/api/index.html Reviewed-by: erikj, jjg
This commit is contained in:
parent
e380f5fa69
commit
b18841ffa0
5 changed files with 332 additions and 247 deletions
|
@ -31,6 +31,7 @@ import java.lang.annotation.ElementType;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
import java.text.Collator;
|
import java.text.Collator;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import javax.tools.StandardLocation;
|
import javax.tools.StandardLocation;
|
||||||
|
|
||||||
import com.sun.javadoc.*;
|
import com.sun.javadoc.*;
|
||||||
|
@ -783,9 +784,8 @@ public class Util {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A general purpose String comparator, which compares two Strings using a Collator
|
* A general purpose case insensitive String comparator, which compares two Strings using a Collator
|
||||||
* strength of "SECONDARY", thus providing optimum case insensitive comparisons in
|
* strength of "TERTIARY".
|
||||||
* most Locales.
|
|
||||||
*
|
*
|
||||||
* @param s1 first String to compare.
|
* @param s1 first String to compare.
|
||||||
* @param s2 second String to compare.
|
* @param s2 second String to compare.
|
||||||
|
@ -793,14 +793,32 @@ public class Util {
|
||||||
* argument is less than, equal to, or greater than the second.
|
* argument is less than, equal to, or greater than the second.
|
||||||
*/
|
*/
|
||||||
public static int compareStrings(String s1, String s2) {
|
public static int compareStrings(String s1, String s2) {
|
||||||
|
return compareStrings(true, s1, s2);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* A general purpose case sensitive String comparator, which compares two Strings using a Collator
|
||||||
|
* strength of "SECONDARY".
|
||||||
|
*
|
||||||
|
* @param s1 first String to compare.
|
||||||
|
* @param s2 second String to compare.
|
||||||
|
* @return a negative integer, zero, or a positive integer as the first
|
||||||
|
* argument is less than, equal to, or greater than the second.
|
||||||
|
*/
|
||||||
|
public static int compareCaseCompare(String s1, String s2) {
|
||||||
|
return compareStrings(false, s1, s2);
|
||||||
|
}
|
||||||
|
private static int compareStrings(boolean caseSensitive, String s1, String s2) {
|
||||||
Collator collator = Collator.getInstance();
|
Collator collator = Collator.getInstance();
|
||||||
collator.setStrength(Collator.SECONDARY);
|
collator.setStrength(caseSensitive ? Collator.TERTIARY : Collator.SECONDARY);
|
||||||
return collator.compare(s1, s2);
|
return collator.compare(s1, s2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A comparator for index file uses, this sorts first on names, then on
|
* A comparator for index file uses,
|
||||||
* parameter types and finally on the fully qualified name.
|
* 1. this sorts first on simple names
|
||||||
|
* 2. if equal, case insensitive comparison of Parameter types
|
||||||
|
* 3. if equal, case sensitive comparison of Parameter types
|
||||||
|
* 4. if equal, compare the FQNs of the entities
|
||||||
|
* 5. if equal, then compare the DocKinds ex: Package, Interface etc.
|
||||||
* @return a comparator for index file use
|
* @return a comparator for index file use
|
||||||
*/
|
*/
|
||||||
public static Comparator<Doc> makeComparatorForIndexUse() {
|
public static Comparator<Doc> makeComparatorForIndexUse() {
|
||||||
|
@ -816,29 +834,35 @@ public class Util {
|
||||||
* argument is less than, equal to, or greater than the second.
|
* argument is less than, equal to, or greater than the second.
|
||||||
*/
|
*/
|
||||||
public int compare(Doc d1, Doc d2) {
|
public int compare(Doc d1, Doc d2) {
|
||||||
int result = compareStrings(d1.name(), d2.name());
|
int result = compareNames(d1, d2);
|
||||||
if (result != 0) {
|
if (result != 0) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
if (d1 instanceof ExecutableMemberDoc && d2 instanceof ExecutableMemberDoc) {
|
if (d1 instanceof ExecutableMemberDoc && d2 instanceof ExecutableMemberDoc) {
|
||||||
result = compareExecutableMembers(
|
Parameter[] param1 = ((ExecutableMemberDoc) d1).parameters();
|
||||||
(ExecutableMemberDoc) d1,
|
Parameter[] param2 = ((ExecutableMemberDoc) d2).parameters();
|
||||||
(ExecutableMemberDoc) d2);
|
result = compareParameters(false, param1, param2);
|
||||||
if (result != 0) {
|
if (result != 0) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
result = compareParameters(true, param1, param2);
|
||||||
}
|
}
|
||||||
if (d1 instanceof ProgramElementDoc && d2 instanceof ProgramElementDoc) {
|
if (result != 0) {
|
||||||
return compareProgramElementDoc((ProgramElementDoc)d1, (ProgramElementDoc)d2);
|
return result;
|
||||||
}
|
}
|
||||||
return 0;
|
result = compareFullyQualifiedNames(d1, d2);
|
||||||
|
if (result != 0) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
return compareDocKinds(d1, d2);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Comparator for ClassUse representations, this sorts on member names,
|
* Comparator for ClassUse representations, this sorts on member names,
|
||||||
* fully qualified member names and then the parameter types if applicable.
|
* fully qualified member names and then the parameter types if applicable,
|
||||||
|
* and finally the Doc kinds ie. package, class, interface etc.
|
||||||
* @return a comparator to sort classes and members for class use
|
* @return a comparator to sort classes and members for class use
|
||||||
*/
|
*/
|
||||||
public static Comparator<Doc> makeComparatorForClassUse() {
|
public static Comparator<Doc> makeComparatorForClassUse() {
|
||||||
|
@ -853,46 +877,88 @@ public class Util {
|
||||||
* argument is less than, equal to, or greater than the second.
|
* argument is less than, equal to, or greater than the second.
|
||||||
*/
|
*/
|
||||||
public int compare(Doc d1, Doc d2) {
|
public int compare(Doc d1, Doc d2) {
|
||||||
int result = compareStrings(d1.name(), d2.name());
|
int result = compareNames(d1, d2);
|
||||||
if (result != 0) {
|
if (result != 0) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
if (d1 instanceof ProgramElementDoc && d2 instanceof ProgramElementDoc) {
|
result = compareFullyQualifiedNames(d1, d2);
|
||||||
result = compareProgramElementDoc((ProgramElementDoc) d1, (ProgramElementDoc) d2);
|
if (result != 0) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
if (d1 instanceof ExecutableMemberDoc && d2 instanceof ExecutableMemberDoc) {
|
||||||
|
Parameter[] param1 = ((ExecutableMemberDoc) d1).parameters();
|
||||||
|
Parameter[] param2 = ((ExecutableMemberDoc) d2).parameters();
|
||||||
|
result = compareParameters(false, param1, param2);
|
||||||
if (result != 0) {
|
if (result != 0) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
return compareParameters(true, param1, param2);
|
||||||
}
|
}
|
||||||
if (d1 instanceof ExecutableMemberDoc && d2 instanceof ExecutableMemberDoc) {
|
return compareDocKinds(d1, d2);
|
||||||
return compareExecutableMembers((ExecutableMemberDoc)d1, (ExecutableMemberDoc)d2);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A general purpose comparator to sort Doc entities, basically provides the building blocks
|
* A general purpose comparator to sort Doc entities, basically provides the building blocks
|
||||||
* for creating specific comparators for an use-case.
|
* for creating specific comparators for an use-case.
|
||||||
* @param <T> a Doc entity
|
* @param <T> a Doc entity
|
||||||
*/
|
*/
|
||||||
static abstract class DocComparator<T extends Doc> implements Comparator<Doc> {
|
static abstract class DocComparator<T extends Doc> implements Comparator<Doc> {
|
||||||
|
static enum DocKinds {
|
||||||
|
PACKAGE,
|
||||||
|
FIELD,
|
||||||
|
ENUM,
|
||||||
|
ANNOTATION,
|
||||||
|
INTERFACE,
|
||||||
|
CLASS,
|
||||||
|
CONSTRUCTOR,
|
||||||
|
METHOD
|
||||||
|
};
|
||||||
|
private DocKinds getValue(Doc d) {
|
||||||
|
if (d.isAnnotationType() || d.isAnnotationTypeElement()) {
|
||||||
|
return DocKinds.ANNOTATION;
|
||||||
|
} else if (d.isEnum() || d.isEnumConstant()) {
|
||||||
|
return DocKinds.ENUM;
|
||||||
|
} else if (d.isField()) {
|
||||||
|
return DocKinds.FIELD;
|
||||||
|
} else if (d.isInterface()) {
|
||||||
|
return DocKinds.INTERFACE;
|
||||||
|
} else if (d.isClass()) {
|
||||||
|
return DocKinds.CLASS;
|
||||||
|
} else if (d.isConstructor()) {
|
||||||
|
return DocKinds.CONSTRUCTOR;
|
||||||
|
} else if (d.isMethod()) {
|
||||||
|
return DocKinds.METHOD;
|
||||||
|
} else {
|
||||||
|
return DocKinds.PACKAGE;
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* compares two parameter arrays by comparing each Type of the parameter in the array,
|
* Compares two Doc entities' kinds, and these are ordered as defined in
|
||||||
* as possible, if the matched strings are identical, and have mismatched array lengths
|
* the DocKinds enumeration.
|
||||||
* then compare the lengths.
|
* @param d1 the first Doc object
|
||||||
|
* @param d2 the second Doc object
|
||||||
|
* @return a negative integer, zero, or a positive integer as the first
|
||||||
|
* argument is less than, equal to, or greater than the second.
|
||||||
|
*/
|
||||||
|
protected int compareDocKinds(Doc d1, Doc d2) {
|
||||||
|
return getValue(d1).compareTo(getValue(d2));
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Compares two parameter arrays by comparing each Type of the parameter in the array,
|
||||||
|
* and as many as possible, otherwise compare their lengths.
|
||||||
|
* @param ignoreCase specifies case sensitive or insensitive comparison.
|
||||||
* @param params1 the first parameter array.
|
* @param params1 the first parameter array.
|
||||||
* @param params2 the first parameter array.
|
* @param params2 the first parameter array.
|
||||||
* @return a negative integer, zero, or a positive integer as the first
|
* @return a negative integer, zero, or a positive integer as the first
|
||||||
* argument is less than, equal to, or greater than the second.
|
* argument is less than, equal to, or greater than the second.
|
||||||
*/
|
*/
|
||||||
protected int compareParameters(Parameter[] params1, Parameter[] params2) {
|
protected int compareParameters(boolean ignoreCase, Parameter[] params1, Parameter[] params2) {
|
||||||
if (params1.length == 0 && params2.length == 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
// try to compare as many as possible
|
// try to compare as many as possible
|
||||||
for (int i = 0; i < params1.length && i < params2.length; i++) {
|
for (int i = 0; i < params1.length && i < params2.length; i++) {
|
||||||
int result = compareStrings(params1[i].typeName(), params2[i].typeName());
|
int result = compareStrings(ignoreCase, params1[i].typeName(), params2[i].typeName());
|
||||||
if (result != 0) {
|
if (result != 0) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -901,41 +967,32 @@ public class Util {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compares two MemberDocs, typically the name of a method,
|
* Compares two Doc entities typically the simple name of a method,
|
||||||
* field or constructor.
|
* field, constructor etc.
|
||||||
* @param e1 the first MemberDoc.
|
* @param d1 the first Doc.
|
||||||
* @param e2 the second MemberDoc.
|
* @param d2 the second Doc.
|
||||||
* @return a negative integer, zero, or a positive integer as the first
|
* @return a negative integer, zero, or a positive integer as the first
|
||||||
* argument is less than, equal to, or greater than the second.
|
* argument is less than, equal to, or greater than the second.
|
||||||
*/
|
*/
|
||||||
protected int compareMembers(MemberDoc e1, MemberDoc e2) {
|
protected int compareNames(Doc d1, Doc d2) {
|
||||||
return compareStrings(e1.name(), e2.name());
|
return compareStrings(d1.name(), d2.name());
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Compares two ExecutableMemberDocs such as methods and constructors,
|
|
||||||
* as well as the parameters the entity might take.
|
|
||||||
* @param m1 the first ExecutableMemberDoc.
|
|
||||||
* @param m2 the second ExecutableMemberDoc.
|
|
||||||
* @return a negative integer, zero, or a positive integer as the first
|
|
||||||
* argument is less than, equal to, or greater than the second.
|
|
||||||
*/
|
|
||||||
protected int compareExecutableMembers(ExecutableMemberDoc m1, ExecutableMemberDoc m2) {
|
|
||||||
int result = compareMembers(m1, m2);
|
|
||||||
if (result == 0)
|
|
||||||
result = compareParameters(m1.parameters(), m2.parameters());
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compares the fully qualified names of the entities
|
* Compares the fully qualified names of the entities
|
||||||
* @param p1 the first ProgramElementDoc.
|
* @param d1 the first entity
|
||||||
* @param p2 the first ProgramElementDoc.
|
* @param d2 the second entity
|
||||||
* @return a negative integer, zero, or a positive integer as the first
|
* @return a negative integer, zero, or a positive integer as the first
|
||||||
* argument is less than, equal to, or greater than the second.
|
* argument is less than, equal to, or greater than the second.
|
||||||
*/
|
*/
|
||||||
protected int compareProgramElementDoc(ProgramElementDoc p1, ProgramElementDoc p2) {
|
protected int compareFullyQualifiedNames(Doc d1, Doc d2) {
|
||||||
return compareStrings(p1.qualifiedName(), p2.qualifiedName());
|
String name1 = (d1 instanceof ProgramElementDoc)
|
||||||
|
? ((ProgramElementDoc)d1).qualifiedName()
|
||||||
|
: d1.name();
|
||||||
|
String name2 = (d2 instanceof ProgramElementDoc)
|
||||||
|
? ((ProgramElementDoc)d2).qualifiedName()
|
||||||
|
: d2.name();
|
||||||
|
return compareStrings(name1, name2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -451,8 +451,12 @@ public abstract class JavadocTester {
|
||||||
for (String s : strings) {
|
for (String s : strings) {
|
||||||
int currentIndex = fileString.indexOf(s);
|
int currentIndex = fileString.indexOf(s);
|
||||||
checking(s + " at index " + currentIndex);
|
checking(s + " at index " + currentIndex);
|
||||||
if (currentIndex >= prevIndex) {
|
if (currentIndex == -1) {
|
||||||
passed(s + "is in the correct order");
|
failed(s + " not found.");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (currentIndex > prevIndex) {
|
||||||
|
passed(s + " is in the correct order");
|
||||||
} else {
|
} else {
|
||||||
failed(s + " is in the wrong order.");
|
failed(s + " is in the wrong order.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 8039410 8042601
|
* @bug 8039410 8042601 8042829
|
||||||
* @summary test to determine if members are ordered correctly
|
* @summary test to determine if members are ordered correctly
|
||||||
* @author ksrini
|
* @author ksrini
|
||||||
* @library ../lib/
|
* @library ../lib/
|
||||||
|
@ -31,6 +31,16 @@
|
||||||
* @run main TestOrdering
|
* @run main TestOrdering
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static java.nio.file.StandardOpenOption.*;
|
||||||
|
|
||||||
public class TestOrdering extends JavadocTester {
|
public class TestOrdering extends JavadocTester {
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
|
@ -39,7 +49,7 @@ public class TestOrdering extends JavadocTester {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testUnnamedPackages() {
|
void testUnnamedPackagesForClassUse() {
|
||||||
javadoc("-d", "out",
|
javadoc("-d", "out",
|
||||||
"-sourcepath", testSrc,
|
"-sourcepath", testSrc,
|
||||||
"-use",
|
"-use",
|
||||||
|
@ -49,16 +59,94 @@ public class TestOrdering extends JavadocTester {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testNamedPackages() {
|
void testNamedPackagesForClassUse() {
|
||||||
javadoc("-d", "out-1",
|
javadoc("-d", "out-1",
|
||||||
"-sourcepath", testSrc,
|
"-sourcepath", testSrc,
|
||||||
"-use",
|
"-use",
|
||||||
"pkg1");
|
"pkg1");
|
||||||
checkExit(Exit.OK);
|
checkExit(Exit.OK);
|
||||||
checkClassUseOrdering("pkg1/class-use/UsedClass.html");
|
checkClassUseOrdering("pkg1/class-use/UsedClass.html");
|
||||||
checkIndexPathOrdering("index-all.html");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum ListOrder { NONE, REVERSE, SHUFFLE };
|
||||||
|
/*
|
||||||
|
* By default we do not shuffle the input list, in order to keep the list deterministic,
|
||||||
|
* and the test predictable. However, we can turn on the stress mode, by setting the following
|
||||||
|
* property if required.
|
||||||
|
*/
|
||||||
|
static final ListOrder STRESS_MODE = Boolean.getBoolean("TestOrder.STRESS")
|
||||||
|
? ListOrder.SHUFFLE
|
||||||
|
: ListOrder.REVERSE;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Controls the number of sibling packages, pkg0, pkg1, pkg2, .....
|
||||||
|
*/
|
||||||
|
static final int MAX_PACKAGES = 4;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Controls the number of children packages, pkg0, pkg0.pkg, pkg0.pkg.pkg, .....
|
||||||
|
* Note: having too long a depth (> 256 chars on Windows), will likely lead to
|
||||||
|
* cause problems with automated build and test systems.
|
||||||
|
*/
|
||||||
|
static final int MAX_SUBPACKAGES_DEPTH = 4;
|
||||||
|
@Test
|
||||||
|
void testIndexOrdering() throws IOException {
|
||||||
|
final String clsname = "Add";
|
||||||
|
List<String> cmdArgs = new ArrayList();
|
||||||
|
cmdArgs.add("-d");
|
||||||
|
cmdArgs.add("out-2");
|
||||||
|
cmdArgs.add("-sourcepath");
|
||||||
|
cmdArgs.add("src");
|
||||||
|
cmdArgs.add("-package");
|
||||||
|
System.out.println("STRESS_MODE: " + STRESS_MODE);
|
||||||
|
emitFile(null, clsname, STRESS_MODE);
|
||||||
|
for (int width = 0 ; width < MAX_PACKAGES ; width++) {
|
||||||
|
String wpkgname = "add" + width;
|
||||||
|
String dpkgname = wpkgname;
|
||||||
|
emitFile(wpkgname, clsname, ListOrder.NONE); // list as-is
|
||||||
|
cmdArgs.add(wpkgname);
|
||||||
|
for (int depth = 1 ; depth < MAX_SUBPACKAGES_DEPTH ; depth++) {
|
||||||
|
dpkgname = dpkgname + ".add";
|
||||||
|
emitFile(dpkgname, clsname, STRESS_MODE);
|
||||||
|
cmdArgs.add(dpkgname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
File srcDir = new File(new File("."), "src");
|
||||||
|
cmdArgs.add(new File(srcDir, clsname + ".java").getPath());
|
||||||
|
javadoc(cmdArgs.toArray(new String[cmdArgs.size()]));
|
||||||
|
checkExit(Exit.OK);
|
||||||
|
checkOrder("index-all.html", composeTestVectors());
|
||||||
|
}
|
||||||
|
String[] composeTestVectors() {
|
||||||
|
List<String> testList = new ArrayList<>();
|
||||||
|
|
||||||
|
for (String x : expectedMethodOrdering) {
|
||||||
|
testList.add(x);
|
||||||
|
for (int i = 0; i < MAX_PACKAGES; i++) {
|
||||||
|
String wpkg = "add" + i;
|
||||||
|
testList.add(wpkg + "/" + x);
|
||||||
|
String dpkg = wpkg;
|
||||||
|
for (int j = 1; j < MAX_SUBPACKAGES_DEPTH; j++) {
|
||||||
|
dpkg = dpkg + "/" + "add";
|
||||||
|
testList.add(dpkg + "/" + x);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (String x : expectedEnumOrdering) {
|
||||||
|
testList.add(x.replace("REPLACE_ME", "<Unnamed>"));
|
||||||
|
for (int i = 0; i < MAX_PACKAGES; i++) {
|
||||||
|
String wpkg = "add" + i;
|
||||||
|
testList.add(wpkg + "/" + x.replace("REPLACE_ME", wpkg));
|
||||||
|
String dpkg = wpkg;
|
||||||
|
for (int j = 1; j < MAX_SUBPACKAGES_DEPTH; j++) {
|
||||||
|
dpkg = dpkg + "/" + "add";
|
||||||
|
testList.add(dpkg + "/" + x.replace("REPLACE_ME", pathToPackage(dpkg)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
testList.addAll(Arrays.asList(expectedFieldOrdering));
|
||||||
|
return testList.toArray(new String[testList.size()]);
|
||||||
|
}
|
||||||
void checkExecutableMemberOrdering(String usePage) {
|
void checkExecutableMemberOrdering(String usePage) {
|
||||||
String contents = readFile(usePage);
|
String contents = readFile(usePage);
|
||||||
// check constructors
|
// check constructors
|
||||||
|
@ -109,29 +197,125 @@ public class TestOrdering extends JavadocTester {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void checkIndexPathOrdering(String indexPage) {
|
static String[] contents = {
|
||||||
checkOrder(indexPage,
|
"public add ADDADD;",
|
||||||
"pkg1/UsedClass.html#add--",
|
"public add AddAdd;",
|
||||||
"pkg1/ZZTop.html#add--",
|
"public add addadd;",
|
||||||
"pkg1/UsedClass.html#add-double-",
|
"public enum add {add, ADD, addd, ADDD};",
|
||||||
"pkg1/UsedClass.html#add-java.lang.Double-",
|
"public enum ADD {ADD, add, addd, ADDD};",
|
||||||
"pkg1/ZZTop.html#add-double-",
|
"public void add(){}",
|
||||||
"pkg1/ZZTop.html#add-java.lang.Double-",
|
"public void add(double d){}",
|
||||||
"pkg1/UsedClass.html#add-double-byte-",
|
"public void add(int i, float f){}",
|
||||||
"pkg1/ZZTop.html#add-double-byte-",
|
"public void add(float f, int i){}",
|
||||||
"pkg1/UsedClass.html#add-double-double-",
|
"public void add(double d, byte b){}",
|
||||||
"pkg1/UsedClass.html#add-double-java.lang.Double-",
|
"public Double add(Double d) {return (double) 22/7;}",
|
||||||
"pkg1/ZZTop.html#add-double-double-",
|
"public double add(double d1, double d2) {return d1 + d2;}",
|
||||||
"pkg1/ZZTop.html#add-double-java.lang.Double-",
|
"public double add(double d1, Double d2) {return d1 + d2;}",
|
||||||
"pkg1/UsedClass.html#add-float-",
|
"public Float add(float f) {return (float) 22/7;}",
|
||||||
"pkg1/ZZTop.html#add-float-",
|
"public void add(int i){}",
|
||||||
"pkg1/UsedClass.html#add-float-int-",
|
"public int add(Integer i) {return 0;}"
|
||||||
"pkg1/ZZTop.html#add-float-int-",
|
};
|
||||||
"pkg1/UsedClass.html#add-int-",
|
|
||||||
"pkg1/ZZTop.html#add-int-",
|
void emitFile(String pkgname, String clsname, ListOrder order) throws IOException {
|
||||||
"pkg1/UsedClass.html#add-int-float-",
|
File srcDir = new File("src");
|
||||||
"pkg1/ZZTop.html#add-int-float-",
|
File outDir = pkgname == null
|
||||||
"pkg1/UsedClass.html#add-java.lang.Integer-",
|
? srcDir
|
||||||
"pkg1/ZZTop.html#add-java.lang.Integer-");
|
: new File(srcDir, pkgname.replace(".", File.separator));
|
||||||
|
File outFile = new File(outDir, clsname + ".java");
|
||||||
|
outDir.mkdirs();
|
||||||
|
List<String> scratch = new ArrayList<>(Arrays.asList(contents));
|
||||||
|
switch (order) {
|
||||||
|
case SHUFFLE:
|
||||||
|
Collections.shuffle(scratch);
|
||||||
|
break;
|
||||||
|
case REVERSE:
|
||||||
|
Collections.reverse(scratch);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// leave list as-is
|
||||||
|
}
|
||||||
|
// insert the header
|
||||||
|
scratch.add(0, "public class " + clsname + " {");
|
||||||
|
if (pkgname != null) {
|
||||||
|
scratch.add(0, "package " + pkgname + ";");
|
||||||
|
}
|
||||||
|
// append the footer
|
||||||
|
scratch.add("}");
|
||||||
|
Files.write(outFile.toPath(), scratch, CREATE, TRUNCATE_EXISTING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String pathToPackage(String in) {
|
||||||
|
return in.replace("/", ".");
|
||||||
|
}
|
||||||
|
|
||||||
|
final String expectedMethodOrdering[] = {
|
||||||
|
"Add.html#add--",
|
||||||
|
"Add.html#add-double-",
|
||||||
|
"Add.html#add-java.lang.Double-",
|
||||||
|
"Add.html#add-double-byte-",
|
||||||
|
"Add.html#add-double-double-",
|
||||||
|
"Add.html#add-double-java.lang.Double-",
|
||||||
|
"Add.html#add-float-",
|
||||||
|
"Add.html#add-float-int-",
|
||||||
|
"Add.html#add-int-",
|
||||||
|
"Add.html#add-int-float-",
|
||||||
|
"Add.html#add-java.lang.Integer-"
|
||||||
|
};
|
||||||
|
final String expectedEnumOrdering[] = {
|
||||||
|
"Add.add.html\" title=\"enum in REPLACE_ME\"",
|
||||||
|
"Add.ADD.html\" title=\"enum in REPLACE_ME\""
|
||||||
|
};
|
||||||
|
final String expectedFieldOrdering[] = {
|
||||||
|
"Add.html#addadd\"",
|
||||||
|
"add0/add/add/add/Add.html#addadd\"",
|
||||||
|
"add0/add/add/Add.html#addadd\"",
|
||||||
|
"add0/add/Add.html#addadd\"",
|
||||||
|
"add0/Add.html#addadd\"",
|
||||||
|
"add1/add/add/add/Add.html#addadd\"",
|
||||||
|
"add1/add/add/Add.html#addadd\"",
|
||||||
|
"add1/add/Add.html#addadd\"",
|
||||||
|
"add1/Add.html#addadd\"",
|
||||||
|
"add2/add/add/add/Add.html#addadd\"",
|
||||||
|
"add2/add/add/Add.html#addadd\"",
|
||||||
|
"add2/add/Add.html#addadd\"",
|
||||||
|
"add2/Add.html#addadd\"",
|
||||||
|
"add3/add/add/add/Add.html#addadd\"",
|
||||||
|
"add3/add/add/Add.html#addadd\"",
|
||||||
|
"add3/add/Add.html#addadd\"",
|
||||||
|
"add3/Add.html#addadd\"",
|
||||||
|
"Add.html#AddAdd\"",
|
||||||
|
"add0/add/add/add/Add.html#AddAdd\"",
|
||||||
|
"add0/add/add/Add.html#AddAdd\"",
|
||||||
|
"add0/add/Add.html#AddAdd\"",
|
||||||
|
"add0/Add.html#AddAdd\"",
|
||||||
|
"add1/add/add/add/Add.html#AddAdd\"",
|
||||||
|
"add1/add/add/Add.html#AddAdd\"",
|
||||||
|
"add1/add/Add.html#AddAdd\"",
|
||||||
|
"add1/Add.html#AddAdd\"",
|
||||||
|
"add2/add/add/add/Add.html#AddAdd\"",
|
||||||
|
"add2/add/add/Add.html#AddAdd\"",
|
||||||
|
"add2/add/Add.html#AddAdd\"",
|
||||||
|
"add2/Add.html#AddAdd\"",
|
||||||
|
"add3/add/add/add/Add.html#AddAdd\"",
|
||||||
|
"add3/add/add/Add.html#AddAdd\"",
|
||||||
|
"add3/add/Add.html#AddAdd\"",
|
||||||
|
"add3/Add.html#AddAdd\"",
|
||||||
|
"Add.html#ADDADD\"",
|
||||||
|
"add0/add/add/add/Add.html#ADDADD\"",
|
||||||
|
"add0/add/add/Add.html#ADDADD\"",
|
||||||
|
"add0/add/Add.html#ADDADD\"",
|
||||||
|
"add0/Add.html#ADDADD\"",
|
||||||
|
"add1/add/add/add/Add.html#ADDADD\"",
|
||||||
|
"add1/add/add/Add.html#ADDADD\"",
|
||||||
|
"add1/add/Add.html#ADDADD\"",
|
||||||
|
"add1/Add.html#ADDADD\"",
|
||||||
|
"add2/add/add/add/Add.html#ADDADD\"",
|
||||||
|
"add2/add/add/Add.html#ADDADD\"",
|
||||||
|
"add2/add/Add.html#ADDADD\"",
|
||||||
|
"add2/Add.html#ADDADD\"",
|
||||||
|
"add3/add/add/add/Add.html#ADDADD\"",
|
||||||
|
"add3/add/add/Add.html#ADDADD\"",
|
||||||
|
"add3/add/Add.html#ADDADD\"",
|
||||||
|
"add3/Add.html#ADDADD\""
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,72 +23,6 @@
|
||||||
|
|
||||||
package pkg1;
|
package pkg1;
|
||||||
/**
|
/**
|
||||||
* For index and class-use testing
|
* For class-use testing
|
||||||
*/
|
*/
|
||||||
public class UsedClass {
|
public class UsedClass {}
|
||||||
|
|
||||||
/**
|
|
||||||
* just an empty param method.
|
|
||||||
*/
|
|
||||||
public void add(){}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param d param
|
|
||||||
*/
|
|
||||||
public void add(double d){}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param i param
|
|
||||||
* @param f param
|
|
||||||
*/
|
|
||||||
public void add(int i, float f){}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param f param
|
|
||||||
* @param i param
|
|
||||||
*/
|
|
||||||
public void add(float f, int i){}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param d param
|
|
||||||
* @param b param
|
|
||||||
*/
|
|
||||||
public void add(double d, byte b){}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param d param
|
|
||||||
* @return Double
|
|
||||||
*/
|
|
||||||
public Double add(Double d) {return (double) 22/7;}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param d1 param
|
|
||||||
* @param d2 param
|
|
||||||
* @return double
|
|
||||||
*/
|
|
||||||
public double add(double d1, double d2) {return d1 + d2;}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param d1 param
|
|
||||||
* @param d2 param
|
|
||||||
* @return double
|
|
||||||
*/
|
|
||||||
public double add(double d1, Double d2) {return d1 + d2;}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param f param
|
|
||||||
* @return Float
|
|
||||||
*/
|
|
||||||
public Float add(float f) {return (float) 22/7;}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param i param
|
|
||||||
*/
|
|
||||||
public void add(int i){}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param i param
|
|
||||||
* @return double
|
|
||||||
*/
|
|
||||||
public int add(Integer i) {return 0;}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,94 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2014, 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
|
|
||||||
* under the terms of the GNU General Public License version 2 only, as
|
|
||||||
* published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
* version 2 for more details (a copy is included in the LICENSE file that
|
|
||||||
* accompanied this code).
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License version
|
|
||||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
||||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*
|
|
||||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
||||||
* or visit www.oracle.com if you need additional information or have any
|
|
||||||
* questions.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package pkg1;
|
|
||||||
/**
|
|
||||||
* For index testing only
|
|
||||||
*/
|
|
||||||
public class ZZTop {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* just an empty param method.
|
|
||||||
*/
|
|
||||||
public void add(){}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param d param
|
|
||||||
*/
|
|
||||||
public void add(double d){}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param i param
|
|
||||||
* @param f param
|
|
||||||
*/
|
|
||||||
public void add(int i, float f){}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param f param
|
|
||||||
* @param i param
|
|
||||||
*/
|
|
||||||
public void add(float f, int i){}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param d param
|
|
||||||
* @param b param
|
|
||||||
*/
|
|
||||||
public void add(double d, byte b){}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param d param
|
|
||||||
* @return Double
|
|
||||||
*/
|
|
||||||
public Double add(Double d) {return (double) 22/7;}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param d1 param
|
|
||||||
* @param d2 param
|
|
||||||
* @return double
|
|
||||||
*/
|
|
||||||
public double add(double d1, double d2) {return d1 + d2;}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param d1 param
|
|
||||||
* @param d2 param
|
|
||||||
* @return double
|
|
||||||
*/
|
|
||||||
public double add(double d1, Double d2) {return d1 + d2;}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param f param
|
|
||||||
* @return Float
|
|
||||||
*/
|
|
||||||
public Float add(float f) {return (float) 22/7;}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param i param
|
|
||||||
*/
|
|
||||||
public void add(int i){}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param i param
|
|
||||||
* @return double
|
|
||||||
*/
|
|
||||||
public int add(Integer i) {return 0;}
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue