I just wanted to play around with the jdk . Like changing the implementation of some algo in some utilities in java.util etc . I just tried copying Treemap to a new class but in the same package java.util . But when i try to use my copied class , I get
Exception in thread "main" java.lang.SecurityException: Prohibited package name: java.util
at java.lang.ClassLoader.preDefineClass(Unknown Source)
at java.lang.ClassLoader.defineClassCond(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 Test.main(Test.java:7)
But i cant change the package also since Treemap is using some package access stuff from other classes in java.util .
I jst told what i did . But please do tell me if there is an easier way to change some part of jdk implementation and use the modified code ?
Use
-Xbootclasspath/p:mydirto load you classes into the bootstrap class loader in preference to the system classes. (pis prepend.)If you want to make a copy of the classes instead of replace them, then they will need to be outside of the
java.If it depends upon package-private access, then you’ll need to copy the other classes to (or make them public in place with-Xbootclasspath/p:). package hierarchy.