You can decompile the bytecode contents of a jar-file from the Decompile pane. You need to provide access to an external decompiler such as SourceAgain or Soot.
You need to provide a program
jDecompile jardir class classpath
java.lang.Object
) name of
the class that should be decompiled. If class is
set to ALLCLASSES
the program should return the result of decompiling all
classes in jardir.
For example, jDecompile
might be called like
this:
> jDecompile /tmp/smkCFC94620 myprogram.mypackage.MyClass > jDecompile /tmp/smkCFC94620 ALLCLASSES > jDecompile /tmp/smkCFC94620 TTTApplication sandmark.jar > jDecompile /tmp/smkCFC94620 ALLCLASSES sandmark.jar
Here is an example jDecompile
script that works for the
SourceAgain decompiler running under Unix:
#!/bin/csh -f set jarPath = $1 set className = $2 set classPath = $3 set JDK = /cs/linux/j2sdk1.4.2_02 # FIX THIS PATH! set RT = $JDK/jre/lib/rt.jar set CFG = /home/collberg/share/SourceAgain.cfg # FIX THIS PATH! set SA = /home/collberg/bin/srcagain # FIX THIS PATH! if ($classPath != "") then set CP = {$RT}:{$jarPath}:{$classPath} else set CP = {$RT}:{$jarPath} endif set CMD = "$SA -name $CFG -ilocal -topdecl -tabwidth 3 -i $CP" if ($className == "ALLCLASSES") then foreach i (`find $jarPath -name \*.class`) echo "-------------------- " $i $CMD $i echo end else $CMD $className endif exit 0
SourceAgain.cfg
is SourceAgain's configuration file.
It could look like this:
int: i j k l m n o p i# smNode: A B C D E F G A# long: l# float: f# double: d# char: c# byte: by# boolean: b# short: sh# java.lang.Object: o# java.lang.String: S T U V S# java.lang.Integer: I J K L M N O P I# #array: prefix a #temp: prefix t #default: short lower @
soot
decompiler can be downloaded
from
http://www.sable.mcgill.ca/soot .
Here is an example script that works for Soot running under Unix:
#!/bin/csh -f set jarPath = $1 set className = $2 set classPath = $3 set JDK = /cs/linux/j2sdk1.4.2_02 # FIX THIS PATH! set RT = $JDK/jre/lib/rt.jar set SOOT = /home/collberg/smark/smextern3 # FIX THIS PATH! set SOOTCP = $SOOT/soot.jar:$SOOT/jasmin.jar set TMP = $jarPath/SOOT-RESULT set CMD = "$JDK/bin/java -classpath $SOOTCP soot.Main -f dava -soot-classpath $JDK/jre/lib/rt.jar:$jarPath/:$classPath -d $jarPath" if ($className == "ALLCLASSES") then set XCMD = "$CMD -process-dir $jarPath" else set XCMD = "$CMD $className" endif $XCMD >&! $TMP grep Exception $TMP > /dev/null if ($status == 0) then echo "Executing Soot failed." cat $TMP exit endif foreach out (`grep "Generating" $TMP | sed 's/Generating//g;s/\.\.\.//g' `) cat $out echo "---------------------------" end
TTT
application found
here .
Note that sandmark.jar
has been included on the class
path since TTT
calls annotation methods from
the sandmark.watermark.ct.trace.Annotate
class.