Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.