Bug 92334 - Exception on rename of aspect type if used in enclosed pointcut
Summary: Exception on rename of aspect type if used in enclosed pointcut
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.5.0M2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 1.5.0 M3   Edit
Assignee: Adrian Colyer CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-04-22 02:00 EDT by Wes Isberg CLA
Modified: 2005-06-03 11:39 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 Wes Isberg CLA 2005-04-22 02:00:15 EDT
fyi, unisolated but repeating bug...

Using AJDT 1.2.0 M3 with AspectJ 1.5.0M2 and the following code, when I rename
the aspect to "Logging", I get the BCException below.  Not true of simpler
scenarios, and the entire code is a bit much for now.  Appeared to result from
reference to renamed type in "within(..)".

Sorry for no test case.

----------------------------
    static aspect Logging {
        pointcut logAdvice() : Pointcuts.logging() 
            && adviceexecution() 
            && within(!Logging) 
            && cflow(execution(void WrapMain.runMain(String[])))
            && !cflow(adviceexecution() && within(Logging))
            ;
        
        pointcut logTests() : Pointcuts.logging() 
            && (execution(void WrapMain.runMain(String[])) 
                || execution(static void main(String[])) 
                || execution(void AComposite.recurse(..))
                );

        // todo @SuppressAjWarnings;
        before() : logAdvice() {
            log(""+thisJoinPoint);
        }
        
        // todo @SuppressAjWarnings;
        before() : logTests() { 
            log(thisJoinPoint 
                    + " this: " + thisJoinPoint.getThis()
                    + " targ: " + thisJoinPoint.getTarget()
                    + " args: " + LangUtil.flatten(thisJoinPoint.getArgs())
                    );
        }
        
        after(WrapMain me) returning (List<Object> list) : Pointcuts.logging()
            && args(me) &&
            execution(static * MainAssembler.PackageDir.packageChildren(WrapMain)) {
            log(me + " kids " + list);
        }
    }


---------------------------
java.lang.ClassCastException: org.aspectj.weaver.ResolvedMember
at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:933)
at
org.aspectj.ajdt.internal.compiler.AjCompilerAdapter.weave(AjCompilerAdapter.java:244)
at
org.aspectj.ajdt.internal.compiler.AjCompilerAdapter.afterCompiling(AjCompilerAdapter.java:119)
at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:385)
at
org.aspectj.ajdt.internal.core.builder.AjBuildManager.performCompilation(AjBuildManager.java:683)
at
org.aspectj.ajdt.internal.core.builder.AjBuildManager.doBuild(AjBuildManager.java:168)
at
org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild(AjBuildManager.java:102)
at org.aspectj.ajde.internal.CompilerAdapter.compile(CompilerAdapter.java:122)
at
org.aspectj.ajde.internal.AspectJBuildManager$CompilerThread.run(AspectJBuildManager.java:165)
Comment 1 Andrew Clement CLA 2005-05-31 08:49:06 EDT
Problem actually occurs because some advice is not matching - this is probably
because of the rename.  Here is a standalone program that blows up in the same way:

aspect Logging {
  before(): call(* *(..)) && cflow(execution(* *(..)) {}
}

The problem is a line of code assuming shadow mungers are of a certain class,
this is the code that puts out the 'advice did not match warning' (this message
is only put out if -1.5 option is specified for compilation).  Some features of
the AJ language are implemented by creating other classes of shadow munger - for
example, the cflow() above.  In these cases the code attempts to cast a munger
to an invalid type and BANG.

This is fixed in the latest dev build.
Comment 2 Andrew Clement CLA 2005-06-01 12:17:07 EDT
Should mention the other bug, bug 93345 fixed this.  Will close in a few days if
no update...
Comment 3 Andrew Clement CLA 2005-06-03 11:39:32 EDT
Fixed, grab the latest dev build.