From b5e6307a63b0513cb058e8d6e56ff87287bdfa15 Mon Sep 17 00:00:00 2001 From: aclement Date: Fri, 27 Aug 2004 10:03:54 +0000 Subject: [PATCH] fix for Bugzilla Bug 72150 AJC possible bug with static nested classes --- tests/bugs/java5/arrayCloning/A.java | 6 +++ tests/bugs/java5/arrayCloning/C.java | 41 ++++++++++++++++++ tests/bugs/java5/arrayCloning/OneFiveCode.jar | Bin 0 -> 1467 bytes tests/bugs/java5/arrayCloning/explanation.txt | 2 + tests/bugs/java5/arrayCloning/rebuild.bat | 4 ++ .../systemtest/ajc121/Ajc121Tests.java | 4 ++ .../systemtest/ajc121/ajc121-tests.xml | 6 +++ weaver/src/org/aspectj/weaver/TypeX.java | 9 +++- 8 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 tests/bugs/java5/arrayCloning/A.java create mode 100644 tests/bugs/java5/arrayCloning/C.java create mode 100644 tests/bugs/java5/arrayCloning/OneFiveCode.jar create mode 100644 tests/bugs/java5/arrayCloning/explanation.txt create mode 100644 tests/bugs/java5/arrayCloning/rebuild.bat diff --git a/tests/bugs/java5/arrayCloning/A.java b/tests/bugs/java5/arrayCloning/A.java new file mode 100644 index 000000000..10cb71381 --- /dev/null +++ b/tests/bugs/java5/arrayCloning/A.java @@ -0,0 +1,6 @@ +aspect A { + Object around(): call(* clone(..)) { + return proceed(); + } +} + diff --git a/tests/bugs/java5/arrayCloning/C.java b/tests/bugs/java5/arrayCloning/C.java new file mode 100644 index 000000000..8886906f5 --- /dev/null +++ b/tests/bugs/java5/arrayCloning/C.java @@ -0,0 +1,41 @@ +import java.lang.reflect.*; + +class C { + + public static B.D[] arr = new B.D[5]; + + public static void main(String[]argv) { + arr[0] = new B.D(42); + arr[1] = new B.D(22); + arr[2] = new B.D(46); + arr[3] = new B.D(50); + arr[4] = new B.D(54); + + B.D[] arr2 = arr.clone(); + + + // Check the clone is OK + if (arr2[0].i!=42) throw new RuntimeException("Call that a clone 0"); + if (arr2[1].i!=22) throw new RuntimeException("Call that a clone 1"); + if (arr2[2].i!=46) throw new RuntimeException("Call that a clone 2"); + if (arr2[3].i!=50) throw new RuntimeException("Call that a clone 3"); + if (arr2[4].i!=54) throw new RuntimeException("Call that a clone 4"); + System.err.println("Clone OK - attempting value manipulation"); + + // Change the clone, check the original is OK + arr2[2] = new B.D(1); + if (arr[2].i == 1) throw new RuntimeException("Shouldnt have affected original"); + if (arr2[2].i != 1) throw new RuntimeException("Should have affected clone"); + + + System.err.println("Clone OK - finished"); + } +} + + +class B { + public static class D { + public int i; + D(int x) { i=x;} + } +} diff --git a/tests/bugs/java5/arrayCloning/OneFiveCode.jar b/tests/bugs/java5/arrayCloning/OneFiveCode.jar new file mode 100644 index 0000000000000000000000000000000000000000..0196f39b0ac812d95a8cdb16a02fe6843733315c GIT binary patch literal 1467 zcmWIWW@Zs#-~d8DFKI&tB*4kQ!r-LhqL-YLSX}(?6a#~7pTGBE2Z5vaRSYwew$!iL zTM@*P&9A%Ho8MQHWr^IBd*-DRbql#YUw{9k(8O-&!bgIc5*H`x7o+72k8d%`@U~+up~&HLp5%%~Rg_^`e{j zNBaP8b`HN;1^m~6erIB2UZhfV*W^VcLfV&9mw0eC zt#H2hH?!a14QJHf@Z}4f~;I3ejWpZUHU%FN6 zkk7QGTAbH(uD&ewGiYDTyin|!yX%K*E5l~rRt-BEcT6&VPHdgF&{iMqq}Ius_jrpl z@&4PTP@*N55;VUlwiXV?WGQx3$>co zbVWsFE>u|bK%8~UM!}@swgS^F&bw1~tG=DKLjR%ii&lLFsSct2dA=g|(rs6ix_u(|bL_lLJA=KR z-ktSy%Co%=wF?u>jU|6(Ee;dVo+keMyo&9Ag>y+39l;Wp3c9-j3;FLZyUkk2Uf#T; z-L-9D*}LPs$G2)F{j79+vm^gy89JJ@g?s`FMnjOQuZxha#{9e z4_j7|q&CmS9+lPnXE`VDUbiB^+wbI^r)ADFMBhbN^Uki0&DtS5~7w=hX);@17KPsM@*t_`fjIt#0S^S~=nt zwoK%k;duL_&h19e_m*DoXDdGF^jB}StKxQXdtu^az4)%UJwvs+?D>nYrUxus5a^{C zd(-&G1=la<<#tVR)_ASh75F)2<)tn&-T7N4`JUEaTXOl*64TpTzCHZSRj?-?T+?+1sU>xId3ky z_3HZPkozXGhu>OdXgqFF)*BB0i}ONCJ_ci35Z-0fJ#7AfKnc!YemjhprQf+gn-2gwBW$d dgya@fO$ + + + + + \ No newline at end of file diff --git a/weaver/src/org/aspectj/weaver/TypeX.java b/weaver/src/org/aspectj/weaver/TypeX.java index b871d721b..eb0ec35b4 100644 --- a/weaver/src/org/aspectj/weaver/TypeX.java +++ b/weaver/src/org/aspectj/weaver/TypeX.java @@ -583,8 +583,13 @@ public class TypeX { if (name.equals("void")) return "V"; if (name.endsWith("[]")) return "[" + nameToSignature(name.substring(0, name.length() - 2)); - if (name.length() != 0) // lots more tests could be made here... - return "L" + name.replace('.', '/') + ";"; + if (name.length() != 0) { + // lots more tests could be made here... + + // 1) If it is already an array type, do not mess with it. + if (name.charAt(0)=='[' && name.charAt(name.length()-1)==';') return name; + else return "L" + name.replace('.', '/') + ";"; + } else throw new BCException("Bad type name: " + name); } -- 2.39.5