Netbeans:意外异常

Netbeans: Unexpected Exception

我在我的电脑上安装了 Apache Netbeans。一切正常。但是第二天我想继续我的工作,但是从那以后我一直得到一个例外:

A java.lang.IllegalAccessError exception has occurred.
Please report this at https://issues.apache.org/jira/projects/NETBEANS/issues,
including a copy of your messages.log file as an attachment.
The messages.log file is located in your 
C:\Users\svent\AppData\Roaming\NetBeans.0\var\log folder.

我有以下设置:

产品版本:Apache NetBeans IDE12.0

Java: 17; OpenJDK 64 位服务器虚拟机 17+35-2724

系统:Windows10 amd64

我试过卸载所有东西然后重新安装。我还尝试使用 Java 11 或 Java 14。我还尝试从 AppData 中的 netbeans 中删除 12.0 文件夹。但是 none 这有帮助。

这是确切的例外:

java.lang.IllegalAccessError: superclass access check failed: class org.netbeans.lib.nbjavac.services.CancelAbort (in unnamed module @0x6a51d5d0) cannot access class com.sun.tools.javac.util.Abort (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.util to unnamed module @0x6a51d5d0
    at java.base/java.lang.ClassLoader.defineClass1(Native Method)
    at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1012)
    at org.netbeans.JarClassLoader.doLoadClass(JarClassLoader.java:287)
    at org.netbeans.ProxyClassLoader.selfLoadClass(ProxyClassLoader.java:246)
    at org.netbeans.ProxyClassLoader.doFindClass(ProxyClassLoader.java:174)
    at org.netbeans.ProxyClassLoader.loadClass(ProxyClassLoader.java:125)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
    at org.netbeans.modules.java.source.parsing.JavacParserFactory.createPrivateParser(JavacParserFactory.java:79)
    at org.netbeans.api.java.source.JavaSource$JavaSourceAccessorImpl.createCompilationController(JavaSource.java:739)
    at org.netbeans.modules.java.source.JavaSourceUtilImpl.getModuleInfoHandle(JavaSourceUtilImpl.java:271)
    at org.netbeans.modules.java.preprocessorbridge.spi.JavaSourceUtilImpl$MyAccessor.getModuleInfoHandle(JavaSourceUtilImpl.java:119)
    at org.netbeans.modules.java.preprocessorbridge.api.ModuleUtilities.init(ModuleUtilities.java:122)
    at org.netbeans.modules.java.preprocessorbridge.api.ModuleUtilities.resolveModule(ModuleUtilities.java:104)
    at org.netbeans.modules.java.api.common.classpath.ModuleClassPaths$ModuleInfoClassPathImplementation.getResources(ModuleClassPaths.java:882)
    at org.netbeans.api.java.classpath.ClassPath.entries(ClassPath.java:363)
    at org.netbeans.spi.java.classpath.support.MuxClassPathImplementation.getResources(MuxClassPathImplementation.java:90)
    at org.netbeans.api.java.classpath.ClassPath$SPIListener.propertyChange(ClassPath.java:1343)
    at org.openide.util.WeakListenerImpl$PropertyChange.propertyChange(WeakListenerImpl.java:190)
    at java.desktop/java.beans.PropertyChangeSupport.fire(PropertyChangeSupport.java:343)
    at java.desktop/java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:335)
    at java.desktop/java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:268)
    at org.netbeans.spi.java.classpath.support.MuxClassPathImplementation.propertyChange(MuxClassPathImplementation.java:127)
    at org.openide.util.WeakListenerImpl$PropertyChange.propertyChange(WeakListenerImpl.java:190)
    at java.desktop/java.beans.PropertyChangeSupport.fire(PropertyChangeSupport.java:343)
    at java.desktop/java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:335)
    at java.desktop/java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:268)
    at org.netbeans.modules.java.api.common.classpath.ClassPathProviderImpl$SourceLevelSelector.propertyChange(ClassPathProviderImpl.java:1575)
    at org.openide.util.WeakListenerImpl$PropertyChange.propertyChange(WeakListenerImpl.java:190)
    at java.desktop/java.beans.PropertyChangeSupport.fire(PropertyChangeSupport.java:343)
    at java.desktop/java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:335)
    at org.netbeans.spi.project.support.ant.SequentialPropertyEvaluator.stateChanged(SequentialPropertyEvaluator.java:185)
    at org.openide.util.WeakListenerImpl$Change.stateChanged(WeakListenerImpl.java:331)
    at org.openide.util.ChangeSupport.fireChange(ChangeSupport.java:108)
    at org.openide.util.ChangeSupport.fireChange(ChangeSupport.java:94)
    at org.netbeans.spi.project.support.ant.ProjectProperties$PP.run(ProjectProperties.java:365)
    at org.netbeans.spi.project.support.ant.ProjectProperties$PP.run(ProjectProperties.java:363)
    at org.netbeans.modules.openide.util.DefaultMutexImplementation.readAccess(DefaultMutexImplementation.java:188)
    at org.openide.util.Mutex.readAccess(Mutex.java:193)
    at org.netbeans.spi.project.support.ant.ProjectProperties$PP.fireChange(ProjectProperties.java:371)
    at org.netbeans.spi.project.support.ant.ProjectProperties$PP.put(ProjectProperties.java:225)
    at org.netbeans.spi.project.support.ant.ProjectProperties.putProperties(ProjectProperties.java:107)
    at org.netbeans.spi.project.support.ant.AntProjectHelper.run(AntProjectHelper.java:740)
    at org.netbeans.spi.project.support.ant.AntProjectHelper.run(AntProjectHelper.java:738)
    at org.netbeans.modules.openide.util.DefaultMutexImplementation.writeAccess(DefaultMutexImplementation.java:229)
    at org.openide.util.Mutex.writeAccess(Mutex.java:246)
    at org.netbeans.spi.project.support.ant.AntProjectHelper.putProperties(AntProjectHelper.java:738)
    at org.netbeans.modules.java.j2seproject.api.J2SEProjectBuilder.createProject(J2SEProjectBuilder.java:579)
    at org.netbeans.modules.java.j2seproject.api.J2SEProjectBuilder.lambda$build[=11=](J2SEProjectBuilder.java:312)
    at org.openide.filesystems.EventControl.runAtomicAction(EventControl.java:102)
    at org.openide.filesystems.FileSystem.runAtomicAction(FileSystem.java:494)
    at org.netbeans.modules.java.j2seproject.api.J2SEProjectBuilder.build(J2SEProjectBuilder.java:310)
    at org.netbeans.modules.java.j2seproject.J2SEProjectGenerator.createProject(J2SEProjectGenerator.java:59)
    at org.netbeans.modules.java.j2seproject.ui.wizards.NewJ2SEProjectWizardIterator.instantiate(NewJ2SEProjectWizardIterator.java:187)
    at org.openide.loaders.TemplateWizard$InstantiatingIteratorBridge.instantiate(TemplateWizard.java:1048)
    at org.openide.loaders.TemplateWizard.handleInstantiate(TemplateWizard.java:602)
    at org.netbeans.modules.project.ui.NewProjectWizard.handleInstantiate(NewProjectWizard.java:51)
    at org.openide.loaders.TemplateWizard.instantiateNewObjects(TemplateWizard.java:436)
    at org.openide.loaders.TemplateWizardIterImpl.instantiate(TemplateWizardIterImpl.java:228)
    at org.openide.loaders.TemplateWizardIteratorWrapper$ProgressInstantiatingIterator.instantiate(TemplateWizardIteratorWrapper.java:155)
    at org.openide.WizardDescriptor.callInstantiateOpen(WizardDescriptor.java:1602)
    at org.openide.WizardDescriptor.callInstantiate(WizardDescriptor.java:1546)
    at org.openide.WizardDescriptor.access00(WizardDescriptor.java:67)
    at org.openide.WizardDescriptor$Listener.run(WizardDescriptor.java:2233)
    at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1418)
    at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:45)
    at org.openide.util.lookup.Lookups.executeWith(Lookups.java:278)
[catch] at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2033)

我希望有人能帮我解决这个问题,因为我不知道该怎么办了。

您是 运行 NetBeans 12.0 和 JDK 17。这不是受支持的组合。

您有两个选择:

  • 坚持使用 NetBeans 12.0,并改用 JDK 14。
  • 坚持使用 JDK 17,改用 NetBeans 12.5。 (在这种情况下,您不需要先卸载 NetBeans 12.0。)

请参阅 NetBeans 12.0 and NetBeans 12.5 的发行说明,了解支持哪些 Java 版本的详细信息。

与此类似的问题在这里很常见,不幸的是,NetBeans 没有更好地主动防止使用不受支持的 JDKs。也就是说,在 NetBeans 防御中:

  • 您发布的错误消息明确建议您参阅 NetBeans 日志文件 (messages.log) 以获取更多信息。
  • NetBeans 发行说明始终明确说明给定 NetBeans 版本支持哪些 Java 版本,不应做出任何假设。例如,对于 NetBeans 12.5,支持的版本是 "JDK LTS releases 8 and 11, with experimental support for JDK 17"。该信息很重要,因为它表明尽管 JDK 17 具有“实验性支持”,但不支持 JDK 12 到 JDK 16 版本。