Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
899d718
Report an annotation file that cannot be read as a warning; read arch…
mernst Nov 16, 2026
73a4144
Do not read hidden files, or archives, found by searching a directory
mernst Nov 16, 2026
bf6565f
Treat "." entry-name components as not hidden; recognize .zip archive…
mernst Nov 16, 2026
c5c240d
Report an unlistable directory as a warning; parse classpath stubs vi…
mernst Nov 16, 2026
d199b06
Merge remote-tracking branch 'origin/annotation-file-archive-read' in…
mernst Nov 16, 2026
beeef2d
Merge branch 'master' into annotation-file-archive-read
mernst Nov 16, 2026
d826b25
Merge branch 'annotation-file-archive-read' into annotation-file-search
mernst Nov 16, 2026
e379465
Accept only .jar archives; document that an ajava file in an archive …
mernst Nov 17, 2026
f095234
Document that -Aajava entries are delimited by File.pathSeparator
mernst Nov 17, 2026
cbb3c80
Merge branch 'master' into annotation-file-archive-read
mernst Nov 18, 2026
2c17177
Merge branch 'annotation-file-archive-read' into annotation-file-search
mernst Nov 18, 2026
1eae69f
Merge branch 'master' into annotation-file-archive-read
mernst Nov 19, 2026
2af1c15
Merge branch 'annotation-file-archive-read' into annotation-file-search
mernst Nov 19, 2026
87008b6
Merge remote-tracking branch 'upstream/master' into annotation-file-a…
mernst Nov 21, 2026
7b2c186
Report an archive or directory that cannot be read; read archive entr…
mernst Nov 21, 2026
42a02e7
Do not rename readEntry's parameter
mernst Nov 21, 2026
48197bc
Merge remote-tracking branch 'origin/annotation-file-unreadable-archi…
mernst Nov 21, 2026
d5c3c0d
Report an annotation file that cannot be read as a warning, with the …
mernst Nov 21, 2026
b08137b
Merge remote-tracking branch 'origin/annotation-file-read-warning' in…
mernst Nov 21, 2026
63eaba6
Move the behavior of forEachAnnotationFile from @param to the descrip…
mernst Nov 21, 2026
176a302
Merge remote-tracking branch 'origin/annotation-file-unreadable-archi…
mernst Nov 21, 2026
0037431
Merge remote-tracking branch 'origin/annotation-file-read-warning' in…
mernst Nov 21, 2026
29bac03
Brevity
mernst Nov 21, 2026
0d98231
Brevity
mernst Nov 21, 2026
337203c
Brevity
mernst Nov 21, 2026
ea40cb0
Merge remote-tracking branch 'origin/annotation-file-archive-read' in…
mernst Nov 21, 2026
f1a1c19
Brevity
mernst Nov 21, 2026
fe34d40
Merge remote-tracking branch 'origin/annotation-file-unreadable-archi…
mernst Nov 21, 2026
b01abea
Merge remote-tracking branch 'origin/annotation-file-read-warning' in…
mernst Nov 21, 2026
5945b99
Merge remote-tracking branch 'origin/annotation-file-read-warning' in…
mernst Nov 21, 2026
fe3e5f4
Merge remote-tracking branch 'origin/annotation-file-archive-read' in…
mernst Nov 21, 2026
06128fc
Clarify documentation of archive entries and the order of annotation …
mernst Nov 21, 2026
5538c00
Merge branch 'master' into annotation-file-unreadable-archive
mernst Nov 22, 2026
258c701
Merge branch 'annotation-file-unreadable-archive' into annotation-fil…
mernst Nov 22, 2026
47dec48
Merge branch 'annotation-file-read-warning' into annotation-file-arch…
mernst Nov 22, 2026
fe43dbb
Merge branch 'annotation-file-archive-read' into annotation-file-search
mernst Nov 22, 2026
97322e8
Read the whole annotation file before checking whether it is whitespa…
mernst Nov 22, 2026
aa82c28
Skip annotation files only when confirmed whitespace-only; report rea…
mernst Nov 22, 2026
8af56fc
Revert "Skip annotation files only when confirmed whitespace-only; re…
mernst Nov 22, 2026
0632f85
Merge remote-tracking branch 'origin/annotation-file-archive-read' in…
mernst Nov 22, 2026
9e8c8cb
Load the checker with the extra classpath in AnnotationFileElementTyp…
mernst Nov 22, 2026
5130ae1
Do not warn about a named file whose name lacks the expected extension
mernst Nov 22, 2026
aea5173
Merge remote-tracking branch 'origin/annotation-file-archive-read' in…
mernst Nov 22, 2026
3cb6469
Move implementation detail of forEachAnnotationFile into its body; cl…
mernst Nov 23, 2026
a5782e4
Merge branch 'annotation-file-unreadable-archive' into annotation-fil…
mernst Nov 23, 2026
2c3d14c
Merge branch 'annotation-file-read-warning' into annotation-file-arch…
mernst Nov 23, 2026
0ea5ae9
Merge branch 'annotation-file-archive-read' into annotation-file-search
mernst Nov 23, 2026
4e06a4b
Merge branch 'master' into annotation-file-read-warning
mernst Nov 23, 2026
68fda0a
Merge branch 'annotation-file-read-warning' into annotation-file-arch…
mernst Nov 23, 2026
29197d0
Merge branch 'annotation-file-archive-read' into annotation-file-search
mernst Nov 23, 2026
fa9fdb5
Test that a classpath annotation file that cannot be read yields a wa…
mernst Nov 23, 2026
2e7e38e
Report a directory within a directory that cannot be listed as a note…
mernst Nov 23, 2026
1db3363
Issue each read-failure warning once per compound checker; share a te…
mernst Nov 23, 2026
afb8a93
Test the warnings about an unreadable ajava file and an unreadable ch…
mernst Nov 24, 2026
3013f67
Merge branch 'annotation-file-read-warning' into annotation-file-arch…
mernst Nov 24, 2026
c049808
Merge branch 'annotation-file-archive-read' into annotation-file-search
mernst Nov 24, 2026
0b1f3ba
Issue the note about a skipped archive or directory once per compound…
mernst Nov 24, 2026
4ef91b0
Merge branch 'master' into annotation-file-read-warning
mernst Nov 24, 2026
4c88d92
Merge branch 'annotation-file-read-warning' into annotation-file-arch…
mernst Nov 24, 2026
58511af
Merge branch 'annotation-file-archive-read' into annotation-file-search
mernst Nov 24, 2026
4780917
Do not use a static import
mernst Nov 25, 2026
be0e78a
Brevity
mernst Nov 25, 2026
239c1a7
Merge branch 'master' into annotation-file-read-warning
mernst Nov 26, 2026
f393b9d
Merge branch 'annotation-file-read-warning' into annotation-file-arch…
mernst Nov 26, 2026
348201c
Merge branch 'annotation-file-archive-read' into annotation-file-search
mernst Nov 26, 2026
0989883
Merge branch 'master' into annotation-file-read-warning
mernst Nov 26, 2026
d945519
Merge branch 'annotation-file-read-warning' into annotation-file-arch…
mernst Nov 26, 2026
41fc20e
Merge branch 'annotation-file-archive-read' into annotation-file-search
mernst Nov 26, 2026
7796ea7
Qualify calls to AnnotationFileTestUtil.write
mernst Nov 27, 2026
fb94110
Statically import AnnotationFileTestUtil.write in stub tests
mernst Nov 27, 2026
2863c20
Merge branch 'master' into annotation-file-archive-read
mernst Nov 27, 2026
b5fe4da
Merge branch 'annotation-file-archive-read' into annotation-file-search
mernst Nov 27, 2026
615a5b5
Close a classpath annotation file's jar, test leading whitespace, and…
mernst Nov 27, 2026
112e604
Remove SystemUtil.readCodePoint(), which is unused
mernst Nov 27, 2026
73ade9e
Merge branch 'annotation-file-archive-read' into annotation-file-search
mernst Nov 27, 2026
09c722f
Describe AnnotationFileUtilTest as testing AnnotationFileUtil
mernst Nov 27, 2026
82559c9
Test whitespace-only and non-ASCII-led annotation files; share the ja…
mernst Nov 28, 2026
26a88b0
Treat as whitespace only the characters that the stub parser ignores;…
mernst Nov 28, 2026
aac46c0
Merge branch 'master' into annotation-file-archive-read
mernst Nov 28, 2026
aff2889
Merge branch 'annotation-file-archive-read' into annotation-file-search
mernst Nov 28, 2026
e103bfe
Merge remote-tracking branch 'upstream/master' into annotation-file-s…
mernst Nov 29, 2026
4066f8b
Note only an archive that might hold annotation files; warn about an …
mernst Nov 30, 2026
1114029
Search a directory at most once when symbolic links make it reachable…
mernst Nov 30, 2026
852ff83
Merge branch 'annotation-file-search' into annotation-file-symlink-loop
mernst Nov 30, 2026
c128dbe
Merge branch 'master' into annotation-file-search
mernst Nov 30, 2026
2c6fd2d
Merge branch 'annotation-file-search' into annotation-file-symlink-loop
mernst Nov 30, 2026
34b787d
Don't use static imports
mernst Nov 30, 2026
8181fb2
Merge branch 'master' into annotation-file-search
mernst Nov 30, 2026
13caf0f
Code review; brevity
mernst Dec 1, 2026
60b5653
Merge branch 'master' into annotation-file-search
mernst Dec 1, 2026
5eb9c60
Merge branch 'annotation-file-search' into annotation-file-symlink-loop
mernst Dec 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions docs/manual/annotating-libraries.tex
Original file line number Diff line number Diff line change
Expand Up @@ -478,10 +478,12 @@
\end{Verbatim}
\end{myxsmall}

Each stub path entry is a stub file (ending with \<.astub>), directory, or
\<.jar> file; specifying a directory or \<.jar> file is
equivalent to specifying every file in it whose name ends with
\code{.astub}. The stub path entries are delimited by
Each stub path entry is a stub file (ending with
\<.astub>), a directory, or an archive (ending with \<.jar>).
Specifying a directory or archive is equivalent to
specifying every non-hidden non-archive file in it whose name ends with
\code{.astub}.
The stub path entries are delimited by
\<File.pathSeparator> (``\<:>'' for Linux and Mac, ``\<;>'' for Windows).

A checker automatically reads some of its own stub files, even without a
Expand Down Expand Up @@ -991,9 +993,10 @@
\subsectionAndLabel{Using an Ajava file}{ajava-using}

The \code{-Aajava} command-line argument works like \code{-Astubs} (see
Section~\ref{stub-using}). It takes a colon-separated list of
files and directories containing ajava files, which end in the \code{.ajava}
extension.
Section~\ref{stub-using}). It takes a list of
ajava files, directories, and archives that contain \code{.ajava} files.
The entries are delimited by \<File.pathSeparator> (``\<:>'' for Linux and
Mac, ``\<;>'' for Windows).

For example:

Expand Down Expand Up @@ -1028,6 +1031,10 @@
than being found under directories). For example, if the \<-Aajava> argument
was \<-Aajava=~/foo/Bar.ajava:~/baz/foo/Bar.ajava>, the two \<.ajava> files
would be considered ambiguous and an \<ambiguous.ajava> warning would be issued.
An ajava file within an archive never corresponds to a source file. The
Checker Framework reads it as it reads a stub file, so it ignores
annotations in the archived ajava file that a stub file cannot express,
such as annotations within anonymous and local classes.
Files found under a directory are always unambiguous, because their file structure
must match their package name; the solution to an \<ambiguous.ajava> warning is to
convert the specific files in the \<-Aajava> argument to directories.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,17 @@ private void parseAnnotationFiles(List<String> annotationFiles, AnnotationFileTy
File location = AnnotationFileUtil.findFileSystemLocation(path);
if (location != null) {
AnnotationFileUtil.forEachAnnotationFile(
location, fileType, resource -> parseAnnotationFileResource(resource, parseType));
location,
fileType,
resource -> parseAnnotationFileResource(resource, parseType),
archive ->
checker.messageOnce(
Diagnostic.Kind.NOTE,
"Not reading archive "
+ archive
+ ", which is within directory "
+ location
+ "; to read it, name the archive itself"));
} else {
// We didn't find the files.
// If the file has a prefix of "checker.jar/" then look for the file in the top
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.function.Consumer;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
Expand Down Expand Up @@ -391,30 +394,117 @@ public void visit(WildcardType n, Void arg) {
}

/**
* Returns true if the given file is an annotation file of the given type.
* Runs {@code action} on each annotation file of type {@code fileType} at the given file system
* location. Passes the files under a directory in order of their names, and the entries in an
* archive in the order that the archive stores them.
*
* <p>If {@code location} is a file, then it is used if it is an archive (see {@link #isArchive})
* or if its name ends with the extension of {@code fileType} ({@code .astub} for a stub file or
* {@code .ajava} for an ajava file). If {@code location} is a directory or archive, then a file
* or entry within it is used if its name ends with that extension and no component of its path
* within the directory or archive is hidden (see {@link #isHidden}). An example of a hidden file
* is the {@code ._Foo.astub} metadata file that macOS adds to archives and to non-Mac file
* systems. An archive within a directory is not read. Such an archive is passed to {@code
* skippedAction} if it contains an annotation file of type {@code fileType} or if it cannot be
* opened. If {@code location} is an archive that cannot be opened, or if {@code location} or a
* directory within it cannot be listed, then {@code action} is passed a resource whose {@link
* AnnotationFileResource#getInputStream} throws an exception, so the client reports the error
* rather than treating the archive or directory as empty.
*
* <p>A directory is searched at most once, even if symbolic links make it reachable along several
* paths, such as a link {@code stubs/loop} whose target is {@code stubs}.
*
* @param location a file or directory that was named explicitly, such as in the {@code -Astubs}
* command-line option or by a checker's {@code @StubFiles} annotation
* @param fileType type of annotation files to pass to {@code action}
* @param action the operation to perform on each annotation file
* @param skippedAction the operation to perform on each archive within the directory {@code
* location} that is not read and that might contain an annotation file of type {@code
* fileType}
*/
public static void forEachAnnotationFile(
File location,
AnnotationFileType fileType,
Consumer<AnnotationFileResource> action,
Consumer<File> skippedAction) {
forEachAnnotationFile(
location, fileType, /* wasFoundBySearch= */ false, action, skippedAction, new HashSet<>());
}

/**
* Returns true if {@code name} ends with {@code .astub} or {@code .ajava}, depending on {@code
* fileType}.
*
* @param f the file to check
* @param fileType the type of file to check against
* @return true if {@code f} is a file with file type matching {@code fileType}, false otherwise
* @param name a file name or path, or the name of an archive entry
* @param fileType a type of annotation file
* @return true if {@code name} ends with the file name extension of {@code fileType}
*/
private static boolean isAnnotationFile(File f, AnnotationFileType fileType) {
return f.isFile() && isAnnotationFile(f.getName(), fileType);
private static boolean hasAnnotationFileExtension(String name, AnnotationFileType fileType) {
return name.endsWith(fileType.isStub() ? ".astub" : ".ajava");
}

/**
* Returns true if the given file is an annotation file of the given kind.
* Returns true if {@code name} is the name of a hidden file or directory.
*
* @param path a file
* @param fileType the type of file to check against
* @return true if {@code path} represents a file with file type matching {@code fileType}, false
* otherwise
* @param name a file or directory name, without any directory component
* @return true if {@code name} is the name of a hidden file or directory
*/
private static boolean isAnnotationFile(String path, AnnotationFileType fileType) {
return path.endsWith(fileType.isStub() ? ".astub" : ".ajava");
private static boolean isHidden(String name) {
// The special names `.` and `..` are not hidden.
return name.startsWith(".") && !name.equals(".") && !name.equals("..");
}

private static boolean isJar(File f) {
return f.isFile() && f.getName().endsWith(".jar");
/**
* Returns true if the archive entry whose name is {@code entryName} is an annotation file of type
* {@code fileType}: no component of its name is hidden, and it has the file name extension of
* {@code fileType}.
*
* @param entryName the name of an archive entry, such as {@code java/lang/String.astub}
* @param fileType a type of annotation file
* @return true if the given archive entry is an annotation file of type {@code fileType}
*/
private static boolean isArchiveEntryAnnotationFile(
String entryName, AnnotationFileType fileType) {
// Archive entry names use "/" as the separator on every platform.
for (String component : entryName.split("/", -1)) {
if (isHidden(component)) {
return false;
}
}
return hasAnnotationFileExtension(entryName, fileType);
}

/**
* Returns true if {@code name} is the name of a JAR archive file.
*
* @param name a file name
* @return true if {@code name} is the name of a JAR archive file
*/
static boolean isArchive(String name) {
return name.endsWith(".jar");
}

/**
* Returns true if the given archive contains an annotation file of type {@code fileType}, or if
* it cannot be opened, so its contents are unknown.
*
* @param archive a JAR or ZIP archive
* @param fileType a type of annotation file
* @return true if {@code archive} contains an annotation file of type {@code fileType} or cannot
* be opened
*/
private static boolean mightContainAnnotationFile(File archive, AnnotationFileType fileType) {
try (JarFile jarFile = new JarFile(archive)) {
Iterator<JarEntry> entries = jarFile.entries().asIterator();
while (entries.hasNext()) {
if (isArchiveEntryAnnotationFile(entries.next().getName(), fileType)) {
return true;
}
}
return false;
} catch (IOException e) {
return true;
}
}

/**
Expand Down Expand Up @@ -478,27 +568,36 @@ public InputStream getInputStream() throws IOException {

/**
* Runs {@code action} on each annotation file of type {@code fileType} at the given file system
* location. Passes the files under a directory in order of their names, and the entries in an
* archive in the order that the archive stores them.
*
* <p>If {@code location} is a directory, recurses on all files contained in it. If {@code
* location} is a jarfile that cannot be opened or a directory that cannot be listed, passes a
* resource whose {@link AnnotationFileResource#getInputStream} throws an exception, so the client
* reports the error rather than treating {@code location} as empty.
* location, as described in {@link #forEachAnnotationFile(File, AnnotationFileType, Consumer,
* Consumer)}.
*
* @param location an annotation file (a stub file or ajava file), a jarfile, or a directory
* @param location a file or directory that was named explicitly, or that was found by searching a
* directory
* @param fileType type of annotation files to pass to {@code action}
* @param wasFoundBySearch true if {@code location} was found by searching a directory, rather
* than being named explicitly (such as in the {@code -Astubs} command-line option or by a
* checker's {@code @StubFiles} annotation). A hidden file or directory found by searching is
* skipped, and an archive found by searching is not read.
* @param action the operation to perform on each annotation file
* @param skippedAction the operation to perform on each archive found by searching a directory
* that might contain an annotation file of type {@code fileType}
* @param searchedDirectories the directories already searched, as real paths (see {@link
* #realPath}); this method adds to it
*/
public static void forEachAnnotationFile(
File location, AnnotationFileType fileType, Consumer<AnnotationFileResource> action) {
if (isAnnotationFile(location, fileType)) {
action.accept(new FileAnnotationFileResource(location));
} else if (isJar(location)) {
// Passes an archive entry while its archive is open, and reads the entry's contents just
// before passing it, so an archive's entries need not all be in memory at once.
forEachArchiveEntry(location, fileType, action);
} else if (location.isDirectory()) {
private static void forEachAnnotationFile(
File location,
AnnotationFileType fileType,
boolean wasFoundBySearch,
Consumer<AnnotationFileResource> action,
Consumer<File> skippedAction,
Set<Path> searchedDirectories) {
if (wasFoundBySearch && isHidden(location.getName())) {
return;
}
if (location.isDirectory()) {
if (!searchedDirectories.add(realPath(location))) {
return;
}
File[] directoryContents = location.listFiles();
if (directoryContents == null) {
action.accept(
Expand All @@ -507,8 +606,40 @@ public static void forEachAnnotationFile(
}
Arrays.sort(directoryContents, Comparator.comparing(File::getName));
for (File enclosed : directoryContents) {
forEachAnnotationFile(enclosed, fileType, action);
forEachAnnotationFile(enclosed, fileType, true, action, skippedAction, searchedDirectories);
}
} else if (location.isFile()) {
String name = location.getName();
if (isArchive(name)) {
if (!wasFoundBySearch) {
// Passes an archive entry while its archive is open, and reads the entry's contents just
// before passing it, so an archive's entries need not all be in memory at once.
forEachArchiveEntry(location, fileType, action);
} else if (mightContainAnnotationFile(location, fileType)) {
skippedAction.accept(location);
}
} else if (hasAnnotationFileExtension(name, fileType)) {
action.accept(new FileAnnotationFileResource(location));
}
}
}

/**
* Returns the real path of the given file: an absolute path with no symbolic links and no {@code
* .} or {@code ..} components. For example, if {@code /home/user/stubs/loop} is a symbolic link
* whose target is {@code .}, then its real path is {@code /home/user/stubs}. If the real path
* cannot be determined, returns the file's absolute path with its {@code .} and {@code ..}
* components removed.
*
* @param file a file or directory
* @return the real path of {@code file}
*/
private static Path realPath(File file) {
Path path = file.toPath();
try {
return path.toRealPath();
} catch (IOException e) {
return path.toAbsolutePath().normalize();
}
}

Expand All @@ -533,7 +664,7 @@ private static void forEachArchiveEntry(
Iterator<JarEntry> entries = jarFile.entries().asIterator();
while (entries.hasNext()) {
JarEntry entry = entries.next();
if (isAnnotationFile(entry.getName(), fileType)) {
if (isArchiveEntryAnnotationFile(entry.getName(), fileType)) {
action.accept(archiveEntry(archive, jarFile, entry));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,84 @@ private static void assertOneWarning(String text, List<String> diagnostics) {
Assert.assertTrue(matching.get(0), matching.get(0).startsWith("WARNING: "));
}

/** Tests that an archive within a named directory yields a note. */
@Test
public void archiveInDirectory() throws IOException {
File dir = tmp.newFolder("stubdir");
File jar = AnnotationFileTestUtil.writeStubJar(new File(dir, "lib.jar"), "A.astub");
assertHasDiagnostic("NOTE: Not reading archive " + jar, diagnostics(dir.getPath()));
}

/** Tests that an archive that holds no stub file, within a named directory, yields no note. */
@Test
public void archiveWithoutStubFilesInDirectory() throws IOException {
File dir = tmp.newFolder("stubdir");
AnnotationFileTestUtil.writeStubJar(new File(dir, "lib.jar"), "p/A.class");
for (String diagnostic : diagnostics(dir.getPath())) {
Assert.assertFalse(diagnostic, diagnostic.startsWith("NOTE: Not reading archive"));
}
}

/**
* Tests that a compound checker, each of whose checkers searches the named directory, yields one
* note about an archive within the directory.
*/
@Test
public void archiveInDirectoryCompoundChecker() throws IOException {
File dir = tmp.newFolder("stubdir");
File jar = AnnotationFileTestUtil.writeStubJar(new File(dir, "lib.jar"), "A.astub");
List<String> diagnostics =
diagnostics(
"org.checkerframework.framework.testchecker.compound.CompoundChecker",
null,
"-Astubs=" + dir.getPath());
int count = 0;
for (String diagnostic : diagnostics) {
if (diagnostic.startsWith("NOTE: Not reading archive " + jar)) {
count++;
}
}
Assert.assertEquals(diagnostics.toString(), 1, count);
}

/** Tests that a named directory that cannot be listed yields a warning. */
@Test
public void unlistableDirectory() throws IOException {
File dir = tmp.newFolder("stubdir");
AnnotationFileTestUtil.write(new File(dir, "A.astub"), "package p;");
// Making a directory unreadable has no effect for the root user.
Assume.assumeTrue(dir.setReadable(false));
try {
Assume.assumeTrue(dir.listFiles() == null);
assertOneWarning(
"Could not read annotation resource: " + dir.getPath() + ": ",
diagnostics(dir.getPath()));
} finally {
dir.setReadable(true);
}
}

/**
* Tests that a directory that cannot be listed, within a named directory, yields a warning, as an
* annotation file that cannot be read does.
*/
@Test
public void unlistableDirectoryInDirectory() throws IOException {
File dir = tmp.newFolder("stubdir");
File sub = new File(dir, "sub");
AnnotationFileTestUtil.write(new File(sub, "A.astub"), "package p;");
// Making a directory unreadable has no effect for the root user.
Assume.assumeTrue(sub.setReadable(false));
try {
Assume.assumeTrue(sub.listFiles() == null);
assertOneWarning(
"Could not read annotation resource: " + sub.getPath() + ": ",
diagnostics(dir.getPath()));
} finally {
sub.setReadable(true);
}
}

/** Tests that a named archive that cannot be opened yields one warning. */
@Test
public void corruptArchive() throws IOException {
Expand Down
Loading