最新使用2019版本的idea开发支持JDK17的项目发现项目启动编译报错,下面是我当前机器mac操作系统版本以及idea的安装的版本
IntelliJ IDEA 2019.3.5 (Ultimate Edition)
Build #IU-193.7288.26, built on May 6, 2020
Licensed to xiaozhangge
Runtime version: 11.0.6+8-b520.66 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.15.7
GC: ParNew, ConcurrentMarkSweep
Memory: 1979M
Cores: 12
Registry: compiler.automake.allow.when.app.running=true
Non-Bundled Plugins: GsonFormat, JRebelPlugin, Lombook Plugin, Statistic, cn.olange.rule, com.baomidou.plugin.idea.mybatisx, com.github.chencn.yamlandprops, com.zhaow.restful.toolkit, mobi.hsz.idea.gitignore
当机器运行jdk高于13版本发现运行启动项目会报以下错误信息
Compilation failed: internal java compiler error
build-log/build.log包含:
2022-06-28 12:37:37,055 [ 797] ERROR - tellij.util.io.FileChannelUtil - symbolic reference class is not accessible: class sun.nio.ch.FileChannelImpl, from class com.intellij.util.io.FileChannelUtil (unnamed module @27808f31)
java.lang.IllegalAccessException: symbolic reference class is not accessible: class sun.nio.ch.FileChannelImpl, from class com.intellij.util.io.FileChannelUtil (unnamed module @27808f31)
at java.base/java.lang.invoke.MemberName.makeAccessException(MemberName.java:957)
at java.base/java.lang.invoke.MethodHandles$Lookup.checkSymbolicClass(MethodHandles.java:3675)
at java.base/java.lang.invoke.MethodHandles$Lookup.resolveOrFail(MethodHandles.java:3647)
at java.base/java.lang.invoke.MethodHandles$Lookup.findVirtual(MethodHandles.java:2687)
at com.intellij.util.io.FileChannelUtil.setupUnInterruptibleHandle(FileChannelUtil.java:36)
at com.intellij.util.io.FileChannelUtil.(FileChannelUtil.java:18)
at com.intellij.util.io.ReadWriteDirectBufferWrapper$FileContext$1.execute(ReadWriteDirectBufferWrapper.java:59)
at com.intellij.util.io.ReadWriteDirectBufferWrapper$FileContext$1.execute(ReadWriteDirectBufferWrapper.java:49)
at com.intellij.openapi.util.io.FileUtilRt.doIOOperation(FileUtilRt.java:957)
at com.intellij.util.io.ReadWriteDirectBufferWrapper$FileContext.(ReadWriteDirectBufferWrapper.java:49)
at com.intellij.util.io.ReadWriteDirectBufferWrapper.create(ReadWriteDirectBufferWrapper.java:35)
at com.intellij.util.io.DirectBufferWrapper.doCreate(DirectBufferWrapper.java:66)
at com.intellij.util.io.DirectBufferWrapper.getBuffer(DirectBufferWrapper.java:38)
at com.intellij.util.io.ReadWriteDirectBufferWrapper.getBuffer(ReadWriteDirectBufferWrapper.java:22)
at com.intellij.util.io.StorageLock.createValue(StorageLock.java:229)
at com.intellij.util.io.StorageLock.get(StorageLock.java:154)
at com.intellij.util.io.PagedFileStorage.getBufferWrapper(PagedFileStorage.java:324)
at com.intellij.util.io.PagedFileStorage.getReadOnlyBuffer(PagedFileStorage.java:307)
at com.intellij.util.io.PagedFileStorage.getInt(PagedFileStorage.java:110)
at com.intellij.util.io.ResizeableMappedFile.getInt(ResizeableMappedFile.java:203)
at com.intellij.util.io.PersistentEnumeratorBase.(PersistentEnumeratorBase.java:219)
at com.intellij.util.io.PersistentBTreeEnumerator.(PersistentBTreeEnumerator.java:73)
at com.intellij.util.io.PersistentEnumeratorDelegate.createDefaultEnumerator(PersistentEnumeratorDelegate.java:69)
at com.intellij.util.io.PersistentHashMap.(PersistentHashMap.java:165)
at com.intellij.util.io.PersistentHashMap.(PersistentHashMap.java:150)
at com.intellij.util.io.PersistentHashMap.(PersistentHashMap.java:141)
at com.intellij.util.io.PersistentHashMap.(PersistentHashMap.java:133)
at com.intellij.util.io.PersistentHashMap.(PersistentHashMap.java:120)
at org.jetbrains.jps.incremental.storage.AbstractStateStorage.createMap(AbstractStateStorage.java:119)
at org.jetbrains.jps.incremental.storage.AbstractStateStorage.(AbstractStateStorage.java:27)
at org.jetbrains.jps.incremental.storage.FileTimestampStorage.(FileTimestampStorage.java:27)
at org.jetbrains.jps.incremental.storage.ProjectStamps.(ProjectStamps.java:41)
at org.jetbrains.jps.cmdline.BuildRunner.load(BuildRunner.java:88)
at org.jetbrains.jps.cmdline.BuildMain.main(BuildMain.java:124)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at org.jetbrains.jps.cmdline.Launcher.main(Launcher.java:43)
出现以上问题我们可以通过idea中 intelliJ IDEA—->Prefrences—->Compiler—->Shared build process VM options 通过设置参数包括来解决这个错误
--illegal-access=permit --add-opens=java.base/sun.nio.ch=ALL-UNNAMED