aspose file tools
The moose likes Java in General and the fly likes How does JVM detect updated class files ?? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "How does JVM detect updated class files ??" Watch "How does JVM detect updated class files ??" New topic
Author

How does JVM detect updated class files ??

abhishek pendkay
Ranch Hand

Joined: Jan 01, 2007
Posts: 184
I unzipped 'rt.jar' and updated the ArrayIndexOutOfBoundsException class file to display new message instead of the original... then I replaced the original class file with the new one in 'rt.jar'.... but when I try to execute this class it gives me the message "updated class file executed"...
now my question is how does JVM detect that the class file has been updated ,cause I did not change the contract of that class... does it mantain any field similar to 'serialVersionUID' or does it mantain some sort of 'timestamp' ??


The significant problems we face cannot be solved by the same level of thinking which created them – Einstein
SCJP 1.5, SCWCD, SCBCD in the making
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

Why on Earth would you want to replace ArrayOutOfBoundsException, just to change the message? You know that there is also a constructor that takes a string as its message? Using that is much safer.


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
abhishek pendkay
Ranch Hand

Joined: Jan 01, 2007
Posts: 184
OK maybe my question is not very clear...
My idea was not to replace the message in ArrayIndexOutOfBounds ... my idea was to see if this technique works... ArrayIndexOutOfBounds was just a class i choose by chance and i changed the message cause i that change would not voilate the contract of the class ( in Java sense not legal contract) ....
So my question again how does JVM know the class has been changed..??

[ March 17, 2008: Message edited by: abhishek pendkay ]
[ March 17, 2008: Message edited by: abhishek pendkay ]
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32654
    
    4
Don't know, but it is just as well; you are in breach of your licence agreement altering classes with java. in their package name.
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
In the very rare case that you need to replace Sun's version of a java.* class, there is an approved mechanism. Use the "boot class path" (-Xbootclasspath option to java command).

Changing rt.jar ist verboten.


Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.<br /> <br />#:^P
abhishek pendkay
Ranch Hand

Joined: Jan 01, 2007
Posts: 184
Thanks Peter , but I still dont understand how does JVM detect that the class file has been updated..???
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35240
    
    7
It could be using any number of methods - e.g. the modification date of the rt.jar file, or a checksum or hash of its contents. If it does the latter, that would be rather tricky to circumvent.


Android appsImageJ pluginsJava web charts
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
Originally posted by abhishek pendkay:
Thanks Peter , but I still dont understand how does JVM detect that the class file has been updated..???


I suspect you're the only one who cares.
abhishek pendkay
Ranch Hand

Joined: Jan 01, 2007
Posts: 184
yeah maybe i am a bit too curious about it....
anyway Peter's information is very usefull
[ March 18, 2008: Message edited by: abhishek pendkay ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How does JVM detect updated class files ??
 
Similar Threads
From where JVM takes classes(API) ?
java redirection
Do the JVM's Calendar/Date objects use the system's tzdata for daylight savings time changes?
Do we Recompile the java file if rt.jar is changed?
Can jsdk.jar and rt.jar be merged together?