Bug 98451 - [inc-compilation] ClassCastException when compiling (BcelWorld.java:414)
Summary: [inc-compilation] ClassCastException when compiling (BcelWorld.java:414)
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: DEVELOPMENT   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 1.5.0 M4   Edit
Assignee: Adrian Colyer CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-06-05 17:20 EDT by Barry Kaplan CLA
Modified: 2005-10-03 05:18 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 Barry Kaplan CLA 2005-06-05 17:20:15 EDT
This does /not/ occur all the time -- not even for the same file. I don't how I
get into the state where this exception is thrown. However, doing a
clean-rebuild seems to clear it up.

----
java.lang.ClassCastException:
org.aspectj.ajdt.internal.compiler.lookup.EclipseSourceType
	at org.aspectj.weaver.bcel.BcelWorld.getBcelObjectType(BcelWorld.java:414)
	at org.aspectj.weaver.bcel.BcelWeaver.getClassType(BcelWeaver.java:1135)
	at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:947)
	at
org.aspectj.ajdt.internal.compiler.AjCompilerAdapter.weave(AjCompilerAdapter.java:286)
	at
org.aspectj.ajdt.internal.compiler.AjCompilerAdapter.afterCompiling(AjCompilerAdapter.java:165)
	at
org.aspectj.ajdt.internal.compiler.CompilerAdapter.ajc$afterReturning$org_aspectj_ajdt_internal_compiler_CompilerAdapter$2$f9cc9ca0(CompilerAdapter.aj:70)
	at
org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:368)
	at
org.aspectj.ajdt.internal.core.builder.AjBuildManager.performCompilation(AjBuildManager.java:727)
	at
org.aspectj.ajdt.internal.core.builder.AjBuildManager.doBuild(AjBuildManager.java:229)
	at
org.aspectj.ajdt.internal.core.builder.AjBuildManager.incrementalBuild(AjBuildManager.java:147)
	at org.aspectj.ajde.internal.CompilerAdapter.compile(CompilerAdapter.java:116)
	at
org.aspectj.ajde.internal.AspectJBuildManager$CompilerThread.run(AspectJBuildManager.java:191)
Comment 1 Matt Chapman CLA 2005-06-07 06:26:07 EDT
Passing over to AspectJ
Comment 2 Andrew Clement CLA 2005-06-08 04:30:14 EDT
try and look at it for m3. will be tricky to debug without more info - might
need to put trace into the weaver and ship a debug build.
Comment 3 Andrew Clement CLA 2005-07-27 09:52:31 EDT
Ok ... for any ReferenceType (String/Integer/List/etc) there is a delegate which
can answer real questions about the reference type (whats your superclass? what
are your methods?)  Delegates fit the interface ReferenceTypeDelegate and there
are two possible implementations of this interface.

1. BcelObjectType - this is the delegate used when the code for the reference
type is recovered from bytecode (from a .class file)

2. EclipseSourceType - this is the delegate used when the source for the
referencetype was passed in to the front end compiler (and so we haven't needed
to go the bytecode)

In this failure case we have accessed the delegate for a reference type assuming
it is a BcelObjectType but in fact it is an EclipseSourceType.

Now, with all the generics changes recently, Adrian and I have changed
processing for referencetypes and their delegates.  We *may* have inadvertently
fixed this...  needs a retry when we upgrade AJDT with an AJ build.
Comment 4 Andrew Clement CLA 2005-08-24 10:34:33 EDT
not generics related, bumping to M4
Comment 5 Andrew Clement CLA 2005-10-03 05:18:43 EDT
Fixed a while ago, this can't happen any more.  If the delegate for a type is
not a bcelObjectType then getBcelObjectType returns null and the caller is
expected to deal with it.  Quite frequently during incremental compilation we go
digging for reweavable state that may have been stashed for a type - and that
leads to this classcastexception because we happen to be processing an eclipse
source type.  Given that an eclipsesourcetype delegate can't have reweavable
state we simply allow for null to occur from getBcelObjectType() and assume that
means there is no reweavable state.