I want to load my own java.lang.String
public class StringCustomClassFactory {
public static String newInstance() {
URLClassLoader tmp = new URLClassLoader(new URL[] {new URL("file:///home/.../target/classes/") }) {
public Class loadClass(String name) {
if ("java.lang.String".equals(name))
return findClass(name);
return super.loadClass(name);
//exception handling is omitted
}
};
return (String) tmp.loadClass("java.lang.String").newInstance();
//...
But I constantly receive exception:
Exception in thread "main" java.lang.SecurityException: Prohibited package name: java.lang
- In this tutorial I've read that it possible to load your own SecurityManager
The security of the system can be compromised if your class loader returned its own value of java.lang.SecurityManager, which did not have the same checks as the real one did.
- And here I have read that it possible to disable SecurityManger
What would you recommend me to solve this problem and is it solvable at all?