title: Using reflection get a static private hashmap in java
body: <p>I'm trying to find a way to extract a HashMap from a private static field within another class via Java.</p>
  
  <p>eg.</p>
  
  <p>Inside FooClass there is a static field that looks like this:</p>
  
  <pre><code>private Map entityRenderMap;
  </code></pre>
  
  <p>Then in its construct it has:</p>
  
  <p><code>entityRenderMap = new HashMap();</code></p>
  
  <p>How do you get the values within entityRenderMap via Reflection in Java? I've tried this but get errors:</p>
  
  <pre><code>cl = RenderManager.class.getDeclaredField("entityRenderMap");
          cl.setAccessible(true);
          Object foo = cl.get(this.entityRenderMap);
          Mod.log(cl.getName());
  </code></pre>
  
  <p>The error I get is:</p>
  
  <pre><code>java.lang.IllegalArgumentException: Can not set java.util.Map field RenderManager.entityRenderMap to java.util.HashMap
  at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(Unknown Source)
  at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(Unknown Source)
  at sun.reflect.UnsafeFieldAccessorImpl.ensureObj(Unknown Source)
  at sun.reflect.UnsafeObjectFieldAccessorImpl.get(Unknown Source
  </code></pre>