{"id":1529,"date":"2015-03-17T13:17:09","date_gmt":"2015-03-17T11:17:09","guid":{"rendered":"http:\/\/sseblog.ec-spride.de\/?p=1529"},"modified":"2015-03-17T13:17:09","modified_gmt":"2015-03-17T11:17:09","slug":"lambda-expressions-android","status":"publish","type":"post","link":"https:\/\/blogs.uni-paderborn.de\/sse\/2015\/03\/17\/lambda-expressions-android\/","title":{"rendered":"Lambda Expressions Coming to Android?"},"content":{"rendered":"<div class=\"twoclick_social_bookmarks_post_1529 social_share_privacy clearfix 1.6.4 locale-en_US sprite-en_US\"><\/div><div class=\"twoclick-js\"><script type=\"text\/javascript\">\/* <![CDATA[ *\/\njQuery(document).ready(function($){if($('.twoclick_social_bookmarks_post_1529')){$('.twoclick_social_bookmarks_post_1529').socialSharePrivacy({\"txt_help\":\"Wenn Sie diese Felder durch einen Klick aktivieren, werden Informationen an Facebook, Twitter, Flattr, Xing, t3n, LinkedIn, Pinterest oder Google eventuell ins Ausland \\u00fcbertragen und unter Umst\\u00e4nden auch dort gespeichert. N\\u00e4heres erfahren Sie durch einen Klick auf das <em>i<\\\/em>.\",\"settings_perma\":\"Dauerhaft aktivieren und Daten\\u00fcber-tragung zustimmen:\",\"info_link\":\"http:\\\/\\\/www.heise.de\\\/ct\\\/artikel\\\/2-Klicks-fuer-mehr-Datenschutz-1333879.html\",\"uri\":\"https:\\\/\\\/blogs.uni-paderborn.de\\\/sse\\\/2015\\\/03\\\/17\\\/lambda-expressions-android\\\/\",\"post_id\":1529,\"post_title_referrer_track\":\"Lambda+Expressions+Coming+to+Android%3F\",\"display_infobox\":\"on\"});}});\n\/* ]]> *\/<\/script><\/div><p>In Java 8, Oracle added support for <a href=\"http:\/\/docs.oracle.com\/javase\/tutorial\/java\/javaOO\/lambdaexpressions.html\">Lambda expressions<\/a> to the Java programming language and the Java Virtual Machine (JVM). Though Android apps are also written in Java, this however doesn&#8217;t automatically make them available to\u00a0app developers. In fact, it takes some time until\u00a0Android catches up with newer Java developments.<\/p>\n<p>The build chain for Android is (at least at the moment) built on top of the Java build chain: The normal Java compiler takes Java source files and creates Java class files. These files then serve as inputs to Android&#8217;s &#8220;dx&#8221; tool which finally emits the Dalvik bytecode that can be run on an Android device or emulator. In version 19 of the Android build tools, support for Java 1.7 class files was added &#8211; with the usual delay (Java 1.7 came out in July 2011, Android build tools v19 came out in April 2012). Up to now, that was the end of the line. But now, Java 1.8 support might be around the corner.<\/p>\n<p><!--more--><\/p>\n<p>Those who have followed the development of the smali\/baksmali tools closely mnight have noticed a <a href=\"https:\/\/github.com\/JesusFreke\/smali\/commit\/144951a9e9e6c87866245f2bdeebf0ebedaa0e38\">recent commit with\u00a0<\/a>\u00a0a very interesting description:<\/p>\n<blockquote><p>Add lambda experimental dalvik opcodes<\/p><\/blockquote>\n<p>The story goes on in the same commit description:<\/p>\n<blockquote><p>\u00a0Add new -X\/&#8211;experimental flag to [dis]assemble opcodes not in art yet<\/p>\n<p>Add new opcodes liberate-variable, box-lambda, unbox-lambda,\u00a0capture-variable, create-lambda, invoke-lambda<\/p><\/blockquote>\n<p>So the tool now supports opcodes that (judging by their names) will add Lambda support to Android. They are not yet available in ART, but given that the developer who goes by JesusFreke and is the person behind smali\/baksmali is with Google&#8217;s Android team, chances are that we got an unintended sneak preview into the inner workings of the next Android release.<\/p>\n<p>Let&#8217;s look around in the commit a bit further. There is a very interesting test case with the following line of code:<\/p>\n<blockquote><p>options<span class=\"pl-k\">.<\/span>apiLevel <span class=\"pl-k\">=<\/span> <span class=\"pl-c1\">23<\/span>; <span class=\"pl-c\">\/\/ since we need at least level 23 for lambda opcodes<\/span><\/p><\/blockquote>\n<p>The most recent Android API level is currently 22 which is Android 5.1 Lollipop, released March 2015. So we are actually looking at stuff for something still in the works. Whether these opcodes will actually be part of Android 23 is not clear, though &#8211; they might as well be released later.<\/p>\n<p>Speaking of opcodes, let&#8217;s have a look at the numbers. In the &#8220;old world&#8221;, 0xf3 &#8211; 0xf9 were ODEX opcodes. With ART becoming the new execution model, they have been deprecated together with much of ODEX (yeah, it&#8217;s still lurking in some corners, ok). Their place are now taking the Lambda opcodes, e.g., &#8220;invoke-lambda&#8221; at 0xf3. There&#8217;s a certain chance that these Opcodes will still be relocated before a final release and move away from the &#8220;internal&#8221; region.<\/p>\n<p>In summary, there seems to be hope for all those who were missing Lambda expressions and Java 1.8 support on Android. Let&#8217;s see what happens next.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In Java 8, Oracle added support for Lambda expressions to the Java programming language and the Java Virtual Machine (JVM). Though Android apps are also written in Java, this however doesn&#8217;t automatically make them available to\u00a0app developers. In fact, it &hellip; <a href=\"https:\/\/blogs.uni-paderborn.de\/sse\/2015\/03\/17\/lambda-expressions-android\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":6601,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-1529","post","type-post","status-publish","format-standard","hentry","category-android"],"_links":{"self":[{"href":"https:\/\/blogs.uni-paderborn.de\/sse\/wp-json\/wp\/v2\/posts\/1529","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.uni-paderborn.de\/sse\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.uni-paderborn.de\/sse\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.uni-paderborn.de\/sse\/wp-json\/wp\/v2\/users\/6601"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.uni-paderborn.de\/sse\/wp-json\/wp\/v2\/comments?post=1529"}],"version-history":[{"count":0,"href":"https:\/\/blogs.uni-paderborn.de\/sse\/wp-json\/wp\/v2\/posts\/1529\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.uni-paderborn.de\/sse\/wp-json\/wp\/v2\/media?parent=1529"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.uni-paderborn.de\/sse\/wp-json\/wp\/v2\/categories?post=1529"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.uni-paderborn.de\/sse\/wp-json\/wp\/v2\/tags?post=1529"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}