-
Notifications
You must be signed in to change notification settings - Fork 393
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
Proguard removes method invocation, changing behaviour #378
Comments
Simple example: public interface MyConsumer<T> {
public void accept(T t);
}
public class Test {
public static void main(String[] args) {
MyConsumer<String> c = consumer();
c.accept("Hello, World");
}
private static MyConsumer<String> consumer() {
return Test::println;
}
private static void println(String message) {
System.out.println(message);
}
} After some testing, it is indeed seems like Proguard assumes that invocation of Small sample, change .zip to .jar |
Greetings.
Before running Proguard, I apply some logic to the jar file to rewrite invokedynamic instructions to their equivalent parts.
The result of the transformation is, essentially:
Note that
MethodType.fromMethodDescriptorString("....", null)
is decompiler sugar and MT is pushed on the stack with LDC instructions instead. One of MTs references class with method in question according to LambdaMetafactory::metafactory bootstrap logic.Despite not having -assumenosideeffects, the invocation of the method is removed. Bootstrap logic succeeds and lambda is created.
I assume that proguard has some builtin logic to detect lambdas and thus not remove them.
Am I correct that the only way to prevent Proguard from removing a method is to write so in the configuration file using
keepclassmembers
?Thanks.
The text was updated successfully, but these errors were encountered: