Enum variable proguard create a new class

I have a public class that implements Serializable and this class have an enum variable

public class RunResult implements Serializable {

public enum ResultType {PENDING, OK, WARNING, ERROR}

after execute my ProguardTask in gradle, on my output jar I obtain a new enum class so when I try to use my output jar for my other part of the project I got some errors.

I tried using:

keep ‘public class com.xxx.yyy.zzz.utils.agent.RunResult {
public enum ResultType;
}’

to keep having the same nomenclature and not undergo modifications but proguard generate the new enum class:

public enum RunResult$ResultType {
PENDING,
OK,
WARNING,
ERROR;

private RunResult$ResultType() {
}
}

so when I use this output Jar the application got type errors (because names changed [ResultType to RunResult$ResultType])

Thanks!!

PD: I’m ussing proguard 7.1.0

Hi @Leicht ,

In order to tackle your issue related to the return type, you will need to specify the ResultType enum outside the scope of RunResult . Please note even without using ProGuard the return type will change as you described if you do not move the enum outside the scope of the class.

As a side note, the -keep rule you mentioned is not correct. You can preserve enums as shown below, please note changing the -keep rule will not tackle your issue related to the return type.

-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

More information on that can be found here: ProGuard Manual: Examples | Guardsquare

Kind regards,

Jonas

1 Like