Bug 11201 - ClassCastException during build process
Summary: ClassCastException during build process
Status: RESOLVED WORKSFORME
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 1.0   Edit
Hardware: PC Windows 2000
: P1 blocker (vote)
Target Milestone: 2.0 M4   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-03-12 14:03 EST by Jim Thorpe CLA
Modified: 2002-03-15 11:43 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jim Thorpe CLA 2002-03-12 14:03:34 EST
In my particular case, if I compile this project using a JDK1.3 "javac", it 
will compile.  However, when I am using the compiler that comes with WSAD 
Version 4.0.2, it is not able to compile.  (NOTE:  The version choices in the 
bug report indicate 1.0 and 2.0, I have no idea how to tell what I have)

  I get a message box popping up that says "Errors During Build"  and details 
points to 
===> org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding
  
    The log file says:


Log: Thu Mar 07 14:19:10 EST 2002
2 org.eclipse.core.resources 2 Problems occurred when invoking code from plug-
in: org.eclipse.core.resources.
java.lang.ClassCastException: 
org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding
 at org.eclipse.jdt.internal.compiler.lookup.BlockScope.emulateOuterAccess
(BlockScope.java:297)
 at org.eclipse.jdt.internal.compiler.lookup.BlockScope.propagateInnerEmulation
(BlockScope.java:1144)
 at org.eclipse.jdt.internal.compiler.ast.AllocationExpression.analyseCode
(AllocationExpression.java(Compiled Code))
 at org.eclipse.jdt.internal.compiler.ast.AllocationExpression.analyseCode
(AllocationExpression.java(Compiled Code))
 at org.eclipse.jdt.internal.compiler.ast.SingleNameReference.analyseAssignment
(SingleNameReference.java(Compiled Code))
 at org.eclipse.jdt.internal.compiler.ast.Assignment.analyseCode(Assignment.java
(Compiled Code))
 at org.eclipse.jdt.internal.compiler.ast.Block.analyseCode(Block.java(Compiled 
Code))
 at org.eclipse.jdt.internal.compiler.ast.IfStatement.analyseCode
(IfStatement.java(Compiled Code))
 at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.analyseCode
(AbstractMethodDeclaration.java(Compiled Code))
 at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.analyseCode
(TypeDeclaration.java:145)
 at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.analyseCode
(AbstractMethodDeclaration.java(Compiled Code))
 at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.analyseCode
(TypeDeclaration.java(Compiled Code))
 at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.analyseCode
(CompilationUnitDeclaration.java:67)
 at org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:379)
 at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java(Compiled 
Code))
 at org.eclipse.jdt.internal.core.builder.impl.AbstractImageBuilder.compile
(AbstractImageBuilder.java:90)
 at org.eclipse.jdt.internal.core.builder.impl.BatchImageBuilder.build
(BatchImageBuilder.java(Compiled Code))
 at 
org.eclipse.jdt.internal.core.builder.impl.JavaDevelopmentContextImpl.createStat
e(JavaDevelopmentContextImpl.java:146)
 at org.eclipse.jdt.internal.core.builder.impl.JavaBuilder.fullBuild
(JavaBuilder.java:148)
 at org.eclipse.jdt.internal.core.builder.impl.JavaBuilder.build
(JavaBuilder.java:46)
 at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:93)
 at org.eclipse.core.internal.runtime.InternalPlatform.run
(InternalPlatform.java:761)
 at org.eclipse.core.runtime.Platform.run(Platform.java:393)
 at org.eclipse.core.internal.events.BuildManager.basicBuild
(BuildManager.java:114)
 at org.eclipse.core.internal.events.BuildManager.basicBuild
(BuildManager.java:73)
 at org.eclipse.core.internal.events.BuildManager.basicBuild
(BuildManager.java:41)
 at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:140)
 at org.eclipse.core.internal.runtime.InternalPlatform.run
(InternalPlatform.java:761)
 at org.eclipse.core.runtime.Platform.run(Platform.java:393)
 at org.eclipse.core.internal.events.BuildManager.basicBuild
(BuildManager.java:154)
 at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:214)
 at org.eclipse.core.internal.resources.Project.build(Project.java:110)
 at org.eclipse.ui.actions.BuildAction.invokeOperation(BuildAction.java:90)
 at org.eclipse.ui.actions.WorkspaceAction.execute(WorkspaceAction.java:111)
 at org.eclipse.ui.actions.WorkspaceAction$1.execute(WorkspaceAction.java:268)
 at org.eclipse.ui.actions.WorkspaceModifyOperation$1.run
(WorkspaceModifyOperation.java:64)
 at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1197)
 at org.eclipse.ui.actions.WorkspaceModifyOperation.run
(WorkspaceModifyOperation.java:78)


   This is extremely reproduceable.  I'm trying to create a smaller test case 
of the problem but I have isolated the offending "java" source code to one 
particular file.
Comment 1 Olivier Thomann CLA 2002-03-12 14:32:52 EST
It looks like a duplicate of 6378. If you can isolate a test case, we could confirm this is fixed in 
the 2.0 stream.
Comment 2 Jim Thorpe CLA 2002-03-13 12:43:10 EST
I am still working on trying to skinny down the failing source.  (There's about 
271 source files in this project I'm dealing with and I can't really send all 
this source to you).  I will look at problem #6378 as well to see what it 
says.  Thanks!
Comment 3 Olivier Thomann CLA 2002-03-13 12:51:15 EST
Here is an isolated test case for the problem we solved in 6378. If you have a 
pattern of code close to this, then this is fixed in 2.0.

public class A {
public Object foo() {
	B b = new B() {
		protected Object bar() {
			return new B.C() {};
		}
	};
	return b;
}
}

class B {
	class C {
	}
}

If you compile this code in 1.0, you'll get the same stacktrace than the one 
you provided. Did you try to compile your code in a 2.0 build?
Comment 4 Jim Thorpe CLA 2002-03-13 16:14:09 EST
The failing source java file does have a pattern similar to what you describe.  
It's beaucoup inner classes.  Is it possible to get this fix against the 
Eclipse 1.0 base ?
Comment 5 Philipe Mulet CLA 2002-03-14 12:34:18 EST
No this is unlikely, since so many changes did occur in this area in between 
1.0 and 2.0. Attempting to issue a patch would be hard, and likely causing some 
more troubles.

You may want to change your source code for the short term (until you get a 
refreshed WSAD build based on Eclipse 2.0).

The following would compile fine in 1.0:

public class X {
	public Object foo() {
		B b = new B() {
			protected Object bar() {
				return new B.C(this) {
				};
			}
		};
		return b;
	}
}
class B {
	static class C {
		C(B b){
		} 
	}
} 
Comment 6 Jim Thorpe CLA 2002-03-15 11:43:45 EST
I just wanted to document that I did try the Eclipse 2.0 build (20020214) and 
the problem is resolved.