From 4d1c2948a2f18012cd49dbe8e3a32b1a863d4d45 Mon Sep 17 00:00:00 2001 From: aclement Date: Tue, 30 Nov 2004 17:43:50 +0000 Subject: Part of 72766: Bridge methods - we now do the right thing if we see one (i.e. we ignore it as a source of join points) --- tests/java5/bridgeMethods/AspectX.aj | 33 ++++++++++++++++++++++++++++++ tests/java5/bridgeMethods/Comparable.java | 3 +++ tests/java5/bridgeMethods/Number.java | 6 ++++++ tests/java5/bridgeMethods/build.xml | 11 ++++++++++ tests/java5/bridgeMethods/testcode.jar | Bin 0 -> 799 bytes 5 files changed, 53 insertions(+) create mode 100644 tests/java5/bridgeMethods/AspectX.aj create mode 100644 tests/java5/bridgeMethods/Comparable.java create mode 100644 tests/java5/bridgeMethods/Number.java create mode 100644 tests/java5/bridgeMethods/build.xml create mode 100644 tests/java5/bridgeMethods/testcode.jar (limited to 'tests/java5') diff --git a/tests/java5/bridgeMethods/AspectX.aj b/tests/java5/bridgeMethods/AspectX.aj new file mode 100644 index 000000000..fb4827023 --- /dev/null +++ b/tests/java5/bridgeMethods/AspectX.aj @@ -0,0 +1,33 @@ +import java.util.*; + +public aspect AspectX { + + static Set matchedJps = new HashSet(); + + before(): call(* compareTo(..)) { + matchedJps.add(new String("call() matched on "+thisJoinPoint.toString())); + } + + before(): execution(* compareTo(..)) { + matchedJps.add(new String("execution() matched on "+thisJoinPoint.toString())); + } + + public static void main(String []argv) { + Number n1 = new Number(5); + Number n2 = new Number(7); + n1.compareTo(n2); + n1.compareTo("abc"); // A Java5 compiler would *not* allow this, a call to a bridge method: error should be: + /** + AspectX.java:19: compareTo(Number) in Number cannot be applied to (java.lang.String) + n1.compareTo("abc"); + ^ + 1 error + */ + + Iterator i = matchedJps.iterator(); + while (i.hasNext()) { + String s = (String)i.next(); + System.err.println(s); + } + } +} diff --git a/tests/java5/bridgeMethods/Comparable.java b/tests/java5/bridgeMethods/Comparable.java new file mode 100644 index 000000000..0236945e2 --- /dev/null +++ b/tests/java5/bridgeMethods/Comparable.java @@ -0,0 +1,3 @@ +interface Comparable { + public int compareTo(A that); +} diff --git a/tests/java5/bridgeMethods/Number.java b/tests/java5/bridgeMethods/Number.java new file mode 100644 index 000000000..1a866ec19 --- /dev/null +++ b/tests/java5/bridgeMethods/Number.java @@ -0,0 +1,6 @@ +public class Number implements Comparable { + private int i; + public Number(int i) { this.i = i; } + public int getValue() { return i;} + public int compareTo(Number that) { return this.getValue() - that.getValue(); } +} diff --git a/tests/java5/bridgeMethods/build.xml b/tests/java5/bridgeMethods/build.xml new file mode 100644 index 000000000..7170813dc --- /dev/null +++ b/tests/java5/bridgeMethods/build.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/tests/java5/bridgeMethods/testcode.jar b/tests/java5/bridgeMethods/testcode.jar new file mode 100644 index 000000000..f543454b0 Binary files /dev/null and b/tests/java5/bridgeMethods/testcode.jar differ -- cgit v1.2.3