junit-team/junit5 · warning · UnsupportedOperationException

Implement scanForResourcesInPackage(String, ResourceFilter)…

Error message

Implement scanForResourcesInPackage(String, ResourceFilter) instead

What it means

UnsupportedOperationException thrown by the deprecated default method scanForResourcesInPackage(String, Predicate<Resource>) on the ClasspathScanner interface (deprecated since 1.14, forRemoval=true). The default impl throws because implementers must override the new scanForResourcesInPackage(String, ResourceFilter) variant that takes the typed ResourceFilter instead of a raw Predicate.

Solutions

  1. Implement scanForResourcesInPackage(String, ResourceFilter) in the custom ClasspathScanner
  2. Stop calling the deprecated Predicate-based overload
  3. Align all junit-platform-* artifacts on the same version

Example fix

// before
@Override
public List<Resource> scanForResourcesInPackage(String pkg, Predicate<Resource> f) { ... }

// after
@Override
public List<Resource> scanForResourcesInPackage(String pkg, ResourceFilter f) { ... }
Defensive patterns

Strategy: validation

Prevention

When it happens

Trigger: A ClasspathScanner ServiceLoader implementation that does not override the new ResourceFilter-based scanForResourcesInPackage, while the framework or a caller invokes the deprecated Predicate-based default method.

Common situations: Custom ClasspathScanner SPI implementation not yet migrated to the 1.14 API; version skew between junit-platform-commons and a third-party scanner; shading pulling in an old scanner that only knows the Predicate overload.

Related errors


AI-assisted analysis of junit-team/junit5@f070c699a0 (2026-08-11). Data as JSON: /api/errors/9d92db476cc44101. Report an issue: GitHub.

Appendix: source

Thrown at junit-platform-commons/src/main/java/org/junit/platform/commons/support/scanning/ClasspathScanner.java:88

	 *
	 * <p>The classpath scanning algorithm searches recursively in subpackages
	 * beginning with the root of the classpath.
	 *
	 * @param basePackageName the name of the base package in which to start
	 * scanning; must not be {@code null} and must be valid in terms of Java
	 * syntax
	 * @param resourceFilter the resource type filter; never {@code null}
	 * @return a list of all such resources found; never {@code null}
	 * but potentially empty
	 * @deprecated Please implement
	 * {@link #scanForResourcesInPackage(String, ResourceFilter)} instead
	 */
	@API(status = DEPRECATED, since = "1.14")
	@Deprecated(since = "1.14", forRemoval = true)
	@SuppressWarnings({ "removal", "unused" })
	default List<org.junit.platform.commons.support.Resource> scanForResourcesInPackage(String basePackageName,
			Predicate<org.junit.platform.commons.support.Resource> resourceFilter) {
		throw new UnsupportedOperationException("Implement scanForResourcesInPackage(String, ResourceFilter) instead");
	}

	/**
	 * Find all {@linkplain org.junit.platform.commons.support.Resource resources} in the supplied classpath {@code root}
	 * that match the specified {@code resourceFilter} predicate.
	 *
	 * <p>The classpath scanning algorithm searches recursively in subpackages
	 * beginning with the root of the classpath.
	 *
	 * @param root the URI for the classpath root in which to scan; never
	 * {@code null}
	 * @param resourceFilter the resource type filter; never {@code null}
	 * @return a list of all such resources found; never {@code null}
	 * but potentially empty
	 * @deprecated Please implement
	 * {@link #scanForResourcesInClasspathRoot(URI, ResourceFilter)} instead
	 */
	@API(status = DEPRECATED, since = "1.14")

View on GitHub (pinned to f070c699a0)