You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
GenericTypeResolver should be able to introspect generic arguments from lambdas [SPR-12525] #17130
in: coreIssues in core modules (aop, beans, core, context, expression)status: declinedA suggestion or change that we don't feel we should currently applytype: enhancementA general enhancement
I've played around with the suggested code but unfortunately it seems to be very fragile and doesn't even seem to work for some lambda variants that I've tried. That aside, it relies on access to private JVM APIs that are not accessible on JDK 9 anymore. And I'm not keen on custom ASM digging in the constant pool either, which would still rely on the structures of entries there,
I'm afraid we can't provide this until standard JVM facilities are being provided for that purpose :-(
@Jurgen I just noticed your comments - a bit late :)
I agree that the ConstantPool technique for resolving lambda generics is not ideal, but when ConstantPool is present is should be fairly well and covers most lambda use cases (newer versions of TypeTools have improved on this though there is at least one corner case that is not covered). Do you recall which variants you tried that might not have worked?
I'm also seeing ConstantPool still alive and well in OpenJDK 9 builds, for what it's worth.
That all said, due to the target runtime limitations, this capability isn't something that everybody can benefit from and comes with the associated caveats.
FYI: the SerializedLambda approach may prove useful and more reliable than the ConstantPool approach; however, as Brian Goetz points out, "Serialized lambdas have significantly higher performance costs compared to nonserializable lambdas, and are less secure...".
Looks like is basically a duplicate of #18273. I just had someone running into this problem again (declared a functional bean as lambda (a Spring HATEOAS ResourceProcessor and wondered why the generics aren't discovered properly).
I don't think Spring can build a feature that can cover all the lambdas use cases and JDK versions in a non brittle way, so I decline this feature request.
in: coreIssues in core modules (aop, beans, core, context, expression)status: declinedA suggestion or change that we don't feel we should currently applytype: enhancementA general enhancement
Activity
spring-projects-issues commentedon May 7, 2015
Juergen Hoeller commented
I've played around with the suggested code but unfortunately it seems to be very fragile and doesn't even seem to work for some lambda variants that I've tried. That aside, it relies on access to private JVM APIs that are not accessible on JDK 9 anymore. And I'm not keen on custom ASM digging in the constant pool either, which would still rely on the structures of entries there,
I'm afraid we can't provide this until standard JVM facilities are being provided for that purpose :-(
Juergen
spring-projects-issues commentedon May 7, 2015
Artem Bilan commented
No problem, Juergen!
Thank you very much for the investigation and explanation.
Since with API from our Frameworks we always can require an additional type parameter, we will live with the current JVM state until better times.
spring-projects-issues commentedon Mar 30, 2016
Jonathan Halterman commented
@JurgenI just noticed your comments - a bit late :)I agree that the ConstantPool technique for resolving lambda generics is not ideal, but when ConstantPool is present is should be fairly well and covers most lambda use cases (newer versions of TypeTools have improved on this though there is at least one corner case that is not covered). Do you recall which variants you tried that might not have worked?
I'm also seeing ConstantPool still alive and well in OpenJDK 9 builds, for what it's worth.
That all said, due to the target runtime limitations, this capability isn't something that everybody can benefit from and comes with the associated caveats.
spring-projects-issues commentedon Apr 11, 2016
Sam Brannen commented
FYI: the
SerializedLambdaapproach may prove useful and more reliable than theConstantPoolapproach; however, as Brian Goetz points out, "Serialized lambdas have significantly higher performance costs compared to nonserializable lambdas, and are less secure...".spring-projects-issues commentedon Jul 11, 2018
Oliver Drotbohm commented
Looks like is basically a duplicate of #18273. I just had someone running into this problem again (declared a functional bean as lambda (a Spring HATEOAS
ResourceProcessorand wondered why the generics aren't discovered properly).8-bitLincoln commentedon Jun 12, 2019
Looks like https://github.com/jhalterman/typetools has resolved this problem
sbrannen commentedon Jun 12, 2019
Well, that my be true but unfortunately only for Java 8 and 9.
Source: https://github.com/jhalterman/typetools#on-lambda-support
So, that's not a valid option.
sdeleuze commentedon Nov 14, 2024
I don't think Spring can build a feature that can cover all the lambdas use cases and JDK versions in a non brittle way, so I decline this feature request.