• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How does JVM detect updated class files ??

 
Ranch Hand
Posts: 184
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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' ??
 
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
abhishek pendkay
Ranch Hand
Posts: 184
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 1970
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
abhishek pendkay
Ranch Hand
Posts: 184
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Peter , but I still dont understand how does JVM detect that the class file has been updated..???
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Peter Chase
Ranch Hand
Posts: 1970
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 184
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic