Search code examples
javajvmproguard

JRE fatal error after shrinking with Proguard


I'm bundling the JRE with my JavaFX application on Mac using gradle-macappbundle. I'm trying to reduce the size of the JRE so I don't have to include the full ~200 MB. I have followed the instructions in the Java8 README to remove some optional components.

After the macappbundle plugin creates the .app, I want to run Proguard on the JRE(I'm using the gradle plugin for it) to remove even more unused classes.

My current proguard rules:

task shrinkJRE(type: ProGuardTask, dependsOn: 'createApp') {
    injars "build/macApp/"
    outjars "build/libs/pro/"

    keep "class java.** { *; }"

    ignorewarnings()
    dontobfuscate()
    dontoptimize()
}

This produces a JRE about 45 MB.

But after doing chmod +x on the JavaAppLauncher executable and running it, it shows this error:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x000000010c6025e4, pid=86901, tid=0x0000000000002303
#
# JRE version:  (8.0_181-b13) (build )
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.181-b13 mixed mode bsd-amd64 compressed oops)
# Problematic frame:
# V  [libjvm.dylib+0x5825e4]  universe_post_init()+0x6a9
#
# Core dump written. Default location: /cores/core or core.86901
#
# An error report file with more information is saved as:
# /Users/rishiraja/hs_err_pid86901.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
#
Abort trap: 6 (core dumped)

Could anyone help me find the cause of this error?

My guess is that I'm missing some required classes for the JRE, so what are some classes I might also need to "keep"?


Solution

  • The officially supported alternative to doing is now jlink and jpackage. Using the gradle plugin for jlink makes it very easy to produce small packages for distribution.