dcsimg
Can I change the contents of a class file externally
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Ranjan_Sinha
Posted On:   Wednesday, June 13, 2001 02:52 AM

We can modify an exe by changing a hardcoded character array externally. Can we do the same with class files?

For example Consider

String someString = "PLACE_HOLDER";
Now I compile the program and using some external program (In any language)
I open the class file in binary mode and change the value of someString. I ve read that this value goes in class' fields in the class file. But can I retrieve and change this. Thanks in advance.

Re: Can I change the contents of a class file externally

Posted By:   Luigi_Viggiano  
Posted On:   Wednesday, June 13, 2001 03:56 AM

Yes it's possible, but for those things you should use property file (something like a .ini configuration file) to store changeable data outside the class (i.e. error messages). You are not free at all to make any binary change in a class file because, loading the class, the JVM performs a validity verification of the bytecode, and you can make easily a corrupted class. Personally, I consider an ugly practice to change executable binary files, not only in Java platform. This kind of hacks can reveal dangerous aspects that can make your app to fail.
About | Sitemap | Contact