From 709c942d5025ba8a029cd884345a08b2ce0f39cf Mon Sep 17 00:00:00 2001 From: emckee2006 Date: Fri, 18 Sep 2015 12:26:06 -0400 Subject: [PATCH] Merge changes from upstream (hopefully correctly) --- java-decompiler-engine.iml | 1 + .../main/collectors/ImportCollector.java | 3 +- .../attr/StructInnerClassesAttribute.java | 95 +++++++---- .../decompiler/BulkDecompilationTest.java | 21 +-- .../decompiler/DecompilerTestFixture.java | 27 +++- .../java/decompiler/SingleClassesTest.java | 1 + .../decompiler/SingleClassesTestBase.java | 153 ++++++++++-------- testData/bulk/META-INF/MANIFEST.MF | 3 + testData/bulk/pkg/Main.java | 11 ++ testData/bulk/pkg/res/Loader.java | 25 +++ testData/classes/ext/Shadow$B.class | Bin 0 -> 243 bytes testData/classes/ext/Shadow.class | Bin 0 -> 243 bytes testData/classes/pkg/Shadow.class | Bin 0 -> 190 bytes testData/classes/pkg/TestShadowing.class | Bin 0 -> 342 bytes testData/results/TestAnonymousClass.dec | 60 +++---- .../TestClassSimpleBytecodeMapping.dec | 24 +-- testData/results/TestInnerLocal.dec | 50 +++--- testData/results/TestInnerLocalPkg.dec | 50 +++--- testData/results/TestInnerSignature.dec | 64 ++++---- testData/results/TestMethodParameters.dec | 48 +++--- testData/results/TestShadowing.dec | 6 + testData/src/ext/Shadow.java | 6 + testData/src/pkg/Shadow.java | 4 + testData/src/pkg/TestShadowing.java | 5 + 24 files changed, 388 insertions(+), 269 deletions(-) create mode 100644 testData/classes/ext/Shadow$B.class create mode 100644 testData/classes/ext/Shadow.class create mode 100644 testData/classes/pkg/Shadow.class create mode 100644 testData/classes/pkg/TestShadowing.class create mode 100644 testData/results/TestShadowing.dec create mode 100644 testData/src/ext/Shadow.java create mode 100644 testData/src/pkg/Shadow.java create mode 100644 testData/src/pkg/TestShadowing.java diff --git a/java-decompiler-engine.iml b/java-decompiler-engine.iml index d56249d..5880ebf 100644 --- a/java-decompiler-engine.iml +++ b/java-decompiler-engine.iml @@ -9,5 +9,6 @@ + \ No newline at end of file diff --git a/src/org/jetbrains/java/decompiler/main/collectors/ImportCollector.java b/src/org/jetbrains/java/decompiler/main/collectors/ImportCollector.java index 05dc835..ada6abc 100644 --- a/src/org/jetbrains/java/decompiler/main/collectors/ImportCollector.java +++ b/src/org/jetbrains/java/decompiler/main/collectors/ImportCollector.java @@ -99,7 +99,8 @@ public String getShortName(String fullname, boolean imported) { if (existsDefaultClass || (mapSimpleNames.containsKey(nshort) && !npackage.equals(mapSimpleNames.get(nshort)))) { - return fullname; + // don't return full name because if the class is a inner class, full name refers to the parent full name, not the child full name + return retname == null ? fullname : (npackage + "." + retname); } else if (!mapSimpleNames.containsKey(nshort)) { mapSimpleNames.put(nshort, npackage); diff --git a/src/org/jetbrains/java/decompiler/struct/attr/StructInnerClassesAttribute.java b/src/org/jetbrains/java/decompiler/struct/attr/StructInnerClassesAttribute.java index ecef558..406da86 100644 --- a/src/org/jetbrains/java/decompiler/struct/attr/StructInnerClassesAttribute.java +++ b/src/org/jetbrains/java/decompiler/struct/attr/StructInnerClassesAttribute.java @@ -37,44 +37,73 @@ */ public class StructInnerClassesAttribute extends StructGeneralAttribute { - private List entries; + private List entries; + private List classEntries; + private List stringEntries; - @Override - public void initContent(ConstantPool pool) throws IOException { - DataInputStream data = stream(); + @Override + public void initContent(ConstantPool pool) throws IOException { + DataInputStream data = stream(); - int len = data.readUnsignedShort(); - if (len > 0) { - entries = new ArrayList(); + int len = data.readUnsignedShort(); + if (len > 0) { + entries = new ArrayList(); + classEntries = new ArrayList(len); + stringEntries = new ArrayList(len); - for (int i = 0; i < len; i++) { - entries.add(new InnerClassInfo(data, pool)); - } - } - else { - entries = Collections.emptyList(); - } - } + for (int i = 0; i < len; i++) { + entries.add(new InnerClassInfo(data, pool)); + int[] classEntry = new int[4]; + for (int j = 0; j < 4; j++) { + classEntry[j] = data.readUnsignedShort(); + } + classEntries.add(classEntry); - public List getEntries() { - return entries; - } + // inner name, enclosing class, original simple name + String[] stringEntry = new String[3]; + stringEntry[0] = pool.getPrimitiveConstant(classEntry[0]).getString(); + if (classEntry[1] != 0) { + stringEntry[1] = pool.getPrimitiveConstant(classEntry[1]).getString(); + } + if (classEntry[2] != 0) { + stringEntry[2] = pool.getPrimitiveConstant(classEntry[2]).getString(); + } + stringEntries.add(stringEntry); + } + } else { + entries = Collections.emptyList(); + classEntries = Collections.emptyList(); + stringEntries = Collections.emptyList(); + } + } - public static class InnerClassInfo { - public String inner_class; - public String outer_class; - public String inner_name; - public int access; + public List getEntries() { + return entries; + } - private InnerClassInfo(DataInputStream data, ConstantPool pool) throws IOException { - this.inner_class = readString(pool, data.readUnsignedShort()); - this.outer_class = readString(pool, data.readUnsignedShort()); - this.inner_name = readString(pool, data.readUnsignedShort()); - this.access = data.readUnsignedShort(); - } + public List getClassEntries() { + return classEntries; + } - private String readString(ConstantPool pool, int index) { - return index == 0 ? null : pool.getPrimitiveConstant(index).getString(); - } - } + public List getStringEntries() { + return stringEntries; + } + + public static class InnerClassInfo { + public String inner_class; + public String outer_class; + public String inner_name; + public int access; + + private InnerClassInfo(DataInputStream data, ConstantPool pool) throws IOException { + this.inner_class = readString(pool, data.readUnsignedShort()); + this.outer_class = readString(pool, data.readUnsignedShort()); + this.inner_name = readString(pool, data.readUnsignedShort()); + this.access = data.readUnsignedShort(); + } + + private String readString(ConstantPool pool, int index) { + return index == 0 ? null : pool.getPrimitiveConstant(index).getString(); + } + } } diff --git a/test/org/jetbrains/java/decompiler/BulkDecompilationTest.java b/test/org/jetbrains/java/decompiler/BulkDecompilationTest.java index 1b5353b..0211a57 100644 --- a/test/org/jetbrains/java/decompiler/BulkDecompilationTest.java +++ b/test/org/jetbrains/java/decompiler/BulkDecompilationTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,7 +15,6 @@ */ package org.jetbrains.java.decompiler; -import org.hamcrest.Matchers; import org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler; import org.jetbrains.java.decompiler.util.InterpreterUtil; import org.junit.After; @@ -27,7 +26,7 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipFile; -import static org.junit.Assert.assertThat; +import static org.jetbrains.java.decompiler.DecompilerTestFixture.assertFilesEqual; import static org.junit.Assert.assertTrue; public class BulkDecompilationTest { @@ -54,7 +53,7 @@ public void testDirectory() { decompiler.addSpace(classes, true); decompiler.decompileContext(); - compareDirectories(new File(fixture.getTestDataDir(), "bulk"), fixture.getTargetDir()); + assertFilesEqual(new File(fixture.getTestDataDir(), "bulk"), fixture.getTargetDir()); } @Test @@ -66,7 +65,7 @@ public void testJar() { File unpacked = new File(fixture.getTempDir(), "unpacked"); unpack(new File(fixture.getTargetDir(), "bulk.jar"), unpacked); - compareDirectories(new File(fixture.getTestDataDir(), "bulk"), unpacked); + assertFilesEqual(new File(fixture.getTestDataDir(), "bulk"), unpacked); } private static void unpack(File archive, File targetDir) { @@ -95,16 +94,4 @@ private static void unpack(File archive, File targetDir) { throw new RuntimeException(e); } } - - private static void compareDirectories(File expected, File actual) { - String[] expectedList = expected.list(); - String[] actualList = actual.list(); - assertThat(actualList, Matchers.arrayContainingInAnyOrder(expectedList)); - for (String name : expectedList) { - File child = new File(expected, name); - if (child.isDirectory()) { - compareDirectories(child, new File(actual, name)); - } - } - } } diff --git a/test/org/jetbrains/java/decompiler/DecompilerTestFixture.java b/test/org/jetbrains/java/decompiler/DecompilerTestFixture.java index f2c344a..09f8681 100644 --- a/test/org/jetbrains/java/decompiler/DecompilerTestFixture.java +++ b/test/org/jetbrains/java/decompiler/DecompilerTestFixture.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,8 +15,10 @@ */ package org.jetbrains.java.decompiler; +import org.hamcrest.Matchers; import org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler; import org.jetbrains.java.decompiler.main.extern.IFernflowerPreferences; +import org.jetbrains.java.decompiler.util.InterpreterUtil; import java.io.File; import java.io.IOException; @@ -24,6 +26,7 @@ import java.util.HashMap; import java.util.Map; +import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; public class DecompilerTestFixture { @@ -44,6 +47,7 @@ public void setUp(final Map options) throws IOException { if (!isTestDataDir(testDataDir)) testDataDir = new File("../community/plugins/java-decompiler/engine/testData"); if (!isTestDataDir(testDataDir)) testDataDir = new File("../plugins/java-decompiler/engine/testData"); assertTrue("current dir: " + new File("").getAbsolutePath(), isTestDataDir(testDataDir)); + testDataDir = testDataDir.getAbsoluteFile(); //noinspection SSBasedInspection tempDir = File.createTempFile("decompiler_test_", "_dir"); @@ -97,4 +101,25 @@ private static void delete(File file) { } assertTrue(file.delete()); } + + public static void assertFilesEqual(File expected, File actual) { + if (expected.isDirectory()) { + assertThat(actual.list(), Matchers.arrayContainingInAnyOrder(expected.list())); + for (String name : expected.list()) { + assertFilesEqual(new File(expected, name), new File(actual, name)); + } + } + else { + assertThat(getContent(actual), Matchers.equalTo(getContent(expected))); + } + } + + private static String getContent(File expected) { + try { + return new String(InterpreterUtil.getBytes(expected), "UTF-8").replace("\r\n", "\n"); + } + catch (IOException e) { + throw new RuntimeException(e); + } + } } diff --git a/test/org/jetbrains/java/decompiler/SingleClassesTest.java b/test/org/jetbrains/java/decompiler/SingleClassesTest.java index e85cd67..0da0d3b 100644 --- a/test/org/jetbrains/java/decompiler/SingleClassesTest.java +++ b/test/org/jetbrains/java/decompiler/SingleClassesTest.java @@ -61,4 +61,5 @@ protected Map getDecompilerOptions() { @Test public void testInnerLocalPkg() { doTest("pkg/TestInnerLocalPkg"); } @Test public void testInnerSignature() { doTest("pkg/TestInnerSignature"); } @Test public void testParameterizedTypes() { doTest("pkg/TestParameterizedTypes"); } + @Test public void testShadowing() { doTest("pkg/TestShadowing", "pkg/Shadow", "ext/Shadow"); } } diff --git a/test/org/jetbrains/java/decompiler/SingleClassesTestBase.java b/test/org/jetbrains/java/decompiler/SingleClassesTestBase.java index 064ca5c..e55e37d 100644 --- a/test/org/jetbrains/java/decompiler/SingleClassesTestBase.java +++ b/test/org/jetbrains/java/decompiler/SingleClassesTestBase.java @@ -32,73 +32,88 @@ import static org.junit.Assert.assertTrue; public abstract class SingleClassesTestBase { - protected DecompilerTestFixture fixture; - - @Before - public void setUp() throws IOException { - fixture = new DecompilerTestFixture(); - fixture.setUp(getDecompilerOptions()); - } - - @After - public void tearDown() { - fixture.tearDown(); - fixture = null; - } - - protected Map getDecompilerOptions() { - return Collections.emptyMap(); - } - - protected void doTest(String testFile) { - try { - File classFile = new File(fixture.getTestDataDir(), "/classes/" + testFile + ".class"); - assertTrue(classFile.isFile()); - String testName = classFile.getName().substring(0, classFile.getName().length() - 6); - - ConsoleDecompiler decompiler = fixture.getDecompiler(); - - for (File file : collectClasses(classFile)) decompiler.addSpace(file, true); - decompiler.decompileContext(); - - File decompiledFile = new File(fixture.getTargetDir(), testName + ".java"); - assertTrue(decompiledFile.isFile()); - File referenceFile = new File(fixture.getTestDataDir(), "results/" + testName + ".dec"); - assertTrue(referenceFile.isFile()); - compareContent(decompiledFile, referenceFile); - } - catch (Exception e) { - throw new RuntimeException(e); - } - } - - private static List collectClasses(File classFile) { - List files = new ArrayList(); - files.add(classFile); - - File parent = classFile.getParentFile(); - if (parent != null) { - final String pattern = classFile.getName().replace(".class", "") + "\\$.+\\.class"; - File[] inner = parent.listFiles(new FilenameFilter() { - @Override - public boolean accept(File dir, String name) { - return name.matches(pattern); - } - }); - if (inner != null) Collections.addAll(files, inner); - } - - return files; - } - - private static void compareContent(File decompiledFile, File referenceFile) throws IOException { - String decompiledContent = new String(InterpreterUtil.getBytes(decompiledFile), "UTF-8"); - - String referenceContent = new String(InterpreterUtil.getBytes(referenceFile), "UTF-8"); - if (InterpreterUtil.IS_WINDOWS && !referenceContent.contains("\r\n")) { - referenceContent = referenceContent.replace("\n", "\r\n"); // fix for broken Git checkout on Windows - } - - assertEquals(referenceContent, decompiledContent); - } + protected DecompilerTestFixture fixture; + + @Before + public void setUp() throws IOException { + fixture = new DecompilerTestFixture(); + fixture.setUp(getDecompilerOptions()); + } + + @After + public void tearDown() { + fixture.tearDown(); + fixture = null; + } + + protected Map getDecompilerOptions() { + return Collections.emptyMap(); + } + + protected void doTest(String testFile, String... companionFiles) { + try { + File classFile = new File(fixture.getTestDataDir(), "/classes/" + testFile + ".class"); + assertTrue(classFile.isFile()); + String testName = classFile.getName().substring(0, classFile.getName().length() - 6); + + ConsoleDecompiler decompiler = fixture.getDecompiler(); + + for (File file : collectClasses(classFile)) + decompiler.addSpace(file, true); + + for (String companionFile : companionFiles) { + File companionClassFile = new File(fixture.getTestDataDir(), "/classes/" + companionFile + ".class"); + assertTrue(companionClassFile.isFile()); + for (File file : collectClasses(companionClassFile)) { + decompiler.addSpace(file, true); + } + } + decompiler.decompileContext(); + + File decompiledFile = new File(fixture.getTargetDir(), testName + ".java"); + assertTrue(decompiledFile.isFile()); + File referenceFile = new File(fixture.getTestDataDir(), "results/" + testName + ".dec"); + assertTrue(referenceFile.isFile()); + compareContent(decompiledFile, referenceFile); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + private static List collectClasses(File classFile) { + List files = new ArrayList(); + files.add(classFile); + + File parent = classFile.getParentFile(); + if (parent != null) { + final String pattern = classFile.getName().replace(".class", "") + "\\$.+\\.class"; + File[] inner = parent.listFiles(new FilenameFilter() { + @Override + public boolean accept(File dir, String name) { + return name.matches(pattern); + } + }); + if (inner != null) + Collections.addAll(files, inner); + } + + return files; + } + + private static void compareContent(File decompiledFile, File referenceFile) throws IOException { + String decompiledContent = new String(InterpreterUtil.getBytes(decompiledFile), "UTF-8"); + + String referenceContent = new String(InterpreterUtil.getBytes(referenceFile), "UTF-8"); + if (InterpreterUtil.IS_WINDOWS && !referenceContent.contains("\r\n")) { + referenceContent = referenceContent.replace("\n", "\r\n"); // fix + // for + // broken + // Git + // checkout + // on + // Windows + } + + assertEquals(referenceContent, decompiledContent); + } } diff --git a/testData/bulk/META-INF/MANIFEST.MF b/testData/bulk/META-INF/MANIFEST.MF index e69de29..22f53c8 100644 --- a/testData/bulk/META-INF/MANIFEST.MF +++ b/testData/bulk/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Created-By: 1.8.0_20 (Oracle Corporation) + diff --git a/testData/bulk/pkg/Main.java b/testData/bulk/pkg/Main.java index e69de29..f22c5d2 100644 --- a/testData/bulk/pkg/Main.java +++ b/testData/bulk/pkg/Main.java @@ -0,0 +1,11 @@ +package pkg; + +import pkg.res.Loader; + +public class Main { + public static void main(String[] args) { + Loader loader = new Loader(); + String resource = loader.getResource(); + System.out.println(resource); + } +} diff --git a/testData/bulk/pkg/res/Loader.java b/testData/bulk/pkg/res/Loader.java index e69de29..b0326dd 100644 --- a/testData/bulk/pkg/res/Loader.java +++ b/testData/bulk/pkg/res/Loader.java @@ -0,0 +1,25 @@ +package pkg.res; + +import java.io.File; +import java.io.FileInputStream; +import java.net.URL; + +public class Loader { + public String getResource() { + URL resource = this.getClass().getClassLoader().getResource("pkg/res/resource.txt"); + if(resource == null) { + throw new RuntimeException("Resource missing"); + } else { + try { + File e = new File(resource.toURI()); + byte[] bytes = new byte[(int)e.length()]; + FileInputStream stream = new FileInputStream(e); + stream.read(bytes); + stream.close(); + return new String(bytes, "UTF-8"); + } catch (Exception var5) { + throw new RuntimeException("Resource load failed", var5); + } + } + } +} diff --git a/testData/classes/ext/Shadow$B.class b/testData/classes/ext/Shadow$B.class new file mode 100644 index 0000000000000000000000000000000000000000..eeb9d384874454df5be278d03747e9da23ae6fa6 GIT binary patch literal 243 zcmYLD%?`m}5S%S-siGdhLE?aeUL3`NL?RIm75A@vp;BLy{@}HoBn}?HLy2u2Y_dC< znapJ0pXUp}2rUaGSSD-}O@c8FRFF;xrCxtaD9@t3Bs7i(SWlt8@pLMa)~LXjjgAvk%!4TU#ZKQ9~6CMvGMqHPli40_$KbJOBUy literal 0 HcmV?d00001 diff --git a/testData/classes/ext/Shadow.class b/testData/classes/ext/Shadow.class new file mode 100644 index 0000000000000000000000000000000000000000..e576dfd9b0fdfd1b1feffd31f52d1a42bb23e849 GIT binary patch literal 243 zcmYL@%?`m(5QWcZDOGiHVuu$e)UUT<{2~8ciu~0jA6&z%k^Vxsi s_0U0qU(>};=>@D6cI~eRii11o_Kj`U5@W#Rp(^(R943IxRI?%~AJWb&K>z>% literal 0 HcmV?d00001 diff --git a/testData/classes/pkg/Shadow.class b/testData/classes/pkg/Shadow.class new file mode 100644 index 0000000000000000000000000000000000000000..61ed27b36a1d424dc1237961c416e6f9a4490b12 GIT binary patch literal 190 zcmX^0Z`VEs1_l!bUM>b^1}=66ZgvJ9Mg}&U%)HDJJ4Oa(4b3n{1{UZ1lvG9rexJ;| zRKL>Pq|~C2#H1Xc2v=}^X;E^jTPBFZ9h{Mvl3%Wul~|U@!@$D83Y0I%PS=MBGcpK( zB=mC<^V0SGld@8iOBfUxn1Hr|03#3rbpS~=AWs&|XJBB}+RnhZ5iHFPB-wz%3_xX! L3>-k3iGdRUsiz`b literal 0 HcmV?d00001 diff --git a/testData/classes/pkg/TestShadowing.class b/testData/classes/pkg/TestShadowing.class new file mode 100644 index 0000000000000000000000000000000000000000..228fd8f7571f13eb43fd7fd3d86211b334142ec8 GIT binary patch literal 342 zcmY*V%Syvg5IvK`#H6uJ>T~JBg%&XzcZ!P^1fkePi{SDmy~bPPO-WMqw_Hd;!4L4G z#7Pv?#SCX2=Nx7}K40Gf9An3WjnKim2Lqvt6>K=zbg)HeDP2}VCvtStClH5!p|vaq znJ7zH652!gR7K-kG0h+M`X>bYRB2V65zPIAD}pu1r;^YaDlIP;_pvM{BF?zujq^p3 z$a7T}-H9x#ZxN-_qnUURK3eb{Y_sEE2OkbRLO8!mqkkkqP}8DJ=rkI|GnrIu@=L`o z-(~Z?#K9Urh)uY&#?>LrW)}38pxzsd>m|$=SkKL7n{)jh@Rr3&20Dxl1aO-PG45g& F?iW35LgoMf literal 0 HcmV?d00001 diff --git a/testData/results/TestAnonymousClass.dec b/testData/results/TestAnonymousClass.dec index fdce110..75d1df2 100644 --- a/testData/results/TestAnonymousClass.dec +++ b/testData/results/TestAnonymousClass.dec @@ -67,8 +67,15 @@ public abstract class TestAnonymousClass { boolean var1 = true;// 39 }// 40 - interface I { - void foo() throws Exception; + static class InnerRecursive { + TestAnonymousClass.InnerRecursive r; + + public InnerRecursive(TestAnonymousClass.InnerRecursive var1) { + this.r = var1;// 105 + }// 106 + + void foo() { + }// 110 } private static class Inner { @@ -80,15 +87,8 @@ public abstract class TestAnonymousClass { }; } - static class InnerRecursive { - TestAnonymousClass.InnerRecursive r; - - public InnerRecursive(TestAnonymousClass.InnerRecursive var1) { - this.r = var1;// 105 - }// 106 - - void foo() { - }// 110 + interface I { + void foo() throws Exception; } } @@ -180,24 +180,24 @@ class 'pkg/TestAnonymousClass' { } } -class 'pkg/TestAnonymousClass$Inner$1' { - method 'run ()V' { - 0 76 - 1 76 - 2 77 - 3 77 - 4 78 - } -} - class 'pkg/TestAnonymousClass$InnerRecursive' { method ' (Lpkg/TestAnonymousClass$InnerRecursive;)V' { - 6 86 - 9 87 + 6 73 + 9 74 } method 'foo ()V' { - 0 90 + 0 77 + } +} + +class 'pkg/TestAnonymousClass$Inner$1' { + method 'run ()V' { + 0 83 + 1 83 + 2 84 + 3 84 + 4 85 } } @@ -223,9 +223,9 @@ Lines mapping: 53 <-> 18 54 <-> 19 55 <-> 20 -66 <-> 77 -67 <-> 78 -68 <-> 79 +66 <-> 84 +67 <-> 85 +68 <-> 86 75 <-> 24 76 <-> 25 77 <-> 26 @@ -234,9 +234,9 @@ Lines mapping: 91 <-> 37 92 <-> 38 93 <-> 39 -105 <-> 87 -106 <-> 88 -110 <-> 91 +105 <-> 74 +106 <-> 75 +110 <-> 78 Not mapped: 18 104 diff --git a/testData/results/TestClassSimpleBytecodeMapping.dec b/testData/results/TestClassSimpleBytecodeMapping.dec index 1a2532f..a48375a 100644 --- a/testData/results/TestClassSimpleBytecodeMapping.dec +++ b/testData/results/TestClassSimpleBytecodeMapping.dec @@ -33,17 +33,17 @@ public class TestClassSimpleBytecodeMapping { var1.run();// 49 }// 50 - public class InnerClass { - public void print() { - System.out.println("Inner");// 44 - }// 45 - } - public class InnerClass2 { public void print() { System.out.println("Inner2");// 54 }// 55 } + + public class InnerClass { + public void print() { + System.out.println("Inner");// 44 + }// 45 + } } class 'pkg/TestClassSimpleBytecodeMapping$1' { @@ -96,7 +96,7 @@ class 'pkg/TestClassSimpleBytecodeMapping' { } } -class 'pkg/TestClassSimpleBytecodeMapping$InnerClass' { +class 'pkg/TestClassSimpleBytecodeMapping$InnerClass2' { method 'print ()V' { 0 37 3 37 @@ -105,7 +105,7 @@ class 'pkg/TestClassSimpleBytecodeMapping$InnerClass' { } } -class 'pkg/TestClassSimpleBytecodeMapping$InnerClass2' { +class 'pkg/TestClassSimpleBytecodeMapping$InnerClass' { method 'print ()V' { 0 43 3 43 @@ -130,11 +130,11 @@ Lines mapping: 36 <-> 25 38 <-> 27 40 <-> 30 -44 <-> 38 -45 <-> 39 +44 <-> 44 +45 <-> 45 49 <-> 33 50 <-> 34 -54 <-> 44 -55 <-> 45 +54 <-> 38 +55 <-> 39 Not mapped: 39 diff --git a/testData/results/TestInnerLocal.dec b/testData/results/TestInnerLocal.dec index e5aba7d..6ca3a7e 100644 --- a/testData/results/TestInnerLocal.dec +++ b/testData/results/TestInnerLocal.dec @@ -28,14 +28,6 @@ public class TestInnerLocal { new TestInnerLocal.Inner1Static.Inner2Static("test");// 40 }// 41 - class Inner1 { - final String x; - - public Inner1(String var2) { - this.x = var2;// 46 - }// 47 - } - static class Inner1Static { final String x; @@ -51,6 +43,14 @@ public class TestInnerLocal { }// 60 } } + + class Inner1 { + final String x; + + public Inner1(String var2) { + this.x = var2;// 46 + }// 47 + } } class 'TestInnerLocal$1Inner' { @@ -84,24 +84,24 @@ class 'TestInnerLocal$2Inner' { } } -class 'TestInnerLocal$Inner1' { - method ' (LTestInnerLocal;Ljava/lang/String;)V' { - b 34 - e 35 - } -} - class 'TestInnerLocal$Inner1Static' { method ' (Ljava/lang/String;)V' { - 6 42 - 9 43 + 6 34 + 9 35 } } class 'TestInnerLocal$Inner1Static$Inner2Static' { method ' (Ljava/lang/String;)V' { - 6 49 - 9 50 + 6 41 + 9 42 + } +} + +class 'TestInnerLocal$Inner1' { + method ' (LTestInnerLocal;Ljava/lang/String;)V' { + b 50 + e 51 } } @@ -119,12 +119,12 @@ Lines mapping: 39 <-> 27 40 <-> 28 41 <-> 29 -46 <-> 35 -47 <-> 36 -53 <-> 43 -54 <-> 44 -59 <-> 50 -60 <-> 51 +46 <-> 51 +47 <-> 52 +53 <-> 35 +54 <-> 36 +59 <-> 42 +60 <-> 43 Not mapped: 21 33 diff --git a/testData/results/TestInnerLocalPkg.dec b/testData/results/TestInnerLocalPkg.dec index 7ddb0ce..7cafa41 100644 --- a/testData/results/TestInnerLocalPkg.dec +++ b/testData/results/TestInnerLocalPkg.dec @@ -30,14 +30,6 @@ public class TestInnerLocalPkg { new TestInnerLocalPkg.Inner1Static.Inner2Static("test");// 42 }// 43 - class Inner1 { - final String x; - - public Inner1(String var2) { - this.x = var2;// 48 - }// 49 - } - static class Inner1Static { final String x; @@ -53,6 +45,14 @@ public class TestInnerLocalPkg { }// 62 } } + + class Inner1 { + final String x; + + public Inner1(String var2) { + this.x = var2;// 48 + }// 49 + } } class 'pkg/TestInnerLocalPkg$1Inner' { @@ -86,24 +86,24 @@ class 'pkg/TestInnerLocalPkg$2Inner' { } } -class 'pkg/TestInnerLocalPkg$Inner1' { - method ' (Lpkg/TestInnerLocalPkg;Ljava/lang/String;)V' { - b 36 - e 37 - } -} - class 'pkg/TestInnerLocalPkg$Inner1Static' { method ' (Ljava/lang/String;)V' { - 6 44 - 9 45 + 6 36 + 9 37 } } class 'pkg/TestInnerLocalPkg$Inner1Static$Inner2Static' { method ' (Ljava/lang/String;)V' { - 6 51 - 9 52 + 6 43 + 9 44 + } +} + +class 'pkg/TestInnerLocalPkg$Inner1' { + method ' (Lpkg/TestInnerLocalPkg;Ljava/lang/String;)V' { + b 52 + e 53 } } @@ -121,12 +121,12 @@ Lines mapping: 41 <-> 29 42 <-> 30 43 <-> 31 -48 <-> 37 -49 <-> 38 -55 <-> 45 -56 <-> 46 -61 <-> 52 -62 <-> 53 +48 <-> 53 +49 <-> 54 +55 <-> 37 +56 <-> 38 +61 <-> 44 +62 <-> 45 Not mapped: 23 35 diff --git a/testData/results/TestInnerSignature.dec b/testData/results/TestInnerSignature.dec index 406e1f4..3087a40 100644 --- a/testData/results/TestInnerSignature.dec +++ b/testData/results/TestInnerSignature.dec @@ -9,18 +9,6 @@ public class TestInnerSignature { this.c = var3;// 25 }// 26 - public class Inner { - A a; - B b; - C c; - - public Inner(A var1, B var2, C var3) { - this.a = var2;// 34 - this.b = var3;// 35 - this.c = var4;// 36 - }// 37 - } - public static class InnerStatic { A a; B b; @@ -32,6 +20,18 @@ public class TestInnerSignature { this.c = var3;// 48 }// 49 } + + public class Inner { + A a; + B b; + C c; + + public Inner(A var1, B var2, C var3) { + this.a = var2;// 34 + this.b = var3;// 35 + this.c = var4;// 36 + }// 37 + } } class 'TestInnerSignature' { @@ -43,21 +43,21 @@ class 'TestInnerSignature' { } } -class 'TestInnerSignature$Inner' { - method ' (LTestInnerSignature;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V' { - b 17 - 10 18 - 16 19 - 19 20 +class 'TestInnerSignature$InnerStatic' { + method ' (Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V' { + 6 17 + b 18 + 10 19 + 13 20 } } -class 'TestInnerSignature$InnerStatic' { - method ' (Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V' { - 6 29 - b 30 - 10 31 - 13 32 +class 'TestInnerSignature$Inner' { + method ' (LTestInnerSignature;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V' { + b 29 + 10 30 + 16 31 + 19 32 } } @@ -66,14 +66,14 @@ Lines mapping: 24 <-> 8 25 <-> 9 26 <-> 10 -34 <-> 18 -35 <-> 19 -36 <-> 20 -37 <-> 21 -46 <-> 30 -47 <-> 31 -48 <-> 32 -49 <-> 33 +34 <-> 30 +35 <-> 31 +36 <-> 32 +37 <-> 33 +46 <-> 18 +47 <-> 19 +48 <-> 20 +49 <-> 21 Not mapped: 22 33 diff --git a/testData/results/TestMethodParameters.dec b/testData/results/TestMethodParameters.dec index af7ce86..21f0f12 100644 --- a/testData/results/TestMethodParameters.dec +++ b/testData/results/TestMethodParameters.dec @@ -21,14 +21,6 @@ public class TestMethodParameters { }// 39 - class C1 { - C1(@Deprecated int var2) { - }// 24 - - void m(@Deprecated int var1) { - }// 25 - } - static class C2 { C2(@Deprecated int var1) { }// 29 @@ -39,6 +31,14 @@ public class TestMethodParameters { static void m2(@Deprecated int var0) { }// 31 } + + class C1 { + C1(@Deprecated int var2) { + }// 24 + + void m(@Deprecated int var1) { + }// 25 + } } class 'pkg/TestMethodParameters' { @@ -69,26 +69,26 @@ class 'pkg/TestMethodParameters$1Local' { } } -class 'pkg/TestMethodParameters$C1' { - method ' (Lpkg/TestMethodParameters;I)V' { - 9 25 +class 'pkg/TestMethodParameters$C2' { + method ' (I)V' { + 4 25 } - method 'm (I)V' { + method 'm1 (I)V' { 0 28 } -} -class 'pkg/TestMethodParameters$C2' { - method ' (I)V' { - 4 33 + method 'm2 (I)V' { + 0 31 } +} - method 'm1 (I)V' { - 0 36 +class 'pkg/TestMethodParameters$C1' { + method ' (Lpkg/TestMethodParameters;I)V' { + 9 36 } - method 'm2 (I)V' { + method 'm (I)V' { 0 39 } } @@ -97,11 +97,11 @@ Lines mapping: 19 <-> 5 20 <-> 8 21 <-> 11 -24 <-> 26 -25 <-> 29 -29 <-> 34 -30 <-> 37 -31 <-> 40 +24 <-> 37 +25 <-> 40 +29 <-> 26 +30 <-> 29 +31 <-> 32 36 <-> 16 37 <-> 19 39 <-> 22 diff --git a/testData/results/TestShadowing.dec b/testData/results/TestShadowing.dec new file mode 100644 index 0000000..45adbea --- /dev/null +++ b/testData/results/TestShadowing.dec @@ -0,0 +1,6 @@ +package pkg; + +class TestShadowing { + ext.Shadow.B instanceOfB = new ext.Shadow.B(); +} + diff --git a/testData/src/ext/Shadow.java b/testData/src/ext/Shadow.java new file mode 100644 index 0000000..02869ca --- /dev/null +++ b/testData/src/ext/Shadow.java @@ -0,0 +1,6 @@ +package ext; + +// companion class for pkg/TestShadowing.java +public class Shadow { + public static class B { } +} \ No newline at end of file diff --git a/testData/src/pkg/Shadow.java b/testData/src/pkg/Shadow.java new file mode 100644 index 0000000..d76fb78 --- /dev/null +++ b/testData/src/pkg/Shadow.java @@ -0,0 +1,4 @@ +package pkg; + +// companion class for pkg/TestShadowing.java +public class Shadow { } \ No newline at end of file diff --git a/testData/src/pkg/TestShadowing.java b/testData/src/pkg/TestShadowing.java new file mode 100644 index 0000000..c8792b2 --- /dev/null +++ b/testData/src/pkg/TestShadowing.java @@ -0,0 +1,5 @@ +package pkg; + +class TestShadowing { + ext.Shadow.B instanceOfB = new ext.Shadow.B(); +} \ No newline at end of file