How to run a benchmark with SecurityManager?

Weijun Wang weijun.wang at oracle.com
Tue Jan 27 16:00:53 UTC 2015



On 1/27/2015 20:29, Dmitry Chuyko wrote:
> Ah, sorry, it won't work that way.

But maybe I can create a policy file to grant AllPermission to the main 
jar and some permission to my own codes.

> Does setting security manager inside
> benchmark method work?

Not sure. But I don't like it. The method should only do what I want to 
benchmark.

--Max

> If yes, baseline benchmark could be used to
> estimate additional cost of changing SM back and forth.
>
> --
> Dmitry
>
>
> On 01/27/2015 03:21 PM, Dmitry Chuyko wrote:
>> Hi Max,
>>
>> Can't you pack your class+method into separate jar and use
>> URLClassloader with security manager in setup?
>>
>> --
>> Dmitry
>>
>> On 01/27/2015 01:52 PM, Wang Weijun wrote:
>>> Hi All
>>>
>>> I'm trying to benchmark a method that works differently when a
>>> SecurityManager is on (and with different policy files). I've tried
>>> adding -Djava.security.manager on the command line or calling
>>> System.setSecurityManager(new SecurityManager()) inside a @Setup
>>> method, but seems jmh itself cannot run correctly (because it needs
>>> reflection and thread group manipulation).
>>>
>>> Is there anyway to do it? Since JM itself and the benchmark is
>>> compiled into one jar, I cannot grant AllPermission to jmh and less
>>> permission on my own code.
>>>
>>> Thanks
>>> Max
>>>
>>
>


More information about the jmh-dev mailing list