Eclipse 2018-09 goes into endless build loop with

2019-01-27 21:35发布

问题:

I'm running Eclipse 2018-09 (4.9.0) on Windows 10. I'm using Open JDK 11 GA. I have a project using Java 8 compliant source code that compiles fine using the JDK, both from Eclipse and from Maven.

I want to use new Java 11 features, so first I changed the compiler source/target from Java 8 to Java 11. It still built find using Maven on the command line, but couldn't compile in Eclipse (see Eclipse 2018-09 won't compile Java 11 source; thinks it is below 1.7).

So I added the "Java 11 Support for Eclipse 2018-09" plugin from the Eclipse Marketplace. I restarted Eclipse and used Alt+F5 to refresh my Maven projects. Eclipse then attempted to rebuild the project.

Now Eclipse goes into an endless loop, jumping between 8X% finished to 9X% finished, with repeated, endless errors such as these:

!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$1(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$2.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$1.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)

There's no way to stop it. At least Eclipse doesn't freeze, so I hit the "close" button on the application title bar and manage to exit the program. I can get back into the program, but when I try to build it goes into the same endless loop.

回答1:

As mentioned in Bug 539536, this issue has been fixed in the latest build of the Java 11 support patch. The problem was caused by a migration from ZipFile to the java.nio classes, the changes have been reverted for now but is still being discussed at the time of writing.

To install the fix, use the following update site in Eclipse and select v20181001-0921 or more recent: http://download.eclipse.org/eclipse/updates/4.9-P-builds/P20181001-0525/