aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authoraclement <aclement>2010-08-23 20:44:31 +0000
committeraclement <aclement>2010-08-23 20:44:31 +0000
commite3e9be9ad4e035ae65de845c0a8cfaefe5c8b822 (patch)
tree78242c9a9d0c1e9f81582f66815d71933f83d898 /tests
parent701e6bd6988b9a60b68a45c9d750605c873c26c2 (diff)
downloadaspectj-e3e9be9ad4e035ae65de845c0a8cfaefe5c8b822.tar.gz
aspectj-e3e9be9ad4e035ae65de845c0a8cfaefe5c8b822.zip
323438
Diffstat (limited to 'tests')
-rw-r--r--tests/features1610/makeSJPOptimization/Azpect.aj5
-rw-r--r--tests/features1610/makeSJPOptimization/B.java29
-rw-r--r--tests/src/org/aspectj/systemtest/ajc1610/AllTestsAspectJ1610.java1
-rw-r--r--tests/src/org/aspectj/systemtest/ajc1610/NewFeatures.java148
-rw-r--r--tests/src/org/aspectj/systemtest/ajc1610/newfeatures-tests.xml100
5 files changed, 283 insertions, 0 deletions
diff --git a/tests/features1610/makeSJPOptimization/Azpect.aj b/tests/features1610/makeSJPOptimization/Azpect.aj
new file mode 100644
index 000000000..d57dc2b07
--- /dev/null
+++ b/tests/features1610/makeSJPOptimization/Azpect.aj
@@ -0,0 +1,5 @@
+public aspect Azpect {
+ before() : execution(* *(..)) {
+ System.out.println(thisJoinPoint.toLongString());
+ }
+}
diff --git a/tests/features1610/makeSJPOptimization/B.java b/tests/features1610/makeSJPOptimization/B.java
new file mode 100644
index 000000000..9cd1655b7
--- /dev/null
+++ b/tests/features1610/makeSJPOptimization/B.java
@@ -0,0 +1,29 @@
+public class B{
+ public static void main(String args[]) throws Throwable{
+ B b = new B();
+ b.method1(null);
+ b.method2(null,null);
+ b.method3();
+ method4();
+
+ }
+
+
+
+ public Object method1(String p1){
+ return "Hola";
+ }
+
+ public Object method2(String p1, Integer p2) throws Exception{
+ return "Hola";
+ }
+
+ private void method3(){
+ return;
+ }
+
+ public static void method4(){
+ return;
+ }
+
+}
diff --git a/tests/src/org/aspectj/systemtest/ajc1610/AllTestsAspectJ1610.java b/tests/src/org/aspectj/systemtest/ajc1610/AllTestsAspectJ1610.java
index dfbf422f2..2dd2ebf1e 100644
--- a/tests/src/org/aspectj/systemtest/ajc1610/AllTestsAspectJ1610.java
+++ b/tests/src/org/aspectj/systemtest/ajc1610/AllTestsAspectJ1610.java
@@ -19,6 +19,7 @@ public class AllTestsAspectJ1610 {
TestSuite suite = new TestSuite("AspectJ 1.6.10 tests");
// $JUnit-BEGIN$
suite.addTest(Ajc1610Tests.suite());
+ suite.addTest(NewFeatures.suite());
// $JUnit-END$
return suite;
}
diff --git a/tests/src/org/aspectj/systemtest/ajc1610/NewFeatures.java b/tests/src/org/aspectj/systemtest/ajc1610/NewFeatures.java
new file mode 100644
index 000000000..d49d0e5c9
--- /dev/null
+++ b/tests/src/org/aspectj/systemtest/ajc1610/NewFeatures.java
@@ -0,0 +1,148 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Lucierna
+ * 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:
+ * Abraham Nevado - initial API and implementation
+ *******************************************************************************/
+package org.aspectj.systemtest.ajc1610;
+
+import java.io.File;
+
+import junit.framework.Test;
+
+import org.aspectj.apache.bcel.classfile.JavaClass;
+import org.aspectj.apache.bcel.classfile.Method;
+import org.aspectj.apache.bcel.util.ClassPath;
+import org.aspectj.apache.bcel.util.SyntheticRepository;
+import org.aspectj.testing.XMLBasedAjcTestCase;
+
+public class NewFeatures extends org.aspectj.testing.XMLBasedAjcTestCase {
+
+ public void testMakeSJPOptimizationLDCNo() {
+ this.
+ runTest("makeSJP optimization - LDC - No");
+ try {
+ JavaClass myClass = getMyClass("B");
+ Method preClinitMethod = getPreClinitMethod(myClass);
+ NewFeatures.assertTrue("For 1.4 it must use classForName", preClinitMethod.getCode().toString().contains("forName"));
+ } catch (Exception e) {
+ NewFeatures.fail(e.toString());
+ }
+ }
+
+ public void testMakeSJPOptimizationLDCYes() {
+ this.
+ runTest("makeSJP optimization - LDC - Yes");
+ try {
+ JavaClass myClass = getMyClass("B");
+ Method preClinitMethod = getPreClinitMethod(myClass);
+ NewFeatures.assertTrue("For 1.5 it must not use classForName", !preClinitMethod.getCode().toString().contains("forName"));
+ } catch (Exception e) {
+ NewFeatures.fail(e.toString());
+ }
+ }
+
+ public void testMakeSJPOptimizationCollapsedSJPYes() {
+ this.
+ runTest("makeSJP optimization - Collapsed SJP - Yes");
+ try {
+ JavaClass myClass = getMyClass("B");
+ Method preClinitMethod = getPreClinitMethod(myClass);
+ NewFeatures.assertTrue("MakedMethodSig MUST not be present", !preClinitMethod.getCode().toString().contains("makeMethodSig"));
+ } catch (Exception e) {
+ NewFeatures.fail(e.toString());
+ }
+ }
+
+ public void testMakeSJPOptimizationCollapsedSJPNo() {
+ this.
+ runTest("makeSJP optimization - Collapsed SJP - No");
+ try {
+ JavaClass myClass = getMyClass("B");
+ Method preClinitMethod = getPreClinitMethod(myClass);
+ NewFeatures.assertTrue("MakedMethodSig required", preClinitMethod.getCode().toString().contains("makeMethodSig"));
+ } catch (Exception e) {
+ NewFeatures.fail(e.toString());
+ }
+ }
+
+
+ public void testMakeSJPOptimizationNoExceptionNo() {
+ this.
+ runTest("makeSJP optimization - No Exception - No");
+ try {
+ JavaClass myClass = getMyClass("B");
+ Method preClinitMethod = getPreClinitMethod(myClass);
+ NewFeatures.assertTrue("MakedMethodSig required", preClinitMethod.getCode().toString().contains("invokevirtual org.aspectj.runtime.reflect.Factory.makeMethodSig (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Lorg/aspectj/lang/reflect/MethodSignature;"));
+ } catch (Exception e) {
+ NewFeatures.fail(e.toString());
+ }
+ }
+
+ public void testMakeSJPOptimizationNoExceptionYes() {
+ this.
+ runTest("makeSJP optimization - No Exception - Yes");
+ try {
+ JavaClass myClass = getMyClass("B");
+ Method preClinitMethod = getPreClinitMethod(myClass);
+ NewFeatures.assertTrue("MakedMethodSig required", preClinitMethod.getCode().toString().contains("org.aspectj.runtime.reflect.Factory.makeSJP (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)Lorg/aspectj/lang/JoinPoint$StaticPart;"));
+ } catch (Exception e) {
+ NewFeatures.fail(e.toString());
+ }
+ }
+
+ public void testMakeSJPOptimizationRemoveExtraColon() {
+ this.
+ runTest("makeSJP optimization - Remove Colon");
+ try {
+ JavaClass myClass = getMyClass("B");
+ Method preClinitMethod = getPreClinitMethod(myClass);
+ System.out.println(preClinitMethod.getCode().toString());
+ NewFeatures.assertTrue("MakedMethodSig required", preClinitMethod.getCode().toString().contains("50: ldc \"java.lang.String\" (108)"));
+ } catch (Exception e) {
+ NewFeatures.fail(e.toString());
+ }
+ }
+
+
+ /////////////////////////////////////////
+
+ private Method getPreClinitMethod(JavaClass myClass){
+ Method lm[] =myClass.getMethods();
+ for(int i=0; i< lm.length; i++ ){
+ if(lm[i].getName().equals("ajc$preClinit")){
+ return lm[i];
+ }
+ }
+ return null;
+}
+
+ public static Test suite() {
+ return XMLBasedAjcTestCase.loadSuite(NewFeatures.class);
+ }
+
+ private JavaClass getMyClass(String className) throws ClassNotFoundException{
+ return getClassFrom(ajc.getSandboxDirectory(), className);
+ }
+
+
+ public SyntheticRepository createRepos(File cpentry) {
+ ClassPath cp = new ClassPath(cpentry + File.pathSeparator + System.getProperty("java.class.path"));
+ return SyntheticRepository.getInstance(cp);
+ }
+
+ protected JavaClass getClassFrom(File where, String clazzname) throws ClassNotFoundException {
+ SyntheticRepository repos = createRepos(where);
+ return repos.loadClass(clazzname);
+ }
+
+ protected File getSpecFile() {
+ return new File("../tests/src/org/aspectj/systemtest/ajc1610/newfeatures-tests.xml");
+ }
+
+
+} \ No newline at end of file
diff --git a/tests/src/org/aspectj/systemtest/ajc1610/newfeatures-tests.xml b/tests/src/org/aspectj/systemtest/ajc1610/newfeatures-tests.xml
new file mode 100644
index 000000000..513fad0f5
--- /dev/null
+++ b/tests/src/org/aspectj/systemtest/ajc1610/newfeatures-tests.xml
@@ -0,0 +1,100 @@
+<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"[]>
+
+<!-- AspectJ v1.6.0 Tests -->
+<suite>
+
+"makeSJP optimization - LDC - YES
+
+
+
+ <ajc-test dir="features1610/makeSJPOptimization" title="makeSJP optimization - LDC - No">
+ <compile files="B.java Azpect.aj" options="-1.4"/>
+ <run class="B">
+ <stdout>
+ <line text="execution(public static void B.main(java.lang.String[]))"/>
+ <line text="execution(public java.lang.Object B.method1(java.lang.String))"/>
+ <line text="execution(public java.lang.Object B.method2(java.lang.String, java.lang.Integer))"/>
+ <line text="execution(private void B.method3())"/>
+ <line text="execution(public static void B.method4())"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="features1610/makeSJPOptimization" title="makeSJP optimization - LDC - Yes">
+ <compile files="B.java Azpect.aj" options="-1.5"/>
+ <run class="B">
+ <stdout>
+ <line text="execution(public static void B.main(java.lang.String[]))"/>
+ <line text="execution(public java.lang.Object B.method1(java.lang.String))"/>
+ <line text="execution(public java.lang.Object B.method2(java.lang.String, java.lang.Integer))"/>
+ <line text="execution(private void B.method3())"/>
+ <line text="execution(public static void B.method4())"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="features1610/makeSJPOptimization" title="makeSJP optimization - Collapsed SJP - Yes">
+ <compile files="B.java Azpect.aj" options="-1.5 -Xset:targetRuntime1_6_10=true"/>
+ <run class="B">
+ <stdout>
+ <line text="execution(public static void B.main(java.lang.String[]))"/>
+ <line text="execution(public java.lang.Object B.method1(java.lang.String))"/>
+ <line text="execution(public java.lang.Object B.method2(java.lang.String, java.lang.Integer))"/>
+ <line text="execution(private void B.method3())"/>
+ <line text="execution(public static void B.method4())"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="features1610/makeSJPOptimization" title="makeSJP optimization - Collapsed SJP - No">
+ <compile files="B.java Azpect.aj" options="-1.5 -Xset:targetRuntime1_6_10=false"/>
+ <run class="B">
+ <stdout>
+ <line text="execution(public static void B.main(java.lang.String[]))"/>
+ <line text="execution(public java.lang.Object B.method1(java.lang.String))"/>
+ <line text="execution(public java.lang.Object B.method2(java.lang.String, java.lang.Integer))"/>
+ <line text="execution(private void B.method3())"/>
+ <line text="execution(public static void B.method4())"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="features1610/makeSJPOptimization" title="makeSJP optimization - No Exception - No">
+ <compile files="B.java Azpect.aj" options="-1.5 -Xset:targetRuntime1_6_10=false"/>
+ <run class="B">
+ <stdout>
+ <line text="execution(public static void B.main(java.lang.String[]))"/>
+ <line text="execution(public java.lang.Object B.method1(java.lang.String))"/>
+ <line text="execution(public java.lang.Object B.method2(java.lang.String, java.lang.Integer))"/>
+ <line text="execution(private void B.method3())"/>
+ <line text="execution(public static void B.method4())"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="features1610/makeSJPOptimization" title="makeSJP optimization - No Exception - Yes">
+ <compile files="B.java Azpect.aj" options="-1.5 -Xset:targetRuntime1_6_10=true"/>
+ <run class="B">
+ <stdout>
+ <line text="execution(public static void B.main(java.lang.String[]))"/>
+ <line text="execution(public java.lang.Object B.method1(java.lang.String))"/>
+ <line text="execution(public java.lang.Object B.method2(java.lang.String, java.lang.Integer))"/>
+ <line text="execution(private void B.method3())"/>
+ <line text="execution(public static void B.method4())"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="features1610/makeSJPOptimization" title="makeSJP optimization - Remove Colon">
+ <compile files="B.java Azpect.aj" options="-1.5"/>
+ <run class="B">
+ <stdout>
+ <line text="execution(public static void B.main(java.lang.String[]))"/>
+ <line text="execution(public java.lang.Object B.method1(java.lang.String))"/>
+ <line text="execution(public java.lang.Object B.method2(java.lang.String, java.lang.Integer))"/>
+ <line text="execution(private void B.method3())"/>
+ <line text="execution(public static void B.method4())"/>
+ </stdout>
+ </run>
+ </ajc-test>
+</suite>