Java 8 features subset with Retrolambda

suggest change

Retrolambda lets you run Java 8 code with lambda expressions, method references and try-with-resources statements on Java 7, 6 or 5. It does this by transforming your Java 8 compiled bytecode so that it can run on an older Java runtime.

Backported Language Features:

  1. Default methods are backported by copying the default methods to a companion class (interface name + “$”) as static methods, replacing the default methods in the interface with abstract methods, and by adding the necessary method implementations to all classes which implement that interface.
  2. Static methods on interfaces are backported by moving the static methods to a companion class (interface name + “$”), and by changing all methods calls to call the new method location.

Known Limitations:

Retrolambda gradle plugin will automatically build your android project with Retrolambda. The latest version can be found on the releases page.

Usage:

  1. Download and install jdk8
  2. Add the following to your build.gradle
buildscript {
  repositories {
     mavenCentral()
  }

  dependencies {
     classpath 'me.tatarka:gradle-retrolambda:<latest version>'
  }
}

// Required because retrolambda is on maven central
repositories {
  mavenCentral()
}

apply plugin: 'com.android.application' //or apply plugin: 'java'
apply plugin: 'me.tatarka.retrolambda'

android {
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

Known Issues:

retrolambda {
  jvmArgs '-noverify'
}

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents