handlebars.java
handlebars.java copied to clipboard
4.3.0 seems to shadow 'size' under OpenJDK 17
When upgrading to OpenJDK 17, and bumping to 4.3.0, the output of a variable called 'size' used in a loop silently became 1 rather than its expected value of 10. Reverting to 4.2.1, still using Java 17, it's 10 again. Renaming the variable fixes the problem. Would be nice with some warning/error on such shadowing.
Can you include some more code?
Do you have field called size
that is protected
or private
right?
In 4.2.1 on JDK 17 you could not get the value of List.of("stuff").size()
. The below would throw an exception.
MethodValueResolver r = new MethodValueResolver();
var list = List.of("hello", "stuff");
Object o = r.resolve(list, "size");
In 4.3.0 it works now.
I still don't know how you didn't see the exception.
You also probably ran into this:
https://github.com/jknack/handlebars.java/blob/master/handlebars/src/main/java/com/github/jknack/handlebars/ValueResolver.java#L87