Skip to content

Commit d644f1f

Browse files
NullPath, a NPE static analyzer for Java
1 parent 6ebe59b commit d644f1f

File tree

73 files changed

+4144
-169
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+4144
-169
lines changed

build.gradle.kts

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ plugins {
44
id("maven-publish.conventions")
55
}
66

7+
repositories {
8+
mavenCentral()
9+
}
10+
711
group = projectGroupId
812
description = projectArtifactId
913
version = projectVersion
@@ -30,6 +34,14 @@ dependencies {
3034
implementation("org.slf4j:slf4j-nop:2.0.7")
3135
// JSR305, for javax.annotation
3236
implementation("com.google.code.findbugs:jsr305:3.0.2")
37+
// Use asm to read java class file
38+
implementation("org.ow2.asm:asm:9.4")
39+
implementation("org.ow2.asm:asm-commons:9.5")
40+
implementation("org.ow2.asm:asm-tree:9.5")
41+
implementation("org.ow2.asm:asm-util:9.5")
42+
implementation("org.eclipse.jdt:org.eclipse.jdt.core:3.28.0")
43+
44+
implementation("org.sat4j:org.sat4j.core:2.3.1")
3345

3446
testImplementation(platform("org.junit:junit-bom:5.10.0"))
3547
testImplementation("org.junit.jupiter:junit-jupiter")
@@ -53,46 +65,20 @@ task("fatJar", type = Jar::class) {
5365
}
5466
)
5567
from("COPYING", "COPYING.LESSER")
56-
destinationDirectory.set(rootProject.layout.buildDirectory)
68+
destinationDirectory.set(rootProject.buildDir)
5769
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
5870
with(tasks["jar"] as CopySpec)
5971
}
6072

6173
tasks.jar {
6274
from("COPYING", "COPYING.LESSER")
63-
from(zipTree("lib/sootclasses-modified.jar"))
64-
destinationDirectory.set(rootProject.layout.buildDirectory)
75+
destinationDirectory.set(rootProject.buildDir)
6576
}
6677

67-
tasks.withType<Test> {
68-
// Uses JUnit5
69-
useJUnitPlatform()
78+
tasks.test {
7079
// Increases the maximum heap memory of JUnit test process. The default is 512M.
7180
// (see org.gradle.process.internal.worker.DefaultWorkerProcessBuilder.build)
7281
maxHeapSize = "2G"
73-
// Sets the maximum number of test processes to start in parallel.
74-
maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).takeIf { it > 0 } ?: 1
75-
// Sets the default classpath for test execution.
76-
// (see https://docs.gradle.org/current/userguide/upgrading_version_8.html#test_task_default_classpath)
77-
val test by testing.suites.existing(JvmTestSuite::class)
78-
testClassesDirs = files(test.map { it.sources.output.classesDirs })
79-
classpath = files(test.map { it.sources.runtimeClasspath })
80-
}
81-
82-
tasks.test {
83-
// Excludes test suites from the default test task
84-
// to avoid running some tests multiple times.
85-
filter {
86-
excludeTestsMatching("*TestSuite")
87-
}
88-
}
89-
90-
task("testTaieTestSuite", type = Test::class) {
91-
group = "verification"
92-
description = "Runs the Tai-e test suite"
93-
filter {
94-
includeTestsMatching("TaieTestSuite")
95-
}
9682
}
9783

9884
// Automatically agree the Gradle ToS when running gradle with '--scan' option

src/main/java/pascal/taie/analysis/AnalysisManager.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,6 @@ private List<JClass> getClassScope() {
189189

190190
private void runMethodAnalysis(MethodAnalysis<?> analysis) {
191191
getMethodScope()
192-
.parallelStream()
193192
.forEach(m -> {
194193
IR ir = m.getIR();
195194
Object result = analysis.analyze(ir);

src/main/java/pascal/taie/analysis/bugfinder/BugInstance.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,19 @@ public BugInstance(@Nonnull BugType type, Severity severity) {
4646
this.severity = severity;
4747
}
4848

49+
public BugInstance(@Nonnull BugType type, Severity severity, JMethod method) {
50+
this.type = type;
51+
this.severity = severity;
52+
this.jMethod = method;
53+
this.jClass = method.getDeclaringClass();
54+
}
55+
56+
public BugInstance(@Nonnull BugType type, Severity severity, JClass jClass) {
57+
this.type = type;
58+
this.severity = severity;
59+
this.jClass = jClass;
60+
}
61+
4962
public Severity getSeverity() {
5063
return severity;
5164
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package pascal.taie.analysis.bugfinder;
2+
3+
import pascal.taie.analysis.pta.core.solver.PointerFlowEdge;
4+
import pascal.taie.analysis.pta.core.solver.Transfer;
5+
import pascal.taie.analysis.pta.pts.PointsToSet;
6+
7+
import java.util.ArrayList;
8+
import java.util.List;
9+
10+
public class CompositeFilter implements Transfer {
11+
private final List<Transfer> transfers;
12+
13+
public CompositeFilter(Transfer... transfers) {
14+
this.transfers = new ArrayList<>(transfers.length);
15+
this.transfers.addAll(List.of(transfers));
16+
}
17+
18+
public CompositeFilter(List<Transfer> transfers) {
19+
this.transfers = new ArrayList<>(transfers);
20+
}
21+
22+
@Override
23+
public PointsToSet apply(PointerFlowEdge edge, PointsToSet input) {
24+
PointsToSet result = input;
25+
for (Transfer transfer : transfers) {
26+
result = transfer.apply(edge, result);
27+
}
28+
return result;
29+
}
30+
}

0 commit comments

Comments
 (0)