Skip to content

Instantly share code, notes, and snippets.

Last active May 26, 2023 18:39
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Manual patching of ECJ jar for IntelliJ issue

This is what I've done to circumvent this issue. For my project to work, I need the -parameters option and I also like the -preserveAllLocals for debugging.

As IntelliJ accepts a custom ECJ jar, I figured I'd recompile ECJ with the options hardcoded to get around that bug. Unfortunately, the documentation is quite sparse and doesn't show an easy way to build ecj.jar.

I've decided to modify the jar instead! There is a neat tool called Recaf that does just that, decompiles a jar and allow you to easily modify it and repackage it. Neat!

  1. Head to mvn repo to download the latest jar
  2. Download recaf fat jar and execute it with java -jar recaf-2.21.13-J8-jar-with-dependencies.jar
  3. Open the class in org.eclipse.jdt.internal.compiler.batch
  4. For some reason, Recaf couldn't properly decompiled the class so I went to the Eclipse JDT core repo to fetch the real source code (you could also fetch it from the source jar to use the exact version, it would be more robust than what I did). MAKE SURE the main class is the one bundled in the jar!
  5. At the end of the configure method of the class, add this :
  1. Save the file
  2. File -> Export program -> choose a jar name (ecj-patched.jar)
  3. java -jar ecj-patched.jar will now complain about invalid signature of the class, easy to fix with zip -d ecj-patched.jar 'META-INF/.SF' 'META-INF/.RSA' 'META-INF/*SF'

Now, just use this patched jar in IntelliJ and this should work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment