Stefan Zobel - 2017-09-17

User oasisfeng recently came up with an interesting suggestion on the github mirror:

  • Why not create a streamsupport fork targeted at Android developers who want to take advantage of the upcoming Android Studio 3.0 desugar toolchain's capability to use interface default & static methods across Jar file boundaries?

Utilizing this feature of the new desugar toolchain, 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.

This means that even if the new API now uses default & static interface methods (and therefore has to be compiled to Java 8 bytecode), you could still use it for Android projects targeting API level <= 23 provided you use Android Studio 3.0 for these projects.

A streamsupport fork that attempts to make this possible is now available at https://github.com/retrostreams/android-retrostreams

The new fork has its own artifact id android-retrostreams and uses the new package prefix "java9.util" (instead of streamsupport's usage of "java8.util") but has the same version number (1.5.6) as the current stable release of streamsupport (since both are identical featurewise).

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

All public static methods (and static inner classes) that served as a replacement for the Java 8/9 default / static interfaces methods in streamsupport have disappeared in the fork. E.g., no j8.u.s.RefStreams class anymore - all these methods are now in the j9.u.s.Stream interface.

The online Javadoc gives a picture of the API changes.

To experiment with the fork, add the following to your build.gradle:

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

If you have any feedback, please create a new issue on the github site

 

Last edit: Stefan Zobel 2017-12-10