Xtend 2.5.0 Release Notes (Dec 11th, 2013)


With over 100 bugfixes Version 2.5.0 is mainly a bugfix and performance release. The team has been working on ironing out any glitches in the user experience and further improving a fluent workflow with the language and the tools.

Full support for Java 7 Annotations

The Xtend compiler now supports all annotation values and constant expressions in annotations. These annotation can be evaluated during compilation within active annotations. Also all values supported in Java can now be set during annotation processing.

annotation Columns {
  Column[] value = #[ @Column('id') ]
annotation Column {
  String value
  int length = 2 << 16
class Entity {
  @Columns(#[@Column('id'), @Column(value = 'timestamp', length = 2 * 3 * 7)])
  CompositeKey key

Improved compiler checks

The Xtend compiler now detects ambiguously overloaded methods.

Method overload validation

Ambiguous method invocations are checked and reported with a detailled message. The compiler optionally detects valid but suspiciously overloaded methods that could be implemented by accident. This is especially handy when property access and extension methods come into play.

class A {
  def isCheck() {..}
class B extends A {
  def m() {
     * Ambiguous feature call.
     * The methods
     * 	getCheck() in B and
     * 	isCheck() in A
     * both match.
  def getCheck() {..}
Important note:

You have to make sure to use the library in version 2.5 along with the introduced compiler checks.

Discouraged variable names

Some variable names are used implicitely by Xtend, for example the variable name 'self'. The compiler optionally reports if these names were picked manually.

Small language enhancements

Some refinements have been made to the Xtend language semantics to improve the overall experience.

Auto casts

Xtend supported auto-casts right from the beginning with its powerful switch expression. In 2.5, the more familiar syntax with instance-of checks caught up and also applies automatic casts in if expressions and while loops.

def m(CharSequence c) {
  if (c instanceof String) {

Switch over enums

One of the few places where Xtend's syntax could be improved compared to Java, was a switch expression over enumeration values. Now it's no longer necessary to use a qualified name or static imports for the enum values but the literals are available automatically for the case guards.

def m(RetentionPolicy p) {
  switch p {
    case CLASS: 1
    case RUNTIME: 2
    case SOURCE: 3

Customizable template expression

The template expressions can now be semantically enhanced via target typing. One use case is code generation where imports are automatically added when concatenating a type or if the appended object does not have a proper string representation. It is also possible to pass an explicit line delimiter rather than using the platform default.

def StringConcatenationClient m() '''my template''' // uses target type

// caller code
val result = new StringConcatenation(lineDelimiter) // custom line delimiter or subtype
return result.toString()

Improved type inference with primitive values

The local type inference has been improved when primitive types are involved. Their wrapper types will be used in fewer cases which prevents unexpected exceptions at runtime. An optional compiler check can point to places where primitive defaults are used rather than explicit values.

Better experience with Maven and Android

The Android archetype for Maven was improved. It properly configures the compiler and debug settings, uses the latest Android libraries and the produced Eclipse project matches the structure that is created by the ADT wizards.

Xtend 2.4.3 Release Notes (Sep 04th, 2013)


The team is proud to present a release with more than 450 bug fixes and features.

Table of contents

Android Support

Xtend is a great choice for Android application development because it compiles to Java source code and doesn't require a fat runtime library. With version 2.4 the Android support has been further improved.


Debugging Android applications works now. Previously Xtend supported debugging through JSR-45 only, which is not supported by the Dalvik VM. Now you can configure the compiler to install the debug information in a Dalvik-compatible manner.

Maven Archetype

There is also a Maven archetype to set up a working Android project easily. If you have installed Maven and the Android SDK you only need the following command to get started:

mvn archetype:generate -DarchetypeGroupId=org.eclipse.xtend \
  -DarchetypeArtifactId=xtend-android-archetype \

New Language Features

The following new features have been added to the Xtend language.

Streamlined Java syntax

In 2.4.2 we have introduced new (more Java-like) ways to access nested classes and static members. Also type literals can be written by just using the class name.

Here is an example for a static access of the generated methods in Android's ubiquitous R class:

// previously it was (still supported) :

Type literals can now be written even shorter. Let's say you want to filter a list by type:

// where previously you had to write (still supported) :

If you use the Java syntax (e.g. MyType.class), you'll get an error marker pointing you to the right syntax.

Active Annotations (Provisional API)

Active Annotations let developers particpate in the translation process from Xtend code to Java source code. The developer declares an annotation and a call back for the compiler where the generated Java code can be customized arbitrarily. This doesn't break static typing or the IDE! Any changes made in an active annotation are completely reflected by the environment. A simple example would be a JavaBeans property supporting the Observer pattern. Here you need a getter and a setter method for each field and also an observer list and the proper code to notify them about changes. In many software systems you have hundreds of these properties. Active Annotation allow you to define and automate the implementation of such patterns and idioms at a single point and let the compiler expand it on the fly. And all this based on lightweight, custom libraries. You do no longer have to write nor read the boiler plate code anymore. Read more...

Collection Literals and Arrays

Xtend now has literals for unmodifiable collections.

val listOfWords = #["Hello", "Xtend"]
val setOfWords  = #{"Hello", "Xtend"}
val mapOfWords  = #{1->"Hello", 2->"Xtend"}

Collections created with a literal are immutable. The list literal can be used to natively create arrays, too. If the target type is an array, it will compile to an array initializer.

val String[] arrayOfWords = #["Hello", "Xtend"]

In addition to literals for arrays you can now also easily access and modify arrays as well as create empty arrays of any size.

val String[] arrayOfWords = newArrayOfSize(2)
arrayOfWords.set(0, 'Hello')
arrayOfWords.set(1, 'Xtend')

Interfaces, Enums and Annotations

Interfaces, enumerations and annotation types can now be declared directly in Xtend.

interface Container {
  def T findChild((T)=>boolean matcher)

enum Color {

annotation DependsOn {
  Class<? extends Target> value
  val version = "2.4.0" // type 'String' inferred 

Extension Provider

Extension methods allow to add new methods to existing types without modifying them. Consider the omnipresent class java.lang.String. If you have to parse a string to a number, you could always write


but what you actually think of is


To make that possible, you simply import the class Integer as a static extension:

import static extension java.lang.Integer.*

This enables to pass the base of the number as an argument, too:

Extension methods are available in other language such as C# as well, but Xtend can do better. The new Extensions Providers render a former limitiation obsolete: In Xtend 2.4, fields, parameters and local variables can provide extensions, too. Read more...

SAM Type Conversion

Lambda expressions now work with interfaces and classes with a single abstract method (SAM types). For example, the AbstractIterator from the Guava library has a single abstract method computeNext(). A lambda can be used to implement that:

val AbstractIterator<Double> infiniteRandomNumbers = [| Math::random]

New Operators

Some new operators have been added. In addition to the usual == and != operators which map to Object.equals(Object), the operators === and !== respectively can be used to test for identity equality.

if (myObject === otherObject) {
  println("same objects")

Also new exclusive range operators have been introduced. In order to iterate over a list and work with the index you can write:

for (idx : 0 ..< list.size) {
  println("("+idx+") "+list.get(idx))

Or if you want to iterate backwards :

for (idx : list.size >.. 0) {
  println("("+idx+") "+list.get(idx))

New IDE Features

Being an Eclipse project Xtend has always been designed with IDE integration in mind. The team is proud to announce that the editing support is now almost on par with Java's and in some aspects already even better. A user recently wrote in the newsgroup:

Tooling for Xtend is unlike any other language for the JVM after Java. The IDE support is first class. It will take years for some languages to catch up. Some never will.

The following new IDE features improve the editing experience significantly:

Organize Imports

With the new release we have overhauled the Organize imports action. It processes all kinds of imports, asks to resolve conflicts, and shortens qualified names automatically.

Extract Method and Extract Local Variable

New refactorings have been added. You can now extract code into a new local variable

or into a new method.

Supression of Follow-Up Errors

Follow-up error markers are now suppressed and errors in general are much more local, so it is very easy to spot the problem immediately.

Optional Errors and Warnings

The severity of optional compiler errors can be configured globally as well as individually for a single project. They can either be set explicitly or delegate to the equivalent setting of the Java compiler.

More Quickfixes

Xtend now offers to create missing fields, methods, and types through quick fix proposals.

Improved Content Assist

The content assist has become much smarter. It now proposes lambda brackets if the method accepts a single function and it offers hints on the parameter types when you are working with overloaded methods.


A configurable formatter which pretty prints and indents code idiomatically is now available.


An Xtend editor now has validation and content assist within JavaDoc comments.

Copy Qualified Name

You can use Copy Qualified Name in the editor and the outline view to copy the name of types, fields and methods into the clipboard.


@Xtendlang on Twitter