On 9/20/13 1:58 AM, Jochen Theodorou wrote:
Am 20.09.2013 09:09, schrieb Mandy Chung:
[...]
Stack is a "stream" that allows you to walk partial stack (e.g. find
caller) or full stack trace (e.g. throwable). The filtering and mapping
operations are lazy to avoid having the VM eagerly copying the entire
stack trace data even for the short reach case (like Groovy and Log4j).
and is there a link to StackStram too?
No. The concrete implementation is yet to be done and it would need a
new VM entry point that the library code to use.
It's not interesting to read what I did in my hack version that is
intended to help design how the API works with the use cases.
The Thread#walkStack methods don't really describe the behaviour of
the consumer. Will the consumer applied only once, or multiple times?
Apply once to each element like Iterable.forEach.
If only once, then to replace getCallerClass(int depth), you will need
the version with the predicate, which will be difficult to realize
with a simple lambda, since you will need to count as well.
Ah... I see what you need as you mentioned in [1]. Thread.getCaller
skips the first frame that matches the predicate and you want to be able
to control the number of skips. Just curious - do you mind explaining
what the matchLevel is in
org.codehaus.groovy.reflection.ReflectionUtils.getCallingClass(int
matchLevel, Collection<String> extraIgnoredPackages)?
I understand matchLevel == 1 when you look for the immediate caller.
Understand what situation do you look for matchLevel > 1?
Mandy
[1]
http://mail.openjdk.java.net/pipermail/core-libs-dev/2013-September/021243.html
https://github.com/groovy/groovy-core/blob/master/src/main/org/codehaus/groovy/reflection/ReflectionUtils.java#L105