Currently, the javadoc of org.springframework.context.event.EventListener.classes() says the following:

The event classes that this listener handles. If this attribute is specified with a single value, the annotated method may optionally accept a single parameter. However, if this attribute is specified with multiple values, the annotated method must not declare any parameters.

If I have a hierarchy of events or if some events implement a common interface, I would like to be able to declare which event classes this listener must listen to and have the method accept a single parameter which would be a common ancestor of my events or a common interface.

interface FileEvent {
  String fileName();
}

record FileUploadedEvent(String fileName, ...) implements FileEvent {}
record FileDownloadedEvent(String fileName, ...) implements FileEvent {}
record FileDeletedEvent(String fileName, ...) implements FileEvent {}

@EventListener(classes = {FileUploadedEvent.class, FileDownloadedEvent.class})
void onFileTransfered(FileEvent event) { ... }

Comment From: jhoeller

This is effectively a documentation concern: That restriction mentioned in the @EventListener javadoc does not actually exist. We'll revise this for 6.2.12, also adding a corresponding unit test.

For the time being, you can simply declare it as you suggested. This should work fine already since a quick local unit test works as-is.