From a01ac454bb23e0df78b358b489f60bf53c147ebf Mon Sep 17 00:00:00 2001 From: ehilsdal Date: Thu, 31 Jul 2003 06:40:35 +0000 Subject: [PATCH] Added documentation for Bugzilla Bug 29699: call join points in 1.1b2 und 1.1b4 basically documented that the -1.4 flag can change how method calls get generated in terms of the declaring type of the method. --- docs/dist/doc/README-11.html | 48 ++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/docs/dist/doc/README-11.html b/docs/dist/doc/README-11.html index 7417550f7..ff29e5d5b 100644 --- a/docs/dist/doc/README-11.html +++ b/docs/dist/doc/README-11.html @@ -280,6 +280,13 @@ programs from 1.0 to 1.1. clarified. +

Also, it is worth noting that because AspectJ now works on bytecode, + it is somewhat sensitive to how different compilers generate + bytecode, especially when compiling with and without the -1.4 flag.

+ + +

Support Tools

@@ -1461,6 +1468,47 @@ call(* *(int)) && args(i) && !within(A) call(* *(int)) && args(i) && !target(StringBuffer) +

The -1.4 flag and method signatures

+ +

Consider the following aspect +

+ +
+public aspect SwingCalls {
+    
+    pointcut callingAnySwing(): call(* javax.swing..*+.*(..));
+
+    before(): callingAnySwing() {
+        System.out.println("Calling any Swing");
+    }
+}
+
+ +

And then consider the two statements +

+ +
+  JFrame frame = new JFrame();
+  frame.setTitle("Title");
+
+ +

According to the Java Language Specification version 2, the call +to frame.setTitle("Title") should always produce the +bytecode for a call to javax.swing.JFrame.setTitle. +However, older compilers (and eclipse when run without the +-1.4 flag) will generate the bytecode for a call to +java.awt.Frame.setTitle instead since this method is not +overriden by JFrame. The AspectJ weaver depends on the correctly +generated bytecode in order to match patterns like the one you show +correctly.

+ +

This is a good example of why the pattern call(* *(..)) && +target(JFrame) is the recommended style. In general, OO +programmers don't want to care about the static type of an object at a +call site, but only want to know the dynamic instanceof behavior which +is what the target matching will handle.

+ +

Known limitations

The AspectJ 1.1.0 release contains a small number of known limitations -- 2.39.5