1

In Java 8 I needed to obfuscate jar/class files for an application. I'm migrating this application to Java 10 and I'm also updating the build process to use modules so that we don't have to provide the full JRE.

When I compile (javac) with modules and then build my stripped down JRE (jlink), I noticed that dist/lib/modules file is the file that contains my compiled code. However, when I inspect dist/lib/modules this file is not a ZIP file nor does it look like my code is visible.

Is there a way to decompile dist/lib/modules? Should I obfuscate my *.class files before calling jlink?

Here is an example of my build flow:

javac -d my_module/out $(find my_module/src -name *.java)
jar cf libs/my_module-1.0.jar -C my_module/out .
javac -d out -p 'libs/my_module-1.0.jar' \
  src/module-info.java src/application/Main.java
jlink -p $JAVA_HOME/jmods:libs --add-modules com.application \
  --launcher start-application=com.application \
  --strip-debug --compress=2 \
  --output small-dist
nikc
  • 2,198
  • 17
  • 21

1 Answers1

2

jlink doesn't do any obfuscation. To extract module you can use "jimage extract" (see How to extract the file jre-9/lib/modules? )

user158037
  • 2,487
  • 1
  • 21
  • 25