Running with a security manager?

mandy chung mandy.chung at oracle.com
Sat Mar 10 06:37:12 UTC 2018


If you need to grant permission, you can do this:

* @run main/othervm/java.security.policy=<policy file> TestReflectionAPI

If no policy needed, you can set security manager 
(System::setSecurityManager) at the beginning of the test and run in 
othervm mode:
* @run main/othervm TestReflectionAPI

Mandy

On 3/9/18 8:16 PM, David Holmes wrote:
> I want to run a test with a default security manager present. So I 
> added it to the @run:
>
> @run main/othervm -Djava.security.manager TestReflectionAPI
>
> But this breaks jtreg:
>
> Exception in thread "main" java.security.AccessControlException: 
> access denied ("java.io.FilePermission" 
> "/export/users/dh198349/valhalla/repos/valhalla-exp/open/test/hotspot/jtreg/JTwork/runtime/Nestmates/reflectionAPI/TestReflectionAPI.d/main.2.jta" 
> "read")
>     at 
> java.base/java.security.AccessControlContext.checkPermission(AccessControlContext.java:472)
>     at 
> java.base/java.security.AccessController.checkPermission(AccessController.java:895)
>     at 
> java.base/java.lang.SecurityManager.checkPermission(SecurityManager.java:335)
>     at 
> java.base/java.lang.SecurityManager.checkRead(SecurityManager.java:674)
>     at java.base/java.io.FileInputStream.<init>(FileInputStream.java:147)
>     at java.base/java.io.FileInputStream.<init>(FileInputStream.java:113)
>     at java.base/java.io.FileReader.<init>(FileReader.java:58)
>     at 
> com.sun.javatest.regtest.agent.MainWrapper.main(MainWrapper.java:46)
>
> So I presume I need some kind of policy file that gives jtreg 
> necessary permissions while trying to leave the actual test code with 
> the normal default permissions.
>
> How do I do that?
>
> Thanks,
> David

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/jtreg-use/attachments/20180309/a7cd2c98/attachment.html>


More information about the jtreg-use mailing list