aboutsummaryrefslogtreecommitdiffstats
path: root/tests/bugs195/550494
diff options
context:
space:
mode:
authorAndy Clement <aclement@pivotal.io>2019-11-27 19:03:07 -0800
committerAndy Clement <aclement@pivotal.io>2019-11-27 19:03:07 -0800
commit4d6668df0ce64175c209333705f457ee47376ef0 (patch)
tree70208ed1df12c5d293a44b8a8073d218032ebd21 /tests/bugs195/550494
parentaccb931da432b000c34523fcc1da20e43d701a0d (diff)
downloadaspectj-4d6668df0ce64175c209333705f457ee47376ef0.tar.gz
aspectj-4d6668df0ce64175c209333705f457ee47376ef0.zip
Fix 550494
Diffstat (limited to 'tests/bugs195/550494')
-rw-r--r--tests/bugs195/550494/Application.java15
-rw-r--r--tests/bugs195/550494/BaseClass.java19
-rw-r--r--tests/bugs195/550494/Code.java19
-rw-r--r--tests/bugs195/550494/DataSourceConnectionAspectAnno.java20
-rw-r--r--tests/bugs195/550494/DataSourceConnectionAspectCode.java19
-rw-r--r--tests/bugs195/550494/SubClass.java5
6 files changed, 97 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 {}