[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Performing a scene transformation _after_ body transforms...



Andreas,

In general, you should only use a BodyTransformer if you are
analyses/transformations are local to each method body. For
modifications at a higher level (i.e. adding/removing methods), you
should probably implement your solution as a SceneTransformer. For
example,

- create your own SceneTransformer and add it to the "wjtp" or "wjop" 
  Pack
- in your SceneTransformer use "Scene.v().getApplicationClasses()" to
  get the list of classes to analyze (you may add to, or trim this list
  if you like)
- iterate over the classes, and methods in the classes to apply your
  analysis
    -> at this point you might want to create a special BodyTransformer
       that you invoke directly to analyze the methods (i.e. it is not
       added to the standard "jtp" or "jop" Packs
- you can keep track of the methods you want to add/remove in your
  SceneTransformer, then once you have completed a pass over the class
  list, you can modify the SootClass objects without getting a 
  ConcurrentModificationException

I hope these pointers help. I encourage other soot-list readers to
comment on this approach (or point out errors), since it is based on
code I wrote 2 years ago.

Rhodes


On Tue, 2002-02-12 at 08:21, Andreas Martens wrote:
> Good Afternoon,
> 
> I am attempting to create a small transformation system which will
> take parts of methods and place these parts into their own methods.  I
> first started writing this using a bodyTransformer, and managed to find
> out what I wanted to cut from the current method, but I cannot create a
> new method in the same class (ConcurrentModificationException).  Thus I
> though that I could possibly have the bodytransformer store the methods
> I need to create temporarily and when it is completed have a scene
> transformation to create all of the new methods.
> 
> I then discovered that the scene transformations are applied before body
> transformations, so that idea failed...
> 
> If you understand what I have meant above, do you have any ideas how I
> can rectofy my problem?
> 
> Modifying the soot source code to my needs doesn't seem like a good way
> of getting the results I need..
> 
> 
> Cheers
> Andreas
> 
> 
>  --
> Andreas Martens, DoC, Imperial College
> Help fight continental drift
> 
-- 
Rhodes Brown
Sable Research - McGill University

Web:    http://www.sable.mcgill.ca
Email:  rhodesb@sable.mcgill.ca