fixed static interface methods

master
Egor.Ushakov 7 years ago
parent 6a7763922b
commit 478e6896e9
  1. 2
      src/org/jetbrains/java/decompiler/main/ClassWriter.java
  2. 1
      test/org/jetbrains/java/decompiler/SingleClassesTest.java
  3. BIN
      testData/classes/pkg/TestInterfaceMethods.class
  4. 23
      testData/results/TestInterfaceMethods.dec
  5. 6
      testData/src/pkg/TestInterfaceMethods.java

@ -624,7 +624,7 @@ public class ClassWriter {
appendModifiers(buffer, flags, METHOD_ALLOWED, isInterface, METHOD_EXCLUDED);
if (isInterface && mt.containsCode()) {
if (isInterface && !mt.hasModifier(CodeConstants.ACC_STATIC) && mt.containsCode()) {
// 'default' modifier (Java 8)
buffer.append("default ");
}

@ -111,6 +111,7 @@ public class SingleClassesTest {
//@Test public void TestSwitchOnStrings() { doTest("pkg/TestSwitchOnStrings");}
@Test public void testVarArgCalls() { doTest("pkg/TestVarArgCalls"); }
@Test public void testLambdaParams() { doTest("pkg/TestLambdaParams"); }
@Test public void testInterfaceMethods() { doTest("pkg/TestInterfaceMethods"); }
private void doTest(String testFile, String... companionFiles) {
ConsoleDecompiler decompiler = fixture.getDecompiler();

@ -0,0 +1,23 @@
package pkg;
public interface TestInterfaceMethods {
static void staticMethod() {
}// 4
default void defaultMethod() {
}// 5
}
class 'pkg/TestInterfaceMethods' {
method 'staticMethod ()V' {
0 4
}
method 'defaultMethod ()V' {
0 7
}
}
Lines mapping:
4 <-> 5
5 <-> 8

@ -0,0 +1,6 @@
package pkg;
public interface TestInterfaceMethods {
static void staticMethod() {}
default void defaultMethod() {}
}
Loading…
Cancel
Save