• 0

[Java] Replacing parts of the java.* heirarchy


Question

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

  • 0

It got my answer, and it's a no. There's a hard-coded restriction in the ClassLoader (at least in OpenJDK 6) that prevents anyone from defining a class in java.* so I'm just gonna rename the package while I try things out.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.