<div dir="ltr"><div>Hi,</div><div><br></div><div>I am interested in transforming a series of classes A,B,C,D,... that all implement a simple interface foo:</div><div><span style="white-space:pre">    </span>public interface foo</div><div><span style="white-space:pre">  </span>{</div><div><span style="white-space:pre">             </span>void bar(final baz b);</div><div><span style="white-space:pre">        </span>}</div><div>The baz class contains a single method:</div><div><span style="white-space:pre">       </span>public void squirt(Final string s)</div><div>Which causes some side-effect based on the input string (for example, might print it to the console or do something else)</div><div><br></div><div>so if I have a sample class:</div><div><br></div><div>public class A implements foo</div><div>{</div><div><span style="white-space:pre">   </span>static String q = "something something"</div><div><span style="white-space:pre">     </span>@Override</div><div><span style="white-space:pre">     </span>public void bar(Final baz b)</div><div><span style="white-space:pre">  </span>{</div><div><span style="white-space:pre">             </span>StringBuffer sb = new StringBuffer();</div><div><span style="white-space:pre">         </span>sb.append("hello");</div><div><span style="white-space:pre">         </span>sb.append("goodbye");</div><div><span style="white-space:pre">               </span></div><div><span style="white-space:pre">              </span>b.squirt("delete this invokation to squirt");</div><div><span style="white-space:pre">               </span>b.squirt(q);</div><div><span style="white-space:pre">          </span>b.squirt("delete this too" + q)</div><div><span style="white-space:pre">             </span>b.squirt(sb.toString());</div><div><span style="white-space:pre">                      </span></div><div><span style="white-space:pre">                      </span></div><div><span style="white-space:pre">              </span>//let's say someMethod is defined in some other class and returns a string value</div><div><span style="white-space:pre">          </span>b.squirt(someMethod() + "don't delete this");</div><div><span style="white-space:pre">           </span></div><div><span style="white-space:pre">              </span>//let's say B implements interface foo, but also implements a function B.returnSomeString that just returns some string</div><div><span style="white-space:pre">           </span>b.squirt(B.returnSomeString());</div><div><span style="white-space:pre">       </span>}</div><div>}</div><div><br></div><div>I am interested in transforming this class in the following way:</div><div><br></div><div>1) Delete all invocations to squirt that only reference some string constant, or a static field, is the result of a series of StringBuffer concatenations of constants, etc. So ideally all first 4 of the squirt:s above should be removed, and the fifth invocation should be kept as-is, and the last invocation should also be kept (except the B.returnSomeString method should also be transformed)</div><div>2) Keep invocations where the string constant is concatenated with the output of some other method (like someMethod() in the example above)</div><div>3) Also want to transform the B.execute and B.returnSomeString() method according to the above rules</div><div><br></div><div>Can anyone give me some hints in the right direction? I am having trouble getting started. What should be my next step after transforming the .class files to Grimple?</div><div><br></div><div>Thanks,</div><div>Per</div></div>