shrink remove generics information with Java 8
Java class file shrinker, optimizer, obfuscator, and preverifier
Brought to you by:
guardsquare
If you extend a class defined in a JAR compiled with Java 8 and obuscated with "library.pro" (included in proguard5 dist), the generics type is not kept if shrink is enabled.
Workaround: use -dontshrink
== library
public class Foo<T> {
protected T value;
public T getValue() { return value; } public void setValue(T value) { this.value = value; }
}
== application
public class Bar extends Foo<String> {
public int getLength() { return value.length(); }
}
== compilation error
C:\TestApp\src\testapp\Bar.java:12: error: cannot find symbol
return value.length();
symbol: method length()
location: variable value of type Object
Thanks dalmaso for filing this bug.
I wasted a lot of time unsuccessfully fooling around with -keepattributes options.
There's a working workaround, but I'd still be all for increasing the prio on this.
Thanks for the report. This indeed appears to be a fairly serious bug introduced in 5.0: the shrinking step removes some signatures that should be preserved. I'll fix it for the next release.
Great.
Thanks!
I have a similar problem, but I'm not sure if this is the same:
Regards
Adam
Adam, the bug that you reported had a different cause, but it has been solved in ProGuard 5.1 beta1.
Any progress on this?
Awesome! Looking forward to trying this out.
I checked my case, described above ( https://sourceforge.net/p/proguard/bugs/537/#62a5 )
It seems that the problem still exists.
I created new ticked http://sourceforge.net/p/proguard/bugs/537
The fix seems to work for me.
Works for me, too!
Tested with my example in the first post.