GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [core] `RuleSetLoader#loadFromString` ignores previously configured Resource/ClassLoader · Issue #6913 · pmd/pmd

[core] RuleSetLoader#loadFromString ignores previously configured Resource/ClassLoader #6913

New issue
Copy link
New issue
Copy link
Closed
#6921
Closed
[core] RuleSetLoader#loadFromString ignores previously configured Resource/ClassLoader#6913
#6921
Copy link
Labels
a:bugPMD crashes or fails to analyse a file.
Milestone
7.27.0

Description

@AB-xdev
AB-xdev
opened on Jul 29, 2026
Issue body actions

Affects PMD Version:

7.26.0 (latest)

Description:

When loading a Ruleset using RuleSetLoader#loadFromString the method completely ignores the previously set ResouceLoader (which also contains the classloader) and uses it's own ResourceLoader:

pmd/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleSetLoader.java

Lines 150 to 170 in 1ac594b

public RuleSet loadFromString(String filename, final String rulesetXmlContent) {
if (filename == null || filename.isEmpty()) {
throw new IllegalArgumentException("Invalid empty filename");
}
ResourceLoader oldLoader = this.resourceLoader;
try {
loadResourcesWith(new ResourceLoader() {
@Override
public @NonNull InputStream loadResourceAsStream(String name) throws IOException {
if (Objects.equals(name, filename)) {
return new ByteArrayInputStream(rulesetXmlContent.getBytes(StandardCharsets.UTF_8));
}
return oldLoader.loadResourceAsStream(name);
}
});
return loadFromResource(new RuleSetReferenceId(filename, null));
} finally {
loadResourcesWith(oldLoader);
}
}

In my case this ResourceLoader lacks certain classes and resources and therefore causes a subsequent crash.

Exception Stacktrace:

N/A

Code Sample demonstrating the issue:

new RuleSetLoader()
  .loadResourcesWith(customClassLoader)
  .loadFromString(this.getLocation(), rulesetXmlContent); // Ignores customClassLoader

Steps to reproduce:

See code above

Running PMD through: Other

Activity

  1. AB-xdev
    added
    a:bugPMD crashes or fails to analyse a file.
    on Jul 29, 2026
  2. adangel
    added this to the 7.27.0 milestone on Aug 14, 2026
  3. adangel
    closed this as completedin #6921on Aug 14, 2026
  4. lukasgraef
    added a commit that references this issue on Aug 14, 2026

    [core] Fix pmd#6913: Use the configured class loader in RuleSetLoader…

    This issue will close once commit eed52f5 is merged into the 'main' branch.
    eed52f5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    a:bugPMD crashes or fails to analyse a file.

    Type

    No type

    Projects

    No projects

      Milestone

      • 7.27.0

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.