Skip to content

Instantly share code, notes, and snippets.

@ludovicc
Created February 19, 2013 11:14
Show Gist options
  • Save ludovicc/4984963 to your computer and use it in GitHub Desktop.
Save ludovicc/4984963 to your computer and use it in GitHub Desktop.
public class Unicorn {
private static StackTraceElement[] previousTrace;
public static boolean pat() {
Throwable t = new Exception();
StackTraceElement[] trace = t.getStackTrace();
if (previousTrace == null) {
previousTrace = trace;
return true;
}
boolean newTrace = false;
for (int i = 0; i < trace.length; i++) {
if (!trace[i].equals(previousTrace[i])) {
newTrace = true;
break;
}
}
if (newTrace) {
previousTrace = trace;
}
return newTrace;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment