问题遇到的现象和发生背景
编写Idea插件时,运行代码报错
运行结果及报错内容
2022-08-18 09:20:29,467 [ 2172] WARN - llij.ide.plugins.PluginManager - Problems found loading plugins:
The Aegis Coding Assistant (id=com.wuhao.code.check, path=~\AppData\Local\JetBrains\IntelliJIdea2021.3\plugins-sandbox\plugins\aegis-code-plugin, version=1.4.17) plugin Plugin 'Aegis Coding Assistant' requires plugin 'org.jetbrains.plugins.vue' to be installed
2022-08-18 09:20:29,610 [ 2315] ERROR - j.util.ui.EdtInvocationManager - null
java.lang.reflect.InvocationTargetException
at java.desktop/java.awt.EventQueue.invokeAndWait(EventQueue.java:1371)
at java.desktop/java.awt.EventQueue.invokeAndWait(EventQueue.java:1346)
at com.intellij.util.ui.EdtInvocationManager$SwingEdtInvocationManager.invokeAndWait(EdtInvocationManager.java:175)
at com.intellij.util.ui.EdtInvocationManager.invokeAndWaitIfNeeded(EdtInvocationManager.java:151)
at com.intellij.util.ui.UIUtil.invokeAndWaitIfNeeded(UIUtil.java:2196)
at com.intellij.ide.B.V.b.Q(b.java:109)
at com.intellij.ide.B.B.zk.J(zk.java:278)
at com.intellij.ide.B.B.zk.q(zk.java:208)
at com.intellij.ide.B.B.zk.f(zk.java:169)
at com.intellij.ide.B.B.zo.u(zo.java:136)
at java.base/java.util.concurrent.CompletableFuture$UniRun.tryFire(CompletableFuture.java:787)
at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1773)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1760)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)
Caused by: java.lang.ExceptionInInitializerError
at com.intellij.ide.IdeEventQueue.(IdeEventQueue.java:78)
at com.intellij.util.ui.OwnerOptional.fromComponent(OwnerOptional.java:35)
at com.intellij.openapi.ui.impl.DialogWrapperPeerImpl.(DialogWrapperPeerImpl.java:145)
at com.intellij.openapi.ui.impl.DialogWrapperPeerFactoryImpl.createPeer(DialogWrapperPeerFactoryImpl.java:37)
at com.intellij.openapi.ui.DialogWrapper.createPeer(DialogWrapper.java:845)
at com.intellij.openapi.ui.DialogWrapper.(DialogWrapper.java:229)
at com.intellij.openapi.ui.DialogWrapper.(DialogWrapper.java:220)
at com.intellij.openapi.ui.messages.MessageDialog.(MessageDialog.java:70)
at com.intellij.ui.messages.MessagesServiceImpl.showMessageDialog(MessagesServiceImpl.java:77)
at com.intellij.openapi.ui.Messages.showDialog(Messages.java:258)
at com.intellij.ide.B.V.b.F(b.java:119)
at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:308)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:773)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:720)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:714)
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:742)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:117)
at java.desktop/java.awt.WaitDispatchSupport$2.run(WaitDispatchSupport.java:191)
at java.desktop/java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:236)
at java.desktop/java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:234)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
at java.desktop/java.awt.WaitDispatchSupport.enter(WaitDispatchSupport.java:234)
at java.desktop/java.awt.Dialog.show(Dialog.java:1080)
at java.desktop/javax.swing.JOptionPane.showOptionDialog(JOptionPane.java:881)
at java.desktop/javax.swing.JOptionPane.showMessageDialog(JOptionPane.java:677)
at java.desktop/javax.swing.JOptionPane.showMessageDialog(JOptionPane.java:648)
at com.intellij.idea.Main.showMessage(Main.java:291)
at com.intellij.idea.Main.showMessage(Main.java:229)
at com.intellij.ide.plugins.StartupAbortedException.logAndExit(StartupAbortedException.java:91)
at com.intellij.idea.StartupUtil.lambda$start$15(StartupUtil.java:268)
at java.base/java.util.concurrent.CompletableFuture.uniExceptionally(CompletableFuture.java:990)
at java.base/java.util.concurrent.CompletableFuture$UniExceptionally.tryFire(CompletableFuture.java:974)
at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510)
at java.base/java.util.concurrent.CompletableFuture.postFire(CompletableFuture.java:614)
at java.base/java.util.concurrent.CompletableFuture$UniRun.tryFire(CompletableFuture.java:795)
at java.base/java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:482)
at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:773)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:720)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:714)
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:742)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field protected java.lang.Runnable java.awt.event.InvocationEvent.runnable accessible: module java.desktop does not "opens java.awt.event" to unnamed module @63653563
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:180)
at java.base/java.lang.reflect.Field.setAccessible(Field.java:174)
at com.intellij.openapi.application.impl.InvocationUtil.findRunnableField(InvocationUtil.java:49)
at com.intellij.openapi.application.impl.InvocationUtil.(InvocationUtil.java:17)
. 53 more
2022-08-18 09:20:29,614 [ 2319] ERROR - j.util.ui.EdtInvocationManager - IntelliJ IDEA 2021.3.3 Build #IU-213.7172.25
2022-08-18 09:20:29,614 [ 2319] ERROR - j.util.ui.EdtInvocationManager - JDK: 18.0.2; VM: OpenJDK 64-Bit Server VM; Vendor: Oracle Corporation
2022-08-18 09:20:29,614 [ 2319] ERROR - j.util.ui.EdtInvocationManager - OS: Windows 11
2022-08-18 09:20:29,614 [ 2319] ERROR - #com.intellij.idea.Main - Cannot start app
com.intellij.ide.plugins.StartupAbortedException: Cannot start app
at com.intellij.idea.StartupUtil.lambda$start$17(StartupUtil.java:290)
at java.base/java.util.concurrent.CompletableFuture.uniExceptionally(CompletableFuture.java:990)
at java.base/java.util.concurrent.CompletableFuture$UniExceptionally.tryFire(CompletableFuture.java:974)
at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1773)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1760)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)
Caused by: java.lang.NullPointerException: Cannot invoke "java.lang.Integer.intValue()" because the return value of "com.intellij.openapi.util.Ref.get()" is null
at com.intellij.ide.B.V.b.Q(b.java:121)
at com.intellij.ide.B.B.zk.J(zk.java:278)
at com.intellij.ide.B.B.zk.q(zk.java:208)
at com.intellij.ide.B.B.zk.f(zk.java:169)
at com.intellij.ide.B.B.zo.u(zo.java:136)
at java.base/java.util.concurrent.CompletableFuture$UniRun.tryFire(CompletableFuture.java:787)
.8 more
2022-08-18 09:20:29,615 [ 2320] ERROR - #com.intellij.idea.Main - IntelliJ IDEA 2021.3.3 Build #IU-213.7172.25
2022-08-18 09:20:29,615 [ 2320] ERROR - #com.intellij.idea.Main - JDK: 18.0.2; VM: OpenJDK 64-Bit Server VM; Vendor: Oracle Corporation
2022-08-18 09:20:29,615 [ 2320] ERROR - #com.intellij.idea.Main - OS: Windows 11
Your JRE: 18.0.2+9-61 amd64 (Oracle Corporation)
C:x432.jdks\openjdk-18.0.2
我的解答思路和尝试过的方法
将SDK中的jdk版本改为11
我想要达到的结果
运行代码时不报错