The org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider can scan for classes with arbitrary annotations.

// A ClassPathScanningCandidateComponentProvider without default filters:
ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false);

// Add a filter for the desired annotation (example: MyAnnotationTypeName)
provider.addIncludeFilter(new AnnotationTypeFilter(MyAnnotationTypeName.class));

// Find the classes under a given base package:
String basePackage = ...
provider.findCandidateComponents(basePackage).stream()
   // extract the class names.
  .map(BeanDefinition::getBeanClassName)
  ...