]> source.dussan.org Git - aspectj.git/commitdiff
Added easy to understand test for issue of Class.forName differences
authorjhugunin <jhugunin>
Thu, 1 May 2003 00:21:12 +0000 (00:21 +0000)
committerjhugunin <jhugunin>
Thu, 1 May 2003 00:21:12 +0000 (00:21 +0000)
between IBM and SUN's JDKs

Moved a nit-picking part of SourceLocationWithExpr to its own test that
is listed as a known limitation.

tests/ajcTests.xml
tests/new/ClassForName.java [new file with mode: 0644]
tests/new/SourceLocationWithinExpr.java
tests/new/SourceLocationWithinExprHard.java [new file with mode: 0644]

index 13bf490e73c1a1f234c1e88dfb0108258ae99a28..8553355a5f65f5b7a28c6eb43578d6a7d576b408 100644 (file)
         <compile files="SourceLocationWithinExpr.java"/>
         <run class="SourceLocationWithinExpr"/>
     </ajc-test>
+    
+    
+    <ajc-test dir="new" pr="885" keywords="knownLimitation"
+      comment="this behaves differently in 1.3 from 1.4 for unknown reasons, merge with above when resolved"
+      title="source locations within expressions (hard case of constructor start)">
+        <compile files="SourceLocationWithinExprHard.java"/>
+        <run class="SourceLocationWithinExprHard"/>
+    </ajc-test>
 
     <ajc-test dir="new" pr="888"
       title="crashes given method in declared method">
         <compile files="Trg.java,Asp.java"/>
         <run class="Trg"/>
     </ajc-test>
+    
+    <ajc-test dir="new"
+      comment="this is a pureJava test, but we always want to run it"
+      title="arrays via Class.forName()">
+        <compile files="ClassForName.java"/>
+        <run class="ClassForName"/>
+    </ajc-test>
 </suite>
diff --git a/tests/new/ClassForName.java b/tests/new/ClassForName.java
new file mode 100644 (file)
index 0000000..83b8a62
--- /dev/null
@@ -0,0 +1,22 @@
+
+import org.aspectj.testing.Tester;
+import java.util.*;
+
+public class ClassForName {
+    public static void main(String[] args) throws ClassNotFoundException {
+       Class c1 = String[].class;
+       Class c2 = Class.forName("[Ljava.lang.String;");
+       Class c3 = ClassForName.class.getClassLoader().loadClass("[Ljava.lang.String;");
+       
+               Tester.checkEqual(c1, c2, "classes c1, c2");
+               Tester.checkEqual(c2, c3, "classes c2, c3");
+       
+       Tester.checkEqual(c1.getComponentType(), String.class, "component");
+    }
+}
+
+aspect A {
+       before(): execution(void main(..)) {
+               System.out.println(thisJoinPointStaticPart);
+       }
+}
index 797fc430ed3b9c6df1ba195f39e0331b4dff73ae..5a6b8234de8061895f7ddce2aded30f2343a875d 100644 (file)
@@ -6,8 +6,8 @@ import org.aspectj.lang.reflect.*;
 /** @testcase PR#885 call source locations within expression */
 public class SourceLocationWithinExpr {
     public static void main (String[] args) {
-        new                  // 9*
-            C()              // 10
+        new C()                 // 9*
+                              // 10
             .                // 11
             getD()           // 12*
             .                // 13
diff --git a/tests/new/SourceLocationWithinExprHard.java b/tests/new/SourceLocationWithinExprHard.java
new file mode 100644 (file)
index 0000000..013e144
--- /dev/null
@@ -0,0 +1,47 @@
+
+import org.aspectj.testing.Tester;
+import org.aspectj.lang.*;
+import org.aspectj.lang.reflect.*;
+
+/** @testcase PR#885 call source locations within expression */
+public class SourceLocationWithinExprHard {
+    public static void main (String[] args) {
+        new                  // 9*
+            C()              // 10
+            .                // 11
+            getD()           // 12*
+            .                // 13
+            getE()           // 14*
+            .                // 15
+            getF()           // 16*
+            ;
+        Tester.expectEvent("setup");
+        Tester.checkAllEvents();
+    } 
+}
+class C { D getD() { return new D(); } }
+class D { E getE() { return new E(); } }
+class E { F getF() { return new F(); } }
+class F { }
+
+aspect A {
+    private static final String SEP = " - ";
+    static {
+        // using qualifying expr?
+        Tester.expectEvent("C()" + SEP + "9");
+        Tester.expectEvent("getD()" + SEP + "12");
+        Tester.expectEvent("getE()" + SEP + "14");
+        Tester.expectEvent("getF()" + SEP + "16");
+        Tester.event("setup");
+    }
+    pointcut filter() : withincode(static void SourceLocationWithinExpr.main(String[]));
+    before() : filter() && call(C.new()) { signal("C()", thisJoinPoint); }
+    before() : filter() && call(D C.getD()) { signal("getD()", thisJoinPoint); }
+    before() : filter() && call(E D.getE()) { signal("getE()", thisJoinPoint); }
+    before() : filter() && call(F E.getF()) { signal("getF()", thisJoinPoint); }
+    void signal(String prefix, JoinPoint jp) {
+        SourceLocation sl = jp.getSourceLocation();
+        System.out.println(prefix + SEP + sl.getLine());
+        Tester.event(prefix + SEP + sl.getLine());
+    }
+}