SLING-11917 Evaluate constructor parameter names via reflection
This is available if compiled accordingly (with javac option -parameters, https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#option-parameters), supported since javac 8+
can you add a test case evaluating the new behavior?
i've never used the -parameters option, if i understand correctly it's still optional and not activated by default. so we need probably multiple maven verify executions or separate integration tests that test our code with variants of this flag enabled and not enabled, to ensure it works as expected in all conditions?
The API https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/Parameter.html is available since Java 8 (no matter if -parameters is used or not). The only difference is that https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/Parameter.html#isNamePresent-- returns false by default and https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/Parameter.html#getName-- returns an artificial name by default. But I will look into adding ITs (the current ones proof though that everything works by default, i.e. without using --parameters, so only ones with --parameters are currently not existing).
Wouldn't that be as simple as adding another compile step in the project, for a separate source folder, that will have a sling model available to test?
@henrykuijpers Yes, but I tried to do https://github.com/apache/sling-org-apache-sling-models-impl/pull/46 first, which turned out to be more complex.
Quality Gate passed
Issues
1 New issue
0 Accepted issues
Measures
0 Security Hotspots
93.8% Coverage on New Code
0.0% Duplication on New Code
Quality Gate passed
Issues
1 New issue
0 Accepted issues
Measures
0 Security Hotspots
92.9% Coverage on New Code
0.0% Duplication on New Code







