@interface I {} | |||||
class Simple {} | |||||
public aspect pr115607 { | |||||
declare @type: Simple : @I; | |||||
} |
package pack; | |||||
class Test { | |||||
public void testMethod() { | |||||
new Runnable() { | |||||
public void run() { | |||||
} | |||||
}; | |||||
class C { | |||||
public void m(){ | |||||
} | |||||
} | |||||
} | |||||
} | |||||
aspect A { | |||||
pointcut p() : execution(* run(..)); | |||||
before() : p() { | |||||
} | |||||
} |
package pack; | |||||
class Test { | |||||
public void testMethod() { | |||||
new Runnable() { | |||||
public void run() { | |||||
someMethod(); | |||||
} | |||||
}; | |||||
} | |||||
public void someMethod() { | |||||
} | |||||
} | |||||
aspect A { | |||||
declare warning : call(void someMethod(..)) : "blah blah blah"; | |||||
} |
class Test { | |||||
public void testMethod() { | |||||
new Runnable() { | |||||
public void run() { | |||||
} | |||||
}; | |||||
class C { | |||||
public void m(){ | |||||
} | |||||
} | |||||
} | |||||
} | |||||
aspect A { | |||||
pointcut p() : execution(* m(..)); | |||||
before() : p() { | |||||
} | |||||
} |
import org.aspectj.lang.annotation.Aspect; | |||||
import org.aspectj.lang.annotation.DeclareWarning; | |||||
import org.aspectj.lang.annotation.DeclareError; | |||||
@Aspect | |||||
public class A { | |||||
@DeclareWarning("execution(* C.warningMethod())") | |||||
static final String warning = "warning"; | |||||
@DeclareError("execution(* C.badMethod())") | |||||
static final String error = "error"; | |||||
} |
public class C { | |||||
public void warningMethod() { | |||||
} | |||||
public void badMethod() { | |||||
} | |||||
} |
import java.util.List; | |||||
aspect Slide74 { | |||||
public X Bar<X>.getFirst() { | |||||
return lts.get(0); | |||||
} | |||||
<T> Foo<T>.new(List<T> elements) { this(); } | |||||
private List<C> Bar<C>.children;// = new ArrayList<C>(); | |||||
static class Bar<T> { | |||||
List<T> lts; | |||||
} | |||||
} | |||||
class Foo<T> { | |||||
} |
aspect basic { | |||||
declare @method : * debit(..) : @Secured(role="supervisor"); | |||||
declare @constructor : BankAccount+.new(..) : @Secured(role="supervisor"); | |||||
} | |||||
class BankAccount { | |||||
public BankAccount(String s, int i) { | |||||
} | |||||
public void debit(long accId,long amount) { | |||||
} | |||||
} | |||||
@interface Secured { | |||||
String role(); | |||||
} |
package bar; | |||||
public aspect MyBar { | |||||
before() : call(* main(..)) { | |||||
System.out.println("about to call a main method"); | |||||
} | |||||
} |
package foo; | |||||
public class MyFoo { | |||||
public void callMain() { | |||||
new MyFoo().main(); | |||||
} | |||||
public void main() { | |||||
} | |||||
} |
package bar; | |||||
public @interface MyAnnotation { | |||||
} |
package bar; | |||||
import foo.*; | |||||
public aspect MyBar { | |||||
before() : call(* main(..)) {} | |||||
declare warning: get( * System.out ) : "System.out should not be called"; | |||||
declare parents : *Foo extends NewClass; | |||||
declare @type : *Foo* : @MyAnnotation; | |||||
declare @method : public * *Foo.anotMethod(..) : @MyAnnotation; | |||||
declare @constructor : *Foo.new(String) : @MyAnnotation; | |||||
declare @field : int *Foo.* : @MyAnnotation ; | |||||
} |
package foo; | |||||
public class MyFoo { | |||||
public int i; | |||||
public MyFoo() { | |||||
super(); | |||||
} | |||||
public MyFoo(String s) { | |||||
super(); | |||||
} | |||||
public void callMain() { | |||||
new MyFoo().main(); | |||||
} | |||||
public void main() { | |||||
System.out.println("blah"); | |||||
} | |||||
public void anotMethod() { | |||||
} | |||||
} |
package bar; | |||||
public class NewClass { | |||||
} |
aspect DeclareAnnotation { | |||||
declare @method : * debit(..) : @Secured(role="supervisor"); | |||||
} | |||||
class BankAccount { | |||||
public void debit(String accId,long amount) { | |||||
} | |||||
} | |||||
@interface Secured { | |||||
String role(); | |||||
} |
package pkg; | |||||
public aspect A { | |||||
before() : C.pointcutInClass() { | |||||
} | |||||
pointcut pointcutInAspect() : execution(void aMethod()); | |||||
before() : pointcutInAspect() { | |||||
} | |||||
public void aMethod() { | |||||
} | |||||
} |
package pkg; | |||||
public class C { | |||||
pointcut pointcutInClass() : execution(void cMethod()); | |||||
public void cMethod() { | |||||
} | |||||
} |
public void testAtAspectInheritsAbstractPointcut_pr125810 () { | public void testAtAspectInheritsAbstractPointcut_pr125810 () { | ||||
runTest("warning when inherited pointcut not made concrete"); | runTest("warning when inherited pointcut not made concrete"); | ||||
} | } | ||||
public void testAtAspectNoNPEWithDEOWWithoutStructureModel_pr120356() { | |||||
runTest("@AJ no NPE with deow when structure model isn't generated"); | |||||
} | |||||
public void testAtAspectWithoutJoinPointImport_pr121616() { | public void testAtAspectWithoutJoinPointImport_pr121616() { | ||||
runTest("@AJ without JoinPoint import"); | runTest("@AJ without JoinPoint import"); |
<compile files="Pr126316.aj" options="-1.5"/> | <compile files="Pr126316.aj" options="-1.5"/> | ||||
</ajc-test> | </ajc-test> | ||||
<ajc-test dir="bugs151/pr120356" title="@AJ no NPE with deow when structure model isn't generated"> | |||||
<compile files="C.java, A.java" options="-1.5"> | |||||
<message kind="error" line="8" text="error"/> | |||||
<message kind="warning" line="5" text="warning"/> | |||||
</compile> | |||||
</ajc-test> | |||||
<ajc-test dir="bugs151" title="@AJ without JoinPoint import"> | <ajc-test dir="bugs151" title="@AJ without JoinPoint import"> | ||||
<compile files="pr121616.java" options="-1.5"> | <compile files="pr121616.java" options="-1.5"> | ||||
<message kind="error" line="13" text="JoinPoint cannot be resolved to a type"/> | <message kind="error" line="13" text="JoinPoint cannot be resolved to a type"/> |