]> source.dussan.org Git - aspectj.git/commitdiff
456457: unresolvable member fix. Testcode for 456801,455608
authorAndy Clement <aclement@gopivotal.com>
Thu, 8 Jan 2015 00:22:57 +0000 (16:22 -0800)
committerAndy Clement <aclement@gopivotal.com>
Thu, 8 Jan 2015 00:22:57 +0000 (16:22 -0800)
14 files changed:
org.aspectj.matcher/src/org/aspectj/weaver/MemberImpl.java
testing/newsrc/org/aspectj/testing/XMLBasedAjcTestCase.java
tests/bugs185/455608/Code2.java [new file with mode: 0644]
tests/bugs185/455608/Code3.java [new file with mode: 0644]
tests/bugs185/456357/DummyClass.java [new file with mode: 0644]
tests/bugs185/456357/LogMe.java [new file with mode: 0644]
tests/bugs185/456357/SampleAspect.java [new file with mode: 0644]
tests/bugs185/456357/SampleUtil.java [new file with mode: 0644]
tests/multiIncremental/456801/base/src/Code.java [new file with mode: 0644]
tests/multiIncremental/456801/base/src/X.java [new file with mode: 0644]
tests/multiIncremental/456801/inc1/src/X.java [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc185/Ajc185Tests.java
tests/src/org/aspectj/systemtest/ajc185/ajc185.xml
tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java

index 7fc1c65240677217792e65bfee2e49d4ea792336..fbf497ed224f1e8c9774cac4394bf793a200d397 100644 (file)
@@ -105,14 +105,14 @@ public class MemberImpl implements Member {
                StringBuilder buf = new StringBuilder();
                buf.append("(");
                for (UnresolvedType paramType : paramTypes) {
-                       if (eraseGenerics && (paramType.isParameterizedType() || paramType.isTypeVariableReference())) {
+                       if (eraseGenerics) {
                                buf.append(paramType.getErasureSignature());
                        } else {
                                buf.append(paramType.getSignature());
                        }
                }
                buf.append(")");
-               if (eraseGenerics && (returnType.isParameterizedType() || returnType.isTypeVariableReference())) {
+               if (eraseGenerics) {
                        buf.append(returnType.getErasureSignature());
                } else {
                        buf.append(returnType.getSignature());
index 0126d29b32ed81d6358f810dcfb917bdc2415240..14952a537acb3dd0fb1c579e9e3051789df5f4cc 100644 (file)
@@ -11,6 +11,7 @@
  * ******************************************************************/
 package org.aspectj.testing;
 
+import java.io.BufferedInputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FilenameFilter;
@@ -313,6 +314,22 @@ public abstract class XMLBasedAjcTestCase extends AjcTestCase {
                ClassPath cp = new ClassPath(cpentry + File.pathSeparator + System.getProperty("java.class.path"));
                return SyntheticRepository.getInstance(cp);
        }
+       
+       protected byte[] loadFileAsByteArray(File f) {
+               try {
+                       byte[] bs = new byte[100000];
+                       BufferedInputStream bis = new BufferedInputStream(new FileInputStream(f));
+                       int pos = 0;
+                       int len = 0;
+                       while ((len=bis.read(bs, pos, 100000-pos))!=-1) {
+                               pos+=len;
+                       }
+                       bis.close();
+                       return bs;
+               } catch (Exception e) {
+                       return null;
+               }
+       }
 
        public JavaClass getClassFrom(File where, String clazzname) throws ClassNotFoundException {
                SyntheticRepository repos = createRepos(where);
diff --git a/tests/bugs185/455608/Code2.java b/tests/bugs185/455608/Code2.java
new file mode 100644 (file)
index 0000000..6622b7b
--- /dev/null
@@ -0,0 +1,16 @@
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+@Bar(String)
+@Foo("abc")
+public class Code2 {
+
+}
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface Foo { String value();}
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface Bar {
+       Class<?>[] value();
+}
diff --git a/tests/bugs185/455608/Code3.java b/tests/bugs185/455608/Code3.java
new file mode 100644 (file)
index 0000000..a6271fb
--- /dev/null
@@ -0,0 +1,17 @@
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+@Bar(value=String,i=4)
+//@Foo("abc")
+public class Code3 {
+
+}
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface Foo { String value();}
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface Bar {
+       Class<?>[] value();
+int i();
+}
diff --git a/tests/bugs185/456357/DummyClass.java b/tests/bugs185/456357/DummyClass.java
new file mode 100644 (file)
index 0000000..f3d8572
--- /dev/null
@@ -0,0 +1,13 @@
+public class DummyClass {
+       @LogMe
+       public void doSomething() {
+               SampleUtil sampleUtil = new SampleUtil();
+               // pass null for simplicity !
+               sampleUtil.sampleMethod(null);
+               System.out.println("Do Something");
+       }
+
+       public static void main(String[] args) {
+               new DummyClass().doSomething();
+       }
+}
diff --git a/tests/bugs185/456357/LogMe.java b/tests/bugs185/456357/LogMe.java
new file mode 100644 (file)
index 0000000..a16ca76
--- /dev/null
@@ -0,0 +1,5 @@
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+public @interface LogMe {}
diff --git a/tests/bugs185/456357/SampleAspect.java b/tests/bugs185/456357/SampleAspect.java
new file mode 100644 (file)
index 0000000..15b52fa
--- /dev/null
@@ -0,0 +1,10 @@
+import org.aspectj.lang.JoinPoint;
+import org.aspectj.lang.annotation.*;
+
+aspect SampleAspect {
+//@Aspect public class SampleAspect {
+       //@Before("@annotation(logMe)") public void beforeAdvice(JoinPoint thisJoinPoint, LogMe logMe) {
+before(LogMe logMe): @annotation(logMe) {
+               System.out.println(thisJoinPoint);
+       }
+}
diff --git a/tests/bugs185/456357/SampleUtil.java b/tests/bugs185/456357/SampleUtil.java
new file mode 100644 (file)
index 0000000..1ed161c
--- /dev/null
@@ -0,0 +1,5 @@
+import java.util.Map;
+
+public class SampleUtil {
+       public void sampleMethod(Map<String, Object>[] mapArray) {}
+}
diff --git a/tests/multiIncremental/456801/base/src/Code.java b/tests/multiIncremental/456801/base/src/Code.java
new file mode 100644 (file)
index 0000000..5df0fe3
--- /dev/null
@@ -0,0 +1,5 @@
+public class Code {
+  public static void run() {
+    System.out.println("run() running");
+  }
+}
diff --git a/tests/multiIncremental/456801/base/src/X.java b/tests/multiIncremental/456801/base/src/X.java
new file mode 100644 (file)
index 0000000..9f31b06
--- /dev/null
@@ -0,0 +1,5 @@
+aspect X {
+  before(): execution(* run(..)) {
+    System.out.println("advice runnning");
+  }
+}
diff --git a/tests/multiIncremental/456801/inc1/src/X.java b/tests/multiIncremental/456801/inc1/src/X.java
new file mode 100644 (file)
index 0000000..cb45d40
--- /dev/null
@@ -0,0 +1,5 @@
+aspect X {
+  before(): execution(* run(..)) {
+    System.out.println("advice running");
+  }
+}
index 135eb84643f23bcfc80ed5e252efac72a39106c6..cc9800043e9a3f3da8616833a53e6ba31892e940 100644 (file)
  *******************************************************************************/
 package org.aspectj.systemtest.ajc185;
 
+import java.io.BufferedInputStream;
 import java.io.File;
+import java.io.FileInputStream;
 
 import junit.framework.Test;
 
+import org.aspectj.apache.bcel.classfile.JavaClass;
+import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen;
+import org.aspectj.org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
 import org.aspectj.testing.XMLBasedAjcTestCase;
 
 /**
@@ -21,6 +26,30 @@ import org.aspectj.testing.XMLBasedAjcTestCase;
  */
 public class Ajc185Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
 
+       public void testUnresolvableMember_456357() throws Exception {
+               runTest("unresolvable member");
+       }
+       
+       // Waiting on JDT fix. Second test is a 'variant' that is also causing me issues but not JDT it seems. Let's
+       // see what happens when we pick up the real fixes.
+//     public void testBadAnnos_455608() throws Exception {
+//             runTest("bad annos");
+//             JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), "Code2");
+//             File f = new File(ajc.getSandboxDirectory(), "Code2.class");
+//             byte[] data = loadFileAsByteArray(f);
+//             // Will throw ClassFormatException if there is a problem
+//             new ClassFileReader(data, null);
+//     }
+//     
+//     public void testBadAnnos_455608_2() throws Exception {
+//             runTest("bad annos 2");
+//             JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), "Code3");
+//             File f = new File(ajc.getSandboxDirectory(), "Code3.class");
+//             byte[] data = loadFileAsByteArray(f);
+//             // Will throw ClassFormatException if there is a problem
+//             new ClassFileReader(data, null);
+//     }
+       
        public void testITDInterface_451966() throws Exception {
                runTest("itd interface");
        }
index 7c30d7bf4a01ad80ddd0d85331dd258bd5a013b5..15fee4e8400a613bdf3e33381e33bf16d3c90cb5 100644 (file)
@@ -2,6 +2,23 @@
 
 <suite>
 
+<ajc-test dir="bugs185/456357" title="unresolvable member">
+<compile files="DummyClass.java LogMe.java SampleAspect.java SampleUtil.java" options="-1.7">
+</compile>
+</ajc-test>
+
+<ajc-test dir="bugs185/455608" title="bad annos">
+<compile files="Code2.java" options="-1.8 -proceedOnError">
+  <message kind="error" text="String cannot be resolved to a variable"/>
+</compile>
+</ajc-test>
+
+<ajc-test dir="bugs185/455608" title="bad annos 2">
+<compile files="Code3.java" options="-1.8 -proceedOnError">
+  <message kind="error" text="String cannot be resolved to a variable"/>
+</compile>
+</ajc-test>
+
 <ajc-test dir="bugs185/451966" title="itd interface">
 <compile files="Code.java" options="-1.8"/>
 <run class="Code">
index 40bc9322ab853c1cf7da98063478a6bd3605c13b..7080c03c9562c507b6354f0a9f3a2253c321dd3c 100644 (file)
@@ -3570,6 +3570,19 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa
                build("PR154054");
                checkWasntFullBuild();
        }
+       
+       public void testIncrementalBuildAdviceChange_456801() throws Exception {
+               initialiseProject("456801");
+               build("456801");
+               String output = runMethod("456801", "Code", "run");
+               assertEquals("advice runnning\nrun() running\n",output);
+               alter("456801", "inc1");
+               build("456801");
+               output = runMethod("456801", "Code", "run");
+               assertEquals("advice running\nrun() running\n",output);
+               checkCompileWeaveCount("456801", 1, 1);
+               checkWasntFullBuild();
+       }
 
        // change exception type in around advice, does it notice?
        public void testShouldFullBuildOnExceptionChange_pr154054() {