title: Reference to final object in anonymous class constructor a leak?
body: <p>I'm passing a runnable to a service.  The runnable duration may outlive the fragment / activity that passes it.  I'm wondering if the following code snippet would leak the frag object by maintaining a reference inside the runnable?  I realize I can move the whole line containing frag outside of the runnable (like I did with "String key = frag..."), but I'm asking simply to get an understanding of how/when an anonymous class would leak an object.</p>
  
  <p>I'm really not certain.  The runnable only needs frag to determine a variable upon initializing the instance, and it's initialized in-line here.  So in theory, it doesn't need to have any reference to frag after creating the in-line instance.  </p>
  
  <p>If I had a reference to frag in the run() function, I would think a leak then would be guaranteed as it would need to keep frag alive to reference it sometime in the future (and frag might very well be gc'd at that point, but for the reference).</p>
  
  <pre><code>private static void fg_downloadFile(final FragMyDrive frag, final File file, final Drive drive){
  
      final String key = frag.getCastedActivity().getKey();
  
      Runnable rx_downloadFile = new Runnable() {
  
          Context ServiceContext = frag.getCastedActivity().mService;
  
          @Override
          public void run() {
  
              bg_downloadFile(ServiceContext, key, file, drive);
          }
      }; 
  
      //.... Submit runnable to service...
  }
  </code></pre>