I don't think there is a (reliable) easy way. There is an unreliable way though: temporarily replace that code with something that just calls startServer
, and try running it in a security sandbox.
I suspect that the doPrivileged
call is needed though. A method with that name and a port
parameter is likely to try to create / bind / listen on a ServerSocket
. The latter will fail if the SecurityManager.checkListen
method does not allow the operation ... which it won't do in a typical sandbox. (We don't normally want untrusted code to be able to start stealth network services ...)