© Copyright 2011 Contributors. All rights reserved.

AspectJ 1.7.0.M1 Readme

The full list of resolved issues in 1.7.0 is available here.

1.7.0.M1 available 16-Dec-2011

Notable Changes

M1 - upgrade to Java 7

This milestone is the first after the upgrade to the Eclipse Java 7 compiler. AspectJ moved from Eclipse JDT Core 0.785_R33x (Eclipse 3.3) to Eclipse JDT Core 0.B79_R37x (Eclipse 3.7). This is a big change where AspectJ is picking up four years of change from the Eclipse compiler.

It means that you can now use the new Java 7 language constructs in your programs:

- Diamond operator in advice:

aspect Foo {
  before(): execution(* *(..)) {
    List ls = new ArrayList<>();
  }
}

- Diamond operator in ITD:

public List DiamondITD.ls = new ArrayList<>();

- Underscore literals and binary literals in advice:

  before(): execution(* *(..)) {
    int onemill = 1_000_000;
    int four =0b100;
  }

- Multi-catch:

before(): execution(* main(..)) {
    try {
      foo("abc");
    } catch (ExceptionA | ExceptionB ex) {
      bar(ex);
    }
}

- String switch:

 before(String s): execution(* *(..)) && args(s) {
   switch(s) {
     case "quux":
       foo();
       break;
     case "bar":
       foo();
       break;
     default:
       foo();
       break;
   }
 }

- Try with resources:

   try (
     InputStream in = new FileInputStream(src);
     OutputStream out = new FileOutputStream(dest))
   {
     // code
   }

Note: there is still more to be done for full Java7 support. invokedynamic handling is not in place yet (AspectJ may have trouble if it encounters that bytecode instruction). Also interplay between the new language constructs and the existing pointcuts needs some work - for example handler() pointcut and multicatch has a known issue right now.