Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MethodHandles / VarHandles Support #131

Open
burningtnt opened this issue Dec 2, 2024 · 2 comments
Open

MethodHandles / VarHandles Support #131

burningtnt opened this issue Dec 2, 2024 · 2 comments

Comments

@burningtnt
Copy link

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.

@tvoc-gs
Copy link
Contributor

tvoc-gs commented Dec 3, 2024

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:

  1. Expected behavior
  2. Actual behavior

@burningtnt
Copy link
Author

burningtnt commented Dec 4, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants