Bug 93489 - Around advice invoking protected on inner aspect bug
Summary: Around advice invoking protected on inner aspect bug
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   Edit
Assignee: Adrian Colyer CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-05-03 04:13 EDT by Ron Bodkin CLA
Modified: 2006-05-30 09:58 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 Ron Bodkin CLA 2005-05-03 04:13:04 EDT
I haven't yet narrowed it down, but the following advice fails with an 
error "RuntimeException thrown: Ranges must be updated with an enclosing 
instructionList"

If I make it just advise call(* *(..)), it gives
"IllegalStateException thrown: no this"

Any ideas what's wrong? I will try to narrow this down tomorrow (as always, 
simplified standalone versions don't do this)...

---

        Object around() : call(* *(..)) || execution(* *(..)) || 
adviceexecution() || call(new(..)) || execution(new(..)) {
            VirtualDynamicMock vdMock = getFirstMatch(thisJoinPoint);
            // not handled yet: >1 matches per join point... eventually might 
need precedence
            if (vdMock != null) {
                Invocation jpInvocation = new JpInvocation(thisJoinPoint) {
                    public Object doProceed() {
                        return proceed();
                    }
                };
                try {
                    return vdMock.mockInvocation(jpInvocation);
                } catch (Throwable t) {
                    throw new RuntimeException(t); // bad
                }
            } else {
                return proceed();
            }
        }
Comment 1 Ron Bodkin CLA 2005-05-03 10:33:20 EDT
Here is a simple test program that reproduces the problem:
public aspect MockProcessing {
    public pointcut scope(): !within(MockProcessing);
    
    Object around() : scope() && (call(* *(..)) || execution(* *(..)) || 
adviceexecution() || call(new(..)) || execution(new(..))) {
            return proceed();
    }
    
}    

class ContractChecking {
    public static final boolean enabled = Boolean.getBoolean
(ContractChecking.class.getName());
}

Compiler output:
Ranges must be updated with an enclosing instructionList
Ranges must be updated with an enclosing instructionList
java.lang.RuntimeException: Ranges must be updated with an enclosing 
instruction
List
        at org.aspectj.weaver.bcel.Range.updateTarget(Range.java:170)
        at org.aspectj.weaver.bcel.BcelShadow.retargetFrom(BcelShadow.java:230)
        at org.aspectj.weaver.bcel.BcelShadow.deleteNewAndDup
(BcelShadow.java:20
7)
        at org.aspectj.weaver.bcel.BcelShadow.prepareForMungers
(BcelShadow.java:
247)
        at org.aspectj.weaver.Shadow.implement(Shadow.java:349)
        at org.aspectj.weaver.bcel.BcelClassWeaver.implement
(BcelClassWeaver.jav
a:1618)
        at org.aspectj.weaver.bcel.BcelClassWeaver.weave
(BcelClassWeaver.java:38
6)
        at org.aspectj.weaver.bcel.BcelClassWeaver.weave
(BcelClassWeaver.java:92
)
        at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1267)
        at org.aspectj.weaver.bcel.BcelWeaver.weaveWithoutDump
(BcelWeaver.java:1
232)
        at org.aspectj.weaver.bcel.BcelWeaver.weaveAndNotify
(BcelWeaver.java:102
6)
        at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:915)
        at org.aspectj.ajdt.internal.compiler.AjCompilerAdapter.weave
(AjCompiler
Adapter.java:244)
        at org.aspectj.ajdt.internal.compiler.AjCompilerAdapter.afterCompiling
(A
jCompilerAdapter.java:119)
        at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.compile
(Compil
er.java:385)
        at 
org.aspectj.ajdt.internal.core.builder.AjBuildManager.performCompilat
ion(AjBuildManager.java:683)
        at org.aspectj.ajdt.internal.core.builder.AjBuildManager.doBuild
(AjBuild
Manager.java:168)
        at org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild
(AjBu
ildManager.java:102)
        at org.aspectj.ajdt.ajc.AjdtCommand.doCommand(AjdtCommand.java:109)
        at org.aspectj.ajdt.ajc.AjdtCommand.runCommand(AjdtCommand.java:60)
        at org.aspectj.tools.ajc.Main.run(Main.java:291)
        at org.aspectj.tools.ajc.Main.runMain(Main.java:227)
        at org.aspectj.tools.ajc.Main.main(Main.java:80)


1 fail|abort

Comment 2 Andrew Clement CLA 2005-12-08 06:45:34 EST
thanks to Rons great testcase I've fixed the problem with updating targeters reported - I fixed it under the more recent 109614.  The problem was in advising an implicit call to the NoClassDefFoundError ctor that is put into the static initializer.  I've fixed it not to crash - but you may need to test it to verify the woven result does what you expect.
Comment 3 Andrew Clement CLA 2006-05-30 09:58:14 EDT
presumed fixed - as mentioned in the previous comment.