Last active
December 30, 2015 10:19
-
-
Save christopherperry/7815316 to your computer and use it in GitHub Desktop.
Evil reflective code
This file contains 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
@Test | |
public void happyDebuggingSuckers() throws SecurityException, NoSuchFieldException, IllegalAccessException { | |
Field value = Boolean.class.getDeclaredField("value"); | |
value.setAccessible(true); | |
Boolean trueBool = true; | |
Boolean falseBool = false; | |
value.setBoolean(trueBool, false); | |
value.setBoolean(falseBool, true); | |
Boolean setToTrue = true; | |
assertThat(setToTrue).isFalse(); | |
Boolean setToFalse = false; | |
assertThat(setToFalse).isTrue(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment