Menu ▾ ▴

#548 default method in generic interface

v5.0
closed-fixed
None
7
2016-10-23
2014-10-28
No

Applies to version 5.1
I reported my problem in https://sourceforge.net/p/proguard/bugs/537/#62a5. I tested it with new ProGuard 5.1 and it seems, that the bug still exists.

Java 1.8.20, Win7.
I override default method in generic interface. ProGuard removes call of that method.

public class J8ProGuardGenerics {
    public static void main(String[] args) {
        Interface1 o = new J8PG();

        System.out.println("before setObjectValue");

        //--- this line is not excecuted after obfuscation 
        //--- workaround: -dontshrink 
        o.setObjectValue("setObjectValue");

        System.out.println("after setObjectValue");
    }

    public static interface Interface1 {
        public void setObjectValue(Object value);
    }

    public static interface Interface2<Type> extends Interface1 {
        void setValue(Type value);
        @SuppressWarnings("unchecked")
        default public void setObjectValue(Object value) {
            setValue((Type)value);
        }
    }

    public static class J8PG implements Interface2<String> {
        @Override
        public void setValue(String value) {
            System.out.println(value);
        }
    }
}

Output without obfuscation:

before setObjectValue
setObjectValue
after setObjectValue

Output with obfuscation:

before setObjectValue
after setObjectValue

Regards
Adam

Discussion

  • Eric Lafortune

    Eric Lafortune - 2015-01-13

    Thanks for your report. This bug has been solved in ProGuard 5.2 beta1.

     
  • Eric Lafortune

    Eric Lafortune - 2015-01-13
    • status: open --> open-fixed
    • assigned_to: Eric Lafortune
    • Priority: 5 --> 7
     
  • Adam Bartoszewicz

    I confirm bug is fixed. Thanks for your great work.

     
  • Eric Lafortune

    Eric Lafortune - 2016-10-23
    • Status: open-fixed --> closed-fixed
     

Log in to post a comment.