Bug 123322 - "A class file was not written. The project may be inconsistent, if so try refreshing this project and building it" error when building classes with multiple nested anonymous inner classes
Summary: "A class file was not written. The project may be inconsistent, if so try ref...
Status: RESOLVED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal with 3 votes (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: needinfo
Depends on:
Blocks:
 
Reported: 2006-01-10 16:30 EST by Janis Krumins CLA
Modified: 2009-08-30 02:08 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Janis Krumins CLA 2006-01-10 16:30:20 EST
This error occurs intermittently only on files which include multiple nested anonymous inner classes. For example, on this one:

package test;

public class Test {
	public void qwertyuiopasdfghjklzxcvbnmQwertyuiopasdfghjklzxcvbnmQwertyuiopasdfghjklzxcvbnmQwertyuiopasdfghjklzxcvbnm(Runnable runnable) {
		runnable.run();
	}
	
	public void abcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyz(Runnable runnable) {
		runnable.run();
	}

	public static void main(String[] args) {
		new Test().qwertyuiopasdfghjklzxcvbnmQwertyuiopasdfghjklzxcvbnmQwertyuiopasdfghjklzxcvbnmQwertyuiopasdfghjklzxcvbnm(new Runnable() {
			public void run() {
				new Test().abcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyz(
				new Runnable() {
					public void run() {
						System.out.println("Hello world.");
					}
				});
			}
		});
	}
	
}

The long method names may or may not be relevant - I am not certain whether they increase the likelihood of this occurring, I'm thinking that they don't.

The only relevant entry in the log seems to be the following:

!ENTRY org.eclipse.jdt.core 4 4 2006-01-10 23:14:25.205
!MESSAGE JavaBuilder handling CoreException
!STACK 1
org.eclipse.core.internal.resources.ResourceException: File not found: C:\projects\test\Test$2.class.
	at org.eclipse.core.internal.localstore.FileSystemResourceManager.read(FileSystemResourceManager.java:518)
	at org.eclipse.core.internal.resources.File.getContents(File.java:294)
	at org.eclipse.jdt.internal.core.util.Util.getResourceContentsAsByteArray(Util.java:992)
	at org.eclipse.jdt.internal.core.builder.IncrementalImageBuilder.writeClassFileCheck(IncrementalImageBuilder.java:629)
	at org.eclipse.jdt.internal.core.builder.IncrementalImageBuilder.writeClassFileBytes(IncrementalImageBuilder.java:601)
	at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.writeClassFile(AbstractImageBuilder.java:477)
	at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.acceptResult(AbstractImageBuilder.java:152)
	at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:335)
	at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:240)
	at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:190)
	at org.eclipse.jdt.internal.core.builder.IncrementalImageBuilder.build(IncrementalImageBuilder.java:114)
	at org.eclipse.jdt.internal.core.builder.JavaBuilder.buildDeltas(JavaBuilder.java:224)
	at org.eclipse.jdt.internal.core.builder.JavaBuilder.build(JavaBuilder.java:152)
	at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:593)
	at org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java:1044)
	at org.eclipse.core.runtime.Platform.run(Platform.java:783)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:168)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:202)
	at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:231)
	at org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java:1044)
	at org.eclipse.core.runtime.Platform.run(Platform.java:783)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:234)
	at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:253)
	at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:282)
	at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:139)
	at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:200)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:76)
!SUBENTRY 1 org.eclipse.core.resources 4 271 2006-01-10 23:14:25.205
!MESSAGE File not found: C:\projects\test\Test$2.class.

This is on Eclipse SDK Version: 3.1.0 Build id: I20050627-1435.
Comment 1 Janis Krumins CLA 2006-01-10 16:39:02 EST
a) The file with the inner classes needs to be touched/modified for the bug to exhibit itself upon the auto-rebuild.
b) Just repeated it with short file names, sorry about the long version:

package test;

public class Test {
	public void b(Runnable runnable) {
		runnable.run();
	}
	
	public void a(Runnable runnable) {
		runnable.run();
	}

	public static void main(String[] args) {
		new Test().b(new Runnable() {
			public void run() {
				new Test().a(
				new Runnable() {
					public void run() {
						System.out.println("Hello world.");
					}
				});
			}
		});
	}
	
}

c) Looks like it exhibits itself after the project was rebuilt using the standard Java 1.5 JDK (invoked from an "ant" script).
Comment 2 Olivier Thomann CLA 2006-10-10 15:39:59 EDT
Do you still get it with 3.2.1 or 3.3 integration builds?
Closing as REMIND.
Please reopen if you still get it.
Comment 3 Denis Roy CLA 2009-08-30 02:08:43 EDT
As of now 'LATER' and 'REMIND' resolutions are no longer supported.
Please reopen this bug if it is still valid for you.