Get value of final field of a static class using reflection
<p>I have following class structure:</p>

<pre><code>       private static class MyStaticClass {  
          public final String name;  
          public final String photoUri; 
          private MyStaticClass(String pName, String pPhotoUri) {
               this.name = pName;
               this.photoUri = pPhotoUri;
          }

          public static MyStaticClass getNewMyStaticClass(String pName) {
              return new MyStaticClass(pName, null);
          }
       } 
</code></pre>

<p>Now when I want to read the value of "name" and "photoUri" fields, it gives me "Object is not an instance of class". Following is the code:</p>

<pre><code>void printValues() {
    try {
        Class cls = Class.forName("my.pkg.name.TestClass$MyStaticClass");
        for(Field field: cls.getDeclaredFields()) {
            System.out.println("Field name: " + field.getName());
            System.out.println("Field value: " + field.get(cls));
        }
    } catch (Throwable e) {
        e.printStackTrace();
    }
}
</code></pre>

<p>I also tried to pass "null" at field.get(null) to read the value but it gives null pointer exception.</p>

<p>Please help me, how can I read the value of the field "name" and "photoUri"?</p>
