I'm using ProGuard to obfuscate my code. My project is comprised of a few modules, each obfuscated independently.
One library includes an interface;
public interface IFace {
public int methodA(boolean b) throws CustomException;
}
Another library provides an implmentation
public class IFaceImpl implements IFace {
@Override
public int methodA(boolean b) throws CustomException {
return 0;
}
}
The library with the interface is built first, and the second is built against the obfuscated version. Unfortunately the compile fails on the @Override
as the interface does not have the throws clause.
I have proguard keeping the interface and all its members, but I can't figure out how to keep the throws clause.
The throws clause in a method declaration serves two purposes: It tells the compiler which exceptions are thrown so that the compiler can report uncaught (checked) exceptions as errors. It tells a programmer who is writing code that calls the method what exceptions to expect.
The throws clause must be used with checked exceptions. The throws clause is followed by the exception class names. The throws clause is used in a method declaration. Using the throws clause, we can declare multiple exceptions at a time.
When a method in superclass throws an unchecked exception the method the subclass method overriding cannot throw a checked exception.
I figured it out.
-keepattributes Exceptions
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With