Skip to content

Instantly share code, notes, and snippets.

@christopherperry
Last active December 30, 2015 10:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christopherperry/7815316 to your computer and use it in GitHub Desktop.
Save christopherperry/7815316 to your computer and use it in GitHub Desktop.
Evil reflective code
@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