diff options
author | acolyer <acolyer> | 2004-08-24 21:10:56 +0000 |
---|---|---|
committer | acolyer <acolyer> | 2004-08-24 21:10:56 +0000 |
commit | 82eae551311afbd3a942d54e55b1c569c5f975b8 (patch) | |
tree | 8a716f4fe9e62354f60594b34185cd6fe53de541 /tests/bugs | |
parent | cfaa79ae72fba6619700f259fd4b05eaed6d3988 (diff) | |
download | aspectj-82eae551311afbd3a942d54e55b1c569c5f975b8.tar.gz aspectj-82eae551311afbd3a942d54e55b1c569c5f975b8.zip |
fix for Bugzilla Bug 72531
declare warning warns at wrong points
Diffstat (limited to 'tests/bugs')
-rw-r--r-- | tests/bugs/pr72531/de/rohith/HelloWorld.java | 11 | ||||
-rw-r--r-- | tests/bugs/pr72531/de/rohith/HelloWorldAspect.java | 31 | ||||
-rw-r--r-- | tests/bugs/pr72531/de/rohith/PrinterWorld.java | 25 |
3 files changed, 67 insertions, 0 deletions
diff --git a/tests/bugs/pr72531/de/rohith/HelloWorld.java b/tests/bugs/pr72531/de/rohith/HelloWorld.java new file mode 100644 index 000000000..f2687aab9 --- /dev/null +++ b/tests/bugs/pr72531/de/rohith/HelloWorld.java @@ -0,0 +1,11 @@ +package de.rohith; +public class HelloWorld { + + public static void main(String[] args) { + PrinterWorld p = new PrinterWorld(); + p.print(); + Integer i = p.returnInt(); + Integer[] intArray = p.returnArrayWithCloning(); + Integer[] array2 = p.returnArrayWithoutCloning(); + } +} diff --git a/tests/bugs/pr72531/de/rohith/HelloWorldAspect.java b/tests/bugs/pr72531/de/rohith/HelloWorldAspect.java new file mode 100644 index 000000000..cbe1dc707 --- /dev/null +++ b/tests/bugs/pr72531/de/rohith/HelloWorldAspect.java @@ -0,0 +1,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); + } +} diff --git a/tests/bugs/pr72531/de/rohith/PrinterWorld.java b/tests/bugs/pr72531/de/rohith/PrinterWorld.java new file mode 100644 index 000000000..cf4277643 --- /dev/null +++ b/tests/bugs/pr72531/de/rohith/PrinterWorld.java @@ -0,0 +1,25 @@ +package de.rohith; +public class PrinterWorld { + private Integer[] intArray = new Integer[2]; + public PrinterWorld() { + + } + public void print() { + System.out.println("Hello World!"); + } + + public Integer returnInt() { + return new Integer(3); + } + + public Integer[] returnArrayWithCloning() { + for (int i = 0; i < intArray.length; i++) { + intArray[i] = new Integer(i++); + } + return (Integer[])intArray.clone(); + } + + public Integer[] returnArrayWithoutCloning() { + return intArray; + } +} |