Eclipse 2018-09 使用 Java 11 插件进入无限构建循环:ClosedFileSystemException

Eclipse 2018-09 goes into endless build loop with Java 11 plugin: ClosedFileSystemException

我在 Windows 10 上 运行 Eclipse 2018-09 (4.9.0)。我正在使用 Open JDK 11 GA。我有一个使用 Java 8 兼容源代码的项目,它使用 JDK 编译得很好,来自 Eclipse 和 Maven。

我想使用新的 Java 11 功能,所以首先我将编译器 source/target 从 Java 8 更改为 Java 11。它仍然使用 Maven 构建查找在命令行上,但无法在 Eclipse 中编译(参见 Eclipse 2018-09 won't compile Java 11 source; thinks it is below 1.7)。

所以我从 Eclipse Marketplace 添加了 "Java 11 Support for Eclipse 2018-09" 插件。我重新启动 Eclipse 并使用 Alt+F5 刷新我的 Maven 项目。然后 Eclipse 尝试重建项目。

现在 Eclipse 进入无限循环,在完成的 8X% 和完成的 9X% 之间跳来跳去,不断重复出现如下错误:

!SESSION 2018-09-27 08:08:51.188 -----------------------------------------------
eclipse.buildId=4.9.0.I20180906-0745
java.version=11
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
Framework arguments:  -product org.eclipse.epp.package.jee.product
Command-line arguments:  -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.jee.product

This is a continuation of log file …\.metadata\.bak_0.log
Created Time: 2018-09-27 08:11:22.981

!ENTRY org.eclipse.core.resources 4 2 2018-09-27 08:11:22.981
!MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.core.resources".
!STACK 0
java.nio.file.ClosedFileSystemException
  at jdk.zipfs/jdk.nio.zipfs.ZipFileSystem.ensureOpen(ZipFileSystem.java:1105)
  at jdk.zipfs/jdk.nio.zipfs.ZipFileSystem.checkAccess(ZipFileSystem.java:332)
  at jdk.zipfs/jdk.nio.zipfs.ZipPath.checkAccess(ZipPath.java:830)
  at jdk.zipfs/jdk.nio.zipfs.ZipFileSystemProvider.checkAccess(ZipFileSystemProvider.java:185)
  at java.base/java.nio.file.Files.exists(Files.java:2439)
  at org.eclipse.jdt.internal.core.builder.ClasspathMultiReleaseJar.findClass(ClasspathMultiReleaseJar.java:206)
  at org.eclipse.jdt.internal.core.builder.ClasspathLocation.findClass(ClasspathLocation.java:58)
  at org.eclipse.jdt.internal.core.builder.NameEnvironment.findClass(NameEnvironment.java:524)
  at org.eclipse.jdt.internal.core.builder.NameEnvironment.findType(NameEnvironment.java:556)
  at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.fromSplitPackageOrOracle(LookupEnvironment.java:414)
  at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.lambda(LookupEnvironment.java:289)
  at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForTypeFromModules(LookupEnvironment.java:384)
  at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType(LookupEnvironment.java:288)
  at org.eclipse.jdt.internal.compiler.lookup.PackageBinding.getTypeOrPackage(PackageBinding.java:262)
  at org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.findImport(CompilationUnitScope.java:530)
  at org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.checkAndSetImports(CompilationUnitScope.java:254)
  at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.completeTypeBindings(LookupEnvironment.java:501)
  at org.eclipse.jdt.internal.compiler.Compiler.internalBeginToCompile(Compiler.java:868)
  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:386)
  at org.eclipse.jdt.internal.core.builder.BatchImageBuilder.compile(BatchImageBuilder.java:214)
  at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:318)
  at org.eclipse.jdt.internal.core.builder.BatchImageBuilder.build(BatchImageBuilder.java:79)
  at org.eclipse.jdt.internal.core.builder.JavaBuilder.buildAll(JavaBuilder.java:265)
  at org.eclipse.jdt.internal.core.builder.JavaBuilder.build(JavaBuilder.java:185)
  at org.eclipse.core.internal.events.BuildManager.run(BuildManager.java:798)
  at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
  at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:219)
  at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:262)
  at org.eclipse.core.internal.events.BuildManager.run(BuildManager.java:315)
  at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
  at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:318)
  at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:370)
  at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:391)
  at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:145)
  at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:235)
  at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)

没有办法阻止它。至少 Eclipse 不会冻结,所以我点击了应用程序标题栏上的 "close" 按钮并设法退出了程序。我可以重新进入程序,但是当我尝试构建它时,它进入了同样的无限循环。

Bug 539536 中所述,此问题已在 Java 11 支持补丁的最新版本中得到修复。问题是由从 ZipFile 迁移到 java.nio 类 引起的,更改现在已恢复但是在撰写本文时仍在讨论中。

要安装修复程序,请在 Eclipse 和 select v20181001-0921 或更新版本中使用以下更新站点: http://download.eclipse.org/eclipse/updates/4.9-P-builds/P20181001-0525/