Overview
Since -parameters
is required for certain use cases starting with Spring Framework 6.1, we should revise related exception messages to explicitly mention the solution.
For example, a Spring MVC @Controller
handler method with a @PathVariable String client
parameter declaration may fail with an exception similar to the following.
java.lang.IllegalArgumentException: Name for argument of type [java.lang.String] not specified, and parameter name information not found in class file either.
To improve diagnostics, we should add something along the lines of Ensure that the compiler uses the -parameters flag.
to the end of that exception message.
Related Issues
-
29531
-
29559
-
31643
-
31666
-
31671
-
31685
-
31729
-
31743
Comment From: philwebb
@sbrannen @bclozel Any thoughts about introducing a dedicated exception type? We could then have a failure analyzer in Spring Boot.
Comment From: sbrannen
Reopening to improve exception message in CacheAspectSupport.generateKey(CacheOperationContext, Object)
.
- see #31729
Comment From: sbrannen
Any thoughts about introducing a dedicated exception type?
That's an interesting idea.
For some use cases (e.g., mvc controller handler methods, and cache key generation) it would be relatively straightforward; however, for other uses (e.g., SpEL expressions, parameter named used as fallback qualifier for dependency injection by type) it may not be as straightforward to pin down what the trigger would be for such an exception.
In any case, we'll discuss it amongst the team.
Comment From: sbrannen
Note to maintainers
If we modify the exception message currently used or introduce a new exception type, etc., we must make sure that the exception message contains "Ensure that the compiler uses the '-parameters' flag"
.
Otherwise, we'll render Spring Boot's failure analysis useless, since it depends on the exception message containing exactly that sub-string.
https://github.com/spring-projects/spring-boot/blob/b5de38787c6abd4fc6522aa006b3d460ae23ffc5/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/MissingParameterNamesFailureAnalyzer.java#L38