Created
February 15, 2020 10:03
-
-
Save nhoxbypass/4d07f8c9304571198133a292cd084fae to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Throws(Exception::class) | |
fun setFinalStatic(field: Field, newValue: Any) { | |
field.setAccessible(true) | |
val modifiersField = Field::class.java.getDeclaredField("modifiers") | |
modifiersField.setAccessible(true) | |
modifiersField.setInt(field, field.getModifiers() and Modifier.FINAL.inv()) | |
field.set(null, newValue) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment