Last active
December 25, 2015 10:09
-
-
Save antelle/6960013 to your computer and use it in GitHub Desktop.
Put this to some deep place in your code before switching jobs (java version).
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
package net.antelle; | |
import java.lang.reflect.Field; | |
import java.lang.reflect.Modifier; | |
public class Program implements java.util.Comparator<java.lang.String> { | |
public static void main(String [] args) { | |
happyDebugging(); | |
System.out.format("compare result: %s", "abc".compareToIgnoreCase("trololo")); | |
} | |
private static void happyDebugging() { | |
try { | |
Field field = String.class.getField("CASE_INSENSITIVE_ORDER"); | |
field.setAccessible(true); | |
Field modifiersField = Field.class.getDeclaredField("modifiers"); | |
modifiersField.setAccessible(true); | |
modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL); | |
field.set(null, new Program()); | |
} catch (Exception e) { | |
} | |
} | |
@Override | |
public int compare(String x, String y) { | |
return 0; // TODO: add randomness here, enable only in release, etc... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment