Skip to content

Problem when obfuscating multi-level sealed interface hierarchies #501

@Emmeral

Description

@Emmeral

In my application I have a class hierarchy similar to the following one

public sealed interface Animal permits Mammal, Fish {}

public sealed interface Mammal permits Cat, Dog{}

public final class Fish implements Animal {}
public final class Cat implements Mammal {}
public final class Dog implements Mammal {}



class Main{
  public static void main(String[] args){
    new Dog();
    new Cat();
    new Fish();
  }
}

When obfuscating with proguard, it changes the permitted subclasses of the Animal class to [...] Animal permits Fish. I'm suspecting because the Mammal class is not used in my application directly. However, when I try to run the obfuscated application, I get the following error

java.lang.IncompatibleClassChangeError: class fj cannot extend sealed interface ff (java.lang.ClassLoader./.defineClass1./.-2)

Here, fj = Mammal and ff = Animal. So java cannot load the Mammal class because it extends the Animal class and is no longer part of the permitted subclasses.

I'm suspecting that there is a bug in proguard that shrinks the application too much so that it can no longer be run.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions