I need to build a program slicer in java to cut the source code based on the cut criterion. I see that there are very few libraries for this purpose. Despite this, I would like to try it myself. I read several publications on this topic, which include the use of dependency graphs for data processing and control dependencies in the program. Then, the cutting algorithm can be used in combination with the cutting criterion to create fragments of the java program. Has anyone done this before? If so, could you point me in the right direction to start with this? I searched and searched and cannot figure out where to start, which APIs exist (if any).
Example:
public class Foo { public void fooBar() { int x = 10; int y = 12; String s = ""; for(int j=0; j<10; j++) { s += x; x++; y += 3; } System.out.println("y value " + y); } }
If the cut criterion (13, y) is selected, where 13 is the last line in the above code, then the result will be
public class Foo { public void fooBar() { int y = 12; for(int j=0; j<10; j++) { y += 3; } } }
The cut criterion returns all operators that can affect the variable 'y' on line 13.
Joeblackdev
source share