Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A NullPointerException occured while using the project #2

Open
Dieulin opened this issue Jan 12, 2016 · 1 comment
Open

A NullPointerException occured while using the project #2

Dieulin opened this issue Jan 12, 2016 · 1 comment

Comments

@Dieulin
Copy link

Dieulin commented Jan 12, 2016

Hello,
I'm trying Java-RSRepair in my academic project to repair bugs automatically. I want to try it with a java program Syllables.java in the package introclassJava with my testcase SyllablesWhiteboxTest.java in a package called introclassJava.

  • Here is the hierarchy of my project files :
|-- exemple
|---- config
|------ build.xml
|------ faulty.cov
|------ jrsrepair.properties
|------ seed.cov
|---- src
|------ introclassJava
|-------- Syllables.java
|---- test
|------ introclassJava
|-------- SyllablesWhiteboxTest.java

I wrote all the config files following the sample config files model in your repository, but when I execute the program, I get a NullPointerException. I tried to debug it but the problem persists. Do you have any solution to resolve my problem ?

  • Here is the stack trace :
Running candidate 1 ...
Running generation 1 ...
Applying addition mutation...null
Applying null mutation...Error: null
Exception in thread "main" java.lang.NullPointerException
    at ca.uwaterloo.ece.qhanam.jrsrepair.Statements.getRandomStatement(Statements.java:63)
    at ca.uwaterloo.ece.qhanam.jrsrepair.context.MutationContext.getRandomMutation(MutationContext.java:61)
    at ca.uwaterloo.ece.qhanam.jrsrepair.JRSRepair.mutationIteration(JRSRepair.java:161)
    at ca.uwaterloo.ece.qhanam.jrsrepair.JRSRepair.repair(JRSRepair.java:61)
    at ca.uwaterloo.ece.qhanam.jrsrepair.JRSRepairMain.main(JRSRepairMain.java:26)
  • Here is my jrsrepair.properties file :
# The coverage files from fault localization
faulty_coverage = ./exemple/config/faulty.cov
seed_coverage = ./exemple/config/seed.cov

# Settings for mutant generation
mutation_candidates = 10
mutation_generations = 1
mutation_attempts = 1

# Test script settings ***
#   Currently there are two options for test scripts:
#     1. Ant script (uses Apache Ant)
#     2. Bash script (user defined shell script for running JUnit)

# Specify the test script. Choose from {ANT,BASH}
test_script = ANT

#1. Ant settings
ant_base_dir = ./exemple/config/
ant_path = /usr/bin/ant
ant_compile_target = compile
ant_test_target = junit

#2. Bash script
bash_script_base_dir = 
bash_script_path = 

# Where to put log the log files and class files
build_directory = ./exemple/config/build
class_directory = ./exemple/config/build/classes

# Path settings for parsing the AST (and resolving bindings) and compiling
sourcepath = {./exemple/src/}
classpath = {}

# Include and exclude filters for copying files from the source directory to the class directory. Default behaviour is that nothing is copied (copy_source_includes = {}).
#copy_source_includes = {.*}
#copy_source_excludes = {.*\.java,package\.html}

# Different random seeds will cause different mutation operation orders and different statement selections
random_seed = 1

# Setting to true causes JRSRepair to perform no mutations. Useful for debugging compilation.
null_mutation_only = false
  • Here my build.xml file :
<project name="introclassJava" default="compile" basedir=".">
    <description>
        Executatable build file for Syllables test program.
    </description>

    <!-- set global properties for this build -->
    <property name="source.java" location="../src"/>
    <property name="source.test" location="../test"/>
    <property name="build" location="build"/>
    <property name="dist"    location="dist"/>

<!-- ========== Properties ================================================ -->

    <!-- This can be used to define 'junit.jar' property if necessary -->
    <property file="build.properties"/>

<!-- ========== Component Declarations ==================================== -->

    <!-- The name of this component -->
    <property name="component.name"                    value="syllables"/>

    <!-- The primary package name of this component -->
    <property name="component.package"             value="introclassJava"/>

    <!-- The short title of this component -->
    <property name="component.title"                 value="Syllables"/>

    <!-- The full title of this component -->
    <property name="component.title.full"        value="Syllables Test Program"/>

    <!-- The current version number of this component -->
    <property name="component.version"             value="1.0"/>

    <!-- The directories for compilation targets -->
    <property name="build.home"                            value="build/"/>
    <property name="build.classes"                     value="${build.home}/classes"/>
    <property name="build.tests"                         value="${build.home}/tests"/>
    <property name="build.test.reports"            value="${build.home}/test-reports"/>
    <property name="junit.jar"                             value="../../libs/junit-4.12.jar"/>
    <property name="hamcrest-all.jar"                 value="../../libs/hamcrest-all-1.3.jar"/>

    <!-- The name/location of the jar file to build -->
    <property name="final.name"                     value="${component.name}-${component.version}"/>
    <property name="jar.name"                         value="${final.name}.jar"/>
    <property name="build.jar.name"             value="${build.home}/${jar.name}"/>

<!-- ========== Settings ================================================== -->

    <!-- Javac -->
    <property name="compile.debug"                     value="true"/>
    <property name="compile.deprecation"         value="true"/>
    <property name="compile.optimize"                value="false"/>

    <!-- JUnit -->
    <property name="test.failonerror"                value="true"/>
    <property name="testcase"                                 value="introclassJava.SyllablesBlackboxTest"/>

<!-- ======================================================== -->
<!-- ======= Executable Targets ============================= -->
<!-- ======================================================== -->

    <target name="init"
                    description="Initialize and evaluate conditionals">
        <echo message="------- ${component.name} ${component.version} ------"/>
    </target>

<!-- ======================================================== -->

    <target name="prepare" depends="init"
                    description="Prepare build directory">
        <mkdir dir="${build.home}"/>
    </target>

<!-- ======================================================== -->

    <target name="compile" depends="init"
                    description="Compile main code">
        <mkdir dir="${build.classes}" />
        <javac srcdir="${source.java}"
                        destdir="${build.classes}"
                        debug="${compile.debug}"
                        deprecation="${compile.deprecation}"
                        optimize="${compile.optimize}">
        </javac>
    </target>

<!-- ======================================================== -->

    <target name="compile.tests" depends="compile"
                    description="Compile unit test cases">
        <mkdir dir="${build.tests}" />
        <javac srcdir="${source.test}"
                        destdir="${build.tests}"
                        debug="true"
                        deprecation="false"
                        optimize="false">
            <classpath>
                <pathelement location="${build.classes}"/>
                <pathelement location="${junit.jar}"/>
                <pathelement location="${hamcrest-all.jar}"/>
            </classpath>
        </javac>
    </target>

<!-- ======================================================== -->

    <target name="jar" depends="compile"
            description="Create jar" >
        <tstamp/>
        <jar     jarfile="${build.jar.name}"
                    basedir="${build.classes}"/>
    </target>

<!-- ======================================================== -->

    <target name="junit" depends="compile.tests"
                    description="Run JUnit test cases.">
        <mkdir dir="${build.test.reports}"/>
        <tstamp>
            <format property="FILE_NAME" pattern="yyyyMMddHHmmssSSS"/>
        </tstamp>
        <echo> the current time is ${FILE_NAME}</echo>
        <junit printsummary="yes" haltonfailure="yes" showoutput="yes">
            <formatter type="brief"/>
            <classpath>
                <pathelement location="${build.classes}"/>
                <pathelement location="${build.tests}"/>
                <pathelement location="${junit.jar}"/>
                <pathelement location="${hamcrest-all.jar}"/>
            </classpath>
            <test name="${testcase}" fork="yes" todir="${build.test.reports}" outfile="TEST-${FILE_NAME}">
                <formatter type="brief" usefile="false"/>
            </test>
        </junit>
    </target>

</project>
  • Here is the faulty.cov file :
introclassJava:Syllables:5:0.1
introclassJava:Syllables:43:0.1
introclassJava:Syllables:45:0.1
introclassJava:Syllables:59:0.1
introclassJava:Syllables:61:0.1
introclassJava:Syllables:62:0.1
introclassJava:Syllables:63:0.1
introclassJava:Syllables:64:0.1
introclassJava:Syllables:65:0.1
introclassJava:Syllables:66:0.1
introclassJava:Syllables:67:0.1
introclassJava:Syllables:70:0.1
introclassJava:Syllables:71:0.1
introclassJava:Syllables:73:0.1
introclassJava:Syllables:74:0.1
introclassJava:Syllables:76:0.1
introclassJava:Syllables:77:0.1
introclassJava:Syllables:79:0.1
introclassJava:Syllables:80:0.1
introclassJava:Syllables:82:0.1
introclassJava:Syllables:83:0.1
introclassJava:Syllables:88:0.1
introclassJava:Syllables:91:0.1
introclassJava:Syllables:93:0.1
  • Here is the seed.cov file :
introclassJava:Syllables:5:1.0
introclassJava:Syllables:43:1.0
introclassJava:Syllables:45:1.0
introclassJava:Syllables:59:1.0
introclassJava:Syllables:61:1.0
introclassJava:Syllables:62:1.0
introclassJava:Syllables:63:1.0
introclassJava:Syllables:64:1.0
introclassJava:Syllables:65:1.0
introclassJava:Syllables:66:1.0
introclassJava:Syllables:67:1.0
introclassJava:Syllables:70:1.0
introclassJava:Syllables:71:1.0
introclassJava:Syllables:73:1.0
introclassJava:Syllables:74:1.0
introclassJava:Syllables:76:1.0
introclassJava:Syllables:77:1.0
introclassJava:Syllables:79:1.0
introclassJava:Syllables:80:1.0
introclassJava:Syllables:82:1.0
introclassJava:Syllables:83:1.0
introclassJava:Syllables:88:1.0
introclassJava:Syllables:91:1.0
introclassJava:Syllables:93:1.0
introclassJava:Syllables:6:1.0
introclassJava:Syllables:68:1.0

Thank you in advance.

@qhanam
Copy link
Owner

qhanam commented Jan 13, 2016

Sounds like this.statements.ceilingEntry(random) is null?

If this is the case, then there are probably no statements in the map. It could be that the java source files are not being parsed correctly or that the statements in the source files aren't being matched to the statements in faulty.cov or seed.cov. Debug around ParserContext.buildASTs (does the parsing with JDT) and MutationASTRequestor (matches the records in faulty.cov and seed.cov to actual statements from JDT).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants