From 2a520d85bd24661523ac4d34d8daf588cd3f9286 Mon Sep 17 00:00:00 2001 From: wisberg Date: Wed, 4 Jun 2003 12:25:32 +0000 Subject: [PATCH] 1.1 doc changes - moving readme's to docs - finishing readme-11 as change/porting - misc... --- docs/dist/LICENSE-AspectJ.html | 152 ++++ docs/dist/README-AspectJ.html | 346 ++++++++ docs/dist/doc/README-11.html | 1491 ++++++++++++++++++++++++++++++++ docs/dist/doc/changes.html | 13 +- docs/dist/doc/index.html | 33 +- docs/dist/doc/porting.html | 37 +- 6 files changed, 2040 insertions(+), 32 deletions(-) create mode 100644 docs/dist/LICENSE-AspectJ.html create mode 100644 docs/dist/README-AspectJ.html create mode 100644 docs/dist/doc/README-11.html diff --git a/docs/dist/LICENSE-AspectJ.html b/docs/dist/LICENSE-AspectJ.html new file mode 100644 index 000000000..88be39978 --- /dev/null +++ b/docs/dist/LICENSE-AspectJ.html @@ -0,0 +1,152 @@ + + + +AspectJ License + + + + +

AspectJTM + Compiler and Core Tools License

+ +

This is a binary-only release.  Source code +is available from +http://eclipse.org/aspectj

+ +

The AspectJ compiler and core tools are distributed under the +Common Public License version 1.0 available + here + and copied below. + This license has been approved by +the Open Source Initiative as +conforming to the Open +Source Definition. +More information about the history and rationale behind this license +can be found at the + eclipse web site.

+ +

+Those portions of this distribution in the org.apache +Java namespace are available under the terms of +the Apache Software License, Version 1.1 +(See + http://jakarta.apache.org). +

+
+ +

Common Public License - v 1.0 +

+

THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. +

+

1. DEFINITIONS +

"Contribution" means: + +

+ + + + + + + + + + +

+

"Contributor" means any person or entity that distributes the Program. +

+

"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program. +

+

"Program" means the Contributions distributed in accordance with this Agreement. +

+

"Recipient" means anyone who receives the Program under this Agreement, including all Contributors. +

+

2. GRANT OF RIGHTS + +

+ + + + + + + + + + + + + + + + + + + + + + +

3. REQUIREMENTS +

A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that: + +

+ + + + + + + + + + + + + + + + + + + +

When the Program is made available in source code form: + +

+ + + + +

+

Contributors may not remove or alter any copyright notices contained within the Program. +

+

Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution. +

+

4. COMMERCIAL DISTRIBUTION +

Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense. +

+

For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages. +

+

5. NO WARRANTY +

EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations. +

+

6. DISCLAIMER OF LIABILITY +

EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +

+

7. GENERAL +

If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable. +

+

If Recipient institutes patent litigation against a Contributor with respect to a patent applicable to software (including a cross-claim or counterclaim in a lawsuit), then any patent licenses granted by that Contributor to such Recipient under this Agreement shall terminate as of the date such litigation is filed. In addition, if Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed. +

+

All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive. +

+

Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. IBM is the initial Agreement Steward. IBM may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved. +

+

This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation. +

+

+ +


+ + + diff --git a/docs/dist/README-AspectJ.html b/docs/dist/README-AspectJ.html new file mode 100644 index 000000000..e7bd6fcf1 --- /dev/null +++ b/docs/dist/README-AspectJ.html @@ -0,0 +1,346 @@ + + + + + + + +AspectJ Readme + + + + + +

AspectJTM

+ +

Version @build.version.long@ released on @build.date@.

+ +

1 Contents of this Package

+ + + +
+ +

2 Install Procedure

+ +

The AspectJ tools ajc and ajbrowser are +Java programs that can be run indirectly from the scripts or +directly from aspectjtools.jar. +The aspectjrt.jar needs to be on the classpath +when compiling or running programs compiled +by ajc. This procedure shows ways to do that. +

+ +

After finishing automatic installation, we recommend that the +following steps to complete your installation:

+ +

2.1 Add <aspectj install dir>/lib/aspectjrt.jar + to your class path

+ +
+

This small .jar file contains classes required to compile programs + with the ajc compiler, and to run programs compiled with the ajc + compiler. You must have these classes somewhere on your class path + when running programs compiled with ajc. For detailed instructions + please see the Configuration + Instructions at the bottom of this document.

+
+ +

2.2 Put the AspectJ bin directory on your PATH

+ +
+

Modify your PATH to include <aspectj install + dir>/bin. This will make it easier to run ajc. + For detailed instructions please see the + Configuration Instructions at the + bottom of this document.

+
+ +

2.3 Review the documentation and examples

+ +
+

Development and programming guides + are available in docs, + and example programs and an Ant script are available in + examples. +

+ +

If you did not use the automatic installation process, you may wish +to create short launch scripts to start ajc easily (section 3).

+ +
+ +

3. Running the Tools

+ +

If you did not use the automatic installation process or the +default launch scripts do not work on your system, you may wish to +create short launch scripts to start ajc easily.

+ +

You can also run the aspectjtools.jar directly +using java's -jar option: + +

+C:\jdk1.3\bin\java.exe -jar D:\aspectj\lib\aspectjtools.jar %* +
+ +

With no arguments or only argument list (.lst) files, this will launch +ajbrowser, the GUI structure browser; otherwise, it will +run ajc, the AspectJ compiler. This means that +if your browser is set up to run jar files, clicking a link +to lib/aspectjtools.jar will +launch ajbrowser. + +

You can also create scripts like those created by the installer. +These scripts use full paths that are system dependent so you will +likely have to change these.

+ +

Here's a sample launch script for WinNT and Win2K (note that this +is single line in the .bat file):

+ +
+C:\jdk1.3\bin\java.exe -classpath D:\aspectj\lib\aspectjtools.jar -Xmx64M +org.aspectj.tools.ajc.Main %* +
+ +

Here's a sample launch script for a Unix shell (on Linux using Sun's JDK1.3):

+ +
+/usr/java/jdk1.3/jre/bin/java -classpath /home/aspectj/lib/aspectjtools.jar -Xmx64M org.aspectj.tools.ajc.Main "$@" +
+ +
+

4. Configuration Instructions

+ +

4.1 Adding <aspectj install dir>/lib/aspectjrt.jar to your classpath

+ +

There are several ways to add this jar file to your classpath:

+ + +

4.2 Setting the Environment Variables on Windows

+ +

The following instructions use the PATH variable as an example, but +this process is identical for the CLASSPATH variable.

+ +

You can do the variables permanently for all the shells that you +will run or temporarily only for the current shell. To change the +PATH only in the current shell, and assuming you've installed AspectJ +in C:\apps\aspectj, type:

+ +
> set PATH=%PATH%;C:\apps\aspectj\bin
+ +

Changing Environment Variables Permanently on WinNT and Win2000 +

+

Changing Environment Variables Permanently on Win9x +

+ + + + diff --git a/docs/dist/doc/README-11.html b/docs/dist/doc/README-11.html new file mode 100644 index 000000000..039c49b88 --- /dev/null +++ b/docs/dist/doc/README-11.html @@ -0,0 +1,1491 @@ + + +AspectJ 1.1 Readme + + + + +
+© Copyright 2002 Palo Alto Research Center, Incorporated, +2003 Contributors. +All rights reserved. +
+ + +

AspectJ 1.1 Readme

+ +

This is the initial release of AspectJ 1.1. It includes a small +number of new language features as well as major improvements to the +functionality of the tools.

+ +

+This document describes the differences between +AspectJ versions 1.1 and 1.0.6. +Users new to AspectJ need only read +the AspectJ Programming Guide +since it describes the 1.1 language. +Users familiar with AspectJ 1.0 may find this document +a quicker way to learn what changed in the language +and tools, and should use it as a guide for porting +programs from 1.0 to 1.1. +

+ +

This document first summarizes changes from the 1.0 release in +

+ + + +

then details some of the language + and compiler changes, + and finally points readers to the bug database for any + known limitations. +

+ + +
+

The Language

+ +

AspectJ 1.1 is a slightly different language than AspectJ 1.0. + In all but a few cases, programs written in AspectJ 1.0 should + compile correctly in AspectJ 1.1. In many cases, there are + new or preferred forms in AspectJ 1.1. However, some AspectJ 1.0 + features have changed in 1.1, so some 1.0 programs + will not compile or will run differently in 1.1. + The corresponding features are marked below as compile-time + or run-time incompatible (RTI or CTI, respectively). + When the language change involves a move in the static shadow effective + at run-time but also apparant at compile-time (e.g., in declare + error or warning statements), it is marked CRTI. + Programs using run-time incompatible forms should be verified that + they are behaving as expected in 1.1. +

+ +

+ Most changes to the language are additions to expressibility + requested by our users: +

+ + + +

Some are have different behavior in edge cases but offer + improved power and clarity:

+ + + +

But in order to support weaving into bytecode effectively, + several incompatible changes had to be made to the language:

+ + + +

There are a couple of language + limitations for things that are rarely used that make the + implementation simpler, so we have restricted the language accordingly. +

+ + + +

We did not implement the long-awaited new + pertype aspect specifier in this release, but it may well + be in a future release.

+ + + +
+

The Compiler

+ +

The compiler for AspectJ 1.1 is different than the compiler for + AspectJ 1.0. While this document describes the differences in the + compiler, it's worthwhile noting that much effort has been made to + make sure that the interface to ajc 1.1 is, as much as possible, the + same as the interface to ajc 1.0. There are two important changes + under the hood, however.

+ +

First, the 1.1 compiler is implemented on top of the + open-source Eclipse compiler. This has two benefits: It allows us + to concentrate on the AspectJ extensions to Java and let the Eclipse + team worry about making sure the Java edge cases work, and it allows + us to piggyback on Eclipse's already mature incremental compilation + facilities.

+ +

Second, ajc now cleanly deliniates compilation of source code + from assembly (or "weaving") of bytecode. The compiler still + accepts source code, but internally it transforms it into bytecode + format before weaving.

+ +

This new architecture, and other changes to the compiler, allows + us to implement some features that were defined in the AspectJ 1.0 + language but not implementable in the 1.1 compiler. It also makes + some new features available:

+ + + +

Some other features we wanted to support for 1.1, but did not make + it into this release:

+ + + +

But some features of the 1.0 compiler are not supported in the + 1.1 compiler:

+ + + +

A short description of the options ajc accepts is available with + "ajc -help". + Longer descriptions are available in the + Development Environment Guide + section on ajc.

+

+ + +

Some changes to the implementation are almost entirely + internal: +

+ + + + +
+

Support Tools

+ +

This release includes an Ant task for old-style 1.0 build + scripts, a new task for all the new compiler options, and a + CompilerAdapter to support running ajc with the Javac + task by setting the build.compiler property. + The new task can automatically copy input resources to output + and work in incremental mode using a "tag" file. +

+ +

This release does not include ajdoc, the + documentation tool for AspectJ sources. + Ajdoc is deeply dependent on the + abstract syntax tree classes from the old compiler, so it needs a + bottom-up rewrite. We think it best to use this opportunity to + implement more general API's for publishing and rendering static + structure. Because those API's are last to settle in the new + architecture, and because the compiler itself is a higher priority, + we are delaying work on ajdoc until after the 1.1 release.

+ +

AspectJ 1.1 will not include ajdb, the AspectJ + stand-alone debugger. It is no longer necessary for two reasons. + First, the -XnoInline flag will tell the compiler to generate + code without inlining that should work correctly with any Java + debugger. For code generated with inlining enabled, more + third-party debuggers are starting to work according to JSR 45, + "Debugging support for other languages," which is supported by + AspectJ 1.0. We aim to support JSR-45 in AspectJ 1.1, but + support will not be in the initial release. Consider using + the -XnoInline flag until support is available.

+ + +
+

The Runtime Library

+ +

This release has minor additions to the runtime library classes. + As with any release, you should compile and run with the runtime + library that came with your compiler, and you may run with + a later version of the library without recompiling your code.

+ +

In one instance, however, runtime classes behave differently this release. + Because the AspectJ 1.1 compiler does its weaving through + bytecode, column numbers of source locations are not available. + Therefore, thisJoinPoint.getSourceLocation().getColumn() + is deprecated and will always return 0.

+ + +
+

The AJDE Tools

+ +

The AspectJ Browser supports incremental compilation and running + programs. AJDE for JBuilder, AJDE for Netbeans, and AJDE for Emacs + are now independent sourceforge projects (to keep their licenses). + They use the batch-build mode of the new compiler. +

+ + +
+

The Sources and the Licenses

+ +

The AspectJ tools sources are available under the + Common Public + License in the CVS repository + at http://eclipse.org/aspectj. + For more information, see the FAQ entry on + building sources. +

+ + + +
+

The AspectJ distribution

+ +

AspectJ 1.0 had many distributions - for the tools, + the documentation, each IDE support package, + their respective sources, and the Ant tasks - + because they came under different licenses. + All of AspectJ 1.1 is licensed under the CPL 1.0, + so the tools, Ant tasks, and documentation are all + in one distribution available from + + http://eclipse.org/aspectj. +To retain their MPL 1.1 license, +Ajde for +Emacs, +NetBeans and +JBuilder +are now independent SourceForge projects.

+ +

+ + + +
+
+

Details of some language and compiler changes

+ +

Aspect Instantiation + and Advice

+ +

In AspectJ 1.0.6, we made an effort to hide some complications + with Aspect instantiation from the user. In particular, the + following code compiled and ran: +

+ +
+      public class Client
+      {
+          public static void main(String[] args) {
+              Client c = new Client();
+          }
+      }
+
+      aspect Watchcall {
+          pointcut myConstructor(): execution(new(..));
+
+          before(): myConstructor() {
+              System.err.println("Entering Constructor");
+          }
+      }
+      
+ +

But there's a conceptual problem with this code: The before + advice should run before the execution of all constructors in the + system. It must run in the context of an instance of the + Watchcall aspect. The only way to get such an instance is to have + Watchcall's default constructor execute. But before that + executes, we need to run the before advice...

+ +

AspectJ 1.0.6 hid this circularity through the ad-hoc + mechanism of preventing an aspect's advice from matching join + points that were within the aspect's definition, and occurred + before the aspect was initialized. But even in AspectJ 1.0.6, + this circularity could be exposed: +

+ +
+      public class Client
+      {
+          public static int foo() { return 3; }
+          public static void main(String[] args) {
+              Client c = new Client();
+          }
+      }
+
+      aspect Watchcall {
+          int i = Client.foo();
+          pointcut myConstructor():
+              execution(new(..)) || execution(int foo());
+
+          before(): myConstructor() {
+              System.err.println("Entering Constructor");
+          }
+      }
+      
+ +

This program would throw a NullPointerException when run, since + Client.foo() was called before the Watchcall instance could be + instantiated.

+ +

In AspectJ 1.1, we have decided that half-hiding the problem + just leads to trouble, and so we are no longer silently hiding + some join points before aspect initialization. However, we have + provided a better exception than a NullPointerException for this + case. In AspectJ 1.1, both of the above programs will throw + org.aspectj.lang.NoAspectBoundException. +

+ +

Matching based on throws

+ +

Type patterns may now be used to pick out methods and + constructors based on their throws clauses. This allows the + following two kinds of extremely wildcarded pointcuts:

+ +
    pointcut throwsMathlike():
+      // each call to a method with a throws clause containing at least
+      // one exception exception with "Math" in its name.
+      call(* *(..) throws *..*Math*);
+
+    pointcut doesNotThrowMathlike():
+      // each call to a method with a throws clause containing no
+      // exceptions with "Math" in its name.
+      call(* *(..) throws !*..*Math*);
+    
+ +

The longwinded rules are that a method or constructor pattern + can have a "throws clause pattern". Throws clause patterns look + like:

+ +
    ThrowsClausePattern:
+        ThrowsClausePatternItem ("," ThrowsClausePatternItem)*
+
+    ThrowsClausePatternItem:
+        ["!"] TypeNamePattern
+    
+ +

A ThrowsClausePattern matches the ThrowsClause of any code + member signature. To match, each ThrowsClausePatternItem must + match the throws clause of the member in question. If any item + doesn't match, then the whole pattern doesn't match. This rule is + unchanged from AspectJ 1.0.

+ +

If a ThrowsClausePatternItem begins with "!", then it matches + a particular throws clause if and only if none of the + types named in the throws clause is matched by the + TypeNamePattern.

+ +

If a ThrowsClausePatternItem does not begin with "!", then it + matches a throws clause if and only if any of the types + named in the throws clause is matched by the TypeNamePattern.

+ +

These rules are completely backwards compatible with + AspectJ 1.0. The rule for "!" matching has one potentially + surprising property, in that the two PCDs shown below will have + different matching rules.

+ +
    [1] call(* *(..) throws !IOException)
+    [2] call(* *(..) throws (!IOException))
+
+    void m() throws RuntimeException, IOException {}
+    
+ +

[1] will NOT match the method m(), because method m's throws + clause declares that it throws IOException. [2] WILL match the + method m(), because method m's throws clause declares the it + throws some exception which does not match IOException, + i.e. RuntimeException.

+ +

New kinded pointcut designators

+ +

AspectJ 1.0 does not provide kinded pointcut designators for + two (rarely used) join points: preinitialization (the code that + runs before a super constructor call is made) and advice + execution. AspectJ 1.1 does not change the meaning of the join + points, but provides two new pointcut designators to pick out + these join points, thus making join points and pointcut + designators more parallel.

+ +

adviceexectuion() will pick out advice execution + join points. You will usually want to use adviceexecution() + && within(Aspect) to restrict it to only those pieces of + advice defined in a particular aspect.
+ preinitialization(ConstructorPattern) will + pick out pre-initialization join points where the initialization + process is entered through + ConstructorPattern.

+ +

New pertype aspect specifier (not in 1.1)

+ +

We strongly considered adding a pertype aspect kind to 1.1. + This is somewhat motivated by the new + restrictions on inter-type + declarations. This is also motivated by many previous request + to support a common logging idiom. Here's what pertype would look + like:

+ +
    /** One instance of this aspect will be created for each class,
+     * interface or aspect in the com.bigboxco packages.
+     */
+    aspect Logger pertype(com.bigboxco..*) {
+        /* This field holds a logger for the class. */
+        Log log;
+
+        /* This advice will run for every public execution defined by
+         * a type for which a Logger aspect has been created, i.e.
+         * any type in com.bigboxco..*
+         */
+        before(): execution(public * *(..)) {
+            log.enterMethod(thisJoinPoint.getSignature().getName());
+        }
+
+        /* We can use a special constructor to initialize the log field */
+        public Logger(Class myType) {
+            this.log = new Log(myType);
+        }
+    }
+
+        /** External code could use aspectOf to get at the log, i.e. */
+        Log l = Logger.aspectOf(com.bigboxco.Foo.class).log;
+    
+ +

The one open question that we see is how this should interact + with inner types. If a pertype aspect is created for an outer + type should advice in that aspect run for join points in inner + types? That is the behavior of the most common uses of this + idiom.

+ +

In any case, this feature will not be in AspectJ 1.1. +

+ +

One target for intertype + declarations

+ +

Intertype declarations (once called "introductions") in + AspectJ 1.1 can only have one target type. So the following code + intended to declare that there is a void doStuff() method on all + subtypes of Target is not legal AspectJ 1.1 code. +

+ +
    aspect A {
+        public void Target+.doStuff() { ... }
+    }
+    
+ +

The functionality of "multi-intertype declarations" can be + recovered by using a helper interface. +

+ +
    aspect A {
+        private interface MyTarget {}
+        declare parents:  Target+ implements MyTarget;
+        public void MyTarget.doStuff() { ... }
+    }
+    
+ +

We believe this is better style in AspectJ 1.0 as well, as it + makes clear the static type of "this" inside the method body. +

+ +

The one piece of functionality that can not be easily + recovered is the ability to add static fields to many classes. We + believe that the pertype proposal provides + this functionality in a much more usable form.

+ +

No initializer execution join + points

+ +

AspectJ 1.1 does not consider initializer execution a + principled join point. The collection of initializer code (the + code that sets fields with initializers and the code in non-static + initializer blocks) is something that makes sense only in Java + source code, not in Java bytecode.

+ +

No after or around advice on handler + join points

+ +

The end of an exception handler is underdetermined in bytecode, + so ajc will not implement after or around advice on handler join + points, instead signalling a compile-time error.

+ +

Initializers run + inside constructor execution join points

+ +

The code generated by the initializers in Java source code now + runs inside of constructor execution join points. This changes + how before advice runs on constructor execution join points. + Consider:

+ +
    class C {
+        C() { }
+        String id = "identifier"; // this assignment
+                                  // has to happen sometime
+    }
+    aspect A {
+        before(C c) this(c) && execution(C.new()) {
+            System.out.println(c.id.length());
+        }
+    }
+    
+ +

In AspectJ 1.0, this will print "10", since id is assigned its + initial value prior to the before advice's execution. However, in + AspectJ 1.1, this will throw a NullPointerExcception, since "id" + does not have a value prior to the before advice's execution. +

+ +

Note that the various flavors of after returning advice are + unchanged in this respect in AspectJ 1.1. Also note that this + only matters for the execution of constructors that call a + super-constructor. Execution of constructors that call a + this-constructor are the same in AspectJ 1.1 as in AspectJ 1.0. +

+ +

We believe this difference should be minimal to real programs, + since programmers using before advice on constructor execution + must always assume incomplete object initialization, since the + constructor has not yet run.

+ +

Inter-type field initializers

+ +

The initializer, if any, of an inter-type field definition runs + before the class-local initializers of its target class.

+ +

In AspectJ 1.0.6, such an initializer would run after the + initializers of a class but before the execution of any of its + constructor bodies. As already discussed in the sections about + initializer execution join + points and constructor + execution, the point in code between the initializers of a class + and its constructor body is not principled in bytecode. So we had a + choice of running the initializer of an inter-type field definition at + the beginning of initialization (i.e., before initializers from + the target class) or at the end (i.e., just before its called + constructor exits). We chose the former, having this pattern in mind: +

+ +
+    int C.methodCount = 0;
+    before(C c): this(c) && execution(* *(..)) { c.methodCount++; }
+    
+ +

We felt there would be too much surprise if a constructor called a + method (thus incrementing the method count) and then the field was + reset to zero after the constructor was done. +

+ +

Small limitations of the within + pointcut

+ +

Becuase of the guarantees made (and not made) by the Java + classfile format, there are cases where AspectJ 1.1 cannot + guarantee that the within pointcut designator will pick out all + code that was originally within the source code of a certain + type. +

+ +

The non-guarantee applies to code inside of anonymous and + local types inside member types. While the within pointcut + designator behaves exactly as it did in AspectJ 1.0 when given a + package-level type (like C, below), if given a member-type (like + C.InsideC, below), it is not guaranteed to capture code in + contained local and anonymous types. For example:

+ +
    class C {
+        Thread t;
+        class InsideC {
+            void setupOuterThread() {
+                t = new Thread(
+                        new Runnable() {
+                            public void run() {
+                                // join points with code here
+                                // might not be captured by
+                                // within(C.InsideC), but are
+                                // captured by within(C)
+                                System.out.println("hi");
+                            }
+                        });
+            }
+        }
+    }
+    
+ +

We believe the non-guarantee is small, and we haven't verified + that it is a problem in practice.

+ +

Small limitations of the withincode + pointcut

+ +

The withincode pointcut has similar issues to those described + above for within. +

+ +

Can't do instanceof matching on + type patterns with wildcard

+ +

The pointcut designators this, target and args specify a + dynamic test on their argument. These tests can not be performed + on type patterns with wildcards in them. The following code that + compiled under 1.0 will be an error in AspectJ-1.1:

+ +
    pointcut oneOfMine(): this(com.bigboxco..*);
+    
+ +

The only way to implement this kind of matching in a modular + way would be to use the reflection API at runtime on the Class of + the object. This would have a very high performance cost and + possible security issues. There are two good work-arounds. If + you control the source or bytecode to the type you want to match + then you can use declare parents, i.e.:

+ +
    private interface OneOfMine {}
+    declare parents: com.bigboxco..* implements OneOfMine;
+    pointcut oneOfMine(): this(OneOfMine);
+    
+ +

If you want the more dynamic matching and are willing to pay + for the performance, then you should use the Java reflection API + combinded with if. That would look something like:

+ +
    pointcut oneOfMine(): this(Object) &&
+        if(classMatches("com.bigboxco..*",
+                        thisJoinPoint.getTarget().getClass()));
+
+    static boolean classMatches(String pattern, Class _class) {
+        if (patternMatches(pattern, _class.getName())) return true;
+        ...
+    }
+    
+ +

Note: wildcard type matching still works in all other pcds that + match based on static types. So, you can use + 'within(com.bigboxco..*+)' to match any code lexically within one + of your classes or a subtype thereof. This is often a good + choice.

+

+ + +

SourceLocation.getColumn()

+ +

The Java .class file format contains information about the + source file and line numbers of its contents; however, it has no + information about source columns. As a result, we can not + effectively support the access of column information in the + reflection API. So, any calls to + thisJoinPoint.getSourceLocation().getColumn() will be marked as + deprecated by the compiler, and will always return 0.

+ +

Aspect precedence

+ +

AspectJ 1.1 has a new declare form: +

+ +
    declare precedence ":"  TypePatternList ";"
+    
+ +

This is used to declare advice ordering constraints on join + points. For example, the constraints that (1) aspects that have + Security as part of their name should dominate all other aspects, and + (2) the Logging aspect (and any aspect that extends it) should + dominate all non-security aspects, can be expressed by:

+ +
    declare precedence: *..*Security*, Logging+, *;
+    
+ +

In the TypePatternList, the wildcard * means "any type not matched + by another type in the declare precedence".

+ +

Various cycles

+ +

It is an error for any aspect to be matched by more than one + TypePattern in a single decare precedence, so:

+ +
      declare precedence:  A, B, A ;  // error
+      
+ +

However, multiple declare precedence forms may legally have this + kind of circularity. For example, each of these declare precedence is + perfectly legal: +

+ +
      declare precedence: B, A;
+      declare precedence: A, B;
+      
+ +

And a system in which both constraints are active may also be + legal, so long as advice from A and B don't share a join point. So + this is an idiom that can be used to enforce that A and B are strongly + independent.

+ +

Applies to concrete aspects

+ +

Consider the following library aspects: +

+ +
      abstract aspect Logging {
+          abstract pointcut logged();
+
+          before(): logged() {
+              System.err.println("thisJoinPoint: " + thisJoinPoint);
+          }
+      }
+
+      aspect aspect MyProfiling {
+          abstract pointcut profiled();
+
+          Object around(): profiled() {
+              long beforeTime = System.currentTimeMillis();
+              try {
+                  return proceed();
+              } finally {
+                  long afterTime = System.currentTimeMillis();
+                  addToProfile(thisJoinPointStaticPart,
+                               afterTime - beforeTime);
+              }
+          }
+          abstract void addToProfile(
+              org.aspectj.JoinPoint.StaticPart jp,
+              long elapsed);
+      }
+      
+ +

In order to use either aspect, they must be extended with + concrete aspects, say, MyLogging and MyProfiling. In AspectJ + 1.0, it was not possible to express that Logging's advice (when + concerned with the concrete aspect MyLogging) dominated + Profiling's advice (when concerned with the concrete aspect + MyProfiling) without adding a dominates clause to Logging + itself. In AspectJ 1.1, we can express that constraint with a + simple:

+ +
      declare precedence: MyLogging, MyProfiling;
+      
+ +

Changing order of advice for sub-aspects

+ +

By default, advice in a sub-aspect has more precedence than + advice in a super-aspect. One use of the AspectJ 1.0 dominates + form was to change this precedence: +

+ +
      abstract aspect SuperA dominates SubA {
+          pointcut foo(): ... ;
+
+          before(): foo() {
+              // in AspectJ 1.0, runs before the advice in SubA
+              // because of the dominates clause
+          }
+      }
+
+      aspect SubA extends SuperA {
+          before(): foo() {
+              // in AspectJ 1.0, runs after the advice in SuperA
+              // because of the dominates clause
+          }
+      }
+      
+ +

This no longer works in AspectJ 1.1, since declare precedence only + matters for concrete aspects. Thus, if you want to regain this kind + of precedence change, you will need to refactor your aspects. +

+ +

The -sourceroots option

+ +

The AspectJ 1.1 compiler now accepts a -sourceroots option used to + pass all .java files in particular directories to the compiler. It + takes either a single directory name, or a list of directory names + separated with the CLASSPATH separator character (":" for various + Unices, ";" for various Windows).

+ +

So, if you have your project separated into a gui module and a + base module, each of which is stored in a directory tree, you might + use one of +

+ +
    ajc -sourceroots /myProject/gui:/myProject/base
+    ajc -sourceroots d:\myProject\gui;d:\myProject\base
+    
+ +

This option may be used in conjunction with lst files, listing + .java files on the command line, and the -injars option. +

+ +

The -injars option

+ +

The AspectJ 1.1 compiler now accepts an -injars option used to + pass all .class files in a particular jar file to the compiler. It + takes either a single directory name, or a list of directory names + separated with the CLASSPATH separator character (":" for various + Unices, ";" for various Windows).

+ +

So, if MyTracing.java defines a trace aspect that you want to + apply to all the classes in myBase.jar and myGui.jar, you would use + one of:

+ +
    ajc -injars /bin/myBase.jar:/bin/myGui.jar MyTracing.java
+    ajc -injars d:\bin\myBase.jar;d:\bin\myGui.jar MyTracing.java
+    
+ +

The class files in the input jars must not have had advice woven + into them, since AspectJ enforces the requirement that advice is woven + into a particular classfile only once. So if the classfiles in the + jar file are to be created with the ajc compiler (as opposed to a pure + Java compiler), they should not be compiled with any non-abstract + aspects.

+ +

This option may be used in conjunction with lst files, listing + .java files on the command line, and the -sourceroots option. +

+ +

The -outjar option

+ +

The -outjar option takes the name of a jar file into which the + results of the compilation should be put. For example: + +

    ajc -injars myBase.jar MyTracing.java -outjar myTracedBase.jar
+    
+ +

No meta information is placed in the output jar file.

+ +

Incremental compilation

+ +

The AspectJ 1.1 compiler now supports incremental compilation. + When ajc is called with the -incremental option, it must also be + passed a -sourceroots option specifying a directory to incrementally + compile. Once the initial compile is done, ajc waits for console + input. Every time it reads a new line (i.e., every time the user + hits return) ajc recompiles those input files that need recompiling. +

+ +

Limitations

+ +

This new functionality is still only lightly tested.

+ +

-XnoWeave, a compiler option to suppress + weaving

+ +

The -XnoWeave option suppresses weaving, and generates + classfiles and that can be passed to ajc again (through the + -injars option) to generate final, woven classfiles.

+ +

This option was originally envisioned to be the primary way to + generate binary aspects that could be linked with other code, and + so it was previously (in AspectJ 1.1beta1) named + -noweave. We feel that using the + -aspectpath option is a + much better option. There may still be use cases for unwoven + classfiles, but we've moved the flag to experimental status. +

+ +

-aspectpath, working with aspects in .class/.jar + form

+ +

When aspects are compiled into classfiles, they include all + information necessary for the ajc compiler to weave their advice + and deal with their inter-type declarations. In order for these + aspects to have an effect on a compilation process, they must be + passed to the compiler on the -aspectpath. Every .jar file on + this path will be searched for aspects and any aspects that are + found will be enabled during the compilation. The binary forms of + this aspects will be untouched.

+ +

Callee-side call join + points

+ +

The 1.0 implementation of AspectJ, when given: +

+ +
    class MyRunnable implements Runnable {
+        public void run() { ... }
+    }
+
+    aspect A {
+        call(): (void run()) && target(MyRunnable) {
+            // do something here
+        }
+    }
+    
+ +

would cause A's advice to execute even when, say, java.lang.Thread + called run() on a MyRunnable instance. +

+ +

With the new compiler, two things have happened in regard to + callee-side calls: +

+ +
    +
  1. because the programmer has access to more code (i.e., + bytecode, not just source code), callee-side calls are much + less important to have.
  2. + +
  3. because compilation is more modular, allowing and + encouraging separate compilation, callee-side calls are much + more difficult to implement
  4. +
+ +

With these two points in mind, advice in an aspect will not be + applied to call join points whose call site is completely + unavailable to the aspect.

+ +
    +
  1. One reason (though not the only reason) we worked so hard in + the implementation of 1.0.6 to expose call join + points, even if we only had access to the callee's code, was + that otherwise users couldn't get access to call join points + where the call was made from bytecode. This is no longer the + case. In short, the implementation controls much more code (or + has the capability to) than ever before.
  2. + +
  3. The implementation model for the AspectJ 1.1 compiler is to + separate the compilation of aspects/advice from their + weaving/linking. A property of the model is that the + compilation requires no access to "target" code, only the + weaving/linking does, and weaving/linking is inherently + per-class local: No action at weaving/linking time depends on + the coordinated mangling of multiple classfiles. Rather, all + weaving is done on a per classfile basis. This is an essential + property for the current separate compilation model.
    + + However, allowing implementation of call advice on either + side requires simultaneous knowlege of both sides. If we first + have access to a call, we can't decide to simply put the advice + on the call site, since later we may decide to implement on the + callee.
  4. +
+ +

This implementation decision is completely in the letter and + the spirit of the AspectJ language. From the semantics guide + describing code the implementation controls:

+ +
+ But AspectJ implementations are permitted to deviate from this + in a well-defined way -- they are permitted to advise only + accesses in code the implementation + controls. Each implementation is free within certain + bounds to provide its own definition of what it means to control + code. +
+ +

And about a particular decision about the 1.0.6 + implementation:

+ +
+ Different join points have different requirements. Method call + join points can be advised only if ajc controls + either the code for the caller or the code + for the receiver, and some call pointcut designators may + require caller context (what the static type of the receiver + is, for example) to pick out join points. +
+ +

The 1.1 implementation makes a different design decision: + Method call join points can be advised only if ajc (in compiler or + linker form) controls the code for the caller.

+ +

What does 1.1 gain from this?

+ + + +

What does 1.1 lose from this?

+ + + +

What are the possibilities for the future?

+ + + +

How will this affect developers?

+ + +

Various -X options

+ +

The AspectJ 1.0 compiler supported a number of options that + started with X, for "experimental". Some of them will not be + supported in 1.1, either because the "experiment" succeeded (in + which case it's part of the normal functionality) or failed. + Others will be supported as is (or nearly so) in 1.1: +

+ + + +

Some confusing error messages

+ +

Building on the eclipse compiler has given us access to a very + sophisticated problem reporting system as well as highly optimized + error messages for pure Java code. Often this leads to noticably + better error messages than from ajc-1.0.6. However, when we don't + handle errors correctly this can sometimes lead to cascading error + messages where a single small syntax error will produce dozens of + other messages. Please report any very confusing error messages as + bugs.

+ + +

Source code context is not shown + for errors and warnings detected during bytecode weaving

+ +

For compiler errors and warnings detected during bytecode weaving, + source code context will not be displayed. In particular, for declare + error and declare warning statements, the compiler now only emits the + file and line. We are investigating ways to overcome this in cases + where the source code is available; in cases where source code is + not available, we might specify the signature of the offending code. + For more information, see bug 31724.

+ + +

The -Xlint option

+ +

-Xlint:ignore,error,warning will set the level for + all Xlint warnings. -Xlint, alone, is an + abbreviation for -Xlint:warning.

+ +

The -Xlintfile:lint.properties allows fine-grained + control. In tools.jar, see + org/aspectj/weaver/XlintDefault.properties for the + default behavior and a template to copy.

+ +

More -Xlint warnings are supported now, and + we may add disabled warnings in subsequent bug-fix releases of 1.1. + Because the configurability allows users to turn off + warnings, we will be able to warn about more potentially + dangerous situations, such as the potentially unsafe casts used by + very polymorphic uses of proceed in around advice.

+ +

Source-specific options

+ +

Because AspectJ 1.1 does not generate source code after + weaving, the source-code-specific options -preprocess, -usejavac, + -nocomment and -workingdir options are meaningless and so not + supported.

+ +

The -strict and -lenient + options

+ +

Because AspectJ 1.1 uses the Eclipse compiler, which has its + own mechanism for changing strictness, we no longer support the + -strict and -lenient options.

+ +

The -porting option

+ +

AspectJ 1.1 does not have a -porting option.

+ +

J2SE 1.3 required

+ +

Because we build on Eclipse, the compiler will no longer run + under J2SE 1.2. You must run the compiler (and all tools based on + the compiler) using J2SE 1.3 or later. The code generated by the + compiler can still run on Java1.1 or later VMs if compiled against + the correct runtime libraries.

+ +

Default + constructors

+ +

AspectJ 1.1 does not allow the inter-type definition of a + zero-argument constructor on a class with a visible default + constructor. So this is no longer allowed:

+ +
+    class C {}
+
+    aspect A {
+        C.new() {}  // was allowed in 1.0.6
+                    // is a "multiple definitions" conflict in 1.1
+    }
+    
+ +

In the Java Programming Language, a class defined without a + constructor actually has a "default" constructor that takes no + arguments and just calls super().

+ +

This default constructor is a member of the class like any other + member, and can be referenced by other classes, and has code generated + for it in classfiles. Therefore, it was an oversight that AspectJ + 1.0.6 allowed such an "overriding" inter-type constructor definition. +

+ +

Initialization join points for + super-interfaces

+ +

In AspectJ, interfaces may have non-static members due to + inter-type declarations. Because of this, the semantics of AspectJ + defines the order that initializer code for interfaces is run. +

+ +

In the semantics document for AspectJ 1.0.6, the following + promises were made about the order of this initialization: +

+ +
    +
  1. a supertype is initialized before a subtype
  2. +
  3. initialized code runs only once
  4. +
  5. initializers for supertypes run in left-to-right order
  6. +
+ +

The first two properties are important and are preserved in + AspectJ 1.1, but the third property is and was ludicrous, and was + never properly implemented (and never could be) in AspectJ 1.0.6. + Consider:

+ +
+    interface Top0 {}
+    interface Top1 {}
+    interface I extends Top0, Top1 {} 
+    interface J extends Top1, Top0 {}
+
+    class C implements I, J {}
+    // I says Top0's inits must run before Top1's
+    // J says Top1's inits must run before Top0's
+
+    aspect A {
+        int Top0.i = foo("I'm in Top0");
+        int Top1.i = foo("I'm in Top1");
+        static int foo(String s) {
+            System.out.println(s);
+            return 37;
+        }
+    }
+    
+ +

This was simply a bug in the AspectJ specification. The correct + third rule is: +

+ +
the initializers for a type's superclass are run before the + initializers for its superinterfaces. +
+ + +

Field Set Join Points

+ +

In AspectJ 1.0.6, the join point for setting a field F had, as a + return type, F's type. This was "java compatible" because + field assignment in java, such as "Foo.i = 37", is in fact an + expression, and does in fact return a value, the value that the + field is assigned to. +

+ +

This was never "java programmer compatible", however, largely + because programmers have absorbed the good style of rarely using an + assignment statement in a value context. Programmers typically expect + "Foo.i = 37" not to return a value, but to simply assign a value.

+ +

Thus, programmers typically wanted to write something like: +

+ +
+    void around(): set(int Foo.i) {
+        if (theSetIsAllowed()) {
+            proceed();
+        }
+    }
+    
+ +

And were confused by it being a compile-time error. They weren't + confused for long, and soon adapted to writing: +

+ +
+    int around(): set(int Foo.i) {
+        if (theSetIsAllowed()) {
+            return proceed();
+        } else {
+            return Foo.i;
+        }
+    }
+    
+ +

But there was definitely a short disconnect.

+ +

On top of that, we were never shown a convincing use-case for + returning an interesting value from a set join point. When we + revisited this issue, in fact, we realized we had a long-standing bug + in 1.0.6 dealing with the return value of pre-increment expressions + (such as ++Foo.i) that nobody had found because nobody cares about the + return value of such join points. +

+ +

So, because it's easier to implement, and because we believe that + this is the last possibility to make the semantics more useful, we + have made set join points have a void return type in 1.1.

+ +

The -XnoInline Option

+ +

The -XnoInline + option to indicate that no inlining of any kind should be done. This + is purely a compiler pragma: No program semantics (apart from stack + traces) will be changed by the presence or absence of this option. +

+ +

Target types made + public

+ +

Even in 1.0.6, the AspectJ compiler has occasionally needed to + convert the visibility of a package-level class to a public one. This + was previously done in an ad-hoc basis that took whole-program + analysis into account. With the incremental compilation model of + AspectJ 1.1, we can now specify the occasions when the compiler makes + these visibility changes. +

+ +

In particular, the types used in the this, + target, and args pointcuts are made public, + as are the super-types from declare parents and the + exception type from declare soft. +

+ +

We believe the visibility changes could be avoided in the future + with various implementation tricks if they become a serious + concern, but did not encounter them as such a concern when they were + done in the 1.0.6 implementation.

+ +

String + now advised

+ +

In Java, the + operator sometimes results in StringBuffer objects +being created, appended to, and used to generate a new String. Thus, +

+ +
+class Foo {
+    String makeEmphatic(String s) {
+        return s + "!";
+    }
+}
+
+ +

is approximately the same at runtime as +

+ +
+class Foo {
+    String makeEmphatic(String s) {
+        return new StringBuffer(s).append("!").toString();
+    }
+}
+
+ + +

In the design process of AspectJ 1.0.6 we didn't expose those +StringBuffer methods and constructors as join points (though we did +discuss it), but in 1.1 we do.

+ +

This change is likely to affect highly wildcarded aspects, and can +do so in surprising ways. In particular: +

+ +
+class A {
+    before(int i): call(* *(int)) && args(i) {
+        System.err.println("entering with " + i);
+    }
+}
+
+ +

may result in a stack overflow error, since the argument to +println is really

+ +
+new StringBuffer("entering with ").append(i).toString()
+
+ +

which has a call to StringBuffer.append(int). In such cases, it's +worth restricting your pointcut, with something like one of: +

+ +
+call(* *(int)) && args(i) && !within(A)
+call(* *(int)) && args(i) && !target(StringBuffer)
+
+ +

Known limitations

+ +

The AspectJ 1.1.0 release contains a small number of known limitations +relative to the AspectJ 1.1 language. +For the most up-to-date information about known limitations in an +AspectJ 1.1 release, see the bug database at + http://bugs.eclipse.org/bugs, +especially the open bugs for the + + compiler, + + IDE support, + + documentation, and + + Ant tasks. +Developers should know about bugs marked with the "info" keyword +because those bugs reflect failures to implement the 1.1 language perfectly. +These might be fixed during the 1.1 release cycle; find them using the query + + https://bugs.eclipse.org/bugs/buglist.cgi?product=AspectJ&keywords=info + +For ajc's 1.1 implementation limitations, see + + Programming Guide Appendix C, "Implementation Limitations". + +

+ diff --git a/docs/dist/doc/changes.html b/docs/dist/doc/changes.html index b64bfafa4..cbfb4674a 100644 --- a/docs/dist/doc/changes.html +++ b/docs/dist/doc/changes.html @@ -1,20 +1,23 @@ - AspectJ 1.0.6 Reference -- Recent Changes + Changes in AspectJ
-© Copyright 1998-2002 Palo Alto Research Center Incorporated. +© Copyright 1998-2002 Palo Alto Research Center Incorporated + 2003 Contributors. All rights reserved.
-

Changes in AspectJ 1.0

-For a list of changes in AspectJ 1.1, -see README-11. +

Changes in AspectJ