Deprecated Reflection constructor

686 Views Asked by At

I am running sonar cloud through my Java code and it has some deprecated constructors. I managed to update most of them, but not this one:

import org.reflections.util.ClasspathHelper;

private static final String PACKAGE_ENTITIES = "my.package";

new Reflections(PACKAGE_ENTITIES, new SubTypesScanner(false), ClasspathHelper.forClassLoader());

'org.reflections.scanners.SubTypesScanner' is deprecated is the official sonar message.

My guess is Scanners.SubTypes (s -> true)

Any tips?

Thanks in advance.

1

There are 1 best solutions below

0
Progman On

Check the documentation of the SubTypesScanner class:

Deprecated.

scan superclass and interfaces of a class, allowing a reverse lookup for subtypes. Deprecated, use Scanners.SubTypes instead

So the solution is to use the Scanners.SubTypes field instead.