Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are Java 8 Streams only available from API level 24?

Supported Java 8 Language Features and APIs states that we can use default methods and lambda expressions in android projects with any min sdk API level.

However, the Stream library (java.util.stream) is only supported for API 24 and higher. Can somebody please shed some light on why this is the case? To me it does not make sense, because as far as I understand, the addition of stream API does not require JVM modification unlike the addition of lambdas or default methods; it simply leverages Java 8 features like default methods on collections and adds some new code to java util library?

like image 522
AAryz Avatar asked Apr 06 '18 14:04

AAryz


1 Answers

Can somebody please shed some light on why this is the case?

Because Google does not have a time machine. Or, if they are, they are not using it to "retcon" previous versions of Android.

it simply leverages Java 8 features like default methods on collections and adds some new code to java util library?

Correct. However, Google has no means of changing java.util classes on previous versions of Android. Even adding new java.util classes via a library would be a problem.

like image 194
CommonsWare Avatar answered Oct 06 '22 00:10

CommonsWare