Bug 51320

Summary: ClasscastException on concretization of if(false)
Product: [Tools] AspectJ Reporter: Eric Bodden <eric>
Component: CompilerAssignee: Andrew Clement <aclement>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: unspecified   
Target Milestone: 1.2   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Aspect none

Description Eric Bodden CLA 2004-02-07 12:26:00 EST
I get the following exception when weaving the attached aspect on the dev build.

java.lang.ClassCastException
	at org.aspectj.weaver.patterns.IfPointcut.concretize1(IfPointcut.java:156)
	at org.aspectj.weaver.patterns.IfPointcut.concretize(IfPointcut.java:143)
	at org.aspectj.weaver.patterns.Pointcut.concretize(Pointcut.java:119)
	at org.aspectj.weaver.Checker.concretize(Checker.java:35)
	at org.aspectj.weaver.CrosscuttingMembers.
addShadowMunger(CrosscuttingMembers.java:78)
	at org.aspectj.weaver.CrosscuttingMembers.addDeclare(CrosscuttingMembers.
java:102)
	at org.aspectj.weaver.CrosscuttingMembers.addDeclares(CrosscuttingMembers.
java:92)
	at org.aspectj.weaver.CrosscuttingMembersSet.
addAdviceLikeDeclares(CrosscuttingMembersSet.java:65)
	at org.aspectj.ajdt.internal.compiler.lookup.AjLookupEnvironment.
addAdviceLikeDeclares(AjLookupEnvironment.java:147)
	at org.aspectj.ajdt.internal.compiler.lookup.AjLookupEnvironment.
completeTypeBindings(AjLookupEnvironment.java:122)
	at org.eclipse.jdt.internal.compiler.Compiler.beginToCompile(Compiler.java:
300)
	at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:314)
	at org.aspectj.ajdt.internal.core.builder.AjBuildManager.
performCompilation(AjBuildManager.java:384)
	at org.aspectj.ajdt.internal.core.builder.AjBuildManager.
doBuild(AjBuildManager.java:125)
	at org.aspectj.ajdt.internal.core.builder.AjBuildManager.
batchBuild(AjBuildManager.java:70)
	at org.aspectj.ajdt.ajc.AjdtCommand.doCommand(AjdtCommand.java:104)
	at org.aspectj.ajdt.ajc.AjdtCommand.runCommand(AjdtCommand.java:53)
	at org.aspectj.tools.ajc.Main.run(Main.java:234)
	at org.aspectj.tools.ajc.Main.runMain(Main.java:170)
	at org.aspectj.tools.ajc.Main.main(Main.java:81)
Comment 1 Eric Bodden CLA 2004-02-07 12:27:39 EST
Created attachment 7721 [details]
Aspect
Comment 2 Eric Bodden CLA 2004-02-07 12:29:17 EST
additional comments:
1.) The object "advice" is of type Checker, which is _not_ a subtype of Advice.
2.) I do realize that the declare warning statement is not necessarily supposed 
to work with an if pointcut. Though a decent error should be given.
Comment 3 Adrian Colyer CLA 2004-02-19 09:51:52 EST
It would be good to improve the error handling here for 1.2 if we can. Marked 
with target = 1.2 for now pending investigation.
Comment 4 Andrew Clement CLA 2004-02-25 06:41:49 EST
Fix checked in.  As per the discussion on the list, the use of PCDs that may 
have dynamic residue is policed and you will get an error message if you try 
to use them in deow statements.


C:\Eclipse\212\eclipse\aspectj_ws\tests\bugs>ajc DecwClassCastException.java
C:\Eclipse\212\eclipse\aspectj_ws\tests\bugs\DecwClassCastException.java:27 if
() pointcut designator cannot be used in declare statement
C:\Eclipse\212\eclipse\aspectj_ws\tests\bugs\DecwClassCastException.java:29 if
() pointcut designator cannot be used in declare statement
C:\Eclipse\212\eclipse\aspectj_ws\tests\bugs\DecwClassCastException.java:31 
cflow() pointcut designator cannot be used in declare statement
C:\Eclipse\212\eclipse\aspectj_ws\tests\bugs\DecwClassCastException.java:33 
cflow() pointcut designator cannot be used in declare statement
C:\Eclipse\212\eclipse\aspectj_ws\tests\bugs\DecwClassCastException.java:35 
cflowbelow() pointcut designator cannot be used in declare statement
C:\Eclipse\212\eclipse\aspectj_ws\tests\bugs\DecwClassCastException.java:37 
cflowbelow() pointcut designator cannot be used in declare statement
C:\Eclipse\212\eclipse\aspectj_ws\tests\bugs\DecwClassCastException.java:39 
this() pointcut designator cannot be used in declare statement
C:\Eclipse\212\eclipse\aspectj_ws\tests\bugs\DecwClassCastException.java:41 
this() pointcut designator cannot be used in declare statement
C:\Eclipse\212\eclipse\aspectj_ws\tests\bugs\DecwClassCastException.java:43 
target() pointcut designator cannot be used in declare statement
C:\Eclipse\212\eclipse\aspectj_ws\tests\bugs\DecwClassCastException.java:45 
target() pointcut designator cannot be used in declare statement
C:\Eclipse\212\eclipse\aspectj_ws\tests\bugs\DecwClassCastException.java:47 
args() pointcut designator cannot be used in declare statement
C:\Eclipse\212\eclipse\aspectj_ws\tests\bugs\DecwClassCastException.java:49 
args() pointcut designator cannot be used in declare statement

12 errors

The line number in the error is always the line number of the declare 
statement.