This PR is to make event mechanisms better support generics.

When I publish an event which contains generics via org.springframework.context.support.AbstractApplicationContext#publishEvent(java.lang.Object, org.springframework.core.ResolvableType) , I find that corresponding listener does not get event message. Please see the unit test cases in my PR. The unit test method of named publishEventWithGeneric fail before this PR submission. So, I think we can add a payloadType field to PayloadApplicationEvent to fix this. In addition, this fix code also can cache the type information of the payload to improve performance.

Thank you for reading and look forward to your reply.

Comment From: snicoll

@chenqimiao thank you!

Comment From: chenqimiao

@snicoll My pleasure

Comment From: chenqimiao

org.springframework.context.event.ApplicationListenerMethodAdapter#onApplicationEvent --> org.springframework.context.event.ApplicationListenerMethodAdapter#processEvent --> org.springframework.context.event.ApplicationListenerMethodAdapter#resolveArguments --> org.springframework.context.event.ApplicationListenerMethodAdapter#getResolvableType --> ResolvableType eventType = payloadEvent.getResolvableType(); // Generics may be lost, see PR test for specific cases .