Skip to content

[core] refactor: AnalysisCache based on Path - #6841

Merged
adangel merged 9 commits into
pmd:mainfrom
adangel:core/analysis-cache-refactoring
Jul 10, 2026
Merged

adangel merged 9 commits into
pmd:mainfrom
adangel:core/analysis-cache-refactoring

Conversation

@adangel

@adangel adangel commented Jul 4, 2026 •

Copy link
Copy Markdown
Member

Describe the PR

This is the first PR working towards a solution for #4953 . It first deals with the AnalysisCache to make it more independent: Now it doesn't depend anymore on classloader instances, but just uses a list of paths.

I've introduced a new utility, which is internal for now: AnalysisClasspathUtil. It supports parsing a string, which is a PMD-like classpath (e.g. given as an --aux-classpath parameter) - PMD-like, because it supports the special prefix "file:".

This new util class is also used for the current (also internal, but more widely used) ClasspathClassLoader.

This PR does not intend to change any behavior. The changes should be all internally.

In the next PRs, I plan to

Related issues

There are a couple of previous PRs/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 2 commits July 4, 2026 13:55
And not anymore based on URLs.
Moved out dependency to (URL)ClassLoader.
Added new utility AnalysisClasspathUtil to interpret with
the classpath.
@adangel adangel added this to the 7.27.0 milestone Jul 4, 2026
@adangel adangel added the in:pmd-internals Affects PMD's internals label Jul 4, 2026
@pmd-actions-helper

pmd-actions-helper Bot commented Jul 4, 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-09 10:34:02+00:00 for 81787a7)

@adangel
adangel merged commit 7e755a6 into pmd:main Jul 10, 2026
13 checks passed
@adangel
adangel deleted the core/analysis-cache-refactoring branch July 10, 2026 12:23
adangel added a commit that referenced this pull request Jul 16, 2026
* [core] Fix #4953: Deprecate PMDConfiguration#getClassLoader

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.

* [core] fix #4952: Document PMDConfiguration classLoader closing

* Add TODO for #6841

* Fix test auxClasspathWithRelativeFile() under Windows

* fix: when verifying auxclasspath allow not existing directory entries

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 #5064).

For now, we only log a warning for each suspicious auxClasspath entry.

* Revert formatting changes in release notes

* Fix tests

* Fix unused import

* refactor: Use AuxClasspathUtil in PMDConfiguration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in:pmd-internals Affects PMD's internals

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants