I have written a List implementation that internally makes use of java.util.ArrayList and java.util.LinkedList. Now, I have a set of JARs that I want to dynamically load and then invoke from Java, but with my implementation redirected everywhere it uses LinkedList or ArrayList.
Is there a way to do this without having to download the source to the JARs, manually replacing everything and then recompiling?
You can copy the Java installation into a new place, compile your code as java.util.ArrayList
and java.util.LinkedList
(ie compile your code with the rt.jar
on the classpath).
Then use jar -u
to put the new classes into rt.jar
. Since rt.jar
isn't signed, you don't have to modify anything else.
This gives you a new rt.jar
for the copy of your Java installation. Replace the file and start the projects using java
from the new copy. The code will now pick up your versions.
Depending on which Java version you use, you can also try to set the "boot classpath". Create a JAR with your replacement classses and put them first into this classpath. Documentation for Oracle's VM .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.