On 14/11/2021 00:59, Claes Redestad wrote:
:
@martin-g mutating static final fields with reflection `setAccessible(true)` is 
an ugly hack with partially undefined behavior that can lead to all manners of 
bugs.. but I think this is an unintentional behavior change.

@mlchung should verify, but it looks like the `MethodHandles.unreflect` API 
used internally in the new implementation is slightly stricter and ignores the 
`setAccessible(true)` for the trusted finality check. This added strictness is 
established behavior for the public `MethodHandles.unreflect` API point, which 
seem perfectly fine there (the MH API is strictly adhering to regular java 
access rules). For this new reflection implementation we should probably make 
an exception to that strictness to be perfectly backwards compatible.

If I read this correctly, a wicked Wicket test is making use of a private method in java.lang.Class so it can hack jlr.Field and change its internal "modifiers" field. I don't think the JDK should be expected to keep crazy hacks like this working from release to release.

Are there many Wicket tests trying to modify static field fields? Have you looked at using an agent to drop the final modifier from these fields when loading the classes?

-Alan

Reply via email to