title: Passing std::unique_ptr to JNI
body: <p>I'm wrapping some C++ code with JNI, and stumbled upon the following factory function:</p>
  
  <pre><code>std::unique_ptr&lt;MetricPlanner&gt; create_metric_planner(*arguments*)
  </code></pre>
  
  <p>I need to pass a reference to the planner this function creates back to Java for later use, but am confounded as to
  a) how to pass it back, and
  b) what will happen to it once it gets passed on.</p>
  
  <p>Normally, I've been passing like so:</p>
  
  <pre><code>Director *DIRECTOR = new Director(arguments);
  return (jlong)DIRECTOR;
  </code></pre>
  
  <p>and it's worked like a charm.</p>
  
  <p>Can someone explain the analogous process for referencing objects with JNI when a factory function returning this type of pointer is used, instead of a normal constructor?</p>