Skip to content

Commit

Permalink
Merge pull request #1146 from soot-oss/failed-jars-branch-20241014
Browse files Browse the repository at this point in the history
Failed jars branch 20241014
  • Loading branch information
sahilagichani14 authored Jan 9, 2025
2 parents 31e67ba + 0d7d55b commit 76f7e78
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,9 @@ public void removeNode(@Nonnull Stmt stmt, boolean keepFlow) {
blockOfRemovedStmt.clearPredecessorBlocks();
blockOfRemovedStmt.clearSuccessorBlocks();
blockOfRemovedStmt.clearExceptionalSuccessorBlocks();

clearBlockFromAllExceptionalBlocks(blockOfRemovedStmt);

blockOfRemovedStmt.removeStmt(blockOfRemovedStmtPair.getLeft());
blocks.remove(blockOfRemovedStmt);

Expand Down Expand Up @@ -976,6 +979,27 @@ public void removeNode(@Nonnull Stmt stmt, boolean keepFlow) {
stmtToBlock.remove(stmt);
}

public void clearBlockFromAllExceptionalBlocks(MutableBasicBlock blockOfRemovedStmt) {
// Remove blockOfRemovedStmt from all exceptionalBlocks in MutableBlockStmtGraph
for (Iterator<MutableBasicBlock> iterator = blocks.iterator(); iterator.hasNext(); ) {
MutableBasicBlock block = iterator.next();
Collection<MutableBasicBlock> blockExceptionalSuccessors =
block.getExceptionalSuccessors().values();
if (!blockExceptionalSuccessors.isEmpty()) {
for (MutableBasicBlock exceptionalBlock : blockExceptionalSuccessors) {
List<MutableBasicBlock> exceptionalBlockSuccessors = exceptionalBlock.getSuccessors();
List<MutableBasicBlock> exceptionalBlockPredecessors = exceptionalBlock.getPredecessors();
if (exceptionalBlockPredecessors.contains(blockOfRemovedStmt)) {
exceptionalBlock.removePredecessorBlock(blockOfRemovedStmt);
}
if (exceptionalBlockSuccessors.contains(blockOfRemovedStmt)) {
exceptionalBlock.removeFromSuccessorBlocks(blockOfRemovedStmt);
}
}
}
}
}

@Override
public void replaceNode(@Nonnull Stmt oldStmt, @Nonnull Stmt newStmt) {
if (oldStmt == newStmt) {
Expand Down
7 changes: 6 additions & 1 deletion sootup.java.bytecode.frontend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@
<artifactId>gson</artifactId>
<version>2.8.9</version>
</dependency>
</dependencies>
<dependency>
<groupId>org.soot-oss</groupId>
<artifactId>sootup.jimple.frontend</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package sootup.java.bytecode.frontend.inputlocation;

import categories.TestCategories;
import java.nio.file.Paths;
import java.util.Collections;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import sootup.core.inputlocation.AnalysisInputLocation;
import sootup.core.model.Body;
import sootup.core.model.SourceType;
import sootup.interceptors.NopEliminator;
import sootup.jimple.frontend.JimpleAnalysisInputLocation;
import sootup.jimple.frontend.JimpleView;

@Tag(TestCategories.JAVA_8_CATEGORY)
public class FixJars extends BaseFixJarsTest {

@Test
/* Isolated testcase from:
* String jarDownloadUrl = "https://repo1.maven.org/maven2/io/github/adven27/exam-core/2024.0.10/exam-core-2024.0.10.jar";
* String methodSignature = "<io.github.adven27.concordion.extensions.exam.core.logger.LoggingFormatterExtension$LoggingFormatterListener: void afterExample(org.concordion.api.listener.ExampleEvent)>";
*/
public void executeexamcorejar() {
AnalysisInputLocation inputLocation =
new JimpleAnalysisInputLocation(
Paths.get("./src/test/resources/"),
SourceType.Application,
Collections.singletonList(new NopEliminator()));
JimpleView jimpleView = new JimpleView(inputLocation);
jimpleView
.getClasses()
.forEach(
sootClass -> {
Body body =
sootClass.getMethodsByName("nopEliminatorBug").stream()
.findFirst()
.get()
.getBody();
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
class DummyClass extends java.lang.Object {

public int nopEliminatorBug() {
this := @this: io.github.adven27.concordion.extensions.exam.core.logger.LoggingFormatterExtension$LoggingFormatterListener;
event := @parameter0: org.concordion.api.listener.ExampleEvent;
staticinvoke <kotlin.jvm.internal.Intrinsics: void checkNotNullParameter(java.lang.Object,java.lang.String)>(event, "event");

label1:
nop;
$stack5 = this.<io.github.adven27.concordion.extensions.exam.core.logger.LoggingFormatterExtension$LoggingFormatterListener: io.github.adven27.concordion.extensions.exam.core.logger.LoggingAdaptor loggingAdaptor>;
it = interfaceinvoke $stack5.<io.github.adven27.concordion.extensions.exam.core.logger.LoggingAdaptor: java.io.File getLogFile()>();
$stack6 = virtualinvoke it.<java.io.File: boolean exists()>();

if $stack6 == 0 goto label2;
specialinvoke this.<io.github.adven27.concordion.extensions.exam.core.logger.LoggingFormatterExtension$LoggingFormatterListener: void appendLogFileLinkToExample(org.concordion.api.listener.ExampleEvent,java.io.File)>(event, it);

label2:
nop;
nop;

label3:
$stack7 = this.<io.github.adven27.concordion.extensions.exam.core.logger.LoggingFormatterExtension$LoggingFormatterListener: io.github.adven27.concordion.extensions.exam.core.logger.LoggingAdaptor loggingAdaptor>;
interfaceinvoke $stack7.<io.github.adven27.concordion.extensions.exam.core.logger.LoggingAdaptor: void stopLogFile()>();

goto label6;

label4:
$stack8 := @caughtexception;
l2 = $stack8;

label5:
$stack9 = this.<io.github.adven27.concordion.extensions.exam.core.logger.LoggingFormatterExtension$LoggingFormatterListener: io.github.adven27.concordion.extensions.exam.core.logger.LoggingAdaptor loggingAdaptor>;
interfaceinvoke $stack9.<io.github.adven27.concordion.extensions.exam.core.logger.LoggingAdaptor: void stopLogFile()>();

throw l2;

label6:
return;

catch java.lang.Throwable from label1 to label3 with label4;
catch java.lang.Throwable from label4 to label5 with label4;
}
}

0 comments on commit 76f7e78

Please sign in to comment.