0

I have a class CustomListener which is Mentioned like below :

public interface CustomListener{
     public abstract void abd(ArrayList<customObject> list);
}

this class is in my library and when I built it with maven and Proguard this method gets optimized to generic ArrayList type as below. How can I skip proguard doing that?

public interface CustomListener{
     public abstract void abd(ArrayList list);
}
Kruti Mevada
  • 517
  • 5
  • 7
  • 21
  • 1
    Why do you want to do that? Anyway, it might not be proguard doing that, but java itself. Proguard operates on the java compiled code, and that does not have the type information anymore, it's just used for compile time error checking and to eliminate casting. – wildhemp Jul 25 '14 at 03:09
  • Because Its a callback method which is called when my download is sucessfull. normal jar file without proguard has ArrayList in my method. so I believe its issue of proguard. – Kruti Mevada Jul 25 '14 at 03:52
  • You response does not really answer my question. Anyway, here's a nice explanation of what happens: http://stackoverflow.com/questions/339699/java-generics-type-erasure-when-and-what-happens And you are right, it's probably proguard, but I still don't see why you need that to be kept. Does it cause an error? – wildhemp Jul 25 '14 at 03:58
  • thanks a lot. I replaced my method parameter to CustomObject[] instead of arraylist and it works :) – Kruti Mevada Jul 25 '14 at 04:25

1 Answers1

2

The Java compiler stores generic signatures in Signature attributes. The Java virtual machine ignores these attributes (erasure), so ProGuard removes them by default. You can keep them if necessary, e.g. for reflection or for processing libraries:

-keepattributes Signature
Eric Lafortune
  • 45,150
  • 8
  • 114
  • 106
  • Thanks a lot... worked for me... also for all the methods which are throwing exceptions.. they are getting modified and never asked me to put try catch when it is suppposed to.. can you let me know how can i keep throws in method signature too.. in my jar file? – Kruti Mevada Jul 28 '14 at 01:02
  • I found it.. thanks... its -keepattributes Exceptions – Kruti Mevada Jul 28 '14 at 01:28