Guardsquare / proguard

ProGuard, Java optimizer and obfuscator
https://www.guardsquare.com/en/products/proguard
GNU General Public License v2.0
2.88k stars 411 forks source link

Proguard 6.2.2: shrink dont work with some interfaces #35

Open caraiz opened 4 years ago

caraiz commented 4 years ago

Hello, shrink dont work completly with the library fastutil (http://fastutil.di.unimi.it), leaving in the output jar unused classes.

Im using openjdk 13.0.2 and proguard 6.2.2.

After some tests, the problem seems be when an interface method is overrided.

public interface BooleanSetOk extends java.util.Set<Boolean>
{
    boolean add2(Boolean aBoolean);
}

public interface BooleanSetFail extends java.util.Set<Boolean>
{
    @Override
    boolean add(Boolean aBoolean);
}

The first class is removed, but the second don't.

EricLafortune commented 4 years ago

Some code is probably calling BooleanSetFail # add(Boolean). ProGuard's shrinking step then won't remove the interface.

In both cases, optimization passes might remove the interface, but this depends on the implementations and invocations,

caraiz commented 4 years ago

I send you a simple example to test what happens.

proguard-test.zip

caraiz commented 3 years ago

Still not working with version 7.1.0

caraiz commented 10 months ago

Hi, i tested again with version 7.4.1

The class is never used but its not shrinked. Seems the problem occurs when overriding a method of a generic interface.

proguard-test.zip

caraiz commented 1 month ago

Hi, i tested again with version 7.5.0

The result is the same, the interface is not used, but still in output. Its more critical in libraries where there are a lot of Generic Interfaces, because all those interfaces are not removed.