MethodHandles / VarHandles Support
The signature of MethodHandle and VarHandle directly use the argument type.
https://github.com/Guardsquare/proguard-core/blob/master/base/src/main/java/proguard/classfile/LibraryClass.java#L326 So the codes here cannot find the ref to MethodHandle and VarHandle and their signature cannot be changed when obfuscating jar with proguard.
Hello @burningtnt,
Thank you for getting in touch with us.
Is it possible to provide a minimal reproducing sample project that triggers the issue when it is obfuscated with ProGuard? If you do have such a sample, please also state:
- Expected behavior
- Actual behavior
What you need is to create these two classes:
public class Main {
public static void main(String[] args) {
MethodHandles.lookup().findVirtual(Hello.class, "hello", MethodType.methodType(void.class)).invokeExact(new Hello());
}
}
public class Hello {
public void hello() {
System.out.println("Hello World");
}
}
And configure ProGuard as 'obfuscate classes name, but don't shrink methods and their names.'
DO REMEBER TO ENABLE -dontwarn java.lang.invoke.MethodHandle
The expected behavior is outputing a "Hello World".
However, the actural behavior is thrown a ClassNotFound for Hello class, as the signature of invokeExact is (LHello;)V instead of something like L(LA;)v
You can simply search -dontwarn java.lang.invoke.MethodHandle on GitHub: https://github.com/search?q=%22-dontwarn+java.lang.invoke.MethodHandle%22&type=code to see a lot of problems.