From 6870da4cbcfbf6b2ec267d50e2bcc04fd32bcaeb Mon Sep 17 00:00:00 2001 From: aclement Date: Fri, 17 Nov 2006 11:18:59 +0000 Subject: [PATCH] tests and fixes for pr164384 --- tests/bugs153/pr164384/Hello.java | 15 +++ tests/bugs153/pr164384/MainClass.java | 11 +++ tests/bugs153/pr164384/MyAnnotation.java | 9 ++ tests/bugs153/pr164384/README.txt | 5 + tests/bugs153/pr164384/WorldAspect.aj | 13 +++ tests/bugs153/pr164384/library.jar | Bin 0 -> 1069 bytes tests/bugs153/pr164384_2/MainClass.java | 9 ++ .../multiIncremental/PR164384/base/Hello.java | 10 ++ .../PR164384/base/MainClass.java | 11 +++ .../PR164384/base/MyAnnotation.java | 9 ++ .../PR164384/base/WorldAspect.aj | 13 +++ .../systemtest/ajc153/Ajc153Tests.java | 6 ++ .../org/aspectj/systemtest/ajc153/ajc153.xml | 30 ++++++ .../tools/AjdeInteractionTestbed.java | 18 +++- .../tools/MultiProjectIncrementalTests.java | 93 ++++++++++++++++++ 15 files changed, 250 insertions(+), 2 deletions(-) create mode 100644 tests/bugs153/pr164384/Hello.java create mode 100644 tests/bugs153/pr164384/MainClass.java create mode 100644 tests/bugs153/pr164384/MyAnnotation.java create mode 100644 tests/bugs153/pr164384/README.txt create mode 100644 tests/bugs153/pr164384/WorldAspect.aj create mode 100644 tests/bugs153/pr164384/library.jar create mode 100644 tests/bugs153/pr164384_2/MainClass.java create mode 100644 tests/multiIncremental/PR164384/base/Hello.java create mode 100644 tests/multiIncremental/PR164384/base/MainClass.java create mode 100644 tests/multiIncremental/PR164384/base/MyAnnotation.java create mode 100644 tests/multiIncremental/PR164384/base/WorldAspect.aj 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 0000000000000000000000000000000000000000..baa98fa958c6aef10b58eb203ff8cd4cc182ffce GIT binary patch literal 1069 zcmWIWW@Zs#-~ht>)_hY2Bp|}T!r-O&y1H)(EGpBvL zb@eXtdh2SPJ9B<>kiiw>2Tvb8Wnu{MX6M*c&-6|jXp|%n2f!_u5{YVo7*Mt#J6+$m z(lIYDza+6FGe1u+IVZ8WIJd{1pV3j^==}#W&;2z-l>#+l7lnEXuud$vxMG@*UiGzk z8_GM^FZ;k)qp?xMFL9Fj;uC2e1wjjiZr}cU-d99Ea`uC&ByMr>$qCzJzH_wfncDpQ$%DEw&eUq@Yv0#s zMGGwMy2TCh|C5OACVPOslVL>mzY5;?^sF#e5%sAKZ1U9PBW_T{b8sRoGzAjw}YQ^ zz0Ky&Y0viF{8{()t8{~Ug}?#jE6dX#|7bm9B)q^WV{TWmV7gQP|XJP1S*>dFMWFYW{S$^?MYKSovaO4p6GK~7qf>!` z#?qV*2hxsxUay`SHSlu3uiuES+nlcf|~Ei?ya&PHWbW1 zZhlYecEjQswj0;m{c8HK$j3b=TlGb9XYS)&4S$WQ4{@d2nuv$$e(QT7o9wsXH|OfN zXV33=%Kv9?KSy=*ce$@o7u)CC>v?&(-+vf(UF=h5K>8+*)o-kI9;$3#zfx?H-u9ys zg?kR^-%MM%yQlqw-bIyF1<&FvfBlUIMfb{?y3;oSqq>?26y1zWA`FNeg`5>YISLiv z%3sK)fU*s8f&yh51V{ujv1cM=GeAiX*_EKAhX9E{w}Z?;N{9j8tZX0!%s_Y?NCz;3 FcmNlxkUIbX literal 0 HcmV?d00001 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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ 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 --- -- 2.39.5