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
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.
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
posted
0
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
posted
0
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
posted
0
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
posted
0
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.