Repository navigation
java.lang.IllegalAccessError: class com.google.googlejavaformat.java.JavaInput #787
Copy link
Copy link
Closed
Labels
Description
Information
IntelliJ IDEA 2022.1.1 (Ultimate Edition)
Build #IU-221.5591.52, built on May 10, 2022
Subscription is active until February 27, 2023.
Runtime version: 17.0.3+7-b423.10 aarch64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 12.3.1
GC: G1 Young Generation, G1 Old Generation
Memory: 2048M
Cores: 8
Metal Rendering is ON
Non-Bundled Plugins:
some.awesome (1.14)
name.kropp.intellij.makefile (221.5591.19)
com.markskelton.one-dark-theme (5.5.2)
com.intellij.properties.bundle.editor (221.5591.57)
google-java-format (1.15.0.0)
com.mallowigi (64.0.0)
Batch Scripts Support (1.0.13)
com.intellij.aspectj (221.5591.19)
ru.adelf.idea.dotenv (2022.1)
izhangzhihao.rainbow.brackets (6.23)
com.haulmont.jpab (2022.2.4-221)
Kotlin: 221-1.6.21-release-337-IJ5591.52
Exception
java.lang.IllegalAccessError: class com.google.googlejavaformat.java.JavaInput (in unnamed module @0x694af582) 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 @0x694af582
at com.google.googlejavaformat.java.JavaInput.buildToks(JavaInput.java:349)
at com.google.googlejavaformat.java.JavaInput.buildToks(JavaInput.java:334)
at com.google.googlejavaformat.java.JavaInput.<init>(JavaInput.java:276)
at com.google.googlejavaformat.java.Formatter.getFormatReplacements(Formatter.java:260)
at com.google.googlejavaformat.intellij.FormatterUtil.getReplacements(FormatterUtil.java:40)
at com.google.googlejavaformat.intellij.GoogleJavaFormatCodeStyleManager.format(GoogleJavaFormatCodeStyleManager.java:150)
at com.google.googlejavaformat.intellij.GoogleJavaFormatCodeStyleManager.formatInternal(GoogleJavaFormatCodeStyleManager.java:137)
at com.google.googlejavaformat.intellij.GoogleJavaFormatCodeStyleManager.reformatText(GoogleJavaFormatCodeStyleManager.java:59)
at com.intellij.codeInsight.completion.JavaChainLookupElement.handleInsert(JavaChainLookupElement.java:129)
at com.intellij.codeInsight.completion.ChainedCallCompletion$1.handleInsert(ChainedCallCompletion.java:58)
at com.intellij.codeInsight.lookup.TailTypeDecorator.handleInsert(TailTypeDecorator.java:35)
at com.intellij.codeInsight.completion.SmartCompletionDecorator.handleInsert(SmartCompletionDecorator.java:113)
at com.intellij.codeInsight.completion.CodeCompletionHandlerBase.lambda$insertItem$14(CodeCompletionHandlerBase.java:689)
at com.intellij.util.indexing.FileBasedIndex.lambda$ignoreDumbMode$0(FileBasedIndex.java:202)
at com.intellij.openapi.util.RecursionManager$1.computePreventingRecursion(RecursionManager.java:114)
at com.intellij.util.indexing.FileBasedIndexEx.ignoreDumbMode(FileBasedIndexEx.java:677)
at com.intellij.util.indexing.FileBasedIndex.ignoreDumbMode(FileBasedIndex.java:201)
at com.intellij.util.indexing.DumbModeAccessType.ignoreDumbMode(DumbModeAccessType.java:43)
at com.intellij.codeInsight.completion.CodeCompletionHandlerBase.lambda$insertItem$15(CodeCompletionHandlerBase.java:688)
at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:1015)
at com.intellij.codeInsight.completion.CodeCompletionHandlerBase.insertItem(CodeCompletionHandlerBase.java:672)
at com.intellij.codeInsight.completion.CodeCompletionHandlerBase.lambda$doInsertItem$12(CodeCompletionHandlerBase.java:597)
at com.intellij.openapi.editor.impl.CaretModelImpl.lambda$runForEachCaret$3(CaretModelImpl.java:312)
at com.intellij.openapi.editor.impl.CaretModelImpl.doWithCaretMerging(CaretModelImpl.java:421)
at com.intellij.openapi.editor.impl.CaretModelImpl.runForEachCaret(CaretModelImpl.java:321)
at com.intellij.openapi.editor.impl.CaretModelImpl.runForEachCaret(CaretModelImpl.java:296)
at com.intellij.codeInsight.completion.CodeCompletionHandlerBase.doInsertItem(CodeCompletionHandlerBase.java:587)
at com.intellij.codeInsight.completion.CodeCompletionHandlerBase.insertItemHonorBlockSelection(CodeCompletionHandlerBase.java:547)
at com.intellij.codeInsight.completion.CodeCompletionHandlerBase.lookupItemSelected(CodeCompletionHandlerBase.java:493)
at com.intellij.codeInsight.completion.CompletionProgressIndicator.itemSelected(CompletionProgressIndicator.java:180)
at com.intellij.codeInsight.completion.BaseCompletionLookupArranger.itemSelected(BaseCompletionLookupArranger.java:218)
at com.intellij.codeInsight.lookup.impl.LookupImpl.fireItemSelected(LookupImpl.java:937)
at com.intellij.codeInsight.lookup.impl.LookupImpl.finishLookupInWritableFile(LookupImpl.java:580)
at com.intellij.codeInsight.lookup.impl.LookupImpl.lambda$finishLookup$5(LookupImpl.java:538)
at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:210)
at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:174)
at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:164)
at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:150)
at com.intellij.codeInsight.lookup.impl.LookupImpl.finishLookup(LookupImpl.java:538)
at com.intellij.codeInsight.lookup.impl.LookupImpl.finishLookup(LookupImpl.java:523)
at com.intellij.codeInsight.lookup.impl.actions.ChooseItemAction$Handler.lambda$doExecute$0(ChooseItemAction.java:72)
at com.intellij.util.SlowOperations.allowSlowOperations(SlowOperations.java:147)
at com.intellij.codeInsight.lookup.impl.actions.ChooseItemAction$Handler.doExecute(ChooseItemAction.java:72)
at com.intellij.openapi.editor.actionSystem.DynamicEditorActionHandler.doExecute(DynamicEditorActionHandler.java:63)
at com.intellij.openapi.editor.actionSystem.EditorActionHandler.lambda$execute$4(EditorActionHandler.java:199)
at com.intellij.openapi.editor.actionSystem.EditorActionHandler.doIfEnabled(EditorActionHandler.java:89)
at com.intellij.openapi.editor.actionSystem.EditorActionHandler.execute(EditorActionHandler.java:198)
at com.intellij.openapi.editor.actionSystem.EditorAction.lambda$actionPerformed$0(EditorAction.java:89)
at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:219)
at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:174)
at com.intellij.openapi.editor.actionSystem.EditorAction.actionPerformed(EditorAction.java:98)
at com.intellij.openapi.editor.actionSystem.EditorAction.actionPerformed(EditorAction.java:73)
at com.intellij.openapi.keymap.impl.ActionProcessor.performAction(ActionProcessor.java:65)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher$1.performAction(IdeKeyEventDispatcher.java:579)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.lambda$doPerformActionInner$10(IdeKeyEventDispatcher.java:704)
at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:106)
at com.intellij.openapi.application.TransactionGuardImpl.performUserActivity(TransactionGuardImpl.java:95)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.lambda$doPerformActionInner$11(IdeKeyEventDispatcher.java:704)
at com.intellij.openapi.actionSystem.ex.ActionUtil.performDumbAwareWithCallbacks(ActionUtil.java:256)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.doPerformActionInner(IdeKeyEventDispatcher.java:701)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processAction(IdeKeyEventDispatcher.java:645)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processAction(IdeKeyEventDispatcher.java:590)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processActionOrWaitSecondStroke(IdeKeyEventDispatcher.java:473)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.inInitState(IdeKeyEventDispatcher.java:462)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.dispatchKeyEvent(IdeKeyEventDispatcher.java:227)
at com.intellij.ide.IdeEventQueue.dispatchKeyEvent(IdeEventQueue.java:804)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:740)
at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$6(IdeEventQueue.java:439)
at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:803)
at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$7(IdeEventQueue.java:438)
at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:119)
at com.intellij.ide.IdeEventQueue.performActivity(IdeEventQueue.java:604)
at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$8(IdeEventQueue.java:436)
at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:873)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:484)
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)
Reactions are currently unavailable
Activity
MatthewRyanRead commentedon Jun 10, 2022
Similar to #779. I think this is caused by #768
chadselph commentedon Jun 16, 2022
Taken from #779 a less-than-ideal workaround is to add these JVM arguments to intellij
You can find instructions here https://www.jetbrains.com/help/idea/tuning-the-ide.html#374b2f00
for me on macOS the file was
/Applications/IntelliJ IDEA 2022.2 EAP.app/Contents/bin/idea.vmoptionsUpdate: best way to find this file is from the menus: Help > Edit Custom VM Options
rdlf0 commentedon Jun 16, 2022
@chadselph I tried this on
2022.1.2, but it didn't help.otbe commentedon Jun 22, 2022
Happens to me on a java11 project and the VM options solved it. Im using 2022.2 EAP right now
rdlf0 commentedon Jun 22, 2022
I can confirm that adding the VM options solves the problem for
2022.2 EAP, but does not for the earlier non-EAP versions.rmetzger commentedon Jul 11, 2022
@rdlf0 did you manage to solve the problem? I filed a new ticket for it: #798
rdlf0 commentedon Jul 11, 2022
@rmetzger I switched to the 2022.2 EAP (currently in beta) as it was the only way I was able to make it work (with the VM options approach).
darkweizer commentedon Jul 28, 2022
Same error on IntelliJ 2022.2 and JDK Sap Machine 11
mbzmak commentedon Jul 28, 2022
Had the issue after upgrading to 2022.2 (Community Edition), and this workaround solved it.
tbroyer commentedon Jul 28, 2022
Fwiw, the arguments used to run tests, and put into the JAR manifest, are a bit different, so I'd rather use those:
jpg1024 commentedon Aug 1, 2022
I use: IntelliJ IDEA 2022.2, it can be used after modifying it in the following way.
Help - Edit Custom VM Options
AchalKansal commentedon Aug 6, 2022
Facing the same issue
Error log:
nicosensei commentedon Aug 8, 2022
Same issue.
Community Edition 2022.2, build #IC-222.3345.118
Xigua7i commentedon Aug 12, 2022
After I added this configuration it worked fine, thank you!
31 remaining items
OllisGit commentedon Jan 13, 2023
fyi: the add-VM args works also for Eclipse (STS 4.16.1.RELEASE)
sormuras commentedon Jan 16, 2023
Perhaps it's a good idea to catch
at some code located in
com.google.googlejavaformat.javain order to forward users to this issue by wrapping it in a newGoogleJavaFormatIssue787Exception😉
jhsenjaliya commentedon Jan 25, 2023
This did not work on IntelliJ IDEA 2022.3.1 (Ultimate Edition), intelliJ stopped opening, and had to remove these options directly from the file in order to start the iDE.
Xu-Justin commentedon Feb 1, 2023
I have the same issue. I easily fix this by changing from JAVA JDK 17 to JAVA JDK 8.
EDIT:
At least it is working for me when changing from Java 17 to Java 8. Maybe it is not supported in new version?? I don't know 😑
utsavb10 commentedon Mar 1, 2023
Doing this caused Intellij to shut down and now it won't start.
Intellij 2022.3 CE on macOS
utsavb10 commentedon Mar 1, 2023
WORKS !
plumpy commentedon Mar 3, 2023
There's not a good way to avoid the
--add-exportsrequirement, unfortunately. But the newest version of the plugin at least detects the issue and links you to the instructions about how to change your IDE's settings.I think that's about the best we can do, so I'm going to mark this fixed for now. Thanks.
kathirsvn commentedon Jun 30, 2023
Yes, It caused my IDE not starting up. To revert to old setup, delete the idea.jdk or idea64.jdk file in the config directory and then start the IDE. Config directory path for IntelliJ in different OS is listed here.
sebing commentedon Jul 25, 2023
What is the fix? Do you know if I need to do anything to fix this issue?


I am getting the error:
On my
tbroyer commentedon Jul 25, 2023
→ https://github.com/google/google-java-format#intellij-jre-config (and maybe also update to the latest version of the plugin)
rtfpessoa commentedon Aug 23, 2023
Latest plugin with all the configs still broken for me.
Bashing the format keybind seems to make it work most times 😢
rikintanna commentedon Feb 29, 2024
seeing a similar problem with a different module in googlejavaformat library
Caused by: java.lang.IllegalAccessError: class com.google.googlejavaformat.java.RemoveUnusedImports (in unnamed module @0x2b099be2) cannot access class com.sun.tools.javac.util.Context (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.util to unnamed module @0x2b099be2 at com.google.googlejavaformat.java.RemoveUnusedImports.removeUnusedImports(RemoveUnusedImports.java:218) ... 142 moreI added the below workaround, but no luck. I'm on IntelliJ IDEA 2023.2.5. any advice?
also note, I am also experiencing this outside of intellij when building. I tried adding the above workaround to my
gradle.propertiesfile like sojava version
thahgr commentedon May 14, 2024
adding jvm options is not a solution, it is a workaround
JesSakana commentedon Jan 6, 2025
--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.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
I add those in here, and it finally works!😂