Yes Alan correct: I wrongly asumed ist a separate stack. So it is a non-issue.
I tried it out and having a doPriv(lambda) block shortens the possible overall thread dept by about 200 calls (with my simple stack usage). BTW: the main thread does behave a bit less predictable: (run results at end of file) https://github.com/ecki/JavaSystemTest/blob/master/src/main/java/net/eckenfels/test/javasystemtest/StackDepth.java#L86 Greetings Bernd -- http://bernd.eckenfels.net Von: Alan Bateman Gesendet: Montag, 20. November 2017 22:02 An: Bernd Eckenfels; OpenJDK Dev list Betreff: Re: Eliminating the security overhead when not running with asecuritymanager On 20/11/2017 20:15, Bernd Eckenfels wrote: : One thing which might be a problem: when doPrivileged does no longer execute the Code in a seperate stack this has implications to the runtime. The stacks will get deeper (and might even overflow (more often)). So maybe this „no seperate stack“ function should be opt-out (if implemented). Are you assuming that the execution of the privileged action is done on a different thread stack? The effect of doPrivileged is to set the top of the privileged stack on the current thread stack, it gets restored when the action completes. So I think there isn't anything to be concerned about here. -Alan