[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-dev] AspectJ 1.8.0.M1 now available !

Hi,

I'm pleased to announce (much sooner than I anticipated) AspectJ 1.8.0.M1. Typically with an AspectJ major release the first milestone can only weave into bytecode for the comparable Java level but not actually compile source for that Java level, but things are different this time: 1.8.0.M1 is a Java8 compiler based on the latest Eclipse JDT and can compile source code containing the new constructs: lambdas, default methods, type annotations, method references, etc.

If anyone wants to try it out the link is on the download page (milestones section):

http://eclipse.org/aspectj/downloads.php

Or it is in the maven.springframework.org/milestones maven repo, named 1.8.0.M1

NOTE: Java 8 isn't finished, specs are still changing, JDK classes are still changing. The code this compiler produces seems to run on a beta jdk level of ~b97 but I think there are some changes to the lambda runtime classes that mean the code won't run on b99.

NOTE2: Even if you aren't writing Java8 source code, this new compiler allows you to compile your 1.6./1.7 source against a 1.8 JRE. The older versions of AspectJ (and the JDT compiler) would choke when the compiler attempted to unpack some of the classes in a 1.8 JRE that contained constructs it couldn't deal with (e.g. default methods in an interface).

Any feedback is appreciated, don't expect it to be bug free !  1.8.0 final cannot be released until the specs/etc are all finalized so expect the 1.7.X line to continue for a while.

Here is a sample test program I compiled this morning:
===
import java.util.Arrays;

interface I {
    // Default method
    default void foo() {
        System.out.println("ABC");
    }
}

public class C implements I{
    public static void main(String[] args) {
        new C().foo();
        // Lambda
        Runnable r = () -> { System.out.println("hello world!"); };
        r.run();
        // Used Java8 b97
        Arrays.asList(MyClass.doSomething()).forEach((p) -> System.out.println(p));
    }
}

aspect X {
    before(): execution(* I.foo()) {
        System.out.println("I.foo running");
    }
    before(): staticinitialization(!X) {
        System.out.println("Clazz "+thisJoinPointStaticPart);
    }
}


class Utils {
    public static int compareByLength(String in, String out) {
        return in.length() - out.length();
    }
}

class MyClass {
    public static String[] doSomething() {
        String []args = new String[]{"4444","333","22","1"};
        // Method reference
        Arrays.sort(args,Utils::compareByLength);
        return args;
    }
}
===

Enjoy!
The AspectJ Team