Skip to content

[java] NoSuchFileException when auxClasspath is given as a classpath file (file: URL) (since 7.27.0) #7081

Closed

Description

@jetmore

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

  1. The aux-classpath detection of jrt-fs.jar doesn't detect jrt-fs.jar being profixed in the contents of a file: URL
  2. 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 issue

Steps to reproduce:

Please provide detailed steps for how we can reproduce the bug.

  1. 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.jar
  2. echo "$JAVA_HOME/libexec/openjdk.jdk/Contents/Home/lib/jrt-fs.jar" >/tmp/classpath.txt
  3. 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
  • 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.jar as 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:

  1. echo "$JAVA_HOME/libexec/openjdk.jdk/Contents/Home/lib/jrt-fs.jar" >/tmp/classpath.txt
  2. pmd 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

  1. added
    a:bug
    on Sep 15, 2026
  2. self-assigned this
    on Sep 15, 2026
  3. added this to the 7.28.0 milestone on Sep 15, 2026
  4. changed the title [-][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[/+] on Sep 17, 2026
  5. changed the title [-][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[/+] on Sep 17, 2026
  6. changed the title [-][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)[/+] on Sep 18, 2026
  7. adangel commented on Sep 18, 2026

    @adangel
    Member

    Regression has been introduced with cb6e772 (#6859).

  8. added a commit that references this issue on Sep 24, 2026
    cc0114a
  9. changed the title [-][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)[/+] on Sep 24, 2026
  10. jetmore commented on Oct 1, 2026

    @jetmore
    ContributorAuthor

    Thank you @adangel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

a:bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions