diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/bugs195/550494/Application.java | 15 | ||||
-rw-r--r-- | tests/bugs195/550494/BaseClass.java | 19 | ||||
-rw-r--r-- | tests/bugs195/550494/Code.java | 19 | ||||
-rw-r--r-- | tests/bugs195/550494/DataSourceConnectionAspectAnno.java | 20 | ||||
-rw-r--r-- | tests/bugs195/550494/DataSourceConnectionAspectCode.java | 19 | ||||
-rw-r--r-- | tests/bugs195/550494/SubClass.java | 5 | ||||
-rw-r--r-- | tests/src/test/java/org/aspectj/systemtest/ajc195/Ajc195Tests.java | 8 | ||||
-rw-r--r-- | tests/src/test/resources/org/aspectj/systemtest/ajc195/ajc195.xml | 30 |
8 files changed, 135 insertions, 0 deletions
diff --git a/tests/bugs195/550494/Application.java b/tests/bugs195/550494/Application.java new file mode 100644 index 000000000..f539edb17 --- /dev/null +++ b/tests/bugs195/550494/Application.java @@ -0,0 +1,15 @@ +package foo; + +import java.sql.SQLException; + +public class Application { + public static void main(String[] args) throws SQLException { + System.out.println("Aspect should not kick in without ITD, but should with ITD"); + new BaseClass().getConnection(); + new BaseClass().getConnection("user", "pw"); + + System.out.println("Aspect should kick in"); + new SubClass().getConnection(); + new SubClass().getConnection("user", "pw"); + } +} diff --git a/tests/bugs195/550494/BaseClass.java b/tests/bugs195/550494/BaseClass.java new file mode 100644 index 000000000..f3087988a --- /dev/null +++ b/tests/bugs195/550494/BaseClass.java @@ -0,0 +1,19 @@ +package foo; + +import java.io.PrintWriter; +import java.sql.Connection; +import java.sql.SQLException; +import java.sql.SQLFeatureNotSupportedException; +import java.util.logging.Logger; + +public class BaseClass { + public PrintWriter getLogWriter() throws SQLException { return null; } + public void setLogWriter(PrintWriter out) throws SQLException {} + public void setLoginTimeout(int seconds) throws SQLException {} + public int getLoginTimeout() throws SQLException { return 0; } + public Logger getParentLogger() throws SQLFeatureNotSupportedException { return null; } + public <T> T unwrap(Class<T> iface) throws SQLException { return null; } + public boolean isWrapperFor(Class<?> iface) throws SQLException { return false; } + public Connection getConnection() throws SQLException { return null; } + public Connection getConnection(String username, String password) throws SQLException { return null; } +} diff --git a/tests/bugs195/550494/Code.java b/tests/bugs195/550494/Code.java new file mode 100644 index 000000000..c7d05ff6a --- /dev/null +++ b/tests/bugs195/550494/Code.java @@ -0,0 +1,19 @@ +public class Code { + public static void main(String[] argv) { + } + + static aspect X { + before(): execution(* Code.main(..)) { + System.out.println( +""" +This +is +on +multiple +lines +""" +); + } + } + +} diff --git a/tests/bugs195/550494/DataSourceConnectionAspectAnno.java b/tests/bugs195/550494/DataSourceConnectionAspectAnno.java new file mode 100644 index 000000000..d78b48192 --- /dev/null +++ b/tests/bugs195/550494/DataSourceConnectionAspectAnno.java @@ -0,0 +1,20 @@ +package foo; + +import javax.sql.DataSource; + +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Before; +import org.aspectj.lang.annotation.DeclareParents; + +@Aspect +public class DataSourceConnectionAspectAnno { + // This statement crashes the AspectJ compiler + @DeclareParents("foo.BaseClass") + private DataSource dataSource; + + @Before("execution(public java.sql.Connection javax.sql.DataSource+.getConnection(..))") + public void myAdvice(JoinPoint thisJoinPoint) { + System.out.println(thisJoinPoint); + } +} diff --git a/tests/bugs195/550494/DataSourceConnectionAspectCode.java b/tests/bugs195/550494/DataSourceConnectionAspectCode.java new file mode 100644 index 000000000..aedc585b1 --- /dev/null +++ b/tests/bugs195/550494/DataSourceConnectionAspectCode.java @@ -0,0 +1,19 @@ +package foo; + +import javax.sql.DataSource; + +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Before; +import org.aspectj.lang.annotation.DeclareParents; + +import javax.sql.DataSource; + + +public aspect DataSourceConnectionAspectCode { + declare parents: BaseClass implements DataSource; + + before() : execution(public java.sql.Connection javax.sql.DataSource+.getConnection(..)) { + System.out.println(thisJoinPoint); + } +} diff --git a/tests/bugs195/550494/SubClass.java b/tests/bugs195/550494/SubClass.java new file mode 100644 index 000000000..7a8b4a3f9 --- /dev/null +++ b/tests/bugs195/550494/SubClass.java @@ -0,0 +1,5 @@ +package foo; + +import javax.sql.DataSource; + +public class SubClass extends BaseClass implements DataSource {} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc195/Ajc195Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc195/Ajc195Tests.java index ef674b404..338ca47e9 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc195/Ajc195Tests.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc195/Ajc195Tests.java @@ -16,6 +16,14 @@ import junit.framework.Test; */ public class Ajc195Tests extends XMLBasedAjcTestCase { + public void testAtDecpNPE_code_550494() { + runTest("at decp npe - code"); + } + + public void testAtDecpNPE_anno_550494() { + runTest("at decp npe - anno"); + } + public void testAvoidWeavingSwitchInfrastructure() { runTest("avoid weaving switch infrastructure"); } diff --git a/tests/src/test/resources/org/aspectj/systemtest/ajc195/ajc195.xml b/tests/src/test/resources/org/aspectj/systemtest/ajc195/ajc195.xml index 1084faf91..d9d679859 100644 --- a/tests/src/test/resources/org/aspectj/systemtest/ajc195/ajc195.xml +++ b/tests/src/test/resources/org/aspectj/systemtest/ajc195/ajc195.xml @@ -2,6 +2,36 @@ <suite> +<ajc-test dir="bugs195/550494" vm="1.8" title="at decp npe - code"> + <compile files="Application.java BaseClass.java SubClass.java DataSourceConnectionAspectCode.java" options="-1.8"/> + <run class="foo.Application"> + <stdout> + <line text="Aspect should not kick in without ITD, but should with ITD"/> + <line text="execution(Connection foo.BaseClass.getConnection())"/> + <line text="execution(Connection foo.BaseClass.getConnection(String, String))"/> + <line text="Aspect should kick in"/> + <line text="execution(Connection foo.BaseClass.getConnection())"/> + <line text="execution(Connection foo.BaseClass.getConnection(String, String))"/> + </stdout> + </run> +</ajc-test> + + +<ajc-test dir="bugs195/550494" vm="1.8" title="at decp npe - anno"> + <compile files="Application.java BaseClass.java SubClass.java DataSourceConnectionAspectAnno.java" options="-1.8"/> + <run class="foo.Application"> + <stdout> + <line text="Aspect should not kick in without ITD, but should with ITD"/> + <line text="execution(Connection foo.BaseClass.getConnection())"/> + <line text="execution(Connection foo.BaseClass.getConnection(String, String))"/> + <line text="Aspect should kick in"/> + <line text="execution(Connection foo.BaseClass.getConnection())"/> + <line text="execution(Connection foo.BaseClass.getConnection(String, String))"/> + </stdout> + </run> +</ajc-test> + + <ajc-test dir="bugs195/333274" vm="1.8" title="around finally blocks and unlinking"> <compile files="Code.java" options="-showWeaveInfo -1.8 -XnoInline"> <message kind="weave" text="Join point 'method-call(void Code.print2(java.lang.String))' in Type 'Code' (Code.java:15) advised by around advice from 'Azpect' (Code.java:35)"/> |