Slicer4J is an accurate, low-overhead dynamic slicer for Java programs.

Overview

Slicer4J

Build Tests drawing

This repository hosts Slicer4J, an accurate, low-overhead dynamic slicer for Java programs. Slicer4J automatically generates a backward dynamic slice from a user selected executed statement and variables used in the statement (slicing criterion). Slicer4J relies on soot which currently supports instrumenting programs compiled with up to Java 9. Contributions to this repo are most welcome!

If you use this tool, please cite:

Khaled Ahmed, Mieszko Lis, and Julia Rubin. Slicer4J: A Dynamic Slicer for Java. The ACM Joint European Software Engineering Conference and Symposium on the Foundations of Software Engineering (ESEC/FSE), 2021. <bibtex>

Also, please check out our video demonstration of Slicer4J

Table of Contents

  1. Requirements
  2. Building the Tool
  3. Using the Tool
  4. Inspecting the Output
  5. Evaluation Benchmarks


Requirements



Building the Tool

Build and install the dynamic slicing core, go to the core's repo: (https://github.com/resess/DynamicSlicingCore)

cd core/
mvn -Dmaven.test.skip=true clean install
cd -

Build Slicer4J, go back to Slicer4J's repo

cd Slicer4J/
mvn -Dmaven.test.skip=true clean install
cd -


Using the Tool

Display the command line parameters using:

java -cp "Slicer4J/target/slicer4j-jar-with-dependencies.jar:Slicer4J/target/lib/*" ca.ubc.ece.resess.slicer.dynamic.slicer4j.Slicer -h

A simpler method to use Slicer4J is by using the wrapper python script: scripts/slicer4j.py

You can list the script parameters using: python3 slicer4j.py -h

Slicer4J uses up to 8GB of RAM. The tool will crash with OutOfMemoryError exception if the trace size is greater than 8GB. In that case, you can change maximum heap size allocated to Slicer4J by changing the -Xmx8g to a higher value (e.g. -Xmx16g).


Slicer4J Mandatory Command Line Parameters:

Parameter
Description
-h show help message and exit
-j Path to jar file
-o Output folder
-b line to slice backward from, in the form of FileName:LineNumber


Slicer4J Optional Command Line Parameters:

Parameter
Description
-m Main class to run with arguments, in the form of "FileName Arguments"
-tc Test class name to run, if this is provided, -tm must also be provided
-tm Test method to run
-dep Directory to folder containing JAR dependencies, if any
-mod Folder containing user-defined method models
-d Slice with data-flow dependencies only
-c Slice with control dependencies only
-once Get only the immediate data-flow and control dependencies of the slicing criteria


User-defined method models:

The following is an example for defining your own method models.

For the methods in this class:

package com.myproject;
class MyClass extends MyOtherClass{
    String field;
    public MyClass put(String val){
        this.field = val;
    }
    public String get(){
        return this.field;
    }
}

create an XML file named "com.myproject.MyClass.xml" and place it in a folder containing your method models, this is the folder we pass to Slicer4J using the -mod parameter

For example, here's the model for the above class

<?xml version="1.0" ?>
<summary fileFormatVersion="101">
<hierarchy superClass="com.myproject.MyOtherClass" />
  <methods>
    <method id="com.myproject.MyClass put(java.lang.String)">
      <flows>
        <flow>
          <from sourceSinkType="Parameter" ParameterIndex="0" />
          <to sourceSinkType="Field" AccessPath="[com.myproject.MyClass: java.lang.String field]"
          	AccessPathTypes="java.lang.String" />
        </flow>
        <flow>
          <from sourceSinkType="Field" />
          <to sourceSinkType="Return" />
        </flow>
      </flows>
    </method>
    <method id="java.lang.String get()">
      <flows>
        <flow>
          <from sourceSinkType="Field" AccessPath="[java.nio.CharBuffer: char[] buffer]"
          	AccessPathTypes="[char[]]" />
           <to sourceSinkType="Return" />
        </flow>
      </flows>
    </method>
</summary>

The id of each method is the method signature. Each method has flows from parameters, the receiver, and their fields, to other parameters, the receiver, their fields, and the return.

Each flow is specified with it sourceSinkType as Parameter, Field, or Return. Parameter is used for parameters. Field is used for the receiver or fields of the receiver. Return is for the method return. For parameters, we also need ParameterIndex to specify which parameter (first, second, etc.). For fields, we specify the signature of the field in AccessPath and its type in AccessPathTypes.



Inspecting the Output:

You can view the output of Slicer4J in 3 different formats: Source Map, Raw Slice, and #Graph.

Let's see the output of slicing the SliceMe program (found under benchmarks/SliceMe):

 1. public class SliceMe {
 2.    public static void main(String[] args) {
 3.        int [] parsed;
 4.        if (args.length > 0){
 5.            parsed = parse(args);
 6.        } else {
 7.            parsed = null;
 8.        }
 9.        System.out.println(parsed.length);
10.    }
11.    private static int[] parse(String[] str) {
12.        String fullString = String.join(", ", str);
13.        int [] arr = new int[fullString.length()];
14.        for (int i = 0; i< fullString.length(); i++) {
15.          arr[i] = fullString.charAt(i)-'0';
16.        }
17.        return arr;
18.    }
20. }

If we run this program using java -jar sliceme-1.0.0.jar SliceMe without providing any arguments to the main method)

cd scripts
python3 slicer4j.py -j ../benchmarks/SliceMe/target/sliceme-1.0.0.jar -o sliceme_slice/ -b SliceMe:9 -m "SliceMe"

In this example, we slice from line 9 in the SliceMe.java file: System.out.println(parsed.length);


Source Map:

This output is only generated if the JAR is compiled with debug information. Slicer4J outputs a list of files-name: source-code-line-number for each statement that compose the slice. This output is stored in the output folder in a file called slice.log

For the example, slice.log contains:

SliceMe:4
SliceMe:7
SliceMe:9

Which indicates that the slice is:

 4.        if (args.length > 0){
 7.            parsed = null;
 9.        System.out.println(parsed.length);

Raw Slice:

Slicer4J outputs a list of Jimple statements with a unique Id for each statement, which we use as our intermediate format, together with the thread id of the thread they are execute in, with the source map of file and line numbers for jars that are compiled with debug information.

Every element in the list is in the format files-name: source-code-line-number thread statement-id:jimple-statement

This output is stored in the output folder in a file called raw-slice.log

For the example, raw-slice.log contains:

SliceMe:4    1    0:$stack2 = lengthof args
SliceMe:4    1    1:if $stack2 <= 0 goto parsed = null
SliceMe:7    1    2:parsed = null
SliceMe:9    1    3:$stack4 = <java.lang.System: java.io.PrintStream out>
SliceMe:9    1    4:$stack3 = lengthof parsed
SliceMe:9    1    5:virtualinvoke $stack4.<java.io.PrintStream: void println(int)>($stack3)

Here we see that all statements are within the same thread (thread #1), and we see how each line is represented in Jimple (if (args.length > 0) in the code maps to $stack2 = lengthof args and if $stack2 <= 0 goto parsed = null in Jimple)


Graph:

Slicer4J outputs a dot graph whose nodes are statements in the slice and edges are data and control dependencies between the statements.

This output is stored in the output folder in a file called slice-graph.pdf

For the example, slice-graph.pdf contents is shown here:

drawing

Here we see the control dependencies (dashed edges) and data flow-dependencies (solid edges) between the Jimple statements from the raw slice.

For example, $stack3 = lengthof parsed is data-flow dependent on parsed = null through the variable parsed, which is written on the edge. Also, parsed = null is control dependent on if $stack2 <= 0 goto parsed = null.



Evaluation Benchmarks

The evaluation benchmarks are stored under benchmarks, please check there for instructions on how to run them.



Contact

If you experience any issues, please submit an issue or contact us at [email protected]

Comments
  • Main Class Errors when trying to execute slicer

    Main Class Errors when trying to execute slicer

    Hello,

    first off, thank you very(!) much for your contribution. I am a student at Graz University of Technology and I am currently working on my Master's thesis which deals with test suite reduction. For my approach I need to compute dynamic slices of Java programs and thus I was very happy when I found out that this tool was published just weeks before I started with my project. I'll make sure to cite your publication and give proper credit to you in my thesis!

    Unfortunately though, as of now, I cannot seem to get the slicer working. Some words on my environment: I use Archlinux and I tried everything with JDK 11 and 16 but there's no difference in behaviour.

    I tried to follow the Readme to produce a dynamic slice of the SliceMe program. For that I conducted the following steps:

    1. mvn -Dmaven.test.skip=true clean install for both, the core and the Slicer4J repo
    2. cd'd to benchmarks/SliceMe and performed a mvn clean install there to get the target/sliceme-1.0.0.jar.

    Then I first tried to run the provided python script for Slicer4J:

    python3 ../../scripts/slicer4j.py -j target/sliceme-1.0.0.jar -o sliceme_slice/ -b SliceMe:9 -m "SliceMe"
    

    which provided the following output:

    Instrumenting the JAR
    Instrumented jar is at: /home/lukas/workspace/master-jsr/slicer/slicer4j/benchmarks/SliceMe/sliceme_slice/sliceme-1.0.0_i.jar
    Running the instrumented JAR
    Running instrumented JAR
    ------------------------------------
    Error: Main Class SliceMe could not be found or loaded
    Caused by: java.lang.ClassNotFoundException: SliceMe
    ------------------------------------
    Slicing from line SliceMe:9
    Traceback (most recent call last):
      File "/home/lukas/workspace/master-jsr/slicer/slicer4j/benchmarks/SliceMe/../../scripts/slicer4j.py", line 181, in <module>
        main()
      File "/home/lukas/workspace/master-jsr/slicer/slicer4j/benchmarks/SliceMe/../../scripts/slicer4j.py", line 67, in main
        log_file, slice_graph = dynamic_slice(jar_file=jar_file, out_dir=out_dir, backward_criterion=backward_criterion,
      File "/home/lukas/workspace/master-jsr/slicer/slicer4j/benchmarks/SliceMe/../../scripts/slicer4j.py", line 128, in dynamic_slice
        line = sc.split(", ")[0]
    UnboundLocalError: local variable 'sc' referenced before assignment
    

    I also tried to run the Slicer4J jar directly as described in the Readme (with the -h option just to verify if the program actually works):

    java -cp "../../Slicer4J/target/slicer4j-jar-with-dependencies.jar:Slicer4J/target/lib/*" ca.ubc.ece.resess.slicer.dynamic.slicer4j.Slicer -h
    

    which yielded the following error message:

    Error: Main class ca.ubc.ece.resess.slicer.dynamic.slicer4j.Slicer cannot be initialized
    Caused by java.lang.NoClassDefFoundError: soot/Type
    

    Please note that I translated parts of the error message from German to English so they might not be a 100% equal to the actual english output.

    It could very well be an error on my end but I can run every other Java program correctly on my system.

    Anyway, I'd be glad if you could help me. Thanks a lot again.

    question 
    opened by Lms24 6
  • Some missing lines on Voronoi

    Some missing lines on Voronoi

    Hi, I'm using the Olden's benchmark (with recursive programs) for playing with the tool. I chose Voronoi with the arguments "-n 9", and the line with the println invocation as criterion.

    The problem is that there are 2 sliced lines in the output, the line with println and the slicingVariable1B declaration. If I try with -n 2 it works! If I try with -n 3 it doesn't work (and it's not producing the output I don't know why) If I try with -n 9 it works returning only 2 lines. I think the problem is on recursion, but I'm know that is too hard to find these issues... (and if there are issues...)

    Vertex.seed = 1023;
    Vertex extra = Vertex.createPoints(1, new MyDouble(1.0), points);
    Vertex point = Vertex.createPoints(points-1, new MyDouble(extra.X()), points-1);
    
    Edge edge = point.buildDelaunayTriangulation(extra);
    
    Edge slicingVariable1 = edge;
    // This is the only line in the slice, and slicingVariable1 is not null
    Boolean slicingVariable1B = (slicingVariable1 != null);
    Edge[] slicingVariable2 = edge.quadList;
    Edge slicingVariable3 = edge.quadList[0];
    int slicingVariable4 = edge.listPos;
    Vertex slicingVariable5 = edge.vertex;
    Edge slicingVariable6 = edge.next;
    
    System.out.println(slicingVariable1B); // I'm slicing this line
    

    I'm attaching the source code and the output (including the trace), except the jars. Voronoi.zip

    Thank you so much in advance, Alexis.

    bug 
    opened by asoifer 4
  • Handling null initializations

    Handling null initializations

    Hi again, I think that I'll be your main slicer tester. This is because I'm working on my own dynamic slicer and I'm performing several tests.

    In this case, I'll use the same case as before, TreeAdd. I developed a comparer for helping me to characterize the difference between different slicers.

    I'm slicing from line 53 in TreeAdd.java with the same parameters as before "-l 2".

    In this picture, lines from 101 to 106 are in the slice, and this is OK! image

    But in this picture, lines 54 and 55 are not in the slice. At the left is my slicer, in the middle Javaslicer, in the right Slcier4j (I used the same for comparing to ORBS). image

    Probably, I guess, this is because the compiler omits those lines (since null values are the default ones...). I don't know if this is easy or not to solve,

    Anyway, I'll upload more "issues" as soon, I hope the best for this tool, And if you need some help I can help :) Regards.

    opened by asoifer 3
  •  Could not find or load main class SliceMe,  MavenReportException: Error while generating Javadoc.

    Could not find or load main class SliceMe, MavenReportException: Error while generating Javadoc.

    i'm trying to execute the SliceMe example but i'm facing some issues. i made sure that the files structure is as instructed, but when i run the python command i get these errors:

    image

    when i ran mvn -Dmaven.test.skip=true clean install to the Slicer4J i got this error: javadocErrors even though it has built successfully, it might be the cause but i couldn't figure how to fix it. java version 1.8, python 3. any help?

    opened by Ghadalamer 2
  • having trouble understanding JacksonCore_4b benchmark slicing criterion

    having trouble understanding JacksonCore_4b benchmark slicing criterion

    In the run_benchmarks.py file you generated slice for the following paramters:

    "JacksonCore_4b": ("target/jackson-core-2.5.0-SNAPSHOT.jar", "org.junit.runner.JUnitCore com.fasterxml.jackson.core.util.TestTextBuffer", "com.fasterxml.jackson.core.util.TextBuffer", "587", "expandCurrentSegment", "JacksonCore_4b/target/test-classes/:JacksonCore_4b/target/dependency/*"),
    

    when debugging I am not finding 587 line in the com.fasterxml.jackson.core.util.TextBuffer test class, neither did I find the expandCurrentSegment method. In the paper you mentioned that you used failing test assertion statement as the slicing criterion , but none of the criteria are taken from a test file. I am investigating this as I am having troubling generating slice from the test assertion as I mentioned in another issue. Any clarification will be highly appreciated.

    opened by soneyahossain 2
  • exception in java -cp

    exception in java -cp "Slicer4J/target/slicer4j-jar-with-dependencies.jar:Slicer4J/target/lib/*" ca.ubc.ece.resess.slicer.dynamic.slicer4j.Slicer -h

    when I run this usage command java -cp "Slicer4J/target/slicer4j-jar-with-dependencies.jar:Slicer4J/target/lib/*" ca.ubc.ece.resess.slicer.dynamic.slicer4j.Slicer -h, it throws exception

    slicer4j/Slicer4J$ java -cp "Slicer4J/target/slicer4j-jar-with-dependencies.jar:Slicer4J/target/lib/*" ca.ubc.ece.resess.slicer.dynamic.slicer4j.Slicer -h usage: java -jar Slicer4j/target/slicer4j-jar-with-dependencies.jar -ctrl,--Control-only Track control dependence only -d,--debug Enable debug -data,--data-only Track data-flow dependence only -f,--framework Path to folder with extra framework methods -fw,--forward-slice-position starting statement for the forward slice (for chopping) -h,--help Display this help and exit -j,--jar jar path -lc,--logger-classes logger classes jar -m,--mode Tool mode: i for instrument, g to produce the dynamic control flow graph, s to slice -o,--outDir Output directory -once,--once Slice one step only -sd,--stub-droid Location of the StubDroid summaries -sl,--static-log Static-log file path -sp,--slice-position starting statement for the slice -sv,--slice-variables dash-joined list of starting variables to slice from -t,--trace Execution trace -tw,--taint-wrapper Location of the FlowDroid's taint-wrapper list usage: java -jar Slicer4j/target/slicer4j-jar-with-dependencies.jar -ctrl,--Control-only Track control dependence only -d,--debug Enable debug -data,--data-only Track data-flow dependence only -f,--framework Path to folder with extra framework methods -fw,--forward-slice-position starting statement for the forward slice (for chopping) -h,--help Display this help and exit -j,--jar jar path -lc,--logger-classes logger classes jar -m,--mode Tool mode: i for instrument, g to produce the dynamic control flow graph, s to slice -o,--outDir Output directory -once,--once Slice one step only -sd,--stub-droid Location of the StubDroid summaries -sl,--static-log Static-log file path -sp,--slice-position starting statement for the slice -sv,--slice-variables dash-joined list of starting variables to slice from -t,--trace Execution trace -tw,--taint-wrapper Location of the FlowDroid's taint-wrapper list Exception in thread "main" ca.ubc.ece.resess.slicer.dynamic.core.exceptions.InvalidCommandsException: Invalid commands at ca.ubc.ece.resess.slicer.dynamic.slicer4j.Slicer.throwParseException(Slicer.java:422) at ca.ubc.ece.resess.slicer.dynamic.slicer4j.Slicer.main(Slicer.java:230)

    opened by soneyahossain 2
  • Missing .gitmodules file

    Missing .gitmodules file

    It seems that the root .gitmodules file wasn't committed to the repo. This problem prevents users of this repo from running the defects4j benchmarks.

    https://git-scm.com/book/en/v2/Git-Tools-Submodules

    opened by david-fong 2
  • Soot-Infoflow library

    Soot-Infoflow library

    Hello again,

    after getting SLicer4J to run, I started looking into the source code and the dependencies. I noticed that Slicer4J's pom.xml declares soot-infoflow as a dependency with a local jar. I assume that was because by the time of developing the tool version 2.9 of the library was not yet released. According to Maven Central version 2.9.0 is publicly available, removing the necessity of including the snapshot jar in this repository in the libs directory. I edited the pom.xml locally and it seems that everything works as before.

    If you want I can submit a PR with the updated pom.xml (although the change is quite subtle).

    Have a good day!

    opened by Lms24 2
  • Possible soundness bug in the presence of recursive methods

    Possible soundness bug in the presence of recursive methods

    Hi, I'm a PhD student from the University of Buenos Aires, I read your paper, Slicer4J: A Dynamic Slicer For Java, and in my opinion, this is a great contribution. So, thank you so much, I appreciate your research on this topic.   I wanted to try to use it on some programs... but I had a soundness problem in the presence of recursive methods. I don't know if this is a known issue or if I'm doing something wrong. 

    I'm attaching the complete source code for reproducing this issue (2 files), the log and the slice file produced by this tool.

    This is TreeAdd, from Olden's benchmark. If you run this program with "-l 2", and slice on line 53 (TreeAdd:53) the slice is: TreeAdd:36 TreeAdd:40 TreeAdd:53 TreeNode:49 TreeNode:101 TreeNode:106

    int addTree()
    {
        int total = value; /* line 101 */
        if (left != null)
    	total += left.addTree();
        if (right != null) 
    	total += right.addTree();
        return total; /* line 106 */
    }
    

    The problem is between lines 101 and 106. As you can see in the log, lines from 101 to 106 are executed and they are used to compute the variable total returned in 106 (of TreeNode), which is used to print the criterion in line 53 of TreeAdd. In Javaslicer they are part of the slice (I checked this and it's okay).

    It's important to run this with "-l 2" (or a greater number) as arguments for replying this behaviour. Thanks in advance for everything.

    TreeAdd.zip

    bug 
    opened by asoifer 2
  • does not find line number if the slicing criterion is in the test class

    does not find line number if the slicing criterion is in the test class

    I am trying to generate the dynamic slice for the junit assertions in a test class of the joda-time subject. However, the script throws error such as:

    looking for LINENO:324:FILE:org.joda.time.tz.TestBuilder None Traceback (most recent call last): File "run_benchmarks.py", line 207, in run_slicer4j(project, jar_name, project_arg, extra_libs, sc_file, slice_line) File "run_benchmarks.py", line 148, in run_slicer4j line = sc.split(", ")[0] AttributeError: 'NoneType' object has no attribute 'split'

    Is it because the tool does not instrument test classes? Not sure if I am making any mistake, any help would be highly appreciated!

    opened by soneyahossain 1
  • python3 run_benchmarks.py does not find javaslicer

    python3 run_benchmarks.py does not find javaslicer

    Hi, when I try to run the benchmark using the python3 run_benchmarks.py command, it does not find the javaslicer inside the benchmark directory. Even though it does not show any error by the slice size is zero for the javaslicer and investigating further inside the result directory I found that this tool is not found. Any idea why that would happen?

    Benchmark: javaslicer-bench1-intra-procedural


    Original exec time (s): 0.04744410514831543


    Running Slicer4J Instrumentation time (s): 0.7002263069152832 Execution time (s): 0.04601740837097168 Slice time (s): 0.9844796657562256 Length of trace (Jimple LoC): 10 Slice size (Java LoC): 6


    Running JavaSlicer Instr + exec time (s): 0.005282878875732422 Slice time (s): 0.0013234615325927734 Length of trace (bytecode LoC): 0 Slice size (Java LoC): 0

    opened by soneyahossain 1
  • Java version clarification

    Java version clarification

    Hi, In the readme, it was just changed to specify that 8 is the required java environment version. I just wanted to see if this is correct -- I just installed and ran all of the tests with openjdk 15.0.3 and everything seems to work, but I just wanted to see if there was something about newer versions that breaks the Slicer4J in a way that the tests and installation would not detect. Thanks!

    opened by keltono 0
  • Instrumentation failure, Resolved Field is Null

    Instrumentation failure, Resolved Field is Null

    When trying to run Slicer4J through the python script, the instrumentation fails. I am using JDK 9, on Mac OS. Here is the content of instr-debug.log.

    SLF4J: Class path contains multiple SLF4J bindings.
    SLF4J: Found binding in [jar:file:/Users/austin/git/Slicer4J/Slicer4J/target/slicer4j-jar-with-dependencies.jar!/org/slf4j/impl/StaticLoggerBinder.class]
    SLF4J: Found binding in [jar:file:/Users/austin/git/Slicer4J/Slicer4J/target/lib/soot-infoflow-2.9.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
    SLF4J: Found binding in [jar:file:/Users/austin/git/Slicer4J/Slicer4J/target/lib/slf4j-simple-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
    SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
    SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory]
    [main] INFO JimpleWriter - initialize (17): Initializing Instrumenter
    [main] INFO JimpleWriter - initialize (30): Initialization done
    [main] INFO JimpleWriter - start (37): Running packs ... 
    [main] INFO JimpleWriter - start (39): Writing output ... 
    [main] INFO JimpleWriter - start (41): Output written ... 
    [main] INFO JavaInstrumenter - initialize (79): Initializing Instrumenter
    [main] INFO JavaInstrumenter - initialize (98): Initialization done
    [main] INFO JavaInstrumenter - start (252): Running packs ... 
    [Thread-31] INFO InstrumenterUtils - addPrint (456): Statement: $stack6 = string.<java.lang.String: char[] value>
    [Thread-31] ERROR heros.solver.CountingThreadPoolExecutor - Worker thread execution failed: Resolved field is null: string.<java.lang.String: char[] value>
    Resolved field is null: string.<java.lang.String: char[] value>
    in unit: $stack6 = string.<java.lang.String: char[] value>
    in body: 
         public static boolean regionMatches(java.lang.String, int, java.lang.String, int, int)
        {
            int start, $stack7, length, $stack8, thisStart, $stack10, $stack11, $stack12, $stack14, i, $i0, $i1, hashCode;
            java.lang.String string, thisStr, tmpString, tmpString;
            char $stack16, $stack17;
            char[] $stack6, $stack9, $stack13, $stack15;
            java.lang.StringBuilder sb, sb;
            java.lang.Object tmpField;
    
            thisStr := @parameter0: java.lang.String;
    
            thisStart := @parameter1: int;
    
            string := @parameter2: java.lang.String;
    
            start := @parameter3: int;
    
            length := @parameter4: int;
    
            sb = new java.lang.StringBuilder;
    
            specialinvoke sb.<java.lang.StringBuilder: void <init>()>();
    
            hashCode = staticinvoke <java.lang.System: int identityHashCode(java.lang.Object)>(string);
    
            virtualinvoke sb.<java.lang.StringBuilder: java.lang.StringBuilder append(java.lang.String)>("814193");
    
            tmpString = virtualinvoke sb.<java.lang.StringBuilder: java.lang.String toString()>();
    
            staticinvoke <DynamicSlicingLogger: void println(java.lang.String,int)>(tmpString, hashCode);
    
            $stack6 = string.<java.lang.String: char[] value>;
    
            $stack7 = lengthof $stack6;
    
            $stack8 = $stack7 - start;
    
            if $stack8 < length goto label1;
    
            if start >= 0 goto label2;
    
         label1:
            return 0;
    
         label2:
            if thisStart < 0 goto label3;
    
            $stack9 = thisStr.<java.lang.String: char[] value>;
    
            $stack10 = lengthof $stack9;
    
            $stack11 = $stack10 - thisStart;
    
            if $stack11 >= length goto label4;
    
         label3:
            return 0;
    
         label4:
            if length > 0 goto label5;
    
            return 1;
    
         label5:
            i = 0;
    
         label6:
            if i >= length goto label8;
    
            $stack13 = thisStr.<java.lang.String: char[] value>;
    
            $stack12 = thisStart + i;
    
            $stack17 = $stack13[$stack12];
    
            $stack15 = string.<java.lang.String: char[] value>;
    
            $stack14 = start + i;
    
            $stack16 = $stack15[$stack14];
    
            $i0 = (int) $stack17;
    
            $i1 = (int) $stack16;
    
            if $i0 == $i1 goto label7;
    
            return 0;
    
         label7:
            i = i + 1;
    
            goto label6;
    
         label8:
            return 1;
        }
    
    
    	at soot.jimple.validation.FieldRefValidator.validate(FieldRefValidator.java:83)
    	at soot.jimple.JimpleBody.validate(JimpleBody.java:124)
    	at soot.jimple.JimpleBody.validate(JimpleBody.java:106)
    	at ca.ubc.ece.resess.slicer.dynamic.core.instrumenter.InstrumenterUtils.addPrint(InstrumenterUtils.java:454)
    	at ca.ubc.ece.resess.slicer.dynamic.core.instrumenter.InstrumenterUtils.basicBlockInstrument(InstrumenterUtils.java:70)
    	at ca.ubc.ece.resess.slicer.dynamic.slicer4j.instrumenter.JavaInstrumenter$2.internalTransform(JavaInstrumenter.java:183)
    	at soot.BodyTransformer.transform(BodyTransformer.java:47)
    	at soot.Transform.apply(Transform.java:126)
    	at soot.BodyPack.internalApply(BodyPack.java:49)
    	at soot.Pack.apply(Pack.java:126)
    	at soot.PackManager.runBodyPacks(PackManager.java:991)
    	at soot.PackManager.lambda$runBodyPacks$0(PackManager.java:667)
    	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
    	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
    	at java.base/java.lang.Thread.run(Thread.java:844)
    Exception in thread "main" Resolved field is null: string.<java.lang.String: char[] value>
    in unit: $stack6 = string.<java.lang.String: char[] value>
    in body: 
         public static boolean regionMatches(java.lang.String, int, java.lang.String, int, int)
        {
            int start, $stack7, length, $stack8, thisStart, $stack10, $stack11, $stack12, $stack14, i, $i0, $i1, hashCode;
            java.lang.String string, thisStr, tmpString, tmpString;
            char $stack16, $stack17;
            char[] $stack6, $stack9, $stack13, $stack15;
            java.lang.StringBuilder sb, sb;
            java.lang.Object tmpField;
    
            thisStr := @parameter0: java.lang.String;
    
            thisStart := @parameter1: int;
    
            string := @parameter2: java.lang.String;
    
            start := @parameter3: int;
    
            length := @parameter4: int;
    
            sb = new java.lang.StringBuilder;
    
            specialinvoke sb.<java.lang.StringBuilder: void <init>()>();
    
            hashCode = staticinvoke <java.lang.System: int identityHashCode(java.lang.Object)>(string);
    
            virtualinvoke sb.<java.lang.StringBuilder: java.lang.StringBuilder append(java.lang.String)>("814193");
    
            tmpString = virtualinvoke sb.<java.lang.StringBuilder: java.lang.String toString()>();
    
            staticinvoke <DynamicSlicingLogger: void println(java.lang.String,int)>(tmpString, hashCode);
    
            $stack6 = string.<java.lang.String: char[] value>;
    
            $stack7 = lengthof $stack6;
    
            $stack8 = $stack7 - start;
    
            if $stack8 < length goto label1;
    
            if start >= 0 goto label2;
    
         label1:
            return 0;
    
         label2:
            if thisStart < 0 goto label3;
    
            $stack9 = thisStr.<java.lang.String: char[] value>;
    
            $stack10 = lengthof $stack9;
    
            $stack11 = $stack10 - thisStart;
    
            if $stack11 >= length goto label4;
    
         label3:
            return 0;
    
         label4:
            if length > 0 goto label5;
    
            return 1;
    
         label5:
            i = 0;
    
         label6:
            if i >= length goto label8;
    
            $stack13 = thisStr.<java.lang.String: char[] value>;
    
            $stack12 = thisStart + i;
    
            $stack17 = $stack13[$stack12];
    
            $stack15 = string.<java.lang.String: char[] value>;
    
            $stack14 = start + i;
    
            $stack16 = $stack15[$stack14];
    
            $i0 = (int) $stack17;
    
            $i1 = (int) $stack16;
    
            if $i0 == $i1 goto label7;
    
            return 0;
    
         label7:
            i = i + 1;
    
            goto label6;
    
         label8:
            return 1;
        }
    
    
    	at soot.jimple.validation.FieldRefValidator.validate(FieldRefValidator.java:83)
    	at soot.jimple.JimpleBody.validate(JimpleBody.java:124)
    	at soot.jimple.JimpleBody.validate(JimpleBody.java:106)
    	at ca.ubc.ece.resess.slicer.dynamic.core.instrumenter.InstrumenterUtils.addPrint(InstrumenterUtils.java:454)
    	at ca.ubc.ece.resess.slicer.dynamic.core.instrumenter.InstrumenterUtils.basicBlockInstrument(InstrumenterUtils.java:70)
    	at ca.ubc.ece.resess.slicer.dynamic.slicer4j.instrumenter.JavaInstrumenter$2.internalTransform(JavaInstrumenter.java:183)
    	at soot.BodyTransformer.transform(BodyTransformer.java:47)
    	at soot.Transform.apply(Transform.java:126)
    	at soot.BodyPack.internalApply(BodyPack.java:49)
    	at soot.Pack.apply(Pack.java:126)
    	at soot.PackManager.runBodyPacks(PackManager.java:991)
    	at soot.PackManager.lambda$runBodyPacks$0(PackManager.java:667)
    	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
    	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
    	at java.base/java.lang.Thread.run(Thread.java:844)
    Exception in thread "Thread-31" Resolved field is null: string.<java.lang.String: char[] value>
    in unit: $stack6 = string.<java.lang.String: char[] value>
    in body: 
         public static boolean regionMatches(java.lang.String, int, java.lang.String, int, int)
        {
            int start, $stack7, length, $stack8, thisStart, $stack10, $stack11, $stack12, $stack14, i, $i0, $i1, hashCode;
            java.lang.String string, thisStr, tmpString, tmpString;
            char $stack16, $stack17;
            char[] $stack6, $stack9, $stack13, $stack15;
            java.lang.StringBuilder sb, sb;
            java.lang.Object tmpField;
    
            thisStr := @parameter0: java.lang.String;
    
            thisStart := @parameter1: int;
    
            string := @parameter2: java.lang.String;
    
            start := @parameter3: int;
    
            length := @parameter4: int;
    
            sb = new java.lang.StringBuilder;
    
            specialinvoke sb.<java.lang.StringBuilder: void <init>()>();
    
            hashCode = staticinvoke <java.lang.System: int identityHashCode(java.lang.Object)>(string);
    
            virtualinvoke sb.<java.lang.StringBuilder: java.lang.StringBuilder append(java.lang.String)>("814193");
    
            tmpString = virtualinvoke sb.<java.lang.StringBuilder: java.lang.String toString()>();
    
            staticinvoke <DynamicSlicingLogger: void println(java.lang.String,int)>(tmpString, hashCode);
    
            $stack6 = string.<java.lang.String: char[] value>;
    
            $stack7 = lengthof $stack6;
    
            $stack8 = $stack7 - start;
    
            if $stack8 < length goto label1;
    
            if start >= 0 goto label2;
    
         label1:
            return 0;
    
         label2:
            if thisStart < 0 goto label3;
    
            $stack9 = thisStr.<java.lang.String: char[] value>;
    
            $stack10 = lengthof $stack9;
    
            $stack11 = $stack10 - thisStart;
    
            if $stack11 >= length goto label4;
    
         label3:
            return 0;
    
         label4:
            if length > 0 goto label5;
    
            return 1;
    
         label5:
            i = 0;
    
         label6:
            if i >= length goto label8;
    
            $stack13 = thisStr.<java.lang.String: char[] value>;
    
            $stack12 = thisStart + i;
    
            $stack17 = $stack13[$stack12];
    
            $stack15 = string.<java.lang.String: char[] value>;
    
            $stack14 = start + i;
    
            $stack16 = $stack15[$stack14];
    
            $i0 = (int) $stack17;
    
            $i1 = (int) $stack16;
    
            if $i0 == $i1 goto label7;
    
            return 0;
    
         label7:
            i = i + 1;
    
            goto label6;
    
         label8:
            return 1;
        }
    
    
    	at soot.jimple.validation.FieldRefValidator.validate(FieldRefValidator.java:83)
    	at soot.jimple.JimpleBody.validate(JimpleBody.java:124)
    	at soot.jimple.JimpleBody.validate(JimpleBody.java:106)
    	at ca.ubc.ece.resess.slicer.dynamic.core.instrumenter.InstrumenterUtils.addPrint(InstrumenterUtils.java:454)
    	at ca.ubc.ece.resess.slicer.dynamic.core.instrumenter.InstrumenterUtils.basicBlockInstrument(InstrumenterUtils.java:70)
    	at ca.ubc.ece.resess.slicer.dynamic.slicer4j.instrumenter.JavaInstrumenter$2.internalTransform(JavaInstrumenter.java:183)
    	at soot.BodyTransformer.transform(BodyTransformer.java:47)
    	at soot.Transform.apply(Transform.java:126)
    	at soot.BodyPack.internalApply(BodyPack.java:49)
    	at soot.Pack.apply(Pack.java:126)
    	at soot.PackManager.runBodyPacks(PackManager.java:991)
    	at soot.PackManager.lambda$runBodyPacks$0(PackManager.java:667)
    	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
    	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
    	at java.base/java.lang.Thread.run(Thread.java:844)
    
    opened by amordahl 4
  • Code instumentation errors

    Code instumentation errors

    Hi there, I got another problem with Jar instrumentation. I tried to slice test cases from javapoet and I got the following error message in instr-debug.log:

    SLF4J: Class path contains multiple SLF4J bindings.
    SLF4J: Found binding in [jar:file:/home/lukas/workspace/master-jsr/slicer/Slicer4J/Slicer4J/target/slicer4j-jar-with-dependencies.jar!/org/slf4j/impl/StaticLoggerBinder.class]
    SLF4J: Found binding in [jar:file:/home/lukas/workspace/master-jsr/slicer/Slicer4J/Slicer4J/target/lib/slf4j-simple-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
    SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
    SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory]
    [main] INFO JimpleWriter - initialize (17): Initializing Instrumenter
    [main] INFO JimpleWriter - initialize (29): Initialization done
    [main] INFO JimpleWriter - start (36): Running packs ... 
    [main] INFO JimpleWriter - start (38): Writing output ... 
    [main] INFO JimpleWriter - start (40): Output written ... 
    [main] INFO JavaInstrumenter - initialize (78): Initializing Instrumenter
    [main] INFO JavaInstrumenter - initialize (97): Initialization done
    [main] INFO JavaInstrumenter - start (250): Running packs ... 
    [main] INFO JavaInstrumenter - start (252): Writing output ... 
    [Thread-57] ERROR heros.solver.CountingThreadPoolExecutor - Worker thread execution failed: value null
    java.lang.IllegalArgumentException: value null
    	at org.objectweb.asm.SymbolTable.addConstant(SymbolTable.java:501)
    	at org.objectweb.asm.AnnotationWriter.visit(AnnotationWriter.java:259)
    	at soot.AbstractASMBackend.generateAnnotationElems(AbstractASMBackend.java:595)
    	at soot.AbstractASMBackend.generateAnnotationElems(AbstractASMBackend.java:549)
    	at soot.AbstractASMBackend.generateAnnotations(AbstractASMBackend.java:521)
    	at soot.AbstractASMBackend.generateMethods(AbstractASMBackend.java:355)
    	at soot.AbstractASMBackend.generateByteCode(AbstractASMBackend.java:273)
    	at soot.AbstractASMBackend.generateClassFile(AbstractASMBackend.java:224)
    	at soot.PackManager.writeClass(PackManager.java:1141)
    	at soot.PackManager.lambda$writeOutput$1(PackManager.java:699)
    	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    	at java.base/java.lang.Thread.run(Thread.java:829)
    Exception in thread "Thread-57" Exception in thread "main" java.lang.IllegalArgumentException: value null
    	at org.objectweb.asm.SymbolTable.addConstant(SymbolTable.java:501)
    	at org.objectweb.asm.AnnotationWriter.visit(AnnotationWriter.java:259)
    	at soot.AbstractASMBackend.generateAnnotationElems(AbstractASMBackend.java:595)
    	at soot.AbstractASMBackend.generateAnnotationElems(AbstractASMBackend.java:549)
    	at soot.AbstractASMBackend.generateAnnotations(AbstractASMBackend.java:521)
    	at soot.AbstractASMBackend.generateMethods(AbstractASMBackend.java:355)
    	at soot.AbstractASMBackend.generateByteCode(AbstractASMBackend.java:273)
    	at soot.AbstractASMBackend.generateClassFile(AbstractASMBackend.java:224)
    	at soot.PackManager.writeClass(PackManager.java:1141)
    	at soot.PackManager.lambda$writeOutput$1(PackManager.java:699)
    	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    	at java.base/java.lang.Thread.run(Thread.java:829)
    java.lang.IllegalArgumentException: value null
    	at org.objectweb.asm.SymbolTable.addConstant(SymbolTable.java:501)
    	at org.objectweb.asm.AnnotationWriter.visit(AnnotationWriter.java:259)
    	at soot.AbstractASMBackend.generateAnnotationElems(AbstractASMBackend.java:595)
    	at soot.AbstractASMBackend.generateAnnotationElems(AbstractASMBackend.java:549)
    	at soot.AbstractASMBackend.generateAnnotations(AbstractASMBackend.java:521)
    	at soot.AbstractASMBackend.generateMethods(AbstractASMBackend.java:355)
    	at soot.AbstractASMBackend.generateByteCode(AbstractASMBackend.java:273)
    	at soot.AbstractASMBackend.generateClassFile(AbstractASMBackend.java:224)
    	at soot.PackManager.writeClass(PackManager.java:1141)
    	at soot.PackManager.lambda$writeOutput$1(PackManager.java:699)
    	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    	at java.base/java.lang.Thread.run(Thread.java:829)
    

    Here's the fat jar I created from the project:

    javapoet-1.14.0-SNAPSHOT-fat-tests.zip

    This is not the first time that I am seeing issues related to SymbolTable. When I was trying to perform slicing on the commons-lang library I got similar errors during instrumentation. This is really a problem because I need to benchmark at least 10 projects for my Master's thesis and so far Slicer4J managed to work with 3 of over 20 open source projects I tried.

    I would be really happy if you could look into this issue. Thank you.

    opened by Lms24 3
  • Library classes in jar are thrown out during instrumentation

    Library classes in jar are thrown out during instrumentation

    Hello,

    I am currently trying to create dynamic slices from the test cases of this project. The project depends on the following libraries:

    <dependencies>
      <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
      </dependency> 
      <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.11</version>
        <scope>test</scope>
      </dependency>
    </dependencies>
    

    I've created a fat jar containing the compiled source and test classes, as well as the classes of all libraries.

    After instrumenting the jar with SLice4J (mode i), the classes from javax.servlet are all missing in the resulting *_i.jar file! This is a problem as I get exceptions like this one for obvious reasons when I want to trace the execution:

    Exception in thread "main" java.lang.NoClassDefFoundError: javax/servlet/http/HttpServletRequest
    

    Is there something I can do as a user of Slicer4J to fix this or is this a problem/bug in the implementation or one of its libraries (soot?)?

    Thanks and have a nice day!

    opened by Lms24 2
Owner
The Reliable, Secure, and Sustainable Software Lab
ReSeSS aims at improving software integrity and robustness.
The Reliable, Secure, and Sustainable Software Lab
Design patterns implemented in Java

Design patterns implemented in Java Read in different language : CN, KR, FR, TR, AR Introduction Design patterns are the best formalized practices a p

Ilkka Seppälä 79k Jan 2, 2023
Java EE 7 Samples

Java EE 7 Samples This workspace consists of Java EE 7 Samples and unit tests. They are categorized in different directories, one for each Technology/

JavaEE Samples 2.5k Dec 20, 2022
Solutions for some common algorithm problems written in Java.

Algorithms This repository contains my solution for common algorithms. I've created this repository to learn about algorithms and improve solutions to

Pedro Vicente Gómez Sánchez 2.8k Dec 30, 2022
Algorithms and Data Structures implemented in Java

Java : Algorithms and Data Structure The algorithms and data structures are implemented in Java. This is a collection of algorithms and data structure

Justin Wetherell 4.2k Jan 5, 2023
MCQs and coding questions solutions of Object-Oriented Programming java of coding ninjas

cn-java-sols (⌐■_■) Link to This repository Other similar repository of my friend Link ?? enjoy having full marks ?? ?? now answers avaible up to Stri

Sanyam Mahajan 11 Dec 27, 2022
Rework of html-java-dsl to work with newer Javas

java-html-dsl Example DSL for writing html in Java. Rework of benjiman/java-html-dsl to work with newer versions of Java This String doc = html(

Benji Weber 19 Jan 25, 2022
A toolchain for Minecraft: Java Edition that builds a workspace to interact with the game using the official mappings provided to the public by Mojang Studios.

VanillaGradle is a toolchain for Minecraft: Java Edition that provides a workspace to interact with the game using official mappings provided by Mojan

SpongePowered 75 Nov 22, 2022
Amazing Ruby's "Enumerable" ported to Java

Overview How to use? .all .any .none .select .map .count .reject .find How to contribute? Contributors Overview enumerable4j is a Ruby's well known En

Yurii Dubinka 30 Oct 28, 2022
Java 16 Features

Java 16 Features. Features are separated by package name.

Rahman Usta 9 Jan 7, 2022
Java Kampında derslerde yazılan projeler

nLayeredDemo JavaCampDay5Lesson https://www.youtube.com/watch?v=yaBPeS65vwM&ab_channel=EnginDemiro%C4%9F linkteki derste yapılan proje. Nortwind JavaC

Zeyneb Eda YILMAZ 10 Dec 14, 2021
Engin DEMIROG yotube java kamp HW

JavaBootCamp https://www.kodlama.io/courses/enrolled/1332369 Engin DEMIROG yotube javaBootCamp HW ve projeler Java & React Bootcamp (https://kodlama.i

Melik KARACA 8 Nov 13, 2022
Software Developer Training Camp (JAVA + REACT) works under the guidance of Engin Demiroğ

https://kodlama.io/p/yazilim-gelistirici-yetistirme-kampi2 [EN] Java_React-BootCamp Software Developer Training Camp (JAVA + REACT) works under the gu

Saba ÜRGÜP 18 Dec 24, 2022
A Java game Solitaire, made with JavaFX

Java Solitaire A game made with JavaFX Installation requirements: At least Java 11 installed. setup: 2.1. Intellij -> Open the file in the IDE and exe

Walter Alleyz 15 May 6, 2021
Bitcoin SV Library for Java

Introduction Overview Bitcoin4J is a Bitcoin library for the Java Language licensed under the Apache License 2.0. This library has been built in line

null 17 May 25, 2022
Repository for Bryn and Ethan's Java with MicroServices Batch

210607-FeederProgram This repository houses examples and environment setup for the Revature feeder program beginning on 6/7/2021 Environment Setup Gui

Bryn Portella 17 May 22, 2022
http://kodlama.io "Java & React Bootcamp" up to date Lectures and Homeworks.

Java & React Bootcamp (https://kodlama.io/) Lectures Lecture 1 intro Lecture 2 oopIntro homework Lecture 3 oopIntro2 inheritance inheritance2 homework

Karcan Ozbal 237 Dec 29, 2022
Códigos do Bootcamp Java Básico DIO

Curso Java Básico Digital Innovation One https://digitalinnovation.one Tive a honra de fazer parceria com o pessoal da Digital Innovation One, com doi

Nicole Bidigaray 3 Jul 28, 2021
Ejercicios de CodeSignal resueltos en Java

CodeSignal Ejercicios resueltos en Java de la plataforma CodeSignal. Crear el proyecto con Maven Abrimos un terminal y ejecutamos el siguiente comando

Desarrollo de Interfaces (DAD) 3 Sep 21, 2021
Java Coding Practice

Java Coding Practice I have solved many problems in this, Some of them are Median of Two Sorted Arrays Merge k Sorted Lists First Missing Positive Val

null 10 Nov 12, 2021