2 ms·
> Do you know anyone who does that in their test suite? I'd love to chat with them. I do. Not often, as I don't have a lot of IO in my tests, but I've found th
by pron 11y ago
> Do you know anyone who does that in their test suite? I'd love to chat with them.
I do. Not often, as I don't have a lot of IO in my tests, but I've found the security manager useful for that purpose from time to time. I also use it to help our users enforce global contracts, such as prohibit IO or any blocking code in fork-join computations.
- chadaustin 11y agoThat's cool. I chatted with a friend about this too and they said they've used SecurityManager in this way. But one thing they said is that SecurityManager can't be used to restrict things like accessing the current time. Do you know if that's true or not?
- pron 11y agoThat's true -- out of the box. As with all things JVM, this, too is very pliable. You can create a new permission -- "access clock" -- and then it is quite easy to use an agent to inject a call for the security manager to check for this permission whenever the clock is accessed. In fact, since we started this discussion, I've written a small library that uses an agent to fake all clock accesses on the JVM with a user-supplied virtual clock, that can be set globally or per-thread. Injecting s security check is even easier.