google-java-format icon indicating copy to clipboard operation
google-java-format copied to clipboard

in idea 2022.3.3, this plugin throw error : configure the jre for google-java-format

Open git-code-for-me opened this issue 2 years ago • 7 comments

the configure is not work, in idea 2022.3.3

--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.code=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

--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED

--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED

git-code-for-me avatar May 17 '23 06:05 git-code-for-me

@git-code-for-me I had the exact same problem today. Apparently it's very important that you put a newline at the end of you .vmoptions file otherwise the last option gets concatenated with some other options that idea is adding.

andskiba avatar May 19 '23 16:05 andskiba

adding new line doesn't work for me.

malopez16 avatar Jul 27 '23 17:07 malopez16

I've having same issue, idea 2023.2.4 Running on intel mac. openjdk version "17.0.9" 2023-10-17

Keep getting the popup every time start IDE saying to configure the jre for google-java-format

Formatting doesn't work at all. The preview window in Code Style doesn't update with config changes.

Checked idea.log , and can't see anything to explain why this isn't loading, not errors or warning, just single line saying loaded plugin:

2023-11-02 08:56:58,416 [ 241] INFO - #c.i.i.p.PluginManager - Loaded custom plugins: google-java-format (1.17.0.0), Save Actions - XDEV Edition (1.0.4)

idea.vmoptions

-Xmx2048m
--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.code=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

Is there anywhere else to get logs or diagnostics on why this plugin isn't loading properly?

evilmilo avatar Nov 02 '23 09:11 evilmilo

Can you see if those options are actually being applied to the JVM? For example, if you do a ps auxw | grep idea.Main, do you see those options (all six of them) being passed to the JVM?

(Sorry, I don't have a Mac, so I don't know if ps auxw actually works there, but I think it should...)

plumpy avatar Nov 02 '23 13:11 plumpy

% ps auxw | grep idea.Main
nathan.mcdonald  25041   0.5  0.0 34130588    740 s009  S+    2:01pm   0:00.01 grep idea.Main

evilmilo avatar Nov 02 '23 14:11 evilmilo

So looks like issue with intellij on mac, not the plugin (not picking up vm options).

Instead, I editted: /Applications/IntelliJ\ IDEA\ CE.app/Contents/Info.plist

Found this section:

<key>JVMVersion</key>
      <string>1.8*,1.8+</string>
      <key>MainClass</key>
      <string>com/intellij/idea/Main</string>
      <key>ErrorFile</key>
      <string>-XX:ErrorFile=$USER_HOME/java_error_in_idea_%p.log</string>
      <key>HeapDump</key>
      <string>-XX:HeapDumpPath=$USER_HOME/java_error_in_idea.hprof</string>
      <key>Options</key>
      <array>
        <string>--add-opens=java.base/java.io=ALL-UNNAMED</string>
        <string>--add-opens=java.base/java.lang=ALL-UNNAMED</string>
        <string>--add-opens=java.base/java.lang.ref=ALL-UNNAMED</string>
        <string>--add-opens=java.base/java.lang.reflect=ALL-UNNAMED</string>
        <string>--add-opens=java.base/java.net=ALL-UNNAMED</string>
        <string>--add-opens=java.base/java.nio=ALL-UNNAMED</string>
        <string>--add-opens=java.base/java.nio.charset=ALL-UNNAMED</string>
       ....

and at the end of that array, added the other strings

        <string>--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED</string>
        <string>--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED</string>
        <string>--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED</string>
        <string>--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED</string>
        <string>--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED</string>
        <string>--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED</string>
        <string>--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED</string>
        <string>--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED</string>
        <string>--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED</string>

Restarted, and now works as expected!

evilmilo avatar Nov 02 '23 14:11 evilmilo

Hmm... so raised with Intellij, but they said vm options are loading correctly, so maybe issue with plugin not picking up options correctly?

https://youtrack.jetbrains.com/issue/IDEA-337068/Custom-VM-Options...-are-not-being-applied-when-running-on-Mac

evilmilo avatar Nov 02 '23 15:11 evilmilo