title: Accessing package-private fields in Java
body: <p>Poking around Android API sources. There's <code>FileDescriptor</code> with a data member <code>descriptor</code> with no access modifier:</p>
  
  <pre><code>int descriptor;
  </code></pre>
  
  <p>Then there's class <code>FileOutputStream</code> that constructs a new FileDescriptor and assigns to that field:</p>
  
  <pre><code>fd = new FileDescriptor();
  fd.descriptor = fileSystem.open(...);
  </code></pre>
  
  <p>How is that compatible with the field access control model of Java? I thought package-private fields are not accessible from outside the declaring class, and there's no notion of friendship like in C++.</p>