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

7.1.0-beta2 breaks the obfuscated application #141

Closed
IkoRein opened this issue Apr 1, 2021 · 3 comments
Closed

7.1.0-beta2 breaks the obfuscated application #141

IkoRein opened this issue Apr 1, 2021 · 3 comments
Labels
bug Potential bug in ProGuard. optimization

Comments

@IkoRein
Copy link

IkoRein commented Apr 1, 2021

Hi,
I just tested the 7.1.0-beta2 and my application .jar fails to start after obfuscating with the beta2.

The only thing changed was to go from from 7.1.0-beta1 to 7.1.0-beta2.

My application is (about 350k rows) JavaFX tool, developed with Java 8 (1.8.275 now) in Netbeans (12.0 now) with ANT scripts. Plan is to move to Java 15 in the very near future.

When I obfuscate with beta1, the resulting .jar works perfectly.

When I obfuscate with beta2, first the resulting .jar file is about 20% of the size of the one obfuscated with beta1. (400KB vs 2000KB).
When I run the the resulting jar, it throws the following exception trace:

Exception in Application start method
java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(Unknown Source)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(Unknown Source)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at java.base/sun.launcher.LauncherHelper$FXHelper.main(Unknown Source)
Caused by: java.lang.RuntimeException: Exception in Application start method
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(Unknown Source)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ExceptionInInitializerError
at ak.(SourceFile:441)
at apps.RunMe.start(SourceFile:120)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(Unknown Source)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(Unknown Source)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(Unknown Source)
at java.base/java.security.AccessController.doPrivileged(Unknown Source)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(Unknown Source)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(Unknown Source)
... 1 more
Caused by: java.lang.NullPointerException: Cannot throw exception because "null" is null
at ap.(SourceFile:26)
... 11 more
Exception running application apps.RunMe

When I look with jd-gui, there are a lot of less classes inside the obfuscated .jar obfuscated with beta2 than with beta1 (or earlier versions).

The line in case ap line 26 points to first item in enum (enum constructor has 3 Strings) , which in beta2 obfuscated is just:

public enum ap
{
static
{
throw null;
}
}

Any ideas, what was changed between beta1 and beta2, which caused this? How can I remedy the situation.

@IkoRein IkoRein changed the title 7.1.0-beta2 break the obfuscated application 7.1.0-beta2 breaks the obfuscated application Apr 1, 2021
@mrjameshamilton
Copy link
Contributor

Hi @IkoRein ! Thanks for the report!

There was some extensive refactoring of optimization code, so it's possible something has gone wrong there.

Does it work if you disable any of the features?

  • -dontshrink
  • -dontoptimize
  • -dontobfuscate

Are you able to share the following to help investigation, of both 7.1.0-beta1 and 7.1.0-beta2 builds?

  • build logs (with -verbose in your ProGuard config)
  • -printseeds seeds.txt
  • -printusage usage.txt
  • -printmapping mapping.txt
  • -printconfiguration fullconfig.pro
  • working jar + broken jar

If you could share the full project or a sample that would also be great. If you cannot share them here publicly you can email them to me at james [dot] hamilton [at] guardsquare [dot] com.

@mrjameshamilton mrjameshamilton added the bug Potential bug in ProGuard. label Apr 1, 2021
@IkoRein
Copy link
Author

IkoRein commented Apr 1, 2021

Hmm, must be too tired, this seems so odd.

So this is what came out from the quick testing.

Having in the application.pro
-dontoptimize
alone produces working .jar.

I cannot share the project, but maybe I could do runs with the above settings on both beta1 and beta2. I will email the logs to you.

Edit: Sent you the logs.
Edit2: You email server does not allow me to send .zip files.

Cheers.

@mrjameshamilton
Copy link
Contributor

Hi @IkoRein ! Thanks for the report + sample and thanks for testing out the beta version! I found the cause - the marking of classes with constructors was accidentally removed during the beta2 optimizations update. I've fixed this now, if you build ProGuard from source (https://github.com/Guardsquare/proguard#-building-proguard) it should work now. We'll release beta3 soon with the fix.

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

No branches or pull requests

2 participants