Closed ArtemUntila closed 2 years ago
Main.java:
Main.java
1. import java.util.Arrays; 2. 3. public class Main { 4. 5. public static void main(String[] args) { 6. int[] a = new int[]{ 0, 1 }; 7. a = addAndReturn(a); 8. add(a); 9. System.out.println(Arrays.toString(a)); 10. } 11. 12. public static void add(int[] a) { 13. a[0] += 1; 14. } 15. 16. public static int[] addAndReturn(int[] a) { 17. a[0] += 1; 18. return a; 19. } 20. }
If we run the program, it outputs:
[2, 1]
Running Slicer4J w.r.t. Main:9 line, we get the following slice:
Main:9
cd scripts python3 slicer4j.py -j ../example.jar -o ../example -b Main:9 -m "Main"
slice.log:
slice.log
Main:6 Main:7 Main:17 Main:18 Main:9
Despite method add() affecting the state of variable a, it wasn’t included in the slice, and the sliced program prints:
add()
a
[1, 1]
Thank you for bringing this to my attention. Fixed in the latest commit. Please also pull and build the latest commit of the DynamicSlicingCore.
Main.java
:If we run the program, it outputs:
Running Slicer4J w.r.t.
Main:9
line, we get the following slice:slice.log
:Despite method
add()
affecting the state of variablea
, it wasn’t included in the slice, and the sliced program prints: