Repository navigation
Closed
Description
Affects PMD Version:
7.27.0 (also tried with 7.28.0-SNAPSHOT)
7.26.0 does not exhibit this behavior
Description:
The detection and inclusion of jrt-fs.jar does not work when --aux-classpath is being specified with a file: URL
- The aux-classpath detection of jrt-fs.jar doesn't detect jrt-fs.jar being profixed in the contents of a file: URL
- The auto-addition of jrt-fs.jar to aux-classpath doesn't work when aux-classpath was already set to a file: URL; when using file: in aux-classpath, aux-classpath is ONLY allowed to contain the file: URL
Because of these two things together, I don't see how I can use a file: URL in aux-classpath in pmd-7.27.0
Exception Stacktrace:
no stacktrace generated
Code Sample demonstrating the issue:
// not a local code issueSteps to reproduce:
Please provide detailed steps for how we can reproduce the bug.
ls -l $JAVA_HOME/libexec/openjdk.jdk/Contents/Home/lib/jrt-fs.jar
-rw-r--r--@ 1 jetmore admin 110118 Aug 7 07:31 /opt/homebrew/opt/openjdk@21/libexec/openjdk.jdk/Contents/Home/lib/jrt-fs.jarecho "$JAVA_HOME/libexec/openjdk.jdk/Contents/Home/lib/jrt-fs.jar" >/tmp/classpath.txtpmd check --use-version=java-21 --aux-classpath=file:///tmp/classpath.txt -R rulesets/java/quickstart.xml -d src
[WARN] Adding current platform /opt/homebrew/Cellar/openjdk@21/21.0.12.1/libexec/openjdk.jdk/Contents/Home/lib/jrt-fs.jar to auxClasspath, which could be the wrong java version. Please add the correct jrt-fs.jar explicitly to the auxClasspath.
[ERROR] java.nio.file.NoSuchFileException: /tmp/classpath.txt:/opt/homebrew/Cellar/openjdk@21/21.0.12.1/libexec/openjdk.jdk/Contents/Home/lib/jrt-fs.jar
- The WARN is because pmd doesn't detect jrt-fs.jar in the provided file: URL
- The ERROR is because, since nothing else can be in file: aux-classpath, pmd treats
/tmp/classpath.txt:/opt/homebrew/Cellar/openjdk@21/21.0.12.1/libexec/openjdk.jdk/Contents/Home/lib/jrt-fs.jaras a literal filename to open
An alternative would be to provide the file: and jrt-fs.jar both in aux-classpath in the opposite order (jrt-fs.jar first, then file:), but that doesn't work either:
echo "$JAVA_HOME/libexec/openjdk.jdk/Contents/Home/lib/jrt-fs.jar" >/tmp/classpath.txtpmd check --use-version=java-21 --aux-classpath=$JAVA_HOME/libexec/openjdk.jdk/Contents/Home/lib/jrt-fs.jar:file:///tmp/classpath.txt -R rulesets/java/quickstart.xml -d src
[WARN] Suspicious auxClasspath entry: file does not exist
[WARN] Progressbar rendering conflicts with reporting to STDOUT. No progressbar will be shown. Try running with argument -r <file> to output the report to a file instead.
[WARN] This analysis could be faster, please consider using Incremental Analysis: https://docs.pmd-code.org/pmd-doc-7.27.0/pmd_userdocs_incremental_analysis.html
[WARN] Ignoring not existing auxClasspath entry 'file'
[ERROR] Exception during processing: java.util.zip.ZipException: zip END header not found
[INFO] An error occurred while executing PMD.
Run in verbose mode to see a stack-trace.
If you think this is a bug in PMD, please report this issue at https://github.com/pmd/pmd/issues/new/choose
If you do so, please include a stack-trace, the code sample
causing the issue, and details about your run configuration.
[INFO] Found no violations.
Here's the output from 7.28.0-SNAPSHOT just to show it's still an issue
$ ~/Downloads/pmd-bin-7.28.0-SNAPSHOT/bin/pmd check --use-version=java-21 --aux-classpath=file:///tmp/classpath.txt -R rulesets/java/quickstart.xml -d src
[WARN] Adding current platform /opt/homebrew/Cellar/openjdk@21/21.0.12.1/libexec/openjdk.jdk/Contents/Home/lib/jrt-fs.jar to auxClasspath, which could be the wrong java version. Please add the correct jrt-fs.jar explicitly to the auxClasspath.
[ERROR] java.nio.file.NoSuchFileException: /tmp/classpath.txt:/opt/homebrew/Cellar/openjdk@21/21.0.12.1/libexec/openjdk.jdk/Contents/Home/lib/jrt-fs.jar
[INFO] Found no violations.
Running PMD through: CLI
Activity
[-][java] Issue with auto-inclusion of jrt-fs.jar and using file: for aux-classpath[/-][+][java] Specifying aux-classpath as file: broken due to jrt-fs.jar[/+][-][java] Specifying aux-classpath as file: broken due to jrt-fs.jar[/-][+][java] Specifying aux-classpath as single file: URL is broken due to jrt-fs.jar[/+][-][java] Specifying aux-classpath as single file: URL is broken due to jrt-fs.jar[/-][+][java] NoSuchFileException when auxClasspath is given as a classpath file (file: URL)[/+]adangel commentedon Sep 18, 2026
Regression has been introduced with cb6e772 (#6859).
[java] Fix pmd#7081: Exception when auxClasspath is a file URL (pmd#7085
[-][java] NoSuchFileException when auxClasspath is given as a classpath file (file: URL)[/-][+][java] NoSuchFileException when auxClasspath is given as a classpath file (file: URL) (since 7.27.0)[/+]jetmore commentedon Oct 1, 2026
Thank you @adangel