Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding differences between versions of a Java class file

I am working with a large Java web application from a commercial vendor. I've received a patch from the vendor in the form of a new .class file that is supposed to resolve an issue we're having with the software. In the past, applying patches from this vendor have caused new and completely unrelated problems to arise, so I want to understand the change being made even before applying it to a test instance.

I've got the two .class files side by side, the one extracted from the currently running version and the updated one from the vendor. JAD and JReversePro both decompile and disassemble (respectively) the two versions to the same output. However, the .class files are different sizes and I see differences in the output of od -x, so they're definitely not identical.

What other steps could I take to determine the difference between the two files?


Conclusion:

Thanks for the great responses. Since javap -c output is also identical for the two class files, I am going to conclude that Davr's right and the vendor sent me a placebo. While I'm accepting Davr's answer for that reason, it was Chris Marshall and John Meagher who turned me on to javap, so thanks to all three of you.

like image 453
Anonymoose Avatar asked Sep 17 '08 22:09

Anonymoose


People also ask

How do I find the compiled version of a class file?

In Java, we can use javap -verbose className to print out the class information. D:\projects>javap -verbose Test Classfile /D:/projects/Test. class Last modified 16 Apr 2019; size 413 bytes MD5 checksum 8679313dc0728e291898ad34656241cb Compiled from "Test.

How can I compare two class files?

right click on a file and “Compare” then choose a file on my hard drive to compare with. select two classes in the project view and right click to “Compare” select code, add it into the clipboard, then highlight a different block of code and “Compare with Clipboard”

What is Javap command in Java?

DESCRIPTION. The javap command disassembles one or more class files. Its output depends on the options used. If no options are used, javap prints out the package, protected, and public fields and methods of the classes passed to it. javap prints its output to stdout.

What is Java major version?

Java 8 uses major version 52.


1 Answers

It's possible that they just compiled it with a new version of the java compiler, or with different optimization settings etc, so that the functionality is the same, and the code is the same, but the output bytecode is slightly different.

like image 119
davr Avatar answered Oct 05 '22 04:10

davr