运行 Eclipse 在 Java 17 上出现错误
Errors when running Eclipse on Java 17
当我尝试在 Java 17 JRE 上启动 Eclipse 2021-06 (4.20.0) 时出现错误。
错误显示在对话框和 错误日志中:
我该如何解决这个问题?
报错信息的内容是这样的:
java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @2bc378f7
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.Method.checkCanSetAccessible(Method.java:199)
at java.base/java.lang.reflect.Method.setAccessible(Method.java:193)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.overrideLoadResult(ModuleClassLoader.java:86)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
at org.eclipse.jdt.internal.compiler.parser.Parser.endParse(Parser.java:11750)
at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:12949)
at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:13176)
at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:13133)
at org.eclipse.jdt.internal.compiler.parser.Parser.dietParse(Parser.java:11521)
at org.eclipse.jdt.internal.compiler.Compiler.internalBeginToCompile(Compiler.java:850)
at org.eclipse.jdt.internal.compiler.Compiler.beginToCompile(Compiler.java:394)
at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:444)
at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:426)
at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:377)
at org.eclipse.jdt.internal.core.builder.BatchImageBuilder.compile(BatchImageBuilder.java:214)
at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:309)
at org.eclipse.jdt.internal.core.builder.BatchImageBuilder.build(BatchImageBuilder.java:79)
at org.eclipse.jdt.internal.core.builder.JavaBuilder.buildAll(JavaBuilder.java:272)
at org.eclipse.jdt.internal.core.builder.JavaBuilder.build(JavaBuilder.java:192)
at org.eclipse.core.internal.events.BuildManager.run(BuildManager.java:846)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:229)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:277)
at org.eclipse.core.internal.events.BuildManager.run(BuildManager.java:330)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:333)
at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:385)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:406)
at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:154)
at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:244)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @2bc378f7
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.Method.checkCanSetAccessible(Method.java:199)
at java.base/java.lang.reflect.Method.setAccessible(Method.java:193)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.overrideLoadResult(ModuleClassLoader.java:86)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
at org.eclipse.jdt.internal.compiler.parser.Parser.endParse(Parser.java:11750)
at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:12949)
at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:13176)
at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:13133)
at org.eclipse.jdt.internal.compiler.parser.Parser.dietParse(Parser.java:11521)
at org.eclipse.jdt.internal.compiler.Compiler.internalBeginToCompile(Compiler.java:850)
at org.eclipse.jdt.internal.compiler.Compiler.beginToCompile(Compiler.java:394)
at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:444)
at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:426)
at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:377)
at org.eclipse.jdt.internal.core.builder.BatchImageBuilder.compile(BatchImageBuilder.java:214)
at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:309)
at org.eclipse.jdt.internal.core.builder.BatchImageBuilder.build(BatchImageBuilder.java:79)
at org.eclipse.jdt.internal.core.builder.JavaBuilder.buildAll(JavaBuilder.java:272)
at org.eclipse.jdt.internal.core.builder.JavaBuilder.build(JavaBuilder.java:187)
at org.eclipse.core.internal.events.BuildManager.run(BuildManager.java:846)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:229)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:277)
at org.eclipse.core.internal.events.BuildManager.run(BuildManager.java:330)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:333)
at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:385)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:406)
at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:154)
at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:244)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
java.lang.reflect.InaccessibleObjectException: Unable to make field private static volatile java.net.Authenticator java.net.Authenticator.theAuthenticator accessible: module java.base does not "opens java.net" to unnamed module @1ab8b487
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:178)
at java.base/java.lang.reflect.Field.setAccessible(Field.java:172)
at net.sf.eclipsecs.core.config.configtypes.RemoteConfigurationType$RemoteConfigAuthenticator.getDefault(RemoteConfigurationType.java:376)
at net.sf.eclipsecs.core.config.configtypes.RemoteConfigurationType.getCheckstyleConfiguration(RemoteConfigurationType.java:99)
at net.sf.eclipsecs.core.config.CheckConfiguration.getCheckstyleConfiguration(CheckConfiguration.java:161)
at net.sf.eclipsecs.core.builder.CheckerFactory.getCacheKey(CheckerFactory.java:157)
at net.sf.eclipsecs.core.builder.CheckerFactory.createChecker(CheckerFactory.java:99)
at net.sf.eclipsecs.core.builder.Auditor.runAudit(Auditor.java:139)
at net.sf.eclipsecs.core.builder.CheckstyleBuilder.handleBuildSelection(CheckstyleBuilder.java:307)
at net.sf.eclipsecs.core.builder.CheckstyleBuilder.build(CheckstyleBuilder.java:173)
at org.eclipse.core.internal.events.BuildManager.run(BuildManager.java:846)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:229)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:277)
at org.eclipse.core.internal.events.BuildManager.run(BuildManager.java:330)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:333)
at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:385)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:406)
at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:154)
at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:244)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
原来我的问题是由我使用的 Eclipse 插件引起的,而不是 Eclipse 本身。
插件是这些:
- 龙目岛 1.18.20.
- Eclipse Checkstyle 8.36.1
我的解决方案是 运行 Eclipse 使用较旧的 JRE。
原因
问题是由于插件使用了从未打算公开的内部 JDK 组件。作为此更改的一部分,它们已封装在最后的 JDK 中:
https://openjdk.java.net/jeps/403
更新:修复
- Eclipse Checkstyle 声称已解决此票证中的问题(我尚未验证):https://github.com/checkstyle/eclipse-cs/issues/281
- Lombok 声称已解决此问题单中的问题(我尚未验证):https://github.com/projectlombok/lombok/issues/2810
我欢迎其他解决方案,即使在 Java 17!
上也可以使用相同的旧插件继续 运行ning Eclipse
当我尝试在 Java 17 JRE 上启动 Eclipse 2021-06 (4.20.0) 时出现错误。
错误显示在对话框和 错误日志中:
我该如何解决这个问题?
报错信息的内容是这样的:
java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @2bc378f7
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.Method.checkCanSetAccessible(Method.java:199)
at java.base/java.lang.reflect.Method.setAccessible(Method.java:193)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.overrideLoadResult(ModuleClassLoader.java:86)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
at org.eclipse.jdt.internal.compiler.parser.Parser.endParse(Parser.java:11750)
at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:12949)
at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:13176)
at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:13133)
at org.eclipse.jdt.internal.compiler.parser.Parser.dietParse(Parser.java:11521)
at org.eclipse.jdt.internal.compiler.Compiler.internalBeginToCompile(Compiler.java:850)
at org.eclipse.jdt.internal.compiler.Compiler.beginToCompile(Compiler.java:394)
at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:444)
at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:426)
at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:377)
at org.eclipse.jdt.internal.core.builder.BatchImageBuilder.compile(BatchImageBuilder.java:214)
at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:309)
at org.eclipse.jdt.internal.core.builder.BatchImageBuilder.build(BatchImageBuilder.java:79)
at org.eclipse.jdt.internal.core.builder.JavaBuilder.buildAll(JavaBuilder.java:272)
at org.eclipse.jdt.internal.core.builder.JavaBuilder.build(JavaBuilder.java:192)
at org.eclipse.core.internal.events.BuildManager.run(BuildManager.java:846)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:229)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:277)
at org.eclipse.core.internal.events.BuildManager.run(BuildManager.java:330)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:333)
at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:385)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:406)
at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:154)
at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:244)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @2bc378f7
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.Method.checkCanSetAccessible(Method.java:199)
at java.base/java.lang.reflect.Method.setAccessible(Method.java:193)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.overrideLoadResult(ModuleClassLoader.java:86)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
at org.eclipse.jdt.internal.compiler.parser.Parser.endParse(Parser.java:11750)
at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:12949)
at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:13176)
at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:13133)
at org.eclipse.jdt.internal.compiler.parser.Parser.dietParse(Parser.java:11521)
at org.eclipse.jdt.internal.compiler.Compiler.internalBeginToCompile(Compiler.java:850)
at org.eclipse.jdt.internal.compiler.Compiler.beginToCompile(Compiler.java:394)
at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:444)
at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:426)
at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:377)
at org.eclipse.jdt.internal.core.builder.BatchImageBuilder.compile(BatchImageBuilder.java:214)
at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:309)
at org.eclipse.jdt.internal.core.builder.BatchImageBuilder.build(BatchImageBuilder.java:79)
at org.eclipse.jdt.internal.core.builder.JavaBuilder.buildAll(JavaBuilder.java:272)
at org.eclipse.jdt.internal.core.builder.JavaBuilder.build(JavaBuilder.java:187)
at org.eclipse.core.internal.events.BuildManager.run(BuildManager.java:846)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:229)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:277)
at org.eclipse.core.internal.events.BuildManager.run(BuildManager.java:330)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:333)
at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:385)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:406)
at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:154)
at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:244)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
java.lang.reflect.InaccessibleObjectException: Unable to make field private static volatile java.net.Authenticator java.net.Authenticator.theAuthenticator accessible: module java.base does not "opens java.net" to unnamed module @1ab8b487
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:178)
at java.base/java.lang.reflect.Field.setAccessible(Field.java:172)
at net.sf.eclipsecs.core.config.configtypes.RemoteConfigurationType$RemoteConfigAuthenticator.getDefault(RemoteConfigurationType.java:376)
at net.sf.eclipsecs.core.config.configtypes.RemoteConfigurationType.getCheckstyleConfiguration(RemoteConfigurationType.java:99)
at net.sf.eclipsecs.core.config.CheckConfiguration.getCheckstyleConfiguration(CheckConfiguration.java:161)
at net.sf.eclipsecs.core.builder.CheckerFactory.getCacheKey(CheckerFactory.java:157)
at net.sf.eclipsecs.core.builder.CheckerFactory.createChecker(CheckerFactory.java:99)
at net.sf.eclipsecs.core.builder.Auditor.runAudit(Auditor.java:139)
at net.sf.eclipsecs.core.builder.CheckstyleBuilder.handleBuildSelection(CheckstyleBuilder.java:307)
at net.sf.eclipsecs.core.builder.CheckstyleBuilder.build(CheckstyleBuilder.java:173)
at org.eclipse.core.internal.events.BuildManager.run(BuildManager.java:846)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:229)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:277)
at org.eclipse.core.internal.events.BuildManager.run(BuildManager.java:330)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:333)
at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:385)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:406)
at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:154)
at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:244)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
原来我的问题是由我使用的 Eclipse 插件引起的,而不是 Eclipse 本身。
插件是这些:
- 龙目岛 1.18.20.
- Eclipse Checkstyle 8.36.1
我的解决方案是 运行 Eclipse 使用较旧的 JRE。
原因
问题是由于插件使用了从未打算公开的内部 JDK 组件。作为此更改的一部分,它们已封装在最后的 JDK 中:
https://openjdk.java.net/jeps/403
更新:修复
- Eclipse Checkstyle 声称已解决此票证中的问题(我尚未验证):https://github.com/checkstyle/eclipse-cs/issues/281
- Lombok 声称已解决此问题单中的问题(我尚未验证):https://github.com/projectlombok/lombok/issues/2810
我欢迎其他解决方案,即使在 Java 17!
上也可以使用相同的旧插件继续 运行ning Eclipse