aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/bugs/ArrayCloning.java75
-rw-r--r--tests/src/org/aspectj/systemtest/ajc121/Ajc121Tests.java4
-rw-r--r--tests/src/org/aspectj/systemtest/ajc121/ajc121-tests.xml6
3 files changed, 85 insertions, 0 deletions
diff --git a/tests/bugs/ArrayCloning.java b/tests/bugs/ArrayCloning.java
new file mode 100644
index 000000000..43884833f
--- /dev/null
+++ b/tests/bugs/ArrayCloning.java
@@ -0,0 +1,75 @@
+
+public class ArrayCloning {
+
+ public static void main(String[] args) {
+ ArrayCloning ArrayCloning = new ArrayCloning();
+ Integer[] clonedStaticField = ArrayCloning.clone1();
+ checkIdentical(clonedStaticField,ArrayCloning.staticField);
+
+ Integer[] clonedField = ArrayCloning.clone2();
+ checkIdentical(clonedField,ArrayCloning.nonStaticField);
+
+ Integer[] clown = null;
+
+ clown = ArrayCloning.clone3();
+ clown = ArrayCloning.clone4();
+ Integer[][] ArrayCloningArrayCloning = ArrayCloning.clone5();
+ }
+
+ public static void checkIdentical(Integer[] one, Integer[] two) {
+ if (one[0]!=two[0]) throw new RuntimeException("Not the same (a)");
+ if (one[1]!=two[1]) throw new RuntimeException("Not the same (b)");
+ }
+
+ private static Integer[] staticField = new Integer[2];
+
+ private Integer[] nonStaticField = new Integer[2];
+
+ public ArrayCloning() {
+ nonStaticField[0] = new Integer(32);
+ nonStaticField[1] = new Integer(64);
+ }
+
+ static {
+ staticField[0] = new Integer(1);
+ staticField[1] = new Integer(2);
+ }
+
+ public Integer[] clone1() {
+ System.err.println("Clone call on a static field");
+ return (Integer[])staticField.clone();
+ }
+
+ public Integer[] clone2() {
+ System.err.println("Clone call on a non-static field");
+ return (Integer[])nonStaticField.clone();
+ }
+
+ public Integer[] clone3() {
+ System.err.println("Clone call on a local variable");
+ Integer[] ArrayCloningArrayCloning = staticField;
+ return (Integer[])ArrayCloningArrayCloning.clone();
+ }
+
+
+ // Clone call on anonymous 'thing' !
+ public Integer[] clone4() {
+ System.err.println("Clone call on a 1 dimensional anonymous integer array");
+ return (Integer[])new Integer[5].clone();
+ }
+
+ // Sick
+ public Integer[][] clone5() {
+ System.err.println("Clone call on a 2 dimensional anonymous integer array");
+ return (Integer[][])new Integer[5][3].clone();
+ }
+
+
+}
+
+aspect HelloWorldAspect {
+ Object[] around(): call(* java.lang.Object.clone()) && within(ArrayCloning) {
+ Object[] ret = proceed();
+ return (Object[])ret.clone();
+ }
+}
diff --git a/tests/src/org/aspectj/systemtest/ajc121/Ajc121Tests.java b/tests/src/org/aspectj/systemtest/ajc121/Ajc121Tests.java
index bb9f64266..be7192266 100644
--- a/tests/src/org/aspectj/systemtest/ajc121/Ajc121Tests.java
+++ b/tests/src/org/aspectj/systemtest/ajc121/Ajc121Tests.java
@@ -301,6 +301,10 @@ public class Ajc121Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
public void test055_cnfe() {
runTest("passing null to array arguments confuzes static join point signature. (2)");
}
+
+ public void test056_arrayCloning() {
+ runTest("around advice throws java.lang.VerifyError at runtime");
+ }
}
diff --git a/tests/src/org/aspectj/systemtest/ajc121/ajc121-tests.xml b/tests/src/org/aspectj/systemtest/ajc121/ajc121-tests.xml
index 43dce6610..ddb48afb5 100644
--- a/tests/src/org/aspectj/systemtest/ajc121/ajc121-tests.xml
+++ b/tests/src/org/aspectj/systemtest/ajc121/ajc121-tests.xml
@@ -443,3 +443,9 @@
<compile files="Main2.java,MainAspect.java"/>
<run class="dk.infimum.aspectjtest.Main2"/>
</ajc-test>
+
+ <ajc-test dir="bugs" pr="72528"
+ title="around advice throws java.lang.VerifyError at runtime">
+ <compile files="ArrayCloning.java"/>
+ <run class="ArrayCloning"/>
+ </ajc-test>