title: why static transient field is serialized?
body: <p>I´ve been reading that the static fields are not serialized but, after testing it, I saw that´s not true.</p>
  
  <p>The static modifier even overrides the transient modifier and makes the field serializable.</p>
  
  <p>I write one example from a book that shows that a static transient field is serialized.</p>
  
  <pre><code>import java.io.*;
  
  class USPresident implements Serializable {
  
      private static final long serialVersionUID = 1L;
  
      @Override
      public String toString() {
          return "US President [name=" + name
                  + ", period=" + period + ", term=" + term + "]";
      }
  
      public USPresident(String name, String period, String term) {
          this.name = name;
          this.period = period;
          this.term = term;
      }
      private String name;
      private String period;
      private  static transient  String term;
  }
  
  class TransientSerialization {
  
      public static void main(String[] args) {
          USPresident usPresident = new USPresident("Barack Obama", "2009 to --", "56th term");
          System.out.println(usPresident);
          try (ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("USPresident.data"))) {
              oos.writeObject(usPresident);
          } catch (IOException ioe) {
  // ignore
          }
          try (ObjectInputStream ois = new ObjectInputStream(new FileInputStream("USPresident.data"))) {
              Object obj = ois.readObject();
              if (obj != null &amp;&amp; obj instanceof USPresident) {
                  USPresident presidentOfUS = (USPresident) obj;
                  System.out.println(presidentOfUS);
  
              }
          } catch (IOException ioe) {
  // ignore
          } catch (ClassNotFoundException e) {
  // ignore
          }
      }
  }
  </code></pre>
  
  <p>Is wrong the general concept that static fields are not serialized? Is it just a recommendation?
  Why the transient modifier doen't take effect with static ?</p>
  
  <p>note: I understand that initialize a static field in a constructor is an odd code, but the compiler let me do it and it's just in order to understand static fields serialization.</p>