Skip to content

[core] Fix #4953: Deprecate PMDConfiguration#getClassLoader - #6845

Merged
adangel merged 12 commits into
pmd:mainfrom
adangel:core/issue-4953-deprecate-pmdconfiguration-classloader
Jul 16, 2026
Merged

adangel merged 12 commits into
pmd:mainfrom
adangel:core/issue-4953-deprecate-pmdconfiguration-classloader

Conversation

@adangel

@adangel adangel commented Jul 7, 2026 •

Copy link
Copy Markdown
Member

Describe the PR

This is my new attempt on fixing #4953.
We keep it simple: PMDConfiguration just manages now a String, which is the auxClasspath. No Classloader anymore, no fancy API (like Classpath...).

This also fixes the problem, that Kotlin is currently facing. Setting the --aux-classpath CLI parameter never ended up in JvmLanguagePropertyBundle#AUX_CLASSPATH . The only way was setting the property programmatically. Now the classloader is created not by PMDConfiguration, but by JvmLanguagePropertyBundle (the code was already there but mostly unused). This means, that this commit 4c043ae is not needed anymore.

⚠️ There is one behavioral change: The provided auxClasspath is verified: If there are any jar files referenced, which don't exist, PMD will throw. This helps when PMD is called with invalid parameters resulting in an incomplete classpath. Related to #5064.

This PR replaces the old PRs #6312 and #6398

Related issues

Ready?

  • Added unit tests for fixed bug/feature
  • Passing all unit tests
  • Complete build ./mvnw clean verify passes (checked automatically by github actions)
  • Added (in-code) documentation (if needed)

adangel added 3 commits July 7, 2026 19:33
PMDConfiguration now stores the given raw auxClasspath as string.
For backwards compatibility, a classloader can still be set externally
when using the programmatic API.
But usually (e.g. via CLI), the auxClasspath is set now via the
JvmLanguagePropertyBundle only,
which creates the actual classloader only when requested.
This means, the classloader is not created anymore eagerly by
PMDConfiguration.

The given auxClasspath is checked early for validity.
All files/directories must exist.
@adangel adangel added this to the 7.27.0 milestone Jul 7, 2026
@adangel adangel added the is:deprecation The main focus is deprecating public APIs or rules, eg to make them internal, or removing them label Jul 7, 2026
adangel added 3 commits July 9, 2026 10:24
At least maven-pmd-plugin might provide a directory, which doesn't
exist, e.g. "target/test-classes". As we don't check the auxclasspath
for completeness (which we can't anyway at this point), there is
no difference between a non-existing directory or an empty
directory or an incomplete directory. The result is the same:
the provided auxclasspath is incomplete.
The reason for the empty/non-existing directory might be, that the
project being analyzed was not compiled yet - but we don't know.

Later on, when trying to resolve classes from the auxclasspath
and we don't find classes, we can report this problem, as we
know for sure, that the auxclasspath is incomplete (see pmd#5064).

For now, we only log a warning for each suspicious auxClasspath entry.
Comment thread docs/pages/release_notes.md Resolved
@pmd-actions-helper

pmd-actions-helper Bot commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Documentation Preview

Compared to main:
This changeset changes 0 violations,
introduces 0 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 0 errors and 0 configuration errors.
There are 0 changed duplications, 0 new duplications and 0 removed duplications.
There are 0 changed CPD errors, 0 new CPD errors and 0 removed CPD errors.

Regression Tester Report

(comment created at 2026-07-10 12:45:45+00:00 for 719f55c)

@adangel

This comment was marked as resolved.

@adangel
adangel marked this pull request as draft July 9, 2026 12:07
@adangel
adangel marked this pull request as ready for review July 13, 2026 17:42
@adangel
adangel requested a review from UncleOwen July 13, 2026 17:43
@adangel
adangel merged commit 5e92c27 into pmd:main Jul 16, 2026
2 checks passed
@adangel
adangel deleted the core/issue-4953-deprecate-pmdconfiguration-classloader branch July 16, 2026 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

is:deprecation The main focus is deprecating public APIs or rules, eg to make them internal, or removing them

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[core] Deprecate PMDConfiguration#setClassloader and #getClassloader [doc] Improve doc around PMDConfiguration#prependAuxclasspath #setClassloader

2 participants