[Soot-list] Transforming java library classes

Chris Pickett chris.pickett at mail.mcgill.ca
Mon Feb 25 17:26:02 EST 2008


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
>>  >>
>>


More information about the Soot-list mailing list