In my project I had a jar file, now I need to change the code in one of the class in that jar.
I don't have source code version of that jar, was compiled using java 1.5 which uses generics as well.
I need to decompile, recompile and place the new class in that jar, will it work?
Please suggest me the best decompiler which decompiles java 1.5 class files.
I hate to say it, but when you decompile a class file you're not going to get the exact source file. Comments don't exist in class files. Parameter and local variable names are not stored in class files. And worst of all, because of type erasure, generic information does not exist in class files.
Really? Interesting. I guess the JAD version I'm using is too outdated then.
Joined: Mar 22, 2005
Yep, jad was never updated to deal with generics. JODE wasn't either (publicly), but I was successful in enhancing it to make use of a fair amount of the available information to create source files that have more of the Java 5 stuff.
Uday Shankar Mareedu
Joined: Jun 30, 2012
I had tried with JD-GUI, JAD, DJ but no luck.
I am getting exception hierarchy errors and type cast errors for collections.
Please help me out to resolve this, it is very important for me to move further.
Before you continue, are you sure you're even allowed to modify the classes inside the JAR file? If it's a third party library JAR file and it's been released under some non open source license, decompiling the classes and modifying their contents may be illegal. If it's a JAR file created by the company you work for, the code should still be available. Of course it doesn't have to be unfortunately...
Second: Further to what Rob said, even if you are allowed to do it, I'd be very leery of any "solution" based on a decompilation. Reverse-engineering is tricky stuff. I hope you've run it by your boss AND told him about all the possible downsides.
Isn't it funny how there's always time and money enough to do it WRONG?