Skip to content

Commit

Permalink
Merge branch 'develop' into bug/resourceleak_bytecode
Browse files Browse the repository at this point in the history
  • Loading branch information
swissiety authored Oct 25, 2024
2 parents a7bb4f8 + 2cca700 commit e52d729
Show file tree
Hide file tree
Showing 95 changed files with 2,000 additions and 259 deletions.
18 changes: 11 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -338,19 +338,23 @@
<configuration>
<failOnMissingHeader>${licence-check.failOnMissingHeader}</failOnMissingHeader>
<failOnNotUptodateHeader>${licence-check.failOnMissingHeader}</failOnNotUptodateHeader>
<inceptionYear>1997</inceptionYear>
<inceptionYear>2022</inceptionYear>
<addJavaLicenseAfterPackage>true</addJavaLicenseAfterPackage>
<licenseName>lgpl_v2_1</licenseName>
<organizationName>Raja Vallée-Rai and others</organizationName>
<organizationName>Kadiray Karakaya, Markus Schmidt, Jonas Klauke, Stefan Schott, Palaniappan Muthuraman, Marcus Hüwe and others</organizationName>
<roots>
<root>sootup.java.analysis/src/main/java</root>
<root>sootup.analysis.interprocedural/src/main/java</root>
<root>sootup.analysis.intraprocedural/src/main/java</root>
<root>sootup.apk.frontend/src/main/java</root>
<root>sootup.callgraph/src/main/java</root>
<root>sootup.codepropertygraph/src/main/java</root>
<root>sootup.core/src/main/java</root>
<root>sootup.java.examples/src/main/java</root>
<root>sootup.java.bytecode/src/main/java</root>
<root>sootup.examples/src/main/java</root>
<root>sootup.interceptors/src/main/java</root>
<root>sootup.java.bytecode.frontend/src/main/java</root>
<root>sootup.java.core/src/main/java</root>
<root>sootup.java.sourcecode/src/main/java</root>
<root>sootup.jimple.parser/src/main/java</root>
<root>sootup.java.sourcecode.frontend/src/main/java</root>
<root>sootup.jimple.frontend/src/main/java</root>
<root>sootup.tests/src/main/java</root>
</roots>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import heros.SynchronizedBy;
import heros.solver.IDESolver;
import java.util.*;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import sootup.core.graph.StmtGraph;
import sootup.core.jimple.basic.Value;
Expand Down Expand Up @@ -83,22 +84,26 @@ protected AbstractJimpleBasedICFG() {
}

protected Map<Stmt, Body> createStmtToOwnerMap() {
return new LinkedHashMap<>();
return new IdentityHashMap<>();
}

protected AbstractJimpleBasedICFG(boolean enableExceptions) {
this.enableExceptions = enableExceptions;
}

public Body getBodyOf(Stmt stmt) {
assert stmtToOwner.containsKey(stmt) : "Statement " + stmt + " not in Stmt-to-owner mapping";
return stmtToOwner.get(stmt);
Body body = stmtToOwner.get(stmt);
assert body != null : "Statement " + stmt + " not in Stmt-to-owner mapping";
return body;
}

@Override
public SootMethod getMethodOf(Stmt stmt) {
Body b = getBodyOf(stmt);
return b == null ? null : view.getMethod(b.getMethodSignature()).orElse(null);
if (b == null) {
return null;
}
return view.getMethod(b.getMethodSignature()).orElse(null);
}

@Override
Expand All @@ -107,8 +112,8 @@ public List<Stmt> getSuccsOf(Stmt stmt) {
if (body == null) {
return Collections.emptyList();
}
StmtGraph<?> unitGraph = getOrCreateStmtGraph(body);
return unitGraph.successors(stmt);
StmtGraph<?> stmtGraph = getOrCreateStmtGraph(body);
return stmtGraph.successors(stmt);
}

@Override
Expand All @@ -125,30 +130,23 @@ protected StmtGraph<?> makeGraph(Body body) {
}

protected Set<Stmt> getCallsFromWithinMethod(SootMethod method) {
Set<Stmt> res = null;
for (Stmt u : method.getBody().getStmts()) {
if (isCallStmt(u)) {
if (res == null) {
res = new LinkedHashSet<>();
}
res.add(u);
}
}
return res == null ? Collections.emptySet() : res;
return method.getBody().getStmts().stream()
.filter(this::isCallStmt)
.collect(Collectors.toSet());
}

@Override
public boolean isExitStmt(Stmt stmt) {
Body body = getBodyOf(stmt);
StmtGraph<?> unitGraph = getOrCreateStmtGraph(body);
return unitGraph.getTails().contains(stmt);
StmtGraph<?> stmtGraph = getOrCreateStmtGraph(body);
return stmtGraph.getTails().contains(stmt);
}

@Override
public boolean isStartPoint(Stmt stmt) {
Body body = getBodyOf(stmt);
StmtGraph<?> unitGraph = getOrCreateStmtGraph(body);
return unitGraph.getEntrypoints().contains(stmt);
StmtGraph<?> stmtGraph = getOrCreateStmtGraph(body);
return stmtGraph.getEntrypoints().contains(stmt);
}

@Override
Expand All @@ -174,12 +172,12 @@ public List<Value> getParameterRefs(SootMethod m) {

@Override
public Collection<Stmt> getStartPointsOf(SootMethod m) {
if (m.hasBody()) {
Body body = m.getBody();
StmtGraph<?> unitGraph = getOrCreateStmtGraph(body);
return unitGraph.getEntrypoints();
if (!m.hasBody()) {
return Collections.emptySet();
}
return Collections.emptySet();
Body body = m.getBody();
StmtGraph<?> stmtGraph = getOrCreateStmtGraph(body);
return stmtGraph.getEntrypoints();
}

public boolean setOwnerStatement(Stmt u, Body b) {
Expand All @@ -193,16 +191,16 @@ public boolean isCallStmt(Stmt stmt) {

@Override
public Set<Stmt> allNonCallStartNodes() {
Set<Stmt> res = new LinkedHashSet<>(stmtToOwner.keySet());
res.removeIf(u -> isStartPoint(u) || isCallStmt(u));
return res;
return stmtToOwner.keySet().stream()
.filter(u -> !(isStartPoint(u) || isCallStmt(u)))
.collect(Collectors.toSet());
}

@Override
public Set<Stmt> allNonCallEndNodes() {
Set<Stmt> res = new LinkedHashSet<>(stmtToOwner.keySet());
res.removeIf(u -> isExitStmt(u) || isCallStmt(u));
return res;
return stmtToOwner.keySet().stream()
.filter(u -> !(isExitStmt(u) || isCallStmt(u)))
.collect(Collectors.toSet());
}

@Override
Expand All @@ -216,12 +214,11 @@ public Set<Stmt> getCallsFromWithin(SootMethod m) {
}

public void initializeStmtToOwner(SootMethod m) {
if (m.hasBody()) {
Body b = m.getBody();
for (Stmt node : b.getStmtGraph().getNodes()) {
stmtToOwner.put(node, b);
}
if (!m.hasBody()) {
return;
}
Body b = m.getBody();
b.getStmtGraph().getNodes().forEach(node -> stmtToOwner.put(node, b));
}

@Override
Expand All @@ -231,18 +228,18 @@ public List<Stmt> getPredsOf(Stmt u) {
if (body == null) {
return Collections.emptyList();
}
StmtGraph<?> unitGraph = getOrCreateStmtGraph(body);
return unitGraph.predecessors(u);
StmtGraph<?> stmtGraph = getOrCreateStmtGraph(body);
return stmtGraph.predecessors(u);
}

@Override
public Collection<Stmt> getEndPointsOf(SootMethod m) {
if (m.hasBody()) {
Body body = m.getBody();
StmtGraph<?> unitGraph = getOrCreateStmtGraph(body);
return unitGraph.getTails();
if (!m.hasBody()) {
return Collections.emptySet();
}
return Collections.emptySet();
Body body = m.getBody();
StmtGraph<?> stmtGraph = getOrCreateStmtGraph(body);
return stmtGraph.getTails();
}

@Override
Expand All @@ -252,12 +249,7 @@ public List<Stmt> getPredsOfCallAt(Stmt u) {

@Override
public boolean isReturnSite(Stmt n) {
for (Stmt pred : getPredsOf(n)) {
if (isCallStmt(pred)) {
return true;
}
}
return false;
return getPredsOf(n).stream().anyMatch(this::isCallStmt);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
package sootup.analysis.interprocedural.icfg;

/*-
* #%L
* SootUp
* %%
* Copyright (C) 2022 - 2024 Kadiray Karakaya, Markus Schmidt, Jonas Klauke, Stefan Schott, Palaniappan Muthuraman, Marcus Hüwe and others
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 2.1 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/

import java.util.Collection;
import java.util.List;
import java.util.Set;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
package sootup.analysis.intraprocedural;

/*-
* #%L
* SootUp
* %%
* Copyright (C) 2022 - 2024 Kadiray Karakaya, Markus Schmidt, Jonas Klauke, Stefan Schott, Palaniappan Muthuraman, Marcus Hüwe and others
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 2.1 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/

import sootup.core.graph.BasicBlock;
import sootup.core.graph.StmtGraph;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
package sootup.analysis.intraprocedural;

/*-
* #%L
* SootUp
* %%
* Copyright (C) 2022 - 2024 Kadiray Karakaya, Markus Schmidt, Jonas Klauke, Stefan Schott, Palaniappan Muthuraman, Marcus Hüwe and others
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 2.1 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/

import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
package sootup.analysis.intraprocedural;

/*-
* #%L
* SootUp
* %%
* Copyright (C) 2022 - 2024 Kadiray Karakaya, Markus Schmidt, Jonas Klauke, Stefan Schott, Palaniappan Muthuraman, Marcus Hüwe and others
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 2.1 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/

import sootup.core.graph.BasicBlock;
import sootup.core.graph.StmtGraph;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
package sootup.apk.frontend;

/*-
* #%L
* SootUp
* %%
* Copyright (C) 2022 - 2024 Kadiray Karakaya, Markus Schmidt, Jonas Klauke, Stefan Schott, Palaniappan Muthuraman, Marcus Hüwe and others
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 2.1 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/

import java.io.IOException;
import java.nio.file.Path;
import java.util.*;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
package sootup.apk.frontend;

/*-
* #%L
* SootUp
* %%
* Copyright (C) 2022 - 2024 Kadiray Karakaya, Markus Schmidt, Jonas Klauke, Stefan Schott, Palaniappan Muthuraman, Marcus Hüwe and others
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 2.1 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
Expand Down
Loading

0 comments on commit e52d729

Please sign in to comment.