Support Java 16 records in property lookup
Java 16 records (JEP 395) are a perfect fit for Velocity variables: they are lightweight and desgined to contain immutable data. However, records don’t follow the JavaBean convention: the getter of the field foo is foo(), not getFoo(). Add support for this naming convention.
While this naming convention is mostly useful in projects using Java 16 records, the patch itself doesn’t rely on records, so it doesn’t break Java 1.8 compatibility.
Stupid question: is this limited to records only or will it work with any method without get prefix?
Actually, I could only test it with regular classes because of the project’s Java 1.8 support. So other methods work definitely, records work hopefully. :)
I'm inclined to accept this PR. There is a tiny corner case compatibility issue for templates relying on a property not to be found in a object having such a method for the property, I consider it sufficiently improbable and unusual to move forward without introducing one more compatibility flag.
Thanks for merging it! I’ve tried out Velocity 2.4 in my Java 17 project, and it works like a charm!
I could be wrong, but I believe this change introduced a breaking change. I created ticket https://issues.apache.org/jira/browse/VELOCITY-986 to demonstrate problem.
This change was introduced a breaking change, when we have a map with list. The details in this mail https://lists.apache.org/thread/grd2bhgjjjmbo5rmyn7540btj924lq69 cc @arkanovicz @jtotht @michael-o