Skip to content

Instantly share code, notes, and snippets.

@bitkill
Created February 4, 2020 14:40
Show Gist options
  • Save bitkill/87cf9d114610de1433d54bfd658bd198 to your computer and use it in GitHub Desktop.
Save bitkill/87cf9d114610de1433d54bfd658bd198 to your computer and use it in GitHub Desktop.
Jar class collision finder
#!/bin/bash
if [ $# == 0 ]; then
dir='.'
elif [ $# == 1 ]; then
dir=$1
else
echo "Usage: $0 [dir]";
exit 1;
fi
for lib in `find $dir -name '*.jar'`; do
for class in `unzip -l $lib | egrep -o '[^ ]*.class$'`; do
class=`echo $class | sed s/\\\\.class// | sed s/[-.\\/$]/_/g`
existing=$( eval "echo \$CLS_${class}" )
if [ -n "$existing" ]; then echo "$lib $existing"; fi
eval CLS_${class}="\"${lib} ${existing}\""
done
done | sort | uniq -c | sort -nr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment