summaryrefslogtreecommitdiffstats
path: root/tests/bugs/pr72531/de/rohith/HelloWorldAspect.java
blob: cbe1dc70763abd017384c7fd33a60109d5eb6ff9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package de.rohith;
import java.lang.Object;

public aspect HelloWorldAspect {
    
	private int callDepth = -1;

    public HelloWorldAspect() {
    }
    
    pointcut hello(): !within(HelloWorldAspect);
    
    pointcut method(): execution(public (*[]) de..*(..));
    
    pointcut cloning(): call(* java.lang.Object.clone());

    declare warning: method() && hello(): "*[] returning method called" ;
    
    Object[] around(): cflow(method()) && cloning() && hello() {
    	print("", thisEnclosingJoinPointStaticPart);
    	Object[] ret = proceed(); 
    	return (Object[])ret.clone();
    }

    private void print(String prefix, Object message) {
        for (int i = 0, spaces = callDepth * 2; i < spaces; i++) {
            System.out.print(" ");
        }
        System.out.println(prefix + message);
    }
}