title: Java set security permission of created instances
body: <p>So I have a bit of code, that creates an instance of a class.</p>
  
  <pre><code>Class&lt;?&gt; c = Class.forName("MyClass");
  Constructor&lt;?&gt; cons = c.getConstructor();
  cons.setAccessible(true);
  Object instance = cons.newInstance();
  </code></pre>
  
  <p>Now I want to set some restrictions to that instance. When I call:</p>
  
  <pre><code>instance.doSomething();
  </code></pre>
  
  <p>I want to set restrictions for that bit of code (of the instance). So the methods called from that isntance can not do something fishy (System calls, File operations...).</p>
  
  <p>I have tried to set a security manager, but that restricts all of the code (I still want to read/write files for the rest of my code).
  Is it possible to restrict only certain objects?</p>