[Soot-list] Transforming java library classes

Eric Bodden eric.bodden at mail.mcgill.ca
Mon Feb 25 18:11:08 EST 2008


Yes, and that's the cause... javap is written in Java and therefor
will almost certainly pick any java.lang.* class from the runtime
environment that runs the JVM (i.e. from the boot class path).

Your classes are ok. javap just shows you the wrong classes...

Eric

On 25/02/2008, Khilan Gudka <khilan.gudka at imperial.ac.uk> wrote:
> Hi Chris,
>
>  Thanks for your reply. I'm disassembling the class files that Soot
>  outputs. I executed:
>
>  javap -c -classpath . java.lang.Math
>
>  in the sootOutput directory which seems to be showing the original
>  java.lang.Math, however if I use jad (http://www.kpdus.com/jad.html)
>  then it shows the file generated by Soot with the methods added to it!
>
>  It appears that for sdk classes, java does not look in locations other
>  than rt.jar which seems bizarre. If I prepend . to the classpath then
>  it should look for java.lang.Math there first (and hence find the
>  updated file) but that doesn't seem to be happening as when I execute
>  the program, java complains that it cannot find a method in
>  java.lang.Math.
>
>
>  Khilan
>
>  On 25/02/2008, Chris Pickett <chris.pickett at mail.mcgill.ca> wrote:
>  > Hi Khilan,
>  >
>  >  Sorry for your troubles.  I am pretty sure it is possible to do what you
>  >  want to do.  I have done it with GNU Classpath many times, but not with
>  >  Sun's or IBM's rt.jar.
>  >
>  >  How do you know the method hasn't been added?  Are you disassembling the
>  >  output from Soot?  It won't get included back in rt.jar unless you put
>  >  it there manually.
>  >
>  >  You could try specifying a -cp flag to Soot with the path to each JDK
>  >  .jar file that you need following it.  (We needed jsse.jar, jce.jar, and
>  >  rt.jar most recently for a whole-program analysis using Richard's lock
>  >  allocator.  I don't remember why, but that's what the script says.)
>  >
>  >  If that fails, if you attach your full source code and your full command
>  >  line and the relevant details of your environment (CLASSPATH, JAVA_HOME,
>  >  which VM, etc.), somebody might be able to help you by trying to
>  >  reproduce the issue exactly.  Not necessarily me.....
>  >
>  >
>  >  Chris
>  >
>  >  Khilan Gudka wrote:
>  >  > Dear Chris,
>  >  >
>  >  > Unfortunately that didn't work. This is really weird, as soot is
>  >  > clearly adding the methods. Debug output I am generating:
>  >  >
>  >  > Adding cos96 to java.lang.Math
>  >  > Successfully added? true.
>  >  >
>  >  > The true value is obtained by doing a contains check on the list
>  >  > returned by SootClass.getMethods().
>  >  >
>  >  > Khilan
>  >  >
>  >  >
>  >  >
>  >  > On 25/02/2008, Chris Pickett <chris.pickett at mail.mcgill.ca> wrote:
>  >  >> Try adding --app.  Does it work?
>  >  >>
>  >  >>
>  >  >>  Khilan Gudka wrote:
>  >  >>  > Hi Chris,
>  >  >>  >
>  >  >>  > Sorry about that. Here is the command line I am using:
>  >  >>  >
>  >  >>  > -p cg.spark enabled:true -w -f c -include-all MyClass java.lang.Math
>  >  >>  >
>  >  >>  > and the relevant source code for adding the new method to java.lang.Math is:
>  >  >>  >
>  >  >>  >         SootMethod mPrime = new SootMethod(mPrimeName,
>  >  >>  > m.getParameterTypes(), m.getReturnType(), m.getModifiers(),
>  >  >>  > m.getExceptions());
>  >  >>  >         SootClass c = m.getDeclaringClass();
>  >  >>  >         c.addMethod(mPrime);
>  >  >>  >
>  >  >>  > Thanks,
>  >  >>  > Khilan
>  >  >>  >
>  >  >>  > On 25/02/2008, Chris Pickett <chris.pickett at mail.mcgill.ca> wrote:
>  >  >>  >> Hi Khilan,
>  >  >>  >>
>  >  >>  >>  It's hard for people to help you if you don't provide enough
>  >  >>  >>  information.  (In general, err on the side of providing too much.)
>  >  >>  >>
>  >  >>  >>  Please post your exact command-line and source code.
>  >  >>  >>
>  >  >>  >>
>  >  >>  >>  Chris
>  >  >>  >>
>  >  >>  >>
>  >  >>  >>  Khilan Gudka wrote:
>  >  >>  >>  > Dear Eric,
>  >  >>  >>  >
>  >  >>  >>  > I tried as per your suggestion but still no luck.
>  >  >>  >>  >
>  >  >>  >>  > Khilan
>  >  >>  >>  >
>  >  >>  >>  > On 25/02/2008, Eric Bodden <eric.bodden at mail.mcgill.ca> wrote:
>  >  >>  >>  >> Hi, Khilan.
>  >  >>  >>  >>
>  >  >>  >>  >>  Did you use the -include-all option?
>  >  >>  >>  >>
>  >  >>  >>  >>  See http://www.sable.mcgill.ca/soot/tutorial/usage/index.html
>  >  >>  >>  >>
>  >  >>  >>  >>  Eric
>  >  >>  >>  >>
>  >  >>  >>  >>
>  >  >>  >>  >>  On 25/02/2008, Khilan Gudka <khilan.gudka at imperial.ac.uk> wrote:
>  >  >>  >>  >>  > Dear All,
>  >  >>  >>  >>  >
>  >  >>  >>  >>  >  I would like to be able to modify the java sdk library classes by
>  >  >>  >>  >>  >  adding methods to them. At present, I pass the java library class to
>  >  >>  >>  >>  >  be modified as one of the application classes. Soot generates the
>  >  >>  >>  >>  >  class files for these classes but they don't include the methods that
>  >  >>  >>  >>  >  I added to them using SootClass.addMethod.
>  >  >>  >>  >>  >
>  >  >>  >>  >>  >  Is this the right way to go about modifying java sdk classes?
>  >  >>  >>  >>  >
>  >  >>  >>  >>  >  Thanks,
>  >  >>  >>  >>  >  Khilan
>  >  >>  >>  >>
>  >  >>  >>  >>>  _______________________________________________
>  >  >>  >>  >>  >  Soot-list mailing list
>  >  >>  >>  >>  >  Soot-list at sable.mcgill.ca
>  >  >>  >>  >>  >  http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
>  >  >>  >>  >>  >
>  >  >>  >>  >>
>  >  >>  >>  >>
>  >  >>  >>  >>
>  >  >>  >>  >>  --
>  >  >>  >>  >>  Eric Bodden
>  >  >>  >>  >>  Sable Research Group
>  >  >>  >>  >>  McGill University, Montréal, Canada
>  >  >>  >>  >>
>  >  >>  >>  > _______________________________________________
>  >  >>  >>  > Soot-list mailing list
>  >  >>  >>  > Soot-list at sable.mcgill.ca
>  >  >>  >>  > http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
>  >  >>  >>
>  >  >>
>  >
>


-- 
Eric Bodden
Sable Research Group
McGill University, Montréal, Canada


More information about the Soot-list mailing list