title: Eclipse Plugin --add-exports Java 16+
body: <p>Using the <a href="https://github.com/google/google-java-format#eclipse" rel="nofollow noreferrer">google-java-format</a> eclipse plugin works great when running Eclipse under Java 11, but when running on Java 16+, it fails with the following error:</p>
  <p><a href="https://i.stack.imgur.com/ATXGy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ATXGy.png" alt="issue running code formatter" /></a></p>
  <p>Full error: <code>A save participant caused problems. The save participant 'Code Clean Up' caused an exception: java.lang.IllegalAccessError: class com.google.googlejavaformat.java.JavaInput (in unnamed module @0x99c5646) cannot access class com.sun.tools.javac.parser.Tokens$TokenKind (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.parser to unnamed module @0x99c5646. See the error log for details.</code></p>
  <p>The google-java-formatter <a href="https://github.com/google/google-java-format#jdk-16" rel="nofollow noreferrer">does note</a> that when running on JDK 16+, you need to set the <code>--add-exports</code> flag when running the formatter, due to JEP-396 (strong encapsulation of JDK Internals).  What isn't clear is how to tell set <code>--add-exports</code> for Eclipse plugins.</p>
  <p>Adding the following to <code>eclipse.ini</code> (or in my case <code>SpringToolSuite4.ini</code>) doesn't seem to help (not to mention it feels wrong since its not targetting that particular plugin).  Is there a different way to approach/fix this?</p>
  <pre><code>-vmargs
  -Dosgi.requiredJavaVersion=11
  -Dosgi.dataAreaRequiresExplicitInit=true
  -Xms256m
  -Xmx2048m
  --illegal-access=permit
  --add-modules=ALL-SYSTEM
  --add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
  --add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
  --add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
  --add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
  --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
  </code></pre>