Brian's Waste of Time

Thu, 30 Sep 2004

Redneck CFlow

You know you have been tempted to do this:

    final RuntimeException e = new RuntimeException();
    final StackTraceElement[] stack = e.getStackTrace();

    for (int i = 0; i < stack.length; i++)
    {
        final StackTraceElement frame = stack[i];
        final String clazz = frame.getClassName();
        final String method = frame.getMethodName();
        final int line = frame.getLineNumber();
        final String file = frame.getFileName();
        if (signature.matches(clazz, method, line, file))
        {
           return advice.apply(this, new Object[]{});
        }
    }

At least once ;-)

0 writebacks [/src/java] permanent link