handlebars.java icon indicating copy to clipboard operation
handlebars.java copied to clipboard

Return null on illegal field acces

Open mdesharnais opened this issue 2 years ago • 1 comments

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.

mdesharnais avatar Feb 13 '22 17:02 mdesharnais

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.

agentgt avatar Apr 06 '22 17:04 agentgt