Results 1 to 3 of 3
Thread: Updating class
- 02-06-2012, 12:29 AM #1
Member
- Join Date
- Feb 2012
- Posts
- 2
- Rep Power
- 0
Updating class
Hello all,
I'm trying to figure out how I can update (or reload) a class file during runtime. Instead of replacing the class file in the jar manually, I'd like to 'replace' it at runtime. This is what I got so far, even though it doesn't seem to actually do what I expect to see when it works:
As you can see is "/com/dannycrafts/classes/ThreadLoginVerifier.class" my own version of "net.minecraft.server.ThreadLoginVerifier".Java Code:URL url = getClass().getResource( "/com/dannycrafts/classes/ThreadLoginVerifier.class" ); ClassLoader classLoader = URLClassLoader.newInstance( new URL[]{ url } ); classLoader.loadClass( "net.minecraft.server.ThreadLoginVerifier" );
I would think that this would do the job, but I'm not quit sure if it does.
Also, I am afraid that just a new version of the class is loaded and that everything that was using the class before is still using the old version.
Can anyone help me with this if you know what I'm trying to achieve?
Thanks.
- 02-06-2012, 12:40 AM #2
Re: Updating class
I don't know of a way to replace a previously loaded class. If the JVM has links to the current version of a class, replacing the current version could break the system.
Can you make your version available BEFORE the other version is loaded so your version is the one loaded?
- 02-10-2012, 07:33 PM #3
Member
- Join Date
- Feb 2012
- Posts
- 2
- Rep Power
- 0
Similar Threads
-
Updating JDK
By sandz24 in forum New To JavaReplies: 4Last Post: 01-20-2012, 03:34 AM -
Updating the Instance Variable of a Class
By Leo11221 in forum New To JavaReplies: 19Last Post: 12-01-2011, 05:07 PM -
Updating a JLabel from another class.
By Fumomo in forum AWT / SwingReplies: 6Last Post: 05-04-2011, 04:31 PM -
Updating my gui
By mrx89_7 in forum New To JavaReplies: 4Last Post: 02-09-2011, 05:33 AM -
Updating my GUI
By Catkill in forum AWT / SwingReplies: 6Last Post: 09-01-2009, 05:09 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks