AspectJ is an
aspect-oriented programming (AOP) extension created at
PARC for the
Java
Java (; id, Jawa, ; jv, ꦗꦮ; su, ) is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea to the north. With a population of 151.6 million people, Java is the world's List ...
programming language. It is available in
Eclipse Foundation open-source projects, both stand-alone and integrated into
Eclipse
An eclipse is an astronomical event that occurs when an astronomical object or spacecraft is temporarily obscured, by passing into the shadow of another body or by having another body pass between it and the viewer. This alignment of three ce ...
. AspectJ has become a widely used de facto standard for AOP by emphasizing simplicity and usability for end users. It uses Java-like syntax, and included IDE integrations for displaying
crosscutting structure since its initial public release in 2001.
Simple language description
All valid Java programs are also valid AspectJ programs, but AspectJ lets programmers define special constructs called ''
aspects''. Aspects can contain several entities unavailable to standard classes. These are:
;
Extension method
In object-oriented computer programming, an extension method is a method added to an object after the original object was compiled. The modified object is often a class, a prototype or a type. Extension methods are features of some object-orie ...
s: Allow a programmer to add methods, fields, or interfaces to existing classes from within the aspect. This example adds an
acceptVisitor
(see
visitor pattern
In object-oriented programming and software engineering, the visitor design pattern is a way of separating an algorithm from an object structure on which it operates. A practical result of this separation is the ability to add new operations to ...
) method to the
Point
class:
:
aspect VisitAspect
;
Pointcut In aspect-oriented programming, a pointcut is a set of join points. Pointcut specifies where exactly to apply advice, which allows separation of concerns and helps in modularizing business logic. Pointcuts are often specified using class names or me ...
s: Allow a programmer to specify
join point
In computer science, a join point is a point in the control flow of a program where the control flow can arrive via two different paths. In particular, it's a basic block that has more than one predecessor. In aspect-oriented programming a set of ...
s (well-defined moments in the execution of a program, like method call, object instantiation, or variable access). All pointcuts are expressions (
quantifications) that determine whether a given join point matches. For example, this point-cut matches the execution of any instance method in an object of type
Point
whose name begins with
set
:
:
pointcut set() : execution(* set*(..) ) && this(Point);
;
Advices: Allow a programmer to specify code to run at a join point matched by a
pointcut In aspect-oriented programming, a pointcut is a set of join points. Pointcut specifies where exactly to apply advice, which allows separation of concerns and helps in modularizing business logic. Pointcuts are often specified using class names or me ...
. The actions can be performed ''before'', ''after'', or ''around'' the specified
join point
In computer science, a join point is a point in the control flow of a program where the control flow can arrive via two different paths. In particular, it's a basic block that has more than one predecessor. In aspect-oriented programming a set of ...
. Here, the advice refreshes the display every time something on
Point
is set, using the pointcut declared above:
:
after () : set()
AspectJ also supports limited forms of pointcut-based static checking and aspect reuse (by inheritance). See th
AspectJ Programming Guidefor a more detailed description of the language.
AspectJ compatibility and implementations
AspectJ can be implemented in many ways, including
source-weaving or
bytecode-weaving, and directly in the
virtual machine (VM). In all cases, the AspectJ program becomes a valid Java program that runs in a Java VM. Classes affected by aspects are binary-compatible with unaffected classes (to remain compatible with classes compiled with the unaffected originals). Supporting multiple implementations allows the language to grow as technology changes, and being Java-compatible ensures platform availability.
Key to its success has been engineering and language decisions that make the language usable and programs deployable. The original Xerox AspectJ implementation used source weaving, which required access to source code. When Xerox contributed the code to Eclipse, AspectJ was reimplemented using the Eclipse Java compiler and a bytecode weaver based on
BCEL
The Byte Code Engineering Library (BCEL) is a project sponsored by the Apache Foundation previously under their Jakarta charter to provide a simple API for decomposing, modifying, and recomposing binary Java classes (I.e. bytecode). The project wa ...
, so developers could write aspects for code in binary (.class) form. At this time the AspectJ language was restricted to support a per-class model essential for incremental compilation and load-time weaving. This made IDE integrations as responsive as their Java counterparts, and it let developers deploy aspects without altering the build process. This led to increased adoption, as AspectJ became usable for impatient Java programmers and enterprise-level deployments. Since then, the Eclipse team has increased performance and correctness, upgraded the AspectJ language to support
Java 5 language features like
generics
Generic or generics may refer to:
In business
* Generic term, a common name used for a range or class of similar things not protected by trademark
* Generic brand, a brand for a product that does not have an associated brand or trademark, other ...
and
annotations, and integrated annotation-style pure-java aspects from
AspectWerkz
AspectJ is an aspect-oriented programming (AOP) extension created at PARC for the Java programming language. It is available in Eclipse Foundation open-source projects, both stand-alone and integrated into Eclipse. AspectJ has become a widely use ...
.
The Eclipse project supports both command-line and
Ant interfaces. A related Eclipse project has steadily improved the Eclipse IDE support for AspectJ (called ''AspectJ Development Tools (
AJDT
AspectJ is an aspect-oriented programming (AOP) extension created at PARC (company), PARC for the Java (programming language), Java programming language. It is available in Eclipse Foundation open-source projects, both stand-alone and integrated i ...
)'') and other providers of crosscutting structure. IDE support for
emacs
Emacs , originally named EMACS (an acronym for "Editor MACroS"), is a family of text editors that are characterized by their extensibility. The manual for the most widely used variant, GNU Emacs, describes it as "the extensible, customizable, s ...
,
NetBeans, and
JBuilder foundered when Xerox put them into open source, but support for Oracle's JDeveloper did appear. IDE support has been key to Java programmers using AspectJ and understanding crosscutting concerns.
BEA has offered limited VM support for aspect-oriented extensions, but for extensions supported in all Java VM's would require agreement through Sun's Java Community Process (see also the java.lang.instrument package available since Java SE 5 — which is a common ground for JVM load-time instrumentation).
Academic interest in the semantics and implementation of
aspect-oriented
In computing, aspect-oriented programming (AOP) is a programming paradigm that aims to increase modularity by allowing the separation of cross-cutting concerns. It does so by adding behavior to existing code (an advice) ''without'' modifying th ...
languages has surrounded AspectJ since its release. The leading research implementation of AspectJ is th
AspectBench Compiler or ''abc''; it supports extensions for changing the syntax and semantics of the language and forms the basis for many AOP experiments that the AspectJ team can no longer support, given its broad user base.
Many programmers discover AspectJ as an enabling technology for other projects, most notably
Spring AOP. A sister Spring project,
Spring Roo
Spring Roo is an open-source software tool that uses convention-over-configuration principles to provide rapid application development of Java-based enterprise software. The resulting applications use common Java technologies such as Spring Fram ...
, automatically maintains AspectJ
inter-type declarations as its principal code generation output.
History and contributors
Gregor Kiczales
Gregor Kiczales is an American computer scientist. He is currently a full time professor of computer science at the University of British Columbia in Vancouver, British Columbia, Canada. He is best known for developing the concept of aspect-orient ...
started and led the
Xerox PARC
PARC (Palo Alto Research Center; formerly Xerox PARC) is a research and development company in Palo Alto, California. Founded in 1969 by Jacob E. "Jack" Goldman, chief scientist of Xerox Corporation, the company was originally a division of Xero ...
team that eventually developed AspectJ. He coined the term ''crosscutting''. Fourth on the team,
Chris Maeda coined the term ''aspect-oriented programming.''
Jim Hugunin
Jim Hugunin is a software programmer who created the Python programming language extension Numeric (ancestor to NumPy), and later created Python implementations for the Java Platform (Jython) and for Microsoft .NET platform (IronPython); he has ...
and
Erik Hilsdale (
Xerox PARC
PARC (Palo Alto Research Center; formerly Xerox PARC) is a research and development company in Palo Alto, California. Founded in 1969 by Jacob E. "Jack" Goldman, chief scientist of Xerox Corporation, the company was originally a division of Xero ...
team members 12 and 13) were the original compiler and weaver engineers,
Mik Kersten implemented the IDE integration and started th
Eclipse AJDTproject with
Adrian Colyer (current lead of th
AspectJ project and
Andrew Clement (current compiler engineer).
The
AspectBench Compiler was developed and is maintained as a joint effort of the
Programming Tools Group
Program, programme, programmer, or programming may refer to:
Business and management
* Program management, the process of managing several related projects
* Time management
* Program, a part of planning
Arts and entertainment Audio
* Programm ...
at the
Oxford University Computing Laboratory
The Department of Computer Science is the computer science department of the University of Oxford, England, which is part of the university's Mathematical, Physical and Life Sciences Division, University of Oxford, Mathematical, Physical and Life ...
, the
Sable Research Group
The sable (''Martes zibellina'') is a species of marten, a small omnivorous mammal primarily inhabiting the forest environments of Russia, from the Ural Mountains throughout Siberia, and northern Mongolia. Its habitat also borders eastern Kaza ...
at
McGill University
McGill University (french: link=no, Université McGill) is an English-language public research university located in Montreal, Quebec, Canada. Founded in 1821 by royal charter granted by King George IV,Frost, Stanley Brice. ''McGill Universit ...
, and the Institute for
Basic Research in Computer Science (BRICS).
AspectWerkz
AspectWerkz is a dynamic, lightweight and high-performance
AOP/AOSD framework for
Java
Java (; id, Jawa, ; jv, ꦗꦮ; su, ) is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea to the north. With a population of 151.6 million people, Java is the world's List ...
. It has been merged with the AspectJ project, which supports AspectWerkz functionality since AspectJ 5.
Jonas Boner
Jonas may refer to:
Geography
* Jonas, Netherlands, Netherlands
* Jonas, Pennsylvania, United States
* Jonas Ridge, North Carolina, United States
People with the name
* Jonas (name), people with the given name or surname Jonas
* Jonas, one of t ...
and
Alex Vasseur engineered the AspectWerkz project, and later contributed to the AspectJ project when it merged in the AspectWerkz annotation style and load-time weaving support.
Unlike AspectJ prior to version 5, AspectWerkz did not add any new language constructs to Java, but instead supported declaration of aspects within
Java annotation
In the Java computer programming language, an annotation is a form of syntactic metadata that can be added to Java source code. Classes, methods, variables, parameters and Java packages may be annotated. Like Javadoc tags, Java annotations can ...
s. It utilizes bytecode modification to
weave classes at project build-time, class load time, as well as
runtime. It uses standardized . Aspects can be defined using either Java annotations (introduced with Java 5), Java 1.3/1.4 custom
doclet or a simple XML definition file.
AspectWerkz provides an API to use the very same aspects for proxies, hence providing a transparent experience, allowing a smooth transition for users familiar with proxies.
AspectWerkz is
free software
Free software or libre software is computer software distributed under terms that allow users to run the software for any purpose as well as to study, change, and distribute it and any adapted versions. Free software is a matter of liberty, no ...
. The
LGPL
The GNU Lesser General Public License (LGPL) is a free-software license published by the Free Software Foundation (FSF). The license allows developers and companies to use and integrate a software component released under the LGPL into their own ...
-style license allows the use of AspectWerkz 2.0 in both commercial and open source projects.
See also
*
Aspect-oriented programming
*
Spring AOP (part of the
Spring Framework)
*
Aspect-oriented software development
In computing, aspect-oriented programming (AOP) is a programming paradigm that aims to increase modularity by allowing the separation of cross-cutting concerns. It does so by adding behavior to existing code (an advice) ''without'' modifying t ...
References
*
*
*
*
External links
AJDT* Aspect bench : https://web.archive.org/web/20170816093700/http://www.sable.mcgill.ca/abc/
AspectJ Home PageAspectWerkz Project homepageImprove modularity with aspect-oriented programmingSpring AOP and AspectJ Introduction* Xerox has for AOP/AspectJ, but published AspectJ source code under th
which grants some patent rights.
{{DEFAULTSORT:Aspectj
Programming languages
Aspect-oriented programming
Aspect-oriented software development
Cross-platform software
Eclipse (software)
Eclipse software
Eclipse technology
Java programming language family
Software distribution
Software using the Eclipse license
Programming languages created in 2001
2001 software
Cross-platform free software
High-level programming languages