Bug 36431 - Around advice for if(false) pointcut produces compiler error
Summary: Around advice for if(false) pointcut produces compiler error
Status: RESOLVED INVALID
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows NT
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Jim Hugunin CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-04-13 11:49 EDT by Ramnivas Laddad CLA
Modified: 2003-04-22 13:05 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 Ramnivas Laddad CLA 2003-04-13 11:49:34 EDT
This is a regression from 1.0. Used to work fine in 1.0.

public class Test {
    int foo() {
	return 0;
    }
}

abstract aspect FaultToreranceAspect {
    abstract pointcut retryOperations();

    Object around() : retryOperations() {
	// retry... etc...
	return proceed();
    }
}

aspect MySystemFaultToreranceAspect extends FaultToreranceAspect {
    // let's temporarily disable fault tolerance behavior
    pointcut retryOperations() : if(false);
}

F:\aspectj\bugs\1.1\rc1\if-false>ajc Test.java
F:\aspectj\bugs\1.1\rc1\if-false\Test.java:10 around on initialization not supported
 (compiler limitation)
F:\aspectj\bugs\1.1\rc1\if-false\Test.java:16 around on initialization not supported
 (compiler limitation)
F:\aspectj\bugs\1.1\rc1\if-false\Test.java:10 around on pre-initialization not suppo
rted (compiler limitation)
F:\aspectj\bugs\1.1\rc1\if-false\Test.java:16 around on pre-initialization not suppo
rted (compiler limitation)
F:\aspectj\bugs\1.1\rc1\if-false\Test.java:10 around on initialization not supported
 (compiler limitation)
F:\aspectj\bugs\1.1\rc1\if-false\Test.java:7 around on initialization not supported
(compiler limitation)
F:\aspectj\bugs\1.1\rc1\if-false\Test.java:10 around on pre-initialization not suppo
rted (compiler limitation)
F:\aspectj\bugs\1.1\rc1\if-false\Test.java:7 around on pre-initialization not suppor
ted (compiler limitation)
F:\aspectj\bugs\1.1\rc1\if-false\Test.java:10 around on initialization not supported
 (compiler limitation)
F:\aspectj\bugs\1.1\rc1\if-false\Test.java:1 around on initialization not supported
(compiler limitation)
F:\aspectj\bugs\1.1\rc1\if-false\Test.java:10 around on pre-initialization not suppo
rted (compiler limitation)
F:\aspectj\bugs\1.1\rc1\if-false\Test.java:1 around on pre-initialization not suppor
ted (compiler limitation)

12 errors

If I change the pointcut definition as follows, the compilation
error goes away:
pointcut retryOperations() : if(false) && call(Object fake());

This is a kludgy workaround.
Comment 1 Jim Hugunin CLA 2003-04-22 13:05:18 EDT
This is not a bug.  if(false) is not as well optimized in the 1.1 compiler as 
it was in the 1.0 one (in return for better separate compilation properties).  
If you want to state that a pointcut matches nothing, you should use:

pointcut retryOperations();

This syntax was provided explictly to enable this case of overriding an 
abstract pointcut to indicate that no join points should be matched.