aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAndy Clement <aclement@pivotal.io>2018-09-29 07:47:57 -0700
committerAndy Clement <aclement@pivotal.io>2018-09-29 07:47:57 -0700
commitf6d9aaaf05eca3aaf06d3a769a83f302b0501dca (patch)
treef2f8b3c99f0bd2a77a570f1bf230c2d7aca23647 /tests
parent8aeb774d210a42240f2d6d89dd89e947a084fd7f (diff)
downloadaspectj-f6d9aaaf05eca3aaf06d3a769a83f302b0501dca.tar.gz
aspectj-f6d9aaaf05eca3aaf06d3a769a83f302b0501dca.zip
1.9.2.RC1 changesV1_9_2_RC1
Diffstat (limited to 'tests')
-rw-r--r--tests/bugs192/535156/DemoApp.java15
-rw-r--r--tests/bugs192/535156/DemoApp2.java15
-rw-r--r--tests/bugs192/537825/Code.java53
-rw-r--r--tests/src/org/aspectj/systemtest/AllTests19.java2
-rw-r--r--tests/src/org/aspectj/systemtest/ajc180/ajc180.xml2
-rw-r--r--tests/src/org/aspectj/systemtest/ajc1811/Ajc1811Tests.java3
-rw-r--r--tests/src/org/aspectj/systemtest/ajc190/ModuleTests.java17
-rw-r--r--tests/src/org/aspectj/systemtest/ajc192/Ajc192Tests.java3
-rw-r--r--tests/src/org/aspectj/systemtest/ajc192/AllTestsAspectJ192.java1
-rw-r--r--tests/src/org/aspectj/systemtest/ajc192/SanityTestsJava11.java99
-rw-r--r--tests/src/org/aspectj/systemtest/ajc192/sanity-tests-11.xml69
-rw-r--r--tests/src/org/aspectj/systemtest/ajc193/Ajc193Tests.java36
-rw-r--r--tests/src/org/aspectj/systemtest/ajc193/AllTestsAspectJ193.java25
-rw-r--r--tests/src/org/aspectj/systemtest/ajc193/ajc193.xml18
-rw-r--r--tests/src/org/aspectj/systemtest/apt/AptTests.java4
-rw-r--r--tests/src/org/aspectj/systemtest/incremental/tools/CompilerFactory.java7
16 files changed, 360 insertions, 9 deletions
diff --git a/tests/bugs192/535156/DemoApp.java b/tests/bugs192/535156/DemoApp.java
new file mode 100644
index 000000000..0f25c1568
--- /dev/null
+++ b/tests/bugs192/535156/DemoApp.java
@@ -0,0 +1,15 @@
+import org.aspectj.lang.annotation.*;
+
+public class DemoApp {
+ public static void main(String[]argv) {}
+ private void recurseInsteadOfWhile() {
+ say();
+ }
+
+ public void say() { }
+}
+
+aspect X { // mixed style here...
+ @Around("call(public void DemoApp+.say(..))")
+ public void y() {}
+}
diff --git a/tests/bugs192/535156/DemoApp2.java b/tests/bugs192/535156/DemoApp2.java
new file mode 100644
index 000000000..d48201be1
--- /dev/null
+++ b/tests/bugs192/535156/DemoApp2.java
@@ -0,0 +1,15 @@
+import org.aspectj.lang.annotation.*;
+
+public class DemoApp2 {
+ public static void main(String[]argv) {}
+ private void recurseInsteadOfWhile() {
+ say();
+ }
+
+ public void say() { }
+}
+
+aspect X {
+ void around(): call(public void DemoApp2+.say(..)) {
+ }
+}
diff --git a/tests/bugs192/537825/Code.java b/tests/bugs192/537825/Code.java
new file mode 100644
index 000000000..fa97b47c6
--- /dev/null
+++ b/tests/bugs192/537825/Code.java
@@ -0,0 +1,53 @@
+public class Code {
+
+ public static void main(String[] args) {
+ A.methodA();
+ }
+
+}
+
+class A {
+
+ public static void methodA() {
+ B.methodB();
+ }
+
+}
+
+class B {
+
+ public static void methodB() {
+ C.methodC();
+ int a = 1;
+ int b = 2;
+ System.out.println( a + b );
+ }
+
+}
+
+class C {
+
+ public static void methodC() {
+ D.methodD();
+ }
+
+}
+
+class D {
+
+ public static void methodD() {
+
+ }
+
+}
+
+aspect CFlow {
+
+ public pointcut flow() : cflow(call( * B.methodB() ) ) && !within(CFlow);
+
+ before() : flow() {
+ System.out.println( thisJoinPoint );
+ }
+
+}
+
diff --git a/tests/src/org/aspectj/systemtest/AllTests19.java b/tests/src/org/aspectj/systemtest/AllTests19.java
index d46eeb6d2..c2c798c32 100644
--- a/tests/src/org/aspectj/systemtest/AllTests19.java
+++ b/tests/src/org/aspectj/systemtest/AllTests19.java
@@ -13,6 +13,7 @@ package org.aspectj.systemtest;
import org.aspectj.systemtest.ajc190.AllTestsAspectJ190;
import org.aspectj.systemtest.ajc191.AllTestsAspectJ191;
import org.aspectj.systemtest.ajc192.AllTestsAspectJ192;
+import org.aspectj.systemtest.ajc193.AllTestsAspectJ193;
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -25,6 +26,7 @@ public class AllTests19 {
suite.addTest(AllTestsAspectJ190.suite());
suite.addTest(AllTestsAspectJ191.suite());
suite.addTest(AllTestsAspectJ192.suite());
+ suite.addTest(AllTestsAspectJ193.suite());
suite.addTest(AllTests18.suite());
// $JUnit-END$
return suite;
diff --git a/tests/src/org/aspectj/systemtest/ajc180/ajc180.xml b/tests/src/org/aspectj/systemtest/ajc180/ajc180.xml
index f69d97e7c..257f5972c 100644
--- a/tests/src/org/aspectj/systemtest/ajc180/ajc180.xml
+++ b/tests/src/org/aspectj/systemtest/ajc180/ajc180.xml
@@ -27,7 +27,7 @@
</ajc-test>
<ajc-test dir="bugs180/415957" title="annotations with 1.8 flags">
- <compile files="MyAspect.aj MyClass.java" options="-1.8 -showWeaveInfo">
+ <compile files="MyAspect.aj MyClass.java Resource.java" options="-1.8 -showWeaveInfo">
<message kind="weave" text="Join point 'method-execution(void MyClass.method())' in Type 'MyClass' (MyClass.java:3) advised by before advice from 'MyAspect' (MyAspect.aj:5)"/>
</compile>
</ajc-test>
diff --git a/tests/src/org/aspectj/systemtest/ajc1811/Ajc1811Tests.java b/tests/src/org/aspectj/systemtest/ajc1811/Ajc1811Tests.java
index 80729f894..9aa1bff94 100644
--- a/tests/src/org/aspectj/systemtest/ajc1811/Ajc1811Tests.java
+++ b/tests/src/org/aspectj/systemtest/ajc1811/Ajc1811Tests.java
@@ -12,10 +12,7 @@ package org.aspectj.systemtest.ajc1811;
import java.io.File;
-import org.aspectj.apache.bcel.Constants;
-import org.aspectj.apache.bcel.classfile.Attribute;
import org.aspectj.apache.bcel.classfile.JavaClass;
-import org.aspectj.apache.bcel.classfile.Method;
import org.aspectj.testing.XMLBasedAjcTestCase;
import org.aspectj.weaver.ResolvedMember;
import org.aspectj.weaver.ResolvedType;
diff --git a/tests/src/org/aspectj/systemtest/ajc190/ModuleTests.java b/tests/src/org/aspectj/systemtest/ajc190/ModuleTests.java
index 763d05547..08d7f500f 100644
--- a/tests/src/org/aspectj/systemtest/ajc190/ModuleTests.java
+++ b/tests/src/org/aspectj/systemtest/ajc190/ModuleTests.java
@@ -15,6 +15,7 @@ import org.aspectj.apache.bcel.classfile.JavaClass;
import org.aspectj.apache.bcel.classfile.Method;
import org.aspectj.testing.XMLBasedAjcTestCase;
import org.aspectj.testing.XMLBasedAjcTestCaseForJava9OrLater;
+import org.aspectj.util.LangUtil;
import junit.framework.Test;
@@ -70,22 +71,38 @@ public class ModuleTests extends XMLBasedAjcTestCaseForJava9OrLater {
// This tests that when using --add-modules with one of the JDK modules (in the jmods subfolder of the JDK)
// that it can be found without needing to set --module-path (this seems to be implicitly included by javac too)
public void testAddModules1() {
+ if (LangUtil.is11VMOrGreater()) {
+ // java.xml.bind is gone in Java11
+ return;
+ }
runTest("compile use of java.xml.bind");
}
// This tests that we can use add-modules to pull in something from the JDK jmods package and that
// when subsequently weaving we can see types from those modules
public void testWovenAfterAddModules() {
+ if (LangUtil.is11VMOrGreater()) {
+ // java.xml.bind is gone in Java11
+ return;
+ }
runTest("weave use of java.xml.bind");
}
// --limit-modules
public void testLimitModules1() {
+ if (LangUtil.is11VMOrGreater()) {
+ // java.xml.bind is gone in Java11
+ return;
+ }
runTest("limit modules 1");
}
// --add-reads
public void testAddReads1() {
+ if (LangUtil.is11VMOrGreater()) {
+ // java.xml.bind is gone in Java11
+ return;
+ }
runTest("add reads 1");
}
diff --git a/tests/src/org/aspectj/systemtest/ajc192/Ajc192Tests.java b/tests/src/org/aspectj/systemtest/ajc192/Ajc192Tests.java
index 0629294db..66bae0c9d 100644
--- a/tests/src/org/aspectj/systemtest/ajc192/Ajc192Tests.java
+++ b/tests/src/org/aspectj/systemtest/ajc192/Ajc192Tests.java
@@ -25,7 +25,8 @@ public class Ajc192Tests extends XMLBasedAjcTestCase {
runTest("no final on cflow elements");
}
- public void testAroundAdvice_AnnoStyle() {
+ // TODO Still to be fixed, the workaround to not mix style is good enough for now...
+ public void xtestAroundAdvice_AnnoStyle() {
runTest("around advice");
}
diff --git a/tests/src/org/aspectj/systemtest/ajc192/AllTestsAspectJ192.java b/tests/src/org/aspectj/systemtest/ajc192/AllTestsAspectJ192.java
index 396caafff..e47b11632 100644
--- a/tests/src/org/aspectj/systemtest/ajc192/AllTestsAspectJ192.java
+++ b/tests/src/org/aspectj/systemtest/ajc192/AllTestsAspectJ192.java
@@ -19,6 +19,7 @@ public class AllTestsAspectJ192 {
TestSuite suite = new TestSuite("AspectJ 1.9.2 tests");
// $JUnit-BEGIN$
suite.addTest(Ajc192Tests.suite());
+ suite.addTest(SanityTestsJava11.suite());
// $JUnit-END$
return suite;
}
diff --git a/tests/src/org/aspectj/systemtest/ajc192/SanityTestsJava11.java b/tests/src/org/aspectj/systemtest/ajc192/SanityTestsJava11.java
new file mode 100644
index 000000000..e14ec33df
--- /dev/null
+++ b/tests/src/org/aspectj/systemtest/ajc192/SanityTestsJava11.java
@@ -0,0 +1,99 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2018 Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package org.aspectj.systemtest.ajc192;
+
+import java.io.File;
+
+import org.aspectj.apache.bcel.classfile.JavaClass;
+import org.aspectj.testing.XMLBasedAjcTestCase;
+import org.aspectj.testing.XMLBasedAjcTestCaseForJava11OrLater;
+
+import junit.framework.Test;
+
+/*
+ * Some very trivial tests that help verify things are OK.
+ * These are a copy of the earlier Sanity Tests created for 1.6 but these supply the -10 option
+ * to check code generation and modification with that version specified.
+ *
+ * @author Andy Clement
+ */
+public class SanityTestsJava11 extends XMLBasedAjcTestCaseForJava11OrLater {
+
+ // Incredibly trivial test programs that check the compiler works at all (these are easy-ish to debug)
+ public void testSimpleJava_A() {
+ runTest("simple - a");
+ }
+
+ public void testSimpleJava_B() {
+ runTest("simple - b");
+ }
+
+ public void testSimpleCode_C() {
+ runTest("simple - c");
+ }
+
+ public void testSimpleCode_D() {
+ runTest("simple - d");
+ }
+
+ public void testSimpleCode_E() {
+ runTest("simple - e");
+ }
+
+ public void testSimpleCode_F() {
+ runTest("simple - f");
+ }
+
+ public void testSimpleCode_G() {
+ runTest("simple - g");
+ }
+
+ public void testSimpleCode_H() {
+ runTest("simple - h", true);
+ }
+
+ public void testSimpleCode_I() {
+ runTest("simple - i");
+ }
+
+ public void testVersionCorrect1() throws ClassNotFoundException {
+ runTest("simple - j");
+ checkVersion("A", 55, 0);
+ }
+
+ public void testVersionCorrect2() throws ClassNotFoundException {
+ runTest("simple - k");
+ checkVersion("A", 55, 0);
+ }
+
+ public void testVersionCorrect4() throws ClassNotFoundException { // check it is 49.0 when -1.5 is specified
+ runTest("simple - m");
+ checkVersion("A", 49, 0);
+ }
+
+ private void checkVersion(String classname, int major, int minor) throws ClassNotFoundException {
+ JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), classname);
+ if (jc.getMajor() != major) {
+ fail("Expected major version to be " + major + " but was " + jc.getMajor());
+ }
+ if (jc.getMinor() != minor) {
+ fail("Expected minor version to be " + minor + " but was " + jc.getMinor());
+ }
+ }
+
+ // ///////////////////////////////////////
+ public static Test suite() {
+ return XMLBasedAjcTestCase.loadSuite(SanityTestsJava11.class);
+ }
+
+ @Override
+ protected File getSpecFile() {
+ return getClassResource("sanity-tests-11.xml");
+ }
+
+}
diff --git a/tests/src/org/aspectj/systemtest/ajc192/sanity-tests-11.xml b/tests/src/org/aspectj/systemtest/ajc192/sanity-tests-11.xml
new file mode 100644
index 000000000..cdce29082
--- /dev/null
+++ b/tests/src/org/aspectj/systemtest/ajc192/sanity-tests-11.xml
@@ -0,0 +1,69 @@
+<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"[]>
+
+<suite>
+
+ <!-- empty class -->
+ <ajc-test dir="bugs160/simplejava" title="simple - a">
+ <compile files="SimpleA.java" options="-11"/>
+ </ajc-test>
+
+ <!-- class with one method -->
+ <ajc-test dir="bugs160/simplejava" title="simple - b">
+ <compile files="SimpleB.java" options="-11"/>
+ <run class="SimpleB"/>
+ </ajc-test>
+
+ <!-- empty aspect -->
+ <ajc-test dir="bugs160/simplejava" title="simple - c">
+ <compile files="SimpleC.java" options="-11"/>
+ </ajc-test>
+
+ <!-- simple before -->
+ <ajc-test dir="bugs160/simplejava" title="simple - d">
+ <compile files="SimpleD.java" options="-11"/>
+ </ajc-test>
+
+ <!-- simple itd field -->
+ <ajc-test dir="bugs160/simplejava" title="simple - e">
+ <compile files="SimpleE.java" options="-11"/>
+ </ajc-test>
+
+ <!-- aspect with main calling a static method -->
+ <ajc-test dir="bugs160/simplejava" title="simple - f">
+ <compile files="SimpleF.java" options="-11"/>
+ </ajc-test>
+
+ <!-- pertarget -->
+ <ajc-test dir="bugs160/simplejava" title="simple - g">
+ <compile files="SimpleG.java" options="-11"/>
+ </ajc-test>
+
+ <!-- generic ctor itds -->
+ <ajc-test dir="bugs160/simplejava" title="simple - h">
+ <compile files="SimpleH.java" options="-11"/>
+ </ajc-test>
+
+ <!-- overriding generic itd methods -->
+ <ajc-test dir="bugs160/simplejava" title="simple - i">
+ <compile files="SimpleI.java" options="-11"/>
+ </ajc-test>
+
+ <!-- check class file version is 54.0 -->
+ <ajc-test dir="bugs160/simplejava" title="simple - j">
+ <compile files="SimpleJ.java" options="-11"/>
+ </ajc-test>
+
+ <!-- check class file version is 54.0 -->
+ <ajc-test dir="bugs160/simplejava" title="simple - k">
+ <compile files="SimpleJ.java" options="-source 11"/>
+ </ajc-test>
+
+ <!-- check class file version is 49.0 -->
+ <ajc-test dir="bugs160/simplejava" title="simple - m">
+ <compile files="SimpleJ.java" options="-1.5"/>
+ </ajc-test>
+
+ <ajc-test dir="bugs160/simplejava" title="simple - n">
+ <compile files="SimpleN.java" options="-11"/>
+ </ajc-test>
+</suite>
diff --git a/tests/src/org/aspectj/systemtest/ajc193/Ajc193Tests.java b/tests/src/org/aspectj/systemtest/ajc193/Ajc193Tests.java
new file mode 100644
index 000000000..c813de6f3
--- /dev/null
+++ b/tests/src/org/aspectj/systemtest/ajc193/Ajc193Tests.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andy Clement - initial API and implementation
+ *******************************************************************************/
+package org.aspectj.systemtest.ajc193;
+
+import java.io.File;
+
+import org.aspectj.testing.XMLBasedAjcTestCase;
+import org.aspectj.testing.XMLBasedAjcTestCaseForJava10OrLater;
+
+import junit.framework.Test;
+
+/**
+ * @author Andy Clement
+ */
+public class Ajc193Tests extends XMLBasedAjcTestCaseForJava10OrLater {
+
+ // ---
+
+ public static Test suite() {
+ return XMLBasedAjcTestCase.loadSuite(Ajc193Tests.class);
+ }
+
+ @Override
+ protected File getSpecFile() {
+ return getClassResource("ajc193.xml");
+ }
+
+}
diff --git a/tests/src/org/aspectj/systemtest/ajc193/AllTestsAspectJ193.java b/tests/src/org/aspectj/systemtest/ajc193/AllTestsAspectJ193.java
new file mode 100644
index 000000000..62cfcccb2
--- /dev/null
+++ b/tests/src/org/aspectj/systemtest/ajc193/AllTestsAspectJ193.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andy Clement - initial API and implementation
+ *******************************************************************************/
+package org.aspectj.systemtest.ajc193;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class AllTestsAspectJ193 {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite("AspectJ 1.9.3 tests");
+ // $JUnit-BEGIN$
+ suite.addTest(Ajc193Tests.suite());
+ // $JUnit-END$
+ return suite;
+ }
+}
diff --git a/tests/src/org/aspectj/systemtest/ajc193/ajc193.xml b/tests/src/org/aspectj/systemtest/ajc193/ajc193.xml
new file mode 100644
index 000000000..b214fe51f
--- /dev/null
+++ b/tests/src/org/aspectj/systemtest/ajc193/ajc193.xml
@@ -0,0 +1,18 @@
+<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"[]>
+
+<suite>
+
+<!--
+ <ajc-test dir="bugs191/var" title="var 3">
+ <compile files="Code3.java" options="-10">
+ </compile>
+ <run class="Code3">
+ <stdout>
+ <line text="call(Class java.lang.Object.getClass())"/>
+ <line text="class java.lang.String"/>
+ </stdout>
+ </run>
+ </ajc-test>
+-->
+
+</suite>
diff --git a/tests/src/org/aspectj/systemtest/apt/AptTests.java b/tests/src/org/aspectj/systemtest/apt/AptTests.java
index 14de6b12f..01ab16ca0 100644
--- a/tests/src/org/aspectj/systemtest/apt/AptTests.java
+++ b/tests/src/org/aspectj/systemtest/apt/AptTests.java
@@ -42,6 +42,10 @@ public class AptTests extends XMLBasedAjcTestCase {
}
public void testDisabledApt() {
+ if (LangUtil.is11VMOrGreater()) {
+ // javax.annotation.Generated not in Java11
+ return;
+ }
runTest("disabled annotation processing");
}
diff --git a/tests/src/org/aspectj/systemtest/incremental/tools/CompilerFactory.java b/tests/src/org/aspectj/systemtest/incremental/tools/CompilerFactory.java
index d63527ef5..3b243d5b8 100644
--- a/tests/src/org/aspectj/systemtest/incremental/tools/CompilerFactory.java
+++ b/tests/src/org/aspectj/systemtest/incremental/tools/CompilerFactory.java
@@ -22,7 +22,7 @@ import org.aspectj.ajde.core.AjCompiler;
*/
public class CompilerFactory {
- private static Map compilerMap = new Hashtable();
+ private static Map<String,AjCompiler> compilerMap = new Hashtable<>();
/**
* If an AjCompiler exists for the given projectDir then returns
@@ -48,9 +48,8 @@ public class CompilerFactory {
* IncrementalStateManager)
*/
public static void clearCompilerMap() {
- Collection compilers = compilerMap.values();
- for (Iterator iterator = compilers.iterator(); iterator.hasNext();) {
- AjCompiler compiler = (AjCompiler) iterator.next();
+ Collection<AjCompiler> compilers = compilerMap.values();
+ for (AjCompiler compiler: compilers) {
compiler.clearLastState();
}
compilerMap.clear();