Special case * in target lookup, work around for #5300. * is not an allowed file system character on Windows and checking if it's a directory or file for the wilcard check would throw an InvalidPathException. RELNOTES: None PiperOrigin-RevId: 198595138
diff --git a/src/main/java/com/google/devtools/build/lib/packages/Package.java b/src/main/java/com/google/devtools/build/lib/packages/Package.java index af885be..7e15bd2 100644 --- a/src/main/java/com/google/devtools/build/lib/packages/Package.java +++ b/src/main/java/com/google/devtools/build/lib/packages/Package.java
@@ -498,11 +498,13 @@ // stat(2) is executed. Path filename = getPackageDirectory().getRelative(targetName); String suffix; - if (!PathFragment.isNormalized(targetName)) { - // Don't check for file existence in this case because the error message - // would be confusing and wrong. If the targetName is "foo/bar/.", and - // there is a directory "foo/bar", it doesn't mean that "//pkg:foo/bar/." - // is a valid label. + if (!PathFragment.isNormalized(targetName) || "*".equals(targetName)) { + // Don't check for file existence if the target name is not normalized + // because the error message would be confusing and wrong. If the + // targetName is "foo/bar/.", and there is a directory "foo/bar", it + // doesn't mean that "//pkg:foo/bar/." is a valid label. + // Also don't check if the target name is a single * character since + // it's invalid on Windows. suffix = ""; } else if (filename.isDirectory()) { suffix = "; however, a source directory of this name exists. (Perhaps add "