Skip to content

chore: update ClassGraph to 5.0.2 - #2450

Draft
totally-not-ai[bot] wants to merge 2 commits into
mainfrom
classgraph-5
Draft

totally-not-ai[bot] wants to merge 2 commits into
mainfrom
classgraph-5

Conversation

@totally-not-ai

@totally-not-ai totally-not-ai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Updates ClassGraph from 4.8.184 to 5.0.2 in UI unit testing. ClassGraph 4 is end of life; ClassGraph 5 is the JDK 17–24 line with the same API as ClassGraph 6, which needs JDK 25 and so cannot be used while Vaadin 25 supports JDK 21.

What changed

  • vaadin-testbench-unit-shared/pom.xml: io.github.classgraph:classgraph 4.8.184 → 5.0.2 (it now brings in classgraph-base, classgraph-vfs and classgraph-classpath transitively).
  • BaseUIUnitTest.scanForTesters and Routes.autoDiscoverViews: ClassGraph 5 scans nothing unless a source is enabled, so both scans now call enableClasspath().enableNonSystemModules(), which is what 4.x scanned by default.
  • Routes: getClassesImplementing is renamed to getAllClassesImplementing (same transitive semantics).
  • Routes: ClassGraph 5 no longer loads classes, so discovered routes and error routes are loaded by a new internal loadClass in Utils.kt: the thread context class loader first, then the class loader of Routes, without initializing the class, and an IllegalArgumentException if the class is missing or not of the expected type (as ScanResult.loadClass(name, type, false) did). If the context class loader found the class but could not link it, that error is attached as a suppressed exception.
  • Tester loading in scanForTesters already used findClassOrThrow and is unchanged, so testers keep their existing class loader order.
  • Behaviour: no intended change in which views, error views or testers are discovered. Annotations and supertypes outside the accepted packages (@Route, HasErrorParameter) are still matched without enableExternalClasses().

Test summary

  • mvn test -pl vaadin-testbench-unit-shared,vaadin-testbench-unit,vaadin-testbench-unit-junit5,vaadin-testbench-unit-quarkus: all pass (4, 245, 869 and 14 tests), including the existing route discovery (routesTestBatch, DiscoverRoutesIn*) and TesterScanTest scans.
  • New route tests: views and an error view (implementing HasErrorParameter only through its superclass) compiled into a package only the context class loader sees, with a view whose static initializer throws; a child-first context class loader whose copies of the views win over the class loader of Routes; and discovery without a context class loader.
  • New direct loadClass tests for a class of the wrong type, a missing class, and a linkage error from the context class loader.
  • mvn spotless:check passes for the changed modules.

Working on behalf of @Artur-

ClassGraph 4 is end of life. ClassGraph 5 is the JDK 17+ line and has
the same API as ClassGraph 6, which needs JDK 25.

ClassGraph 5 scans nothing unless a source is enabled, so the tester
and route scans now enable the classpath and the non-system modules,
which is what 4.x scanned by default. ClassGraph no longer loads
classes, so discovered routes and error routes are loaded with the
thread context class loader, falling back to the class loader of
Routes, without initializing them, as before. getClassesImplementing
is now getAllClassesImplementing.
Keep a linkage error from the context class loader as a suppressed
exception when the fallback cannot load the class either, and cover
loadClass directly and through Routes: a context class loader that
defines its own copy of the views wins over the class loader of Routes,
and the views are the same when there is no context class loader.
@totally-not-ai
totally-not-ai Bot requested a review from Artur- December 1, 2026 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants