Similarity detection among Java class files - Ong, Rebecca U. (2005)
Although there are a variety of existing tools that detect similarities among sets of Java files, majority of these tools require the Java source codes to be available. Measure of Software Similarity (MOSS), JPlag and Software Integrity Diagnosis System (SID) are some of these similarity detectors that work with source codes. There are instances, however, wherein only the class file and not the source code itself is available. To handle this problem and extend the use of similarity detectors to other applications as well, the need for similarity detectors handling bytecodes arises. There is a scarcity of such type of tools. Brenda Baker and Udi Manber had implemented a Java bytecode similarity detector but it is not available for public use and only some details on how the tool works were discussed in their paper. In this thesis, we have implemented a similarity detecting tool that works with class file as inputs. Since we are no longer analyzing the source codes themselves, similarity is now measured mainly in terms of resemblance in bytecode structure and functionalities incorporated in the codes. The main advantage of having this type of tool working with class files is the ability to handle similarities among files which may be written using other programming languages, so long as these files could be converted to Java bytecodes. As of now, such compilers, particularly those converting C to bytecodes, are still in the experimental stage. Maturity of these compilers would extend the capability of Java bytecode similarity detectors to handle similarity among files written in other languages as well. Our implementation does not directly manipulate and analyze bytecodes themselves. Rather, it works with disassembled codes that can be generated from the input class files. To evaluate the performance of the tool, it has been executed on a set of test programs which includes assignments and exercises in some Java programming course. The same set of programs was executed on MOSS. Similarity percentage results produced by both tools were then compared. It has been observed that the implemented tool performs as well as MOSS if not better for similarity types explicitly considered and those that were automatically handled at bytecode level. However, the detector gave lower similarity percentage results for similarities involving insertion of additional statements and reordering of statements.