Skip to content

Commit c5daf89

Browse files
committed
8349369: test/docs/jdk/javadoc/doccheck/checks/jdkCheckLinks.java did not report on missing man page files
Reviewed-by: hannesw
1 parent bd08932 commit c5daf89

File tree

3 files changed

+22
-20
lines changed

3 files changed

+22
-20
lines changed

test/docs/jdk/javadoc/doccheck/checks/jdkCheckLinks.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
2323

2424
/*
2525
* @test
26-
* @bug 8337109
26+
* @bug 8337109 8349369
2727
* @summary Check Links in the generated documentation
2828
* @library /test/langtools/tools/lib ../../doccheck /test/lib ../../../../tools/tester
2929
* @build DocTester toolbox.TestRunner

test/docs/jdk/javadoc/doccheck/doccheckutils/FileProcessor.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -44,16 +44,16 @@ public List<Path> getFiles() {
4444

4545
public void processFiles(Path directory) {
4646
try {
47-
Files.walkFileTree(directory, new SimpleFileVisitor<Path>() {
47+
Files.walkFileTree(directory, new SimpleFileVisitor<>() {
4848
@Override
49-
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
49+
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
5050
if (file.toString().endsWith(".html"))
5151
files.add(file);
5252
return FileVisitResult.CONTINUE;
5353
}
5454

5555
@Override
56-
public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
56+
public FileVisitResult postVisitDirectory(Path dir, IOException exc) {
5757
return FileVisitResult.CONTINUE;
5858
}
5959
});

test/docs/jdk/javadoc/doccheck/doccheckutils/checkers/LinkChecker.java

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -220,20 +220,14 @@ private void reportMissingFile(Path file) {
220220

221221
@Override
222222
public boolean isOK() {
223-
return duplicateIds == 0
224-
&& missingIds == 0
225-
&& missingFiles == 0
226-
&& badSchemes == 0;
223+
return log.noErrors() && (missingFiles == 0);
227224
}
228225

229226
@Override
230227
public void close() {
231-
report();
232-
if (!isOK()) {
233-
throw new RuntimeException(
234-
"LinkChecker encountered errors. Duplicate IDs: "
235-
+ duplicateIds + ", Missing IDs: " + missingIds
236-
+ ", Missing Files: " + missingFiles + ", Bad Schemes: " + badSchemes);
228+
if (!log.noErrors()) {
229+
report();
230+
throw new RuntimeException("LinkChecker encountered errors; see log above.");
237231
}
238232
}
239233

@@ -276,6 +270,11 @@ private void foundReference(int line, String ref) {
276270
p = currFile.getParent().resolve(resolvedUriPath).normalize();
277271
}
278272

273+
if (!Files.exists(p)) {
274+
log.log(currFile, line, "missing file reference: " + log.relativize(p));
275+
return;
276+
}
277+
279278
if (fragment != null && !fragment.isEmpty()) {
280279
foundReference(line, p, fragment);
281280
}
@@ -392,7 +391,7 @@ class IDTable {
392391

393392
void addID(int line, String name) {
394393
if (checked) {
395-
throw new IllegalStateException("Adding ID after file has been");
394+
throw new IllegalStateException("Adding ID after file has been checked");
396395
}
397396
Objects.requireNonNull(name);
398397
IDInfo info = map.computeIfAbsent(name, _ -> new IDInfo());
@@ -413,7 +412,9 @@ void addReference(String name, Path from, int line) {
413412
if (name != null) {
414413
IDInfo id = map.get(name);
415414
if (id == null || !id.declared) {
416-
log.log(log.relativize(from), line, "id not found: " + this.pathOrURI + "#" + name);
415+
log.log(log.relativize(from), line,
416+
"id not found: " + this.pathOrURI + "#" + name);
417+
LinkChecker.this.missingIds++;
417418
}
418419
}
419420
} else {
@@ -429,7 +430,8 @@ void check() {
429430
map.forEach((name, id) -> {
430431
if (name != null && !id.declared) {
431432
for (Position ref : id.references) {
432-
log.log(log.relativize(ref.path), ref.line, "id not found: " + this.pathOrURI + "#" + name);
433+
log.log(log.relativize(ref.path), ref.line,
434+
"id not found: " + this.pathOrURI + "#" + name);
433435
}
434436
missingIds++;
435437
}

0 commit comments

Comments
 (0)