bb.util
Class Execute.Caller
java.lang.Object
bb.util.Execute.Caller
- Enclosing class:
- Execute
private static class Execute.Caller
- extends Object
Records information about the class that is calling Execute:
its class name, method name, and whether or not it is the actual program entry point of the current Java process.
This class is multithread safe: it is immutable.
Constructor Summary |
private |
Execute.Caller()
First acquires the stack trace of the current thread. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
classNameThread
private static final String classNameThread
classNameCaller
private static final String classNameCaller
classNameExecute
private static final String classNameExecute
className
private final String className
methodName
private final String methodName
isProgramEntryPoint
private final boolean isProgramEntryPoint
Execute.Caller
private Execute.Caller()
throws IllegalStateException
- First acquires the stack trace of the current thread.
Then confirms that the 0th element comes from
Thread.getStackTrace
.
Next starts searching the remaining elements.
The first StackTraceElement
that it comes across whose class name does not equal this class's or Execute
's
is the class/method that is calling Execute
; this element is used to assign className
and methodName
.
Assigns true
to isProgramEntryPoint
if and only if methodName
equals main
and the StackTraceElement
that methodName
was taken from is the last stack trace element.
(If you only checked that methodName
equals main
, then the caller of this class
could also be merely a main
that is being ultimately called by some other main
which is the true program entry point.)
- Throws:
IllegalStateException
- if some unexpected state is encountered