title: Access package-private variables using reserved package name
body: <p>I was studying the source code of <a href="http://www.java2s.com/Open-Source/Java-Document/6.0-JDK-Core/Collections-Jar-Zip-Logging-regex/java/util/HashMap.java.htm" rel="nofollow"><code>java.util.HashMap</code></a> and I wanted to see how well the hashcode function distributes the key's in the internal array of <code>Entry</code>'s(<em>which is a package private variable</em>).So I made a package named <code>java.util</code> in my project just to check weather I can fool the compiler to think it's the same package.Surprisingly it worked and I wrote the following code:</p>
  
  <pre><code>package java.util;
  
  public class HashMapExt&lt;K, V&gt; extends HashMap&lt;K, V&gt; implements Map&lt;K, V&gt; {
  
      public static void main(String[] args) {
          HashMapExt&lt;Integer, String&gt; mp = new HashMapExt&lt;Integer, String&gt;();
          mp.put(1, "Hello");
          mp.put(2, "Map");
          mp.put(3, "Extention");
          mp.printData();
      }
  
      void printData() {
  
          System.out.println(Arrays.toString(table));
      }
  }
  </code></pre>
  
  <p>It compiled successfully but while running it gave an exception:</p>
  
  <pre><code>Exception in thread "main" java.lang.SecurityException: Prohibited package name: java.util
      at java.lang.ClassLoader.preDefineClass(Unknown Source)
      at java.lang.ClassLoader.defineClass(Unknown Source)
      at java.security.SecureClassLoader.defineClass(Unknown Source)
      at java.net.URLClassLoader.defineClass(Unknown Source)
      at java.net.URLClassLoader.access$000(Unknown Source)
      at java.net.URLClassLoader$1.run(Unknown Source)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(Unknown Source)
      at java.lang.ClassLoader.loadClass(Unknown Source)
      at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
      at java.lang.ClassLoader.loadClass(Unknown Source)
      at java.lang.ClassLoader.loadClassInternal(Unknown Source)
  </code></pre>
  
  <p>Now the question is, is it possible to change the default security model so that I can access the internal variable <code>table</code> or is there any other alternative (<em>maybe  by using reflection</em>) ?</p>