Skip to content

Conversation

derklaro
Copy link
Contributor

@derklaro derklaro commented Feb 17, 2022

This is no longer possible in recent java versions as the modifier field is registered to the reflection filter and writes will always fail. For backwards compatibility the methods are still there but there are no more internal usages of them.

In FieldUtils we can just use the writeStaticField method as it will be able to write to final fields without removing the modifier.

(This change compiles correctly and all tests are passing, see #1510 why it's not compiling with GH actions 😄 )

@dmulloy2
Copy link
Owner

Does essentially removing this functionality impact older Java versions? Or is it essentially unused?

@derklaro
Copy link
Contributor Author

Now it uses a the FieldAccessor class which then uses a Lookup which essentially bypasses all checks the jvm makes if a field is writeable or not. This functionality is the same for all java versions since 8, so I don't see the reason for it to break on older versions at all.

@dmulloy2 dmulloy2 merged commit baecaf4 into dmulloy2:master Feb 25, 2022
@derklaro derklaro deleted the pr/remove-modifier-field-writes branch February 25, 2022 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants