-
Notifications
You must be signed in to change notification settings - Fork 38.5k
Java 8 parameter name discovery for methods and constructors [SPR-9643] #14277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Juergen Hoeller commented Fully integrated for 4.0 RC1 now: With the Parameter.isNamePresent() being available as of OpenJDK 8 b100, we can use a DefaultParameterNameDiscoverer which checks JDK 8's standard reflection first and then falls back to ASM-based debug symbol analysis. Anywhere where we've been defaulting to LocalVariableTableParameterNameDiscoverer before, we're using this new DefaultParameterNameDiscoverer now. |
Nick Williams commented I have a question about this specific new feature in relation to SpEL, and about parameter name discovery in general in relation to SpEL. This also pertains to Spring Security (pre-post annotations), so Rob Winch might want to chime in as well. My (albeit limited and possibly mistaken) understanding of Spring Framework's parameter name discovery and SpEL is that you can always rely on The are several observations regarding parameter name discovery, and they can generally be divided into pre- and post-Java-8 categories: Before Java 8
Starting With Java 8
Because of these problems, I feel it's important for parameter "names" to always be available as At the very least, I feel like the Spring Framework and Spring Security documentation could use some improvement on this topic. Is there something we can always rely on, even in the absence of Java 8 and debug symbols or the presence of a labyrinth of proxies? What is it? If there isn't, then I think some changes need to be made (either in SF, SS, or both), and I understand that may mean separate issues get created. The truth is that debug symbols aren't always desirable in production environments, and "turn on debug symbols" is not an acceptable answer when someone wonders why they can't use method parameters in a SpEL expression. Clearer documentation, and better implementation if necessary, would be a big improvement, IMO. |
Rob Winch commented Nick Williams The Parameter Name discovery is not really limited to SpEL, but is more general. For example, RequestMappingHandlerAdapter uses ParameterNameDiscoverer for binding parameters to Spring MVC arguments from the HTTP servlet request. Spring Security does, however, use the ParameterNameDiscoverer for determining what is available in the SpEL expressions. The constant you are looking for is that much of the framework allows use of annotations to specify the parameter name. For example, Spring Web MVC reference states:
Spring Security currently suffers from being able to bind parameter names on interfaces. Since interfaces do not contain debug symbols, the parameter names cannot be discovered. This can be resolved by using JDK 8 with StandardReflectionParameterNameDiscoverer (or DefaultParameterNameDiscoverer if you want fallback options) if -parameter argument is specified to the compiler. Once resolved, SEC-2151 will allow using annotations to specify the parameter name for Spring Security in a consistent way. |
Nick Williams commented Understood that discovery is broader that SpEL; my questions were SpEL-specific. But what about matching by parameter index like |
Rob Winch commented
I guess I was confused by the context of your comment. Specifically you are commenting on a JIRA pertaining to ParameterNameDiscoverer with JDK 8 and the question seems more related to SpEL.
ParameterNameDiscoverer API could allow an implementation that falls back to use p0, p1, etc. However, the API does not allow for supporting both the parameter names as defined by the JDK and and p0, p1, etc simultaneously. The cache abstraction embeds this logic into LazyParamAwareEvaluationContext (its SpEL EvaluationContext). In summary...
|
Nick Williams commented Okay. That all makes sense. I'll open an SEC issue. |
Uh oh!
There was an error while loading. Please reload this page.
Juergen Hoeller opened SPR-9643 and commented
http://openjdk.java.net/jeps/118
This issue is a sub-task of #14273
0 votes, 7 watchers
The text was updated successfully, but these errors were encountered: