diff --git a/shared-test-resources/bugfixes/TrapSSA.java b/shared-test-resources/bugfixes/TrapSSA.java new file mode 100644 index 0000000000..164e5efd46 --- /dev/null +++ b/shared-test-resources/bugfixes/TrapSSA.java @@ -0,0 +1,11 @@ +import java.io.*; +class TrapSSA { + public static void main(String[] args) throws IOException { + byte[] data; + try (ByteArrayOutputStream output = new ByteArrayOutputStream()) { + output.write(args[0].getBytes("UTF-8")); + data = output.toByteArray(); + } + System.out.println(new String(data, "UTF-8")); + } +} \ No newline at end of file diff --git a/sootup.tests/src/test/java/sootup/tests/InsertBeforeAfterTest.java b/sootup.tests/src/test/java/sootup/tests/InsertBeforeAfterTest.java index b6985abe72..ad203589fb 100644 --- a/sootup.tests/src/test/java/sootup/tests/InsertBeforeAfterTest.java +++ b/sootup.tests/src/test/java/sootup/tests/InsertBeforeAfterTest.java @@ -18,6 +18,7 @@ import sootup.core.model.SourceType; import sootup.core.signatures.MethodSignature; import sootup.core.types.ClassType; +import sootup.core.util.DotExporter; import sootup.java.bytecode.frontend.inputlocation.PathBasedAnalysisInputLocation; import sootup.java.core.JavaIdentifierFactory; import sootup.java.core.language.JavaJimple; @@ -667,4 +668,20 @@ public void testInsertAfterBlockMiddle2() { + "}\n"; Assertions.assertEquals(exceptedBody, builder.build().toString()); } + + @Test + public void testErrors() { + ClassType clazzType = factory.getClassType("TrapSSA"); + MethodSignature methodSignature = + factory.getMethodSignature( + clazzType, "main", "void", Collections.singletonList("java.lang.String[]")); + final Path path = Paths.get(location + "TrapSSA.class"); + PathBasedAnalysisInputLocation inputLocation = + new PathBasedAnalysisInputLocation.ClassFileBasedAnalysisInputLocation( + path, "", SourceType.Application); + JavaView view = new JavaView(inputLocation); + Body body = view.getMethod(methodSignature).get().getBody(); + System.out.println(DotExporter.createUrlToWebeditor(body.getStmtGraph())); + System.out.println(body); + } }