In Java 8 or better, see jls. We can construct a lambda based instance for interfaces.
packagetech.skidonion.identifiersobfuscating;
importjava.util.ArrayList;
importjava.util.List;
publicclassLambdaTest {
interfaceSAMInterfaceA {
Objectsam();
}
interfaceSAMInterfaceB {
List<?> sam();
}
interfaceSAMInterfaceC {
List<String> sam();
}
interfaceSAMInterfaceD {
ArrayList<String> sam();
}
publicstaticvoidmain(String[] args) {
System.out.println(((SAMInterfaceC & SAMInterfaceD & SAMInterfaceB & SAMInterfaceA) () -> newArrayList<String>() {{
add("hello");
}}).sam());
}
}In this case, SAMInterfaceASAMInterfaceBSAMInterfaceCSAMInterfaceD don't point to the same single abstract method statically but dynamically.
When obfuscating, we should statically parse the generated invokedynamic bytecode to generate the correct mapping for all interfaces.
Therefore, it is necessary to add a test to test if that the mapping is correct.
In Java 8 or better, see jls. We can construct a lambda based instance for interfaces.
In this case,
SAMInterfaceASAMInterfaceBSAMInterfaceCSAMInterfaceDdon't point to the same single abstract method statically but dynamically.When obfuscating, we should statically parse the generated invokedynamic bytecode to generate the correct mapping for all interfaces.
Therefore, it is necessary to add a test to test if that the mapping is correct.