same is a GUI-based tool that detects duplicate code chunks within a set of Java files. In a sense it is the opposite of the UNIX diff tool. In a nutshell, same normalizes Java code and is able to find duplicate code chunks even when the formatting is radically different, when the variable name has changed, and even when constants have changed.
Same can run in three modes. It has a GUI which lets you see the code side by side.
Additionally, it can be invoked via the command line.
java -cp same-0_40.jar console.App --help usage: App [-s null] [-d] [-v] [-t] [-l] -d,--dumpast dump ast representation -l,--literals anonymize literals -s,--statements minumum number of statements in a block. default 4 -t,--types anonymize types -v,--variables anonymize variable names
Or, Same can be invoked via Ant as part of the build process:
<target name='quality' description='Run the same ant task against this project'>
<taskdef name='same' classname='console.ant.Same' classpath='lib/build/same.jar'/>
<same src='src' minlengthforchunk='5' quiet='true' anonymizetypes='true'/>
</target>Same can be used to replace RedHill's Simian or PMD's CPD for Java code bases.