diff --git a/src/test/java/jd/core/test/TryCatchFinallyBRTest.java b/src/test/java/jd/core/test/TryCatchFinallyBRTest.java index ec44188d..e57fa828 100644 --- a/src/test/java/jd/core/test/TryCatchFinallyBRTest.java +++ b/src/test/java/jd/core/test/TryCatchFinallyBRTest.java @@ -14,26 +14,43 @@ public class TryCatchFinallyBRTest extends AbstractTestCase { @Test public void testJikes() throws Exception { - test("jikes-1.22"); + test("jikes-1.22", false); + } + @Test + public void testJavac_1_2_2_novar() throws Exception { + test("javac-1.2.2", true); } + @Test + public void testJavac_1_3_1_28() throws Exception { + test("javac-1.3.1_28", true); + } + @Test public void testJavac_1_4_2_19() throws Exception { - test("javac-1.4.2_19"); + test("javac-1.4.2_19", false); } @Test public void testJavac_17_0_4() throws Exception { - test("javac-17.0.4"); + test("javac-17.0.4", false); } - private void test(String compiler) throws IOException { - try (InputStream in = getClass().getResourceAsStream("/try-catch-finally-" + compiler + ".jar")) { + private void test(String compiler, boolean noVar) throws IOException { + StringBuilder expectedFileName = new StringBuilder("TryCatchFinallyBR"); + StringBuilder jarPath = new StringBuilder("/try-catch-finally-"); + jarPath.append(compiler); + if (noVar) { + expectedFileName.append("-novar"); + jarPath.append("-novar"); + } + expectedFileName.append(".txt"); + jarPath.append(".jar"); + try (InputStream in = getClass().getResourceAsStream(jarPath.toString())) { ZipLoader loader = new ZipLoader(in); String internalClassName = "jd/core/test/TryCatchFinallyBR"; String output = decompile(internalClassName, loader); - assertEquals(IOUtils.toString(getClass().getResource("TryCatchFinallyBR.txt"), StandardCharsets.UTF_8), output); + assertEquals(IOUtils.toString(getClass().getResource(expectedFileName.toString()), StandardCharsets.UTF_8), output); } } - } diff --git a/src/test/resources/jd/core/test/TryCatchFinallyBR-novar.txt b/src/test/resources/jd/core/test/TryCatchFinallyBR-novar.txt new file mode 100644 index 00000000..c5b98f97 --- /dev/null +++ b/src/test/resources/jd/core/test/TryCatchFinallyBR-novar.txt @@ -0,0 +1,30 @@ +/* */ package jd.core.test; +/* */ +/* */ import java.io.BufferedReader; +/* */ import java.io.File; +/* */ import java.io.IOException; +/* */ +/* */ public class TryCatchFinallyBR +/* */ { +/* */ void tryCatchFinally(File paramFile) +/* */ { +/* 11 */ BufferedReader localBufferedReader = null; +/* */ try { +/* 13 */ localBufferedReader = new BufferedReader(new java.io.FileReader(paramFile)); +/* */ String str; +/* 15 */ while ((str = localBufferedReader.readLine()) != null) { +/* 16 */ System.out.println(str); +/* */ } +/* */ } catch (Exception localException) { +/* 19 */ localException.printStackTrace(); +/* */ } finally { +/* 21 */ if (localBufferedReader != null) { +/* */ try { +/* 23 */ localBufferedReader.close(); +/* */ } catch (IOException localIOException) { +/* 25 */ localIOException.printStackTrace(); +/* */ } +/* */ } +/* */ } +/* */ } +/* */ } diff --git a/src/test/resources/try-catch-finally-javac-1.2.2-novar.jar b/src/test/resources/try-catch-finally-javac-1.2.2-novar.jar new file mode 100644 index 00000000..56e58f8f Binary files /dev/null and b/src/test/resources/try-catch-finally-javac-1.2.2-novar.jar differ diff --git a/src/test/resources/try-catch-finally-javac-1.3.1_28-novar.jar b/src/test/resources/try-catch-finally-javac-1.3.1_28-novar.jar new file mode 100644 index 00000000..9dd1391c Binary files /dev/null and b/src/test/resources/try-catch-finally-javac-1.3.1_28-novar.jar differ