aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraclement <aclement>2006-11-17 11:18:59 +0000
committeraclement <aclement>2006-11-17 11:18:59 +0000
commit6870da4cbcfbf6b2ec267d50e2bcc04fd32bcaeb (patch)
tree0cebe8f8a0614697f4e6bb09785f747517ab468a
parent39c89755c36f19f98c4775a0a7369c7bd810435a (diff)
downloadaspectj-6870da4cbcfbf6b2ec267d50e2bcc04fd32bcaeb.tar.gz
aspectj-6870da4cbcfbf6b2ec267d50e2bcc04fd32bcaeb.zip
tests and fixes for pr164384
-rw-r--r--tests/bugs153/pr164384/Hello.java15
-rw-r--r--tests/bugs153/pr164384/MainClass.java11
-rw-r--r--tests/bugs153/pr164384/MyAnnotation.java9
-rw-r--r--tests/bugs153/pr164384/README.txt5
-rw-r--r--tests/bugs153/pr164384/WorldAspect.aj13
-rw-r--r--tests/bugs153/pr164384/library.jarbin0 -> 1069 bytes
-rw-r--r--tests/bugs153/pr164384_2/MainClass.java9
-rw-r--r--tests/multiIncremental/PR164384/base/Hello.java10
-rw-r--r--tests/multiIncremental/PR164384/base/MainClass.java11
-rw-r--r--tests/multiIncremental/PR164384/base/MyAnnotation.java9
-rw-r--r--tests/multiIncremental/PR164384/base/WorldAspect.aj13
-rw-r--r--tests/src/org/aspectj/systemtest/ajc153/Ajc153Tests.java6
-rw-r--r--tests/src/org/aspectj/systemtest/ajc153/ajc153.xml30
-rw-r--r--tests/src/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java18
-rw-r--r--tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java93
15 files changed, 250 insertions, 2 deletions
diff --git a/tests/bugs153/pr164384/Hello.java b/tests/bugs153/pr164384/Hello.java
new file mode 100644
index 000000000..c5d23b9df
--- /dev/null
+++ b/tests/bugs153/pr164384/Hello.java
@@ -0,0 +1,15 @@
+package pkg;
+
+public class Hello {
+
+ @MyAnnotation
+ public void sayHello() {
+ System.out.println("hello");
+ int counter = 0;
+ for (int i = 0; i < 10; i++) {
+ counter = i;
+ }
+
+ }
+
+}
diff --git a/tests/bugs153/pr164384/MainClass.java b/tests/bugs153/pr164384/MainClass.java
new file mode 100644
index 000000000..f809d4ef5
--- /dev/null
+++ b/tests/bugs153/pr164384/MainClass.java
@@ -0,0 +1,11 @@
+package pack;
+
+import pkg.Hello;
+
+public class MainClass {
+
+ public static void main(String[] args) {
+ new Hello().sayHello();
+ }
+
+}
diff --git a/tests/bugs153/pr164384/MyAnnotation.java b/tests/bugs153/pr164384/MyAnnotation.java
new file mode 100644
index 000000000..fc10a566c
--- /dev/null
+++ b/tests/bugs153/pr164384/MyAnnotation.java
@@ -0,0 +1,9 @@
+package pkg;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Target;
+
+@Target(ElementType.METHOD)
+public @interface MyAnnotation {
+
+}
diff --git a/tests/bugs153/pr164384/README.txt b/tests/bugs153/pr164384/README.txt
new file mode 100644
index 000000000..f676dd47a
--- /dev/null
+++ b/tests/bugs153/pr164384/README.txt
@@ -0,0 +1,5 @@
+to build library.jar:
+
+Compile the classes with a java6 jvm: javac Hello.java MyAnnotation.java
+
+Create the jar file: jar cf library.jar Hello.class MyAnnotation.class
diff --git a/tests/bugs153/pr164384/WorldAspect.aj b/tests/bugs153/pr164384/WorldAspect.aj
new file mode 100644
index 000000000..781e804e6
--- /dev/null
+++ b/tests/bugs153/pr164384/WorldAspect.aj
@@ -0,0 +1,13 @@
+package pack;
+
+import pkg.MyAnnotation;
+
+public aspect WorldAspect {
+
+ pointcut exec() : execution(@MyAnnotation * *.*(..));
+
+ after() returning : exec() {
+ System.out.println("world");
+ }
+
+}
diff --git a/tests/bugs153/pr164384/library.jar b/tests/bugs153/pr164384/library.jar
new file mode 100644
index 000000000..baa98fa95
--- /dev/null
+++ b/tests/bugs153/pr164384/library.jar
Binary files differ
diff --git a/tests/bugs153/pr164384_2/MainClass.java b/tests/bugs153/pr164384_2/MainClass.java
new file mode 100644
index 000000000..c3b4f2241
--- /dev/null
+++ b/tests/bugs153/pr164384_2/MainClass.java
@@ -0,0 +1,9 @@
+package pack;
+
+public class MainClass {
+
+ public static void main(String[] args) {
+
+ }
+
+}
diff --git a/tests/multiIncremental/PR164384/base/Hello.java b/tests/multiIncremental/PR164384/base/Hello.java
new file mode 100644
index 000000000..6aafc5963
--- /dev/null
+++ b/tests/multiIncremental/PR164384/base/Hello.java
@@ -0,0 +1,10 @@
+package pkg;
+
+public class Hello {
+
+ @MyAnnotation
+ public void sayHello() {
+ System.out.println("hello");
+ }
+
+}
diff --git a/tests/multiIncremental/PR164384/base/MainClass.java b/tests/multiIncremental/PR164384/base/MainClass.java
new file mode 100644
index 000000000..f809d4ef5
--- /dev/null
+++ b/tests/multiIncremental/PR164384/base/MainClass.java
@@ -0,0 +1,11 @@
+package pack;
+
+import pkg.Hello;
+
+public class MainClass {
+
+ public static void main(String[] args) {
+ new Hello().sayHello();
+ }
+
+}
diff --git a/tests/multiIncremental/PR164384/base/MyAnnotation.java b/tests/multiIncremental/PR164384/base/MyAnnotation.java
new file mode 100644
index 000000000..fc10a566c
--- /dev/null
+++ b/tests/multiIncremental/PR164384/base/MyAnnotation.java
@@ -0,0 +1,9 @@
+package pkg;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Target;
+
+@Target(ElementType.METHOD)
+public @interface MyAnnotation {
+
+}
diff --git a/tests/multiIncremental/PR164384/base/WorldAspect.aj b/tests/multiIncremental/PR164384/base/WorldAspect.aj
new file mode 100644
index 000000000..781e804e6
--- /dev/null
+++ b/tests/multiIncremental/PR164384/base/WorldAspect.aj
@@ -0,0 +1,13 @@
+package pack;
+
+import pkg.MyAnnotation;
+
+public aspect WorldAspect {
+
+ pointcut exec() : execution(@MyAnnotation * *.*(..));
+
+ after() returning : exec() {
+ System.out.println("world");
+ }
+
+}
diff --git a/tests/src/org/aspectj/systemtest/ajc153/Ajc153Tests.java b/tests/src/org/aspectj/systemtest/ajc153/Ajc153Tests.java
index cb515089e..a1927d78e 100644
--- a/tests/src/org/aspectj/systemtest/ajc153/Ajc153Tests.java
+++ b/tests/src/org/aspectj/systemtest/ajc153/Ajc153Tests.java
@@ -179,6 +179,12 @@ public class Ajc153Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
public void testNoNPEWithThrownExceptionWarningAndAtAspectj_pr161217() {runTest("NPE with thrown exception warning and at aspectj");}
+ public void testBinaryWeavingIntoJava6Library_pr164384() {runTest("binary weaving into java 6 library");}
+ public void testCompilanceJava6ThrowsUsageError_pr164384() {runTest("compliance java 6 throws usage error");}
+ public void testSourceLevelJava6ThrowsUsageError_pr164384() {runTest("source level java 6 throws usage error");}
+ public void testTargetLevelJava6ThrowsUsageError_pr164384() {runTest("target level java 6 throws usage error");}
+
+
/////////////////////////////////////////
public static Test suite() {
return XMLBasedAjcTestCase.loadSuite(Ajc153Tests.class);
diff --git a/tests/src/org/aspectj/systemtest/ajc153/ajc153.xml b/tests/src/org/aspectj/systemtest/ajc153/ajc153.xml
index 10bb31e01..6ea110e41 100644
--- a/tests/src/org/aspectj/systemtest/ajc153/ajc153.xml
+++ b/tests/src/org/aspectj/systemtest/ajc153/ajc153.xml
@@ -802,4 +802,34 @@
<compile files="AtAspectJAspect.java, C.java" options="-warn:+unusedThrown -1.5"/>
</ajc-test>
+ <ajc-test dir="bugs153/pr164384" title="binary weaving into java 6 library">
+ <compile files="MainClass.java, WorldAspect.aj" inpath="library.jar" options="-1.5 -showWeaveInfo">
+ <message kind="weave" text="Join point 'method-execution(void pkg.Hello.sayHello())' in Type 'pkg.Hello' (Hello.java:7) advised by afterReturning advice from 'pack.WorldAspect' (WorldAspect.aj:9)"/>
+ </compile>
+ </ajc-test>
+
+ <ajc-test dir="bugs153/pr164384" title="compliance java 6 throws usage error">
+ <compile files="MainClass.java" options="-1.6">
+ <message kind="error" text="-1.6"/>
+ <message kind="error" text="no sources specified"/>
+ <message kind="abort" text="AspectJ Compiler"/>
+ </compile>
+ </ajc-test>
+
+ <ajc-test dir="bugs153/pr164384" title="source level java 6 throws usage error">
+ <compile files="MainClass.java" options="-1.6">
+ <message kind="error" text="-1.6"/>
+ <message kind="error" text="no sources specified"/>
+ <message kind="abort" text="AspectJ Compiler"/>
+ </compile>
+ </ajc-test>
+
+ <ajc-test dir="bugs153/pr164384" title="target level java 6 throws usage error">
+ <compile files="MainClass.java" options="-1.6">
+ <message kind="error" text="-1.6"/>
+ <message kind="error" text="no sources specified"/>
+ <message kind="abort" text="AspectJ Compiler"/>
+ </compile>
+ </ajc-test>
+
</suite> \ No newline at end of file
diff --git a/tests/src/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java b/tests/src/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java
index bea6ed71c..be6b2c78e 100644
--- a/tests/src/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java
+++ b/tests/src/org/aspectj/systemtest/incremental/tools/AjdeInteractionTestbed.java
@@ -723,6 +723,12 @@ public class AjdeInteractionTestbed extends TestCase {
static MyBuildOptionsAdapter _instance = new MyBuildOptionsAdapter();
private MyBuildOptionsAdapter() {}
+ private Map javaOptionsMap;
+
+ public static void setJavaOptionsMap(Map options) {
+ _instance.javaOptionsMap = options;
+ }
+
public static void setNonStandardOptions(String options) {
_instance.nonstandardoptions = options;
}
@@ -731,6 +737,7 @@ public class AjdeInteractionTestbed extends TestCase {
public static void reset() {
_instance.nonstandardoptions=null;
+ _instance.javaOptionsMap = null;
}
public static BuildOptionsAdapter getInstance() {
@@ -738,10 +745,13 @@ public class AjdeInteractionTestbed extends TestCase {
}
public Map getJavaOptionsMap() {
+ if (javaOptionsMap != null && !javaOptionsMap.isEmpty() ) return javaOptionsMap;
+
Hashtable ht = new Hashtable();
ht.put("org.eclipse.jdt.core.compiler.compliance","1.5");
ht.put("org.eclipse.jdt.core.compiler.codegen.targetPlatform","1.5");
- return ht;
+ ht.put("org.eclipse.jdt.core.compiler.source","1.5");
+ return ht;
}
public boolean getUseJavacMode() {
@@ -786,11 +796,15 @@ public class AjdeInteractionTestbed extends TestCase {
}
public String getComplianceLevel() {
+ // AJDT doesn't set the compliance level directly
+ // instead it relies on the javaOptionsMap
return null;
}
public String getSourceCompatibilityLevel() {
- return "1.5";
+ // AJDT doesn't set the source compatibility level
+ // instead it relies on the javaOptionsMap
+ return null;
}
public Set getWarnings() {
diff --git a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java
index 75dfd99db..88cbff058 100644
--- a/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java
+++ b/tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java
@@ -17,10 +17,12 @@ import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
+import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
+import org.aspectj.ajde.Ajde;
import org.aspectj.ajdt.internal.compiler.lookup.EclipseFactory;
import org.aspectj.ajdt.internal.core.builder.AjState;
import org.aspectj.ajdt.internal.core.builder.IncrementalStateManager;
@@ -1579,6 +1581,97 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa
AsmManager.getDefault().setHandleProvider(handleProvider);
}
+ /**
+ * If the user has specified that they want Java 6 compliance
+ * and kept the default classfile and source file level settings
+ * (also 6.0) then expect an error saying that we don't support
+ * java 6.
+ */
+ public void testPR164384_1() {
+ Hashtable javaOptions = new Hashtable();
+ javaOptions.put("org.eclipse.jdt.core.compiler.compliance","1.6");
+ javaOptions.put("org.eclipse.jdt.core.compiler.codegen.targetPlatform","1.6");
+ javaOptions.put("org.eclipse.jdt.core.compiler.source","1.6");
+ MyBuildOptionsAdapter.setJavaOptionsMap(javaOptions);
+
+ initialiseProject("PR164384");
+ build("PR164384");
+ List errors = MyTaskListManager.getErrorMessages();
+
+ if (Ajde.getDefault().compilerIsJava6Compatible()) {
+ assertTrue("There should be no errros:\n"+errors,errors.isEmpty());
+ } else {
+ String expectedError = "Java 6.0 compliance level is unsupported";
+ String found = ((IMessage)errors.get(0)).getMessage();
+ assertEquals("Expected 'Java 6.0 compliance level is unsupported'" +
+ " error message but found " + found,expectedError,found);
+ // This is because the 'Java 6.0 compliance' error is an 'error'
+ // rather than an 'abort'. Aborts are really for compiler exceptions.
+ assertTrue("expected there to be more than the one compliance level" +
+ " error but only found that one",errors.size() > 1);
+ }
+
+ }
+
+ /**
+ * If the user has specified that they want Java 6 compliance
+ * and selected classfile and source file level settings to be
+ * 5.0 then expect an error saying that we don't support java 6.
+ */
+ public void testPR164384_2() {
+ Hashtable javaOptions = new Hashtable();
+ javaOptions.put("org.eclipse.jdt.core.compiler.compliance","1.6");
+ javaOptions.put("org.eclipse.jdt.core.compiler.codegen.targetPlatform","1.5");
+ javaOptions.put("org.eclipse.jdt.core.compiler.source","1.5");
+ MyBuildOptionsAdapter.setJavaOptionsMap(javaOptions);
+
+ initialiseProject("PR164384");
+ build("PR164384");
+ List errors = MyTaskListManager.getErrorMessages();
+ if (Ajde.getDefault().compilerIsJava6Compatible()) {
+ assertTrue("There should be no errros:\n"+errors,errors.isEmpty());
+ } else {
+ String expectedError = "Java 6.0 compliance level is unsupported";
+ String found = ((IMessage)errors.get(0)).getMessage();
+ assertEquals("Expected 'Java 6.0 compliance level is unsupported'" +
+ " error message but found " + found,expectedError,found);
+ // This is because the 'Java 6.0 compliance' error is an 'error'
+ // rather than an 'abort'. Aborts are really for compiler exceptions.
+ assertTrue("expected there to be more than the one compliance level" +
+ " error but only found that one",errors.size() > 1);
+ }
+ }
+
+ /**
+ * If the user has specified that they want Java 6 compliance
+ * and set the classfile level to be 6.0 and source file level
+ * to be 5.0 then expect an error saying that we don't support
+ * java 6.
+ */
+ public void testPR164384_3() {
+ Hashtable javaOptions = new Hashtable();
+ javaOptions.put("org.eclipse.jdt.core.compiler.compliance","1.6");
+ javaOptions.put("org.eclipse.jdt.core.compiler.codegen.targetPlatform","1.6");
+ javaOptions.put("org.eclipse.jdt.core.compiler.source","1.5");
+ MyBuildOptionsAdapter.setJavaOptionsMap(javaOptions);
+
+ initialiseProject("PR164384");
+ build("PR164384");
+ List errors = MyTaskListManager.getErrorMessages();
+
+ if (Ajde.getDefault().compilerIsJava6Compatible()) {
+ assertTrue("There should be no errros:\n"+errors,errors.isEmpty());
+ } else {
+ String expectedError = "Java 6.0 compliance level is unsupported";
+ String found = ((IMessage)errors.get(0)).getMessage();
+ assertEquals("Expected 'Java 6.0 compliance level is unsupported'" +
+ " error message but found " + found,expectedError,found);
+ // This is because the 'Java 6.0 compliance' error is an 'error'
+ // rather than an 'abort'. Aborts are really for compiler exceptions.
+ assertTrue("expected there to be more than the one compliance level" +
+ " error but only found that one",errors.size() > 1);
+ }
+ }
// --- helper code ---