Skip to content

Instantly share code, notes, and snippets.

@epickrram
Created February 22, 2013 11:04
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 epickrram/5012657 to your computer and use it in GitHub Desktop.
Save epickrram/5012657 to your computer and use it in GitHub Desktop.
private static final class Unicorn
{
private static int mainMethodLineOfLastPatInvocation = 0;
private static boolean pat()
{
boolean result = false;
final StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
final StackTraceElement mainMethodInvocationPoint = stackTrace[3];
if(mainMethodInvocationPoint.getLineNumber() != mainMethodLineOfLastPatInvocation)
{
result = true;
mainMethodLineOfLastPatInvocation = mainMethodInvocationPoint.getLineNumber();
}
return result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment