Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
7793d51
Add checker-qual for running impurity obj fuzzing
776styjsu Jul 30, 2025
8f604c2
Move all subject program jars into jars/
776styjsu Jul 31, 2025
c69ea5d
Add the jars back
776styjsu Jul 31, 2025
8eda5bd
Remove version number for CF to reduce potential future refactor effort
776styjsu Jul 31, 2025
a7485fe
Less indentation for comments
mernst Aug 6, 2025
3ea8f45
Add annotated jars; use them when GRT_FUZZING is on
776styjsu Aug 8, 2025
2d08e1f
Merge branch 'impurity-annotation' of github.com:776styjsu/grt-testin…
776styjsu Aug 8, 2025
3d1d11a
Add annotated jars; use them when GRT_FUZZING is on; Merge
776styjsu Aug 8, 2025
5905a5a
Add missing separator
776styjsu Aug 8, 2025
ea2a440
Fix jdom dependencies path
776styjsu Aug 9, 2025
37bbb96
Update slf4j jar namespace; remove binders
776styjsu Aug 9, 2025
8b7c211
Merge branch 'randoop:main' into main
776styjsu Aug 10, 2025
cde99c4
Merge ../grt-testing-branch-main into impurity-annotation
mernst Aug 11, 2025
12cea4d
Merge branch 'main' into impurity-annotation
776styjsu Aug 11, 2025
5e6cc7d
Merge ../grt-testing-branch-main into impurity-annotation
mernst Aug 20, 2025
5e6e92e
Merge ../grt-testing-branch-main into impurity-annotation
mernst Sep 1, 2025
c5c5f91
Abstract out version number
mernst Sep 1, 2025
a35c932
Merge ../grt-testing-branch-main into impurity-annotation
mernst Sep 1, 2025
41297e7
Fix make issues
776styjsu Sep 11, 2025
0e3f50e
Fix make
776styjsu Sep 11, 2025
a9f0f73
Update scripts/Makefile
mernst Sep 11, 2025
659177e
Remove stray command-line arguments
mernst Sep 11, 2025
dd22826
Merge ../grt-testing-branch-main into impurity-annotation
mernst Oct 30, 2025
353d40c
Merge branch 'randoop:main' into impurity-annotation
776styjsu Oct 31, 2025
260ce15
Add README.md on building annotated subject-program jars
776styjsu Nov 1, 2025
79545fd
Update README.md
776styjsu Nov 1, 2025
4c6a19f
Update README.md
776styjsu Nov 1, 2025
ceb5b82
Update README.md
776styjsu Nov 1, 2025
5cc6053
Merge ../grt-testing-branch-main into impurity-annotation
mernst Nov 1, 2025
cc23b13
Merge ../grt-testing-branch-main into impurity-annotation
mernst Nov 13, 2025
7672dd7
Merge main into impurity-annotation
Nov 16, 2025
035b0c1
Fix linter
Nov 16, 2025
be4b6c6
Fix bug in grt fuzzing check
Nov 16, 2025
fab2301
Fix last linter
Nov 16, 2025
66b6429
Merge ../grt-testing-branch-main into impurity-annotation
mernst Nov 26, 2025
4635465
Only `sh` is needed, not full `bash`
mernst Nov 26, 2025
9fa1783
Fill paragraph
mernst Nov 26, 2025
a26c382
Brevity, fix `CHECKERFRAMEWORK` environment variable
mernst Nov 26, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion scripts/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
MAKEFILE_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))

all: \
build/checker-framework/checker/dist/checker-qual.jar \
build/evosuite-1.2.0.jar \
build/evosuite-standalone-runtime-1.2.0.jar \
build/hamcrest-core-1.3.jar \
Expand Down Expand Up @@ -64,13 +65,21 @@ build/junit-4.12.jar:

build/hamcrest-core-1.3.jar:
mkdir -p build
cp ../subject-programs/hamcrest-core-1.3.jar build/
cp ../subject-programs/jars/hamcrest-core-1.3.jar build/

build/major/bin/ant-replacecall:
LATEST_RELEASE=$$(curl -s https://api.github.com/repos/randoop/grt-replacecall/releases/latest | grep -o '"tag_name": "[^"]*' | cut -d'"' -f4) && \
wget "https://github.com/randoop/grt-replacecall/releases/download/$${LATEST_RELEASE}/ant-replacecall" && \
mv ant-replacecall build/major/bin/

build/checker-framework/checker/dist/checker-qual.jar:
mkdir -p build
CFVER=3.50.0 && \
cd build && wget "https://github.com/typetools/checker-framework/releases/download/checker-framework-$${CFVER}/checker-framework-$${CFVER}.zip" && \
unzip -o checker-framework-$${CFVER}.zip && \
rm -rf checker-framework && \
mv checker-framework-$${CFVER} checker-framework

build/defects4j:
mkdir -p build
cd build && git clone https://github.com/rjust/defects4j && cd defects4j && cpanm --installdeps . && ./init.sh
Expand Down
4 changes: 2 additions & 2 deletions scripts/mutation-evosuite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ echo
SRC_BASE_DIR="$(realpath "$SCRIPT_DIR/../subject-programs/src/$SUBJECT_PROGRAM")"

# Path to the jar file of the subject program.
SRC_JAR=$(realpath "$SCRIPT_DIR/../subject-programs/$SUBJECT_PROGRAM.jar")
SRC_JAR=$(realpath "$SCRIPT_DIR/../subject-programs/jars/$SUBJECT_PROGRAM.jar")

# Number of classes in given jar file.
NUM_CLASSES=$(jar -tf "$SRC_JAR" | grep -c '.class')
Expand Down Expand Up @@ -318,7 +318,7 @@ case "$SUBJECT_PROGRAM" in
"$SRC_BASE_DIR/lib/jaxen-core.jar" \
"$SRC_BASE_DIR/lib/jaxen-jdom.jar" \
"$SRC_BASE_DIR/lib/saxpath.jar" \
"$SCRIPT_DIR/../subject-programs/jaxen-1.1.6.jar"
"$SCRIPT_DIR/../subject-programs/jars/jaxen-1.1.6.jar"
;;

"joda-time-2.3")
Expand Down
31 changes: 21 additions & 10 deletions scripts/mutation-randoop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ set -o pipefail
Generator=Randoop
generator=randoop
SCRIPT_DIR="$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd -P)"
SCRIPT_NAME=$(basename -- "$0")
MAJOR_HOME=$(realpath "${SCRIPT_DIR}/build/major/") # Major home directory, for mutation testing
RANDOOP_JAR=$(realpath "${SCRIPT_DIR}/build/randoop-all-4.3.4.jar") # Randoop jar file
JACOCO_AGENT_JAR=$(realpath "${SCRIPT_DIR}/build/jacocoagent.jar") # For Bloodhound
JACOCO_CLI_JAR=$(realpath "${SCRIPT_DIR}/build/jacococli.jar") # For coverage report generation
REPLACECALL_JAR=$(realpath "${SCRIPT_DIR}/build/replacecall-4.3.4.jar") # For replacing undesired method calls
MAJOR_HOME=$(realpath "${SCRIPT_DIR}/build/major/") # Major home directory, for mutation testing
RANDOOP_JAR=$(realpath "${SCRIPT_DIR}/build/randoop-all-4.3.4.jar") # Randoop jar file
JACOCO_AGENT_JAR=$(realpath "${SCRIPT_DIR}/build/jacocoagent.jar") # For Bloodhound
JACOCO_CLI_JAR=$(realpath "${SCRIPT_DIR}/build/jacococli.jar") # For coverage report generation
REPLACECALL_JAR=$(realpath "${SCRIPT_DIR}/build/replacecall-4.3.4.jar") # For replacing undesired method calls
CHECKER_QUAL_JAR=$(realpath "${SCRIPT_DIR}/build/checker-framework/checker/dist/checker-qual.jar") # For Randoop Impurity

. "$SCRIPT_DIR/defs.sh" # Define shell functions.

Expand All @@ -70,6 +70,7 @@ require_file "$RANDOOP_JAR"
require_file "$JACOCO_AGENT_JAR"
require_file "$JACOCO_CLI_JAR"
require_file "$REPLACECALL_JAR"
require_file "$CHECKER_QUAL_JAR"

usejdk8
JAVA_VER=$(java -version 2>&1 | awk -F '"' '/version/ {print $2}' | awk -F '.' '{sub("^$", "0", $2); print ($1=="1")?$2:$1}')
Expand Down Expand Up @@ -219,8 +220,18 @@ echo
# Path to the base directory of the source code.
SRC_BASE_DIR="$(realpath "$SCRIPT_DIR/../subject-programs/src/$SUBJECT_PROGRAM")"

# Path to the jar file of the subject program.
SRC_JAR=$(realpath "$SCRIPT_DIR/../subject-programs/$SUBJECT_PROGRAM.jar")
if [[ " ${RANDOOP_FEATURES[*]} " =~ " GRT_FUZZING " ]]; then
# If randoop features contain "GRT_FUZZING", use annotated subject program jar.
ANNOTATED_JAR="$SCRIPT_DIR/../subject-programs/annotated-jars/$SUBJECT_PROGRAM.jar"
if [ ! -f "$ANNOTATED_JAR" ]; then
echo "${SCRIPT_NAME}: error: GRT_FUZZING enabled but annotated JAR not found: $ANNOTATED_JAR" >&2
exit 2
fi
SRC_JAR=$(realpath "$ANNOTATED_JAR")
else
# Else, use the original subject program jar.
SRC_JAR=$(realpath "$SCRIPT_DIR/../subject-programs/jars/$SUBJECT_PROGRAM.jar")
fi

# Number of classes in given jar file.
NUM_CLASSES=$(jar -tf "$SRC_JAR" | grep -c '.class')
Expand Down Expand Up @@ -353,7 +364,7 @@ case "$SUBJECT_PROGRAM" in
"$SRC_BASE_DIR/lib/jaxen-core.jar" \
"$SRC_BASE_DIR/lib/jaxen-jdom.jar" \
"$SRC_BASE_DIR/lib/saxpath.jar" \
"$SCRIPT_DIR/../subject-programs/jaxen-1.1.6.jar"
"$SCRIPT_DIR/../subject-programs/jars/jaxen-1.1.6.jar"
;;

"joda-time-2.3")
Expand Down Expand Up @@ -456,7 +467,7 @@ RANDOOP_BASE_COMMAND=(
-Xbootclasspath/a:"$JACOCO_AGENT_JAR:$REPLACECALL_JAR"
-javaagent:"$JACOCO_AGENT_JAR"
-javaagent:"$REPLACECALL_COMMAND"
-classpath "$RANDOOP_CLASSPATH:$RANDOOP_JAR"
-classpath "$RANDOOP_CLASSPATH:$RANDOOP_JAR:$CHECKER_QUAL_JAR"
randoop.main.Main
gentests
--testjar="$TARGET_JAR"
Expand Down
Binary file not shown.
Binary file added subject-programs/annotated-jars/JSAP-2.1.jar
Binary file not shown.
66 changes: 66 additions & 0 deletions subject-programs/annotated-jars/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Annotated Subject Program JARs

This folder holds subject JARs with purity annotations: `@Pure`,
`@SideEffectFree`, `@Impure`, and related qualifiers from
`org.checkerframework.framework.qual` Compared to `subject-programs/jars/`, the
compiled bytecode here is the same, but the class files have purity
annotations. No other code or resources are altered.

The annotations are produced by the Checker Framework whole-program inference.

## Why the annotations matter

The `GRT_FUZZING` feature in `scripts/mutation-randoop.sh` prioritizes impure
calls to mutate an object's state before exercising additional API entry points.
The annotations provide the information it needs.

## Rebuilding an annotated JAR

1. **Fetch sources**: Run `scripts/get-all-subject-src.sh` to populate
`subject-programs/src/<subject-program>/`.
2. **Build the plain JAR**: In the subject directory, run the build command
found in `subject-programs/README.build`. The result lands in
`subject-programs/jars/` or the subject's usual build folder.
3. **Set up inference tooling**: Point your environment at the local Checker
Framework build:

```sh
export CHECKERFRAMEWORK=/path/to/grt-testing/scripts/build/checker-framework
export PATH="$CHECKERFRAMEWORK/annotation-file-utilities/bin:$PATH"
export JAVAC_JAR="$CHECKERFRAMEWORK/checker/dist/javac.jar"
```

4. **Set the classpath**: Start with the JAR you just built, then
append any dependencies:
- Ant projects usually ship extra JARs in a local `jars/` or `lib/` folder.
- Maven projects can generate a classpath with
`mvn -q dependency:build-classpath -Dmdep.outputFile=target/wpi-classpath.txt`.
5. **Run inference**: From the subject directory, execute:

```sh
$CHECKERFRAMEWORK/checker/bin/infer-and-annotate.sh \
"org.checkerframework.framework.util.PurityChecker" \
"$RUNTIME_CLASSPATH" \
$(find src -name "*.java")
```

The script rewrites the sources in place with the inferred annotations.
6. **Rebuild**: Repeat the command from step 2 to produce an annotated JAR.
Copy it to this folder.

### Worked example (a4j-1.0b)

```sh
cd subject-programs/src/a4j-1.0b
ant createJar # build the baseline JAR
export CHECKERFRAMEWORK=... # reuse the env vars above
export PATH="$CHECKERFRAMEWORK/annotation-file-utilities/bin:$PATH"
export JAVAC_JAR="$CHECKERFRAMEWORK/checker/dist/javac.jar"
RUNTIME_CLASSPATH="../../jars/a4j-1.0b.jar:jars/jox116.jar:jars/log4j-1.2.4.jar"
$CHECKERFRAMEWORK/checker/bin/infer-and-annotate.sh \
"org.checkerframework.framework.util.PurityChecker" \
"$RUNTIME_CLASSPATH" \
$(find src -name "*.java")
ant createJar # rebuild with annotations
cp dist/a4j.jar ../../annotated-jars/a4j-1.0b.jar
```
Binary file added subject-programs/annotated-jars/a4j-1.0b.jar
Binary file not shown.
Binary file added subject-programs/annotated-jars/asm-5.0.1.jar
Binary file not shown.
Binary file added subject-programs/annotated-jars/bcel-5.2.jar
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added subject-programs/annotated-jars/easymock-3.2.jar
Binary file not shown.
Binary file not shown.
Binary file added subject-programs/annotated-jars/guava-16.0.1.jar
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added subject-programs/annotated-jars/jaxen-1.1.6.jar
Binary file not shown.
Binary file not shown.
Binary file added subject-programs/annotated-jars/jdom-1.0.jar
Binary file not shown.
Binary file not shown.
Binary file added subject-programs/annotated-jars/jvc-1.1.jar
Binary file not shown.
Binary file added subject-programs/annotated-jars/nekomud-r16.jar
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added subject-programs/annotated-jars/tiny-sql-2.26.jar
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.