google-java-format
google-java-format copied to clipboard
Not formatting file on save in Intellij 2023.1
My Java files are not being formatted on save, only when I do a reformat manually. I can see that the google-java-format plugin is running when I save the file (it is quickly showing in the status bar), but the file is not reformatted. I cannot find any logs on this.
My setup
- Intellij 2023.1 (Build #IU-231.8109.175, built on March 28, 2023)
- google-java-format plugin 1.16.0.1
- Activated "Reformat code" and "Optimize imports" under settings -> Tools -> actions on save *I have imported the intellij-java-google-style file under settings -> code style -> Scheme.
- Runtime version: 17.0.6+10-b829.5 aarch64
- VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
I have setup custom VM options as follows
-Xmx3072m
-Dsplash=true
--add-opens=java.base/java.lang=ALL-UNNAMED
--add-opens=java.base/java.util=ALL-UNNAMED
--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
same issue. 2023.3.2
Similar issue here. Either it does not reformat at all or it runs forever (indicator at the bottom) and blocks so further autoformats or it dies trying to do so. This happens since 2023.1 RC
Similar issue here. Either it does not reformat at all or it runs forever (indicator at the bottom) and blocks so further autoformats or it dies trying to do so. This happens since 2023.1 RC
I have the same issue in 2022.3 (#IU-223.7571.182). Looks like this is more of a plugin issue rather than related to the IntelliJ version?
I am getting the following exeption:
Cannot create configurable
com.intellij.diagnostic.PluginException: Cannot create class com.dubreuia.ui.Configuration (classloader=PluginClassLoader(plugin=PluginDescriptor(name=Save Actions, id=com.dubreuia, descriptorPath=plugin.xml, path=~/.local/share/JetBrains/IntelliJIdea2023.1/intellij-plugin-save-actions-2.3.0.jar, version=2.3.0, package=null, isBundled=false), packagePrefix=null, instanceId=98, state=active))
at com.intellij.serviceContainer.ComponentManagerImpl.instantiateClass(ComponentManagerImpl.kt:1034)
at com.intellij.serviceContainer.ComponentManagerImpl.instantiateClass(ComponentManagerImpl.kt:1051)
at com.intellij.openapi.options.ConfigurableEP$ClassProducer.createElement(ConfigurableEP.java:438)
at com.intellij.openapi.options.ConfigurableEP.createConfigurable(ConfigurableEP.java:344)
at com.intellij.openapi.options.ex.ConfigurableWrapper.createConfigurable(ConfigurableWrapper.java:43)
at com.intellij.openapi.options.ex.ConfigurableWrapper.getConfigurable(ConfigurableWrapper.java:124)
at com.intellij.openapi.options.ex.ConfigurableWrapper.cast(ConfigurableWrapper.java:99)
at com.intellij.openapi.options.ex.ConfigurableWrapper.getDisplayName(ConfigurableWrapper.java:145)
at com.intellij.openapi.options.ex.Weighted.lambda$static$0(Weighted.java:26)
at java.base/java.util.TimSort.countRunAndMakeAscending(TimSort.java:355)
at java.base/java.util.TimSort.sort(TimSort.java:220)
at java.base/java.util.Arrays.sort(Arrays.java:1307)
at java.base/java.util.ArrayList.sort(ArrayList.java:1721)
at com.intellij.openapi.options.ex.SortedConfigurableGroup.buildConfigurables(SortedConfigurableGroup.java:41)
at com.intellij.openapi.options.SearchableConfigurable$Parent$Abstract.getConfigurables(SearchableConfigurable.java:75)
at com.intellij.openapi.options.ex.EpBasedConfigurableGroupKt.collect(EpBasedConfigurableGroup.kt:149)
at com.intellij.openapi.options.ex.EpBasedConfigurableGroupKt.access$collect(EpBasedConfigurableGroup.kt:1)
at com.intellij.openapi.options.ex.EpBasedConfigurableGroup.<init>(EpBasedConfigurableGroup.kt:111)
at com.intellij.openapi.options.ex.ConfigurableExtensionPointUtil.getConfigurableGroup(ConfigurableExtensionPointUtil.java:118)
at com.intellij.ide.actions.ShowSettingsUtilImpl.getConfigurableGroups(ShowSettingsUtilImpl.java:53)
at com.intellij.ide.actions.ShowSettingsAction.perform(ShowSettingsAction.java:60)
at com.intellij.ide.actions.ShowSettingsAction.actionPerformed(ShowSettingsAction.java:47)
at com.intellij.openapi.actionSystem.ex.ActionUtil.doPerformActionOrShowPopup(ActionUtil.java:333)
at com.intellij.openapi.actionSystem.ex.ActionUtil.lambda$performActionDumbAwareWithCallbacks$4(ActionUtil.java:307)
at com.intellij.openapi.actionSystem.ex.ActionUtil.performDumbAwareWithCallbacks(ActionUtil.java:356)
at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAwareWithCallbacks(ActionUtil.java:307)
at com.intellij.openapi.actionSystem.impl.ActionMenuItem.lambda$performAction$5(ActionMenuItem.java:299)
at com.intellij.openapi.wm.impl.FocusManagerImpl.runOnOwnContext(FocusManagerImpl.java:225)
at com.intellij.openapi.actionSystem.impl.ActionMenuItem.performAction(ActionMenuItem.java:292)
at com.intellij.openapi.actionSystem.impl.ActionMenuItem.lambda$new$0(ActionMenuItem.java:67)
at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1972)
at com.intellij.openapi.actionSystem.impl.ActionMenuItem.lambda$fireActionPerformed$4(ActionMenuItem.java:114)
at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:105)
at com.intellij.openapi.application.TransactionGuardImpl.performUserActivity(TransactionGuardImpl.java:94)
at com.intellij.openapi.actionSystem.impl.ActionMenuItem.fireActionPerformed(ActionMenuItem.java:114)
at com.intellij.ui.plaf.beg.BegMenuItemUI.doClick(BegMenuItemUI.java:526)
at com.intellij.ui.plaf.beg.BegMenuItemUI$MyMouseInputHandler.mouseReleased(BegMenuItemUI.java:558)
at java.desktop/java.awt.Component.processMouseEvent(Component.java:6656)
at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3385)
at java.desktop/java.awt.Component.processEvent(Component.java:6421)
at java.desktop/java.awt.Container.processEvent(Container.java:2266)
at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5026)
at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2324)
at java.desktop/java.awt.Component.dispatchEvent(Component.java:4854)
at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4948)
at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4575)
at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4516)
at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2310)
at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2804)
at java.desktop/java.awt.Component.dispatchEvent(Component.java:4854)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:790)
at java.desktop/java.awt.EventQueue$3.run(EventQueue.java:739)
at java.desktop/java.awt.EventQueue$3.run(EventQueue.java:731)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:97)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:763)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:761)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:760)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.kt:666)
at com.intellij.ide.IdeEventQueue.dispatchMouseEvent(IdeEventQueue.kt:614)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.kt:569)
at com.intellij.ide.IdeEventQueue.access$_dispatchEvent(IdeEventQueue.kt:68)
at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1.compute(IdeEventQueue.kt:349)
at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1.compute(IdeEventQueue.kt:348)
at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:787)
at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1.invoke(IdeEventQueue.kt:348)
at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1.invoke(IdeEventQueue.kt:343)
at com.intellij.ide.IdeEventQueueKt.performActivity$lambda$1(IdeEventQueue.kt:994)
at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:113)
at com.intellij.ide.IdeEventQueueKt.performActivity(IdeEventQueue.kt:994)
at com.intellij.ide.IdeEventQueue.dispatchEvent$lambda$4(IdeEventQueue.kt:343)
at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:831)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.kt:385)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:207)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:92)
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
at com.intellij.serviceContainer.ComponentManagerImpl.instantiateClass(ComponentManagerImpl.kt:1007)
... 81 more
Caused by: com.intellij.diagnostic.PluginException: The specified parameters not match any of the following constructors: public com.dubreuia.model.Storage()
public com.dubreuia.model.Storage(com.dubreuia.model.Storage)
for class com.dubreuia.model.Storage [Plugin: com.dubreuia]
at com.intellij.serviceContainer.ConstructorInjectionKt.getGreediestSatisfiableConstructor(constructorInjection.kt:219)
at com.intellij.serviceContainer.ConstructorInjectionKt.instantiateUsingPicoContainer(constructorInjection.kt:39)
at com.intellij.serviceContainer.ComponentManagerImpl.instantiateClassWithConstructorInjection(ComponentManagerImpl.kt:1041)
at com.intellij.serviceContainer.ServiceComponentAdapter.createAndInitialize(ServiceComponentAdapter.kt:43)
at com.intellij.serviceContainer.ServiceComponentAdapter.doCreateInstance(ServiceComponentAdapter.kt:39)
at com.intellij.serviceContainer.BaseComponentAdapter.doCreateInstance(BaseComponentAdapter.kt:154)
at com.intellij.serviceContainer.BaseComponentAdapter.createInstance$lambda$1(BaseComponentAdapter.kt:133)
at com.intellij.openapi.progress.Cancellation.computeInNonCancelableSection(Cancellation.java:99)
at com.intellij.serviceContainer.BaseComponentAdapter.createInstance(BaseComponentAdapter.kt:132)
at com.intellij.serviceContainer.BaseComponentAdapter.getInstance(BaseComponentAdapter.kt:92)
at com.intellij.serviceContainer.ComponentManagerImpl.doGetService(ComponentManagerImpl.kt:714)
at com.intellij.serviceContainer.ComponentManagerImpl.getService(ComponentManagerImpl.kt:670)
at com.intellij.openapi.components.ServiceManager.getService(ServiceManager.java:27)
at com.dubreuia.ui.Configuration.<init>(Configuration.java:90)
... 87 more
Same issue here with google-java-format
version 1.16.0.2, and intellij idea CE 2023.1.2, no reformat on save (even though we can see the plugin seemingly running in the status bar), but manually triggering a reformat works.
I went back and installed version 1.15.0.0 of the plugin, and it seems to work again, so indeed looks like a plugin issue.
Interestingly, I noticed that with version 1.16.0, after restarting IntelliJ, it worked for me for a few seconds, while IntelliJ was still doing some background tasks of indexing and so on, but after a few moments, when IntelliJ was fully booted, then it stopped formatting on save
Same here with IntelliJ 2023.2 Ultimate and google-java-format 1.16..0.2. Interestingly, another project with editorconfig works as expected. Edit: still same behavior with IntelliJ 2023.2.2 and version 1.17.0.0 of the plugin.
I have added the config in idea64.vmoptions
, but it still reports:
The google-java-format plugin needs additional configuration before it can be used. Follow the instructions here.
Any update on this? Plugin isn't working at all with IntelliJ 2023.2.4 and google-java-format 1.17.0.0. I always get a notification Configure the JRE for google-java-format, but doing so doesn't have any effect. Also, I don't see any exceptions in the log either - I used to see errors in previous versions, I guess somebody is catching them and just popping up a notification, which is unfortunate as it leaves us with no clue to what's going wrong...
Any update on this? Plugin isn't working at all with IntelliJ 2023.2.4 and google-java-format 1.17.0.0. I always get a notification Configure the JRE for google-java-format, but doing so doesn't have any effect. Also, I don't see any exceptions in the log either - I used to see errors in previous versions, I guess somebody is catching them and just popping up a notification, which is unfortunate as it leaves us with no clue to what's going wrong...
Maybe this is a workaround for you while we are waiting for a real fix:
I have reverted to version 1.15.0.0
by using the Settings -> Plugins -> control wheel icon -> Install plugin from disk
feature because that is the last version that is working for me. I'm still using a somewhat dated Intellij installation though (2022.3).
Maybe this is a workaround for you while we are waiting for a real fix: I have reverted to version
1.15.0.0
by using theSettings -> Plugins -> control wheel icon -> Install plugin from disk
feature because that is the last version that is working for me. I'm still using a somewhat dated Intellij installation though (2022.3).
Ok, I don't know what happened... 🤔
I've followed your recommendation and installed version 1.15.0.0
manually. After that, the formatting worked.
I was just about to write you back to thank you when I thought I might try if there is a more recent version that works. So I tried the 1.16.x
versions and they worked. Just out of curiosity, I also tried the latest version 1.17.0.0
again - and suddenly, it also worked...
Don't know, maybe going through all the versions somehow fixed something...?