Skip to content

[core] PMDConfiguration - "Can't mix setClasspath with getAuxClasspath!" #7013

Closed

Description

@AB-xdev

Affects PMD Version:

7.27.0

Description:

Call PMDConfiguration#setClassLoader and do an analysis PmdAnalysis.create(pmdConfig) → Crashes

Exception Stacktrace:

2026-08-31 09:20:49,922 [  94383] SEVERE - #software.xdev.pmd.annotator.PMDExternalLanguageAnnotator - Failed to annotate
java.lang.IllegalStateException: Can't mix setClasspath with getAuxClasspath!
	at net.sourceforge.pmd.PMDConfiguration.getAuxClasspath(PMDConfiguration.java:353)
	at net.sourceforge.pmd.PmdAnalysis.create(PmdAnalysis.java:221)
	at software.xdev.pmd.analysis.PMDAnalyzer.analyzeInternal(PMDAnalyzer.java:203)
        ...

Code Sample demonstrating the issue:

See above

Steps to reproduce:

See above

Running PMD through: Other

Activity

  1. added
    a:bug
    on Aug 31, 2026
  2. UncleOwen commented on Aug 31, 2026

    @UncleOwen
    Member

    Can't reproduce. The following test is green.

        @Test
        void testCreateConfigWithCustomClasspath() {
            PMDConfiguration config = new PMDConfiguration();
            config.setClassLoader(this.getClass().getClassLoader());
    
            assertDoesNotThrow(() -> PmdAnalysis.create(config));
        }
    
  3. AB-xdev commented on Aug 31, 2026

    @AB-xdev
    Author

    @UncleOwen Is this test executed using a JvmLanguagePropertyBundle? You probably need to configure a language like Java because otherwise the condition might not be triggered - at least as far as I have seen in the code...

  4. UncleOwen commented on Aug 31, 2026

    @UncleOwen
    Member

    Ah, I took your problem description a bit too literal. Now I can reproduce.

        @Test
        void testCreateConfigWithCustomClasspath() {
            LanguageRegistry registry = new LanguageRegistry(setOf(new FakeJvmLanguageModule()));
            PMDConfiguration config = new PMDConfiguration(registry);
            config.setClassLoader(this.getClass().getClassLoader());
    
            assertDoesNotThrow(() -> PmdAnalysis.create(config));
        }
    
        private static class FakeJvmLanguageModule extends DummyLanguageModule {
            @Override
            public LanguagePropertyBundle newPropertyBundle() {
                return new JvmLanguagePropertyBundle(this);
            }
        }
  5. changed the title [-]"Can't mix setClasspath with getAuxClasspath!"[/-] [+][core] PMDConfiguration - "Can't mix setClasspath with getAuxClasspath!"[/+] on Aug 31, 2026
  6. added this to the 7.28.0 milestone on Sep 3, 2026
  7. added a commit that references this issue on Sep 3, 2026
    65dca5e
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:bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions