You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
you call Class.getField and then try to make it visible via Field.setAccessible, but this is incorrect by design as Class.getField only return public fields!
Instead you should be using Class.getDeclaredField.
In practice, it means that it is always impossible to access private fields from templates.
In v3, the issue was in ASTExpr but I guess this won't be fixed there? :)
The text was updated successfully, but these errors were encountered:
@parrt right, I didn't know that. It actually makes sense because diverse class in an object hierarchy can have the same private fields... and then it means that maybe it's actually a bad idea to rely on the private fields/methods of an object then?
Hi,
I encountered that issue with v3 but I believe the problem exists also in v4.
Basically in
stringtemplate4/src/org/stringtemplate/v4/misc/ObjectModelAdaptor.java
Line 150 in 9a43949
Class.getField
and then try to make it visible viaField.setAccessible
, but this is incorrect by design asClass.getField
only return public fields!Instead you should be using
Class.getDeclaredField
.In practice, it means that it is always impossible to access private fields from templates.
In v3, the issue was in
ASTExpr
but I guess this won't be fixed there? :)The text was updated successfully, but these errors were encountered: