Skip to content
Backport of Java 9 java.util.stream API for Android Studio 3.x D8 / desugar toolchain, forked from https://github.com/stefan-zobel/streamsupport
Java
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
art added images Jul 12, 2017
docs update Javadoc May 26, 2019
src Bump jsr166 CVS rev. no [no streamsupport relevant changes] Oct 17, 2019
.gitignore update .gitignore Apr 1, 2018
GPL_ClasspathException add LICENSE file Aug 25, 2018
README.md simplify Fabrizio's example Aug 10, 2019
pom.xml Starting out 1.7.2 Jul 1, 2019

README.md

Maven Central javadoc.io Download

android-retrostreams

android-retrostreams is a fork of the streamsupport library targeted at Android developers who want to take advantage of Android Studio 3.x D8 / desugar toolchain's capability to use interface default & static methods across Jar file boundaries.

Utilizing this feature of desugar, the streamsupport API can be even more aligned with the original Java 8 / 9 API exposed in the java.util.function and java.util.stream packages. That allows for Android app's code to be much more in accordance with the standard Java 8 / 9 usage than it is now possible with the original streamsupport API (which is bound by the restrictions of supporting Java 6).

With respect to static / default interface methods the android-retrostreams public API should now be identical to the Java 9 API wherever this is possible (i.e. for all interfaces that have first been introduced in Java 8).

Supplemental helper classes, public static methods and so on that served as a replacement for the default / static interfaces methods in the original streamsupport API are now mostly gone. E.g., no j8.u.s.RefStreams class anymore - all these methods are now in the j9.u.s.Stream interface.

The retrostreams API lives in the packages java9.util.* and java9.lang respectively. So, it's not possible to simply import the java.util.stream package in your code - you'd rather have to use java9.util.stream instead. While that is fine as long as you have full control over your source code there is the other common scenario of using a binary 3rd party dependency that has been compiled against the standard Java 8 java.util.stream API. In the latter case bytecode rewriting via ProGuard might be an option. ProGuard supports most Java 8 language features and the latest release can also replace the standard Java 8 stream API by the streamsupport backport (cf. the Proguard documentation, especially the section titled "Java 8 stream API support"), i.e., in this case, switching to the older streamsupport backport instead of using android-retrostreams might be the more promising approach.

The online Javadoc gives a picture of the API changes.

The current stable release of retrostreams is android-retrostreams-1.7.1.

Please give feedback here if you experience any problems.

build.gradle:

dependencies {
    compile 'net.sourceforge.streamsupport:android-retrostreams:1.7.1'
}

Example usage

import java.util.List;
import java9.util.stream.Stream;
import java9.util.stream.StreamSupport;
import static java9.util.stream.Collectors.toList;

List<Integer> list = Stream.of(1, 2, 3, 4).collect(toList());

List<Integer> incremented = StreamSupport.stream(list)
        .map(i -> i + 1)
        .collect(toList());

Sibling projects

You might also have a use for one of retrostreams' sibling projects:

LICENSE

GNU General Public License, version 2, with the Classpath Exception

You can’t perform that action at this time.