handlebars.java
handlebars.java copied to clipboard
Return null on illegal field acces
This seems to fix issue #940 without breaking any test.
In a nutshell, an IllegalAccessException is now expected when trying to access fields not exported by a module through reflexion.
If we pull your change in we break templates for folks upgrading in possibly very bizarre and not easy to understand ways (see #951 and the plethora of other recent bugs albeit that is caused by the default resolvers changing for java version). I can explain how this happens if you like when I have more time.
The current solution is not ideal but it is better to have it fail fast.
The field value resolver is inherently flawed and really needs a dedicated Java 9+ solution of using tryAccessible
(and various other friends that are only in 9) instead of just catching exceptions and returning null.