Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 550554

Summary: Incremental builder stops showing squiggles
Product: [Eclipse Project] JDT Reporter: Ed Willink <ed>
Component: CoreAssignee: Stephan Herrmann <stephan.herrmann>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert, jarthana, stephan.herrmann
Version: 4.13   
Target Milestone: 4.14 M3   
Hardware: PC   
OS: Windows 10   
See Also: https://bugs.eclipse.org/bugs/show_bug.cgi?id=486979
https://bugs.eclipse.org/bugs/show_bug.cgi?id=534906
https://git.eclipse.org/r/152686
https://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=62050b74fac53d50e60a594ecb3a5be6d7ba9a70
Whiteboard:

Description Ed Willink CLA 2019-08-29 03:57:53 EDT
2019-09'M2'

Normally the JDT editor shows red squiggles for bad source text. These update helpfully as editing proceeds.

However I am finding that this helpful update terminates and I get no further clues about my rubbish code until I save.

The error log below gives a clue. An auto-generated *.java file in an auto-generated project has gone stale. The auto-generated file was viewed and maybe even experimentally edited in a JDT editor. It appears that the stale file provokes an exception that correctly terminates the build of that file but incorrectly terminates all other incremental building too. Seems like yet another case of the stale-project-not-scoped-to-project problem.

When editing the 'stale' file that has come and gone many times during the Eclipse session, the auto-generated file shows squiggles that relate to a previous state and which fail to update in response to an explicit project refresh or clean. It seems that once observed as 'stale' some state gets stuck inhibiting further usage. 

java.lang.Exception: File not found: E:\Development\Chital\Workspace\_QVTd_QVTrCompilerTests__testQVTrCompiler_Persons2Families_CG\bin\org\eclipse\qvtd\qvtrelations\tests\persons2families\Persons2Families.class.
	at org.eclipse.core.internal.resources.ResourceException.provideStackTrace(ResourceException.java:42)
	at org.eclipse.core.internal.resources.ResourceException.<init>(ResourceException.java:38)
	at org.eclipse.core.internal.localstore.FileSystemResourceManager.read(FileSystemResourceManager.java:834)
	at org.eclipse.core.internal.resources.File.getContents(File.java:280)
	at org.eclipse.jdt.internal.core.util.Util.getResourceContentsAsByteArray(Util.java:1146)
	at org.eclipse.jdt.internal.core.builder.IncrementalImageBuilder.writeClassFileCheck(IncrementalImageBuilder.java:942)
	at org.eclipse.jdt.internal.core.builder.IncrementalImageBuilder.writeClassFileContents(IncrementalImageBuilder.java:884)
	at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.writeClassFile(AbstractImageBuilder.java:879)
	at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.acceptResult(AbstractImageBuilder.java:203)
	at org.eclipse.jdt.internal.compiler.Compiler.processCompiledUnits(Compiler.java:615)
	at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:475)
	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.IncrementalImageBuilder.compile(IncrementalImageBuilder.java:371)
	at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:318)
	at org.eclipse.jdt.internal.core.builder.IncrementalImageBuilder.incrementalBuildLoop(IncrementalImageBuilder.java:186)
	at org.eclipse.jdt.internal.core.builder.IncrementalImageBuilder.build(IncrementalImageBuilder.java:143)
	at org.eclipse.jdt.internal.core.builder.JavaBuilder.buildDeltas(JavaBuilder.java:292)
	at org.eclipse.jdt.internal.core.builder.JavaBuilder.build(JavaBuilder.java:212)
	at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:833)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:220)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:263)
	at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:316)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:319)
	at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:371)
	at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:392)
	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)
Comment 1 Dani Megert CLA 2019-08-29 05:30:32 EDT
Please provide steps to reproduce the problem or a test project.
Comment 2 Ed Willink CLA 2019-08-29 05:36:01 EDT
Surely the stack trace shows the exception propagating through a loop that should catch it?
Comment 3 Stephan Herrmann CLA 2019-08-29 10:18:34 EDT
The location where IncrementalImageBuilder.writeClassFileCheck() calls Util.getResourceContentsAsByteArray() already catches ClassFormatException for a corrupt .class file. I think treating a missing .class file in the same way is OK and IMHO doesn't need a test (rare exception :) ).

From Eclipse p.o.v. the .class file should of course never disappear under foot, but idiots like a stray "mvn clean" still shouldn't cause more trouble than necessary. The build result may still be corrupt, when unexpectedly .class files are missing ... so avoiding the exception will give no guarantee that things are fine.
Comment 4 Ed Willink CLA 2019-08-30 04:20:16 EDT
(In reply to Stephan Herrmann from comment #3)
> From Eclipse p.o.v. the .class file should of course never disappear under

The class file is in an auto-generated project for which re-auto-generation deletes all contents, so the bin file will be deleted.

From similar problems in a variety of applications the generic problem that I recognise is that given:

loop-over-many-artefacts
    do-something-with-the-artefact

if the (loop-iterator or an) individual do-something fails the rest of the loop fails.

Therefore the worker loop needs to be coded as

loop
   try
       get-next-artefact
       do-something-with-the-artefact
   catch
       maybe-log-problem

to ensure that the worker loop only fails for the bad artefact, rather than everything thereafter.

A superficial inspection of the stack trace suggests a builder nominally building many things that fails on one and so fails for all thereafter.

However the problem is worse since even after closing the offending project, JDT incremental update remains inactive. So perhaps the broken/absent class file remains somewhere within Eclipse and continues to cause grief.

Unexpected files/projects were identified as causing problems for the Type Hierarchy. See Bug 486979 where a specific fix was provided, with Bug 534906 opened for the general fix. I suspect this is a variant instance of the same underlying problem with bad files. Perhaps the recent Bug 486979 fix created this as a new problem.
Comment 5 Eclipse Genie CLA 2019-11-14 13:16:32 EST
New Gerrit change created: https://git.eclipse.org/r/152686
Comment 7 Stephan Herrmann CLA 2019-11-14 16:57:34 EST
(In reply to Eclipse Genie from comment #6)
> Gerrit change https://git.eclipse.org/r/152686 was merged to [master].
> Commit:
> http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/
> ?id=62050b74fac53d50e60a594ecb3a5be6d7ba9a70

This should catch the exception from comment 0. Released for 4.14 M3
Comment 8 Jay Arthanareeswaran CLA 2019-11-21 00:09:39 EST
Verified for 4.14 M3 using code inspection.