The Java purists out there would probably hate me for even suggesting this, but I'm doing a bit of experimenting with some classes from the Apache Harmony project and need to replace parts of java.* with an implementation I provide. I know I can do this by pre-pending a boot classpath as an argument to the Java runtime. However, I'd like to do his programatically instead since the target runtime is one where I can't change the classpath. I've looked at ClassLoader and have written a basic one that loads from the filesystem and my provided jars before falling back on the default. Unfortunately, ClassLoader.defineClass won't let me load a class who's name begins with "java." and raises a SecurityException when I try to. So my question is, how do I get around this, or if it's even possible?
Question
MrA
The Java purists out there would probably hate me for even suggesting this, but I'm doing a bit of experimenting with some classes from the Apache Harmony project and need to replace parts of java.* with an implementation I provide. I know I can do this by pre-pending a boot classpath as an argument to the Java runtime. However, I'd like to do his programatically instead since the target runtime is one where I can't change the classpath. I've looked at ClassLoader and have written a basic one that loads from the filesystem and my provided jars before falling back on the default. Unfortunately, ClassLoader.defineClass won't let me load a class who's name begins with "java." and raises a SecurityException when I try to. So my question is, how do I get around this, or if it's even possible?
Link to comment
Share on other sites
1 answer to this question
Recommended Posts