Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Inferring an ApplicationListener's event type from a lambda or method reference [SPR-10675] #15303
These two variations do not:
With either of these last two, Spring never starts. The following output is logged:
It seems to me that this should work. Perhaps a tweak to the listener registry to detect the method argument type from lambdas and references, too, instead of just regular and anonymous classes.
Affects: 4.0 M1
2 votes, 8 watchers
Juergen Hoeller commented
If we're trying to support this along the lines of #17130, retrieving the declared type from the lambda-defined instance, we have no acceptable way to retrieve that information yet. See my comment on that issue: hacking into the JVM constant pool isn't really feasible there.
As an alternative, we may also try to introspect the method's return type declaration along the lines of #16146. That will obviously only work for factory methods, not for programmatically registered listener instances, and only if the factory method redeclares the generic event type.