title: Set private field value with reflection
body: <p>I have 2 classes: <code>Father</code> and <code>Child</code></p>
  
  <pre><code>public class Father implements Serializable, JSONInterface {
  
      private String a_field;
  
      //setter and getter here
  
  }
  
  public class Child extends Father {
      //empty class
  }
  </code></pre>
  
  <p>With reflection I want to set <code>a_field</code> in <code>Child</code> class:</p>
  
  <pre><code>Class&lt;?&gt; clazz = Class.forName("Child");
  Object cc = clazz.newInstance();
  
  Field f1 = cc.getClass().getField("a_field");
  f1.set(cc, "reflecting on life");
  String str1 = (String) f1.get(cc.getClass());
  System.out.println("field: " + str1);
  </code></pre>
  
  <p>but I have an exception:</p>
  
  <blockquote>
    <p>Exception in thread "main" java.lang.NoSuchFieldException: a_field</p>
  </blockquote>
  
  <p>But if I try:</p>
  
  <pre><code>Child child = new Child();
  child.setA_field("123");
  </code></pre>
  
  <p>it works.</p>
  
  <p>Using setter method I have same problem:</p>
  
  <pre><code>method = cc.getClass().getMethod("setA_field");
  method.invoke(cc, new Object[] { "aaaaaaaaaaaaaa" });
  </code></pre>