Proposed API for JEP 259: Stack-Walking API (original) (raw)
Mandy Chung mandy.chung at oracle.com
Sat Oct 31 22:59:01 UTC 2015
- Previous message: Proposed API for JEP 259: Stack-Walking API
- Next message: Proposed API for JEP 259: Stack-Walking API
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Oct 31, 2015, at 11:29 AM, Remi Forax <forax at univ-mlv.fr> wrote:
Hi Mandy, I've crawled the code and the documentation again. In the doc and in the code, a lambda with one parameter doesn't require parenthesis around the parameter, (s) -> s.doSomething() should be s -> s.doSomething().
Oh right. (It didn’t look right to me but didn’t pay attention to it).
In the doc of StackWalker, in the first example, the local variable 'frame' should be named ‘callerClass'
Fixed
In the doc of getCallerClass(), the first example do a skip(2) which i believe is not necessary anymore,
It has to skip two frames. Use the second example, the stack looks like this:
StackWalk::getCallerClass Util::getResourceBundle Foo::init ::
also instead of Optional.orElse, orElseGet is better because it avoids to evaluate Thread.currentThread().getClass() if not necessary.
So the example should be: walk(s -> s.map(StackFrame::getDeclaringClass) .findFirst()).orElseGet(() -> Thread.currentThread().getClass());
This would return Util.class instead of Foo.class
In the second example, the field walker should be declared 'final’.
Sure. Fixed.
And as i said earlier, the signature of walk() is: T walk(Function<? super Stream<StackWalker.StackFrame>, ? extends T> function, IntUnaryOperator batchSizeMapper)
I was pondering it and that’s why not changed in the last update. I agree with the upper bounded wildcard "? extends T” for the return type of the function.
But for the function’s input argument, can you help me understand why it should take "? super Stream<StackWalker.StackFrame>”? Is it useful to have function accepting supertype of Stream rather than Stream? VM should be the only source producing this StackFrame stream.
On the other hand, I wonder if the stream argument should be Stream<? extends StackFrame> that may allow future implementation change.
T walk(Function<Stream<? extends StackWalker.StackFrame>, ? extends T> function, …)
Mandy
- Previous message: Proposed API for JEP 259: Stack-Walking API
- Next message: Proposed API for JEP 259: Stack-Walking API
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]