15 ms·
Retropiler: Java 8 Standard Library Backport for Android
- jsiepkes 9y agoSince Android N the Java implementation is actually OpenJDK so I guess this is primarily useful to support older Android versions.
- deleted 9y ago[deleted]
- Filligree 9y agoIt doesn't use Dalvik anymore?
- lloeki 9y ago"Java is four things." - jwz https://www.jwz.org/doc/java.html https://www.jwz.org/doc/java.html
- cwyers 9y agoOh jwz. Maybe we're the manchildren, but maybe it's the person who redirects all HN links to a picture of a hairy scrotum that hasn't in fact grown up yet.
- jsiepkes 9y agoDalvik is a Java runtime implementation (well technically not but let's keep things simple) just like OpenJDK's hotspot; It compiles bytecode to machine language which your device (PC, smartphone, etc.) can execute. Bytecode is the thing the Java compiler produces (class files) from your Java source code. Android N only switched to the Java API (base classes) of OpenJDK. As far as I know they didn't switch runtime environment. (I know dalvik technically doesn't run bytecode but some other form of intermediary code optimized for mobile devices. I sidestepped that to keep things simple)
- dragonwriter 9y agoThey did change runtimes from Dalvik to ART, from Android L on.
- asmosoinio 9y agoNot since 5.0 (Lollipop). "The successor of Dalvik is Android Runtime (ART), which uses the same bytecode and .dex files (but not .odex files), with the succession aiming at performance improvements transparent to the end users. The new runtime environment was included for the first time in Android 4.4 "KitKat" as a technology preview,[4][5] and replaced Dalvik entirely in later versions; Android 5.0 "Lollipop" is the first version in which ART is the only included runtime." https://en.m.wikipedia.org/wiki/Dalvik_(software) https://en.m.wikipedia.org/wiki/Dalvik_(software)
- bitmapbrother 9y agoThe Dalvik runtime was replaced with ART in Android 5.
- pjmlp 9y agoThis is not 100% true, because the Android team cherry picks features from OpenJDK. I advise anyone that actually cares about Java™, to spend some time reading AOSP commits regarding OpenJDK integration.
- jsiepkes 9y agoI don't quite understand what you mean because the entire class library is of OpenJDK since Android N. Sure desktop specific API's like Swing are missing and Android has its own API's for UI and stuff but all classes from standard Java are from OpenJDK in Android. Before Android N they used to come from Apache Harmony and occasionally classes were borrowed from OpenJDK. But thats no longer the case since Android N.
- pjmlp 9y agoNot it is not, as I said read the AOSP commits. Many methods don't have a full implementation, some classes have partial implementation and not every library class from OpenJDK is taken into Android.
- bitmapbrother 9y agoI'm just confused as to why you think this is a problem? OpenJDK is an open source project and Google, or any other company, can fork it and trim as much undesirable fat as they wish. Additionally, as it has repeatedly been pointed out to you, Google does not call their fork Java not do they use any of the Java trademarks so your accusation that it fragments the language isn't true because it was never intended to be compatible with Java and the JVM. If Oracle has a problem with other companies forking OpenJDK then perhaps they should change the license for further releases or perhaps not make it "Open" anymore.
- pjmlp 9y agoBecause Google has broken Java portability, I cannot just take a random Java library and have it work on Android. Thanks to Google now I need to search for Android Java libraries, instead of Java libraries. Funny every time I search for Java on https://developer.android.com/develop/index.html https://developer.android.com/develop/index.html I get several hundred results, and yet Google doesn't call their fork Java, go figure. The difference, is that I don't live on Silicon Valley, I don't care about Google nor do I need to keep Android team happy to make a living. What I care is that now I need to write two libraries instead of one. Oracle (and Sun before) doesn't have a problem with companies that follow the license rules, there several commercial JDK vendors all of them nicely getting along with Oracle.
- brink 9y agoWhy aren't Java runtime environments install-able on Android like they are on almost any other operating system?
- asmosoinio 9y agoBecause Android does not run a normal JVM.
- eropple 9y agoThink you missed a "not" in there. =)
- asmosoinio 9y agoOops, so I did. Thanks, added.
- nurettin 9y agoOracle sued Google for "stealing their java API specs" so they probably aren't touching the Android platform any time soon. However, there is a Java ME SDK that runs on constrained devices such as ARM phones. There is also an emulator called phoneME.
- hota_mazi 9y agoJava ME has been dead for a solid decade.
- deleted 9y ago[deleted]
- leastangle 9y agoI thought the Android team is switching to native Java 8 support anyway? https://android-developers.googleblog.com/2017/03/future-of-java-8-language-feature.html https://android-developers.googleblog.com/2017/03/future-of-...
- vesinisa 9y agoThat targets only Android 7 and above (and even then a subset of the features). If I understand correctly, this actually allows you to target any Android version at or above SDK 15 (Android 4.0.3), because it monkey patches your code to replace part of the standard library with external libraries. Then, when you decide to deprecate Android 6 support one day, you should be able to smoothly transition to fully native Java 8.
- pulse7 9y agoAccording to this table: https://developer.android.com/studio/preview/features/java8-support.html#supported_features https://developer.android.com/studio/preview/features/java8-... you can use Lambda expressions and Method References with any Android version... but without Java 8 libraries...
- pjmlp 9y agoKind of. They are supporting Java 8 language features depending on the Android platform version. Some Java 8 library APIs have been adopted, but require the latest Android versions. Finally, the JVM bytecodes like invoke dynamic and method handles aren't supported thus making libraries that use them, unusable on Android devices.
- vesinisa 9y agoQuoting u/JakeWharton on Reddit to here: > The runtime includes GPL classes which will force your application to GPL. Despite the Apache 2 license the project reports, do not use this unless you understand what adding GPL code to your application means. You are not subject to the classpath exemption when the code is bundled in your app. https://www.reddit.com/r/androiddev/comments/69rvf4/retropiler_java8_standard_library_for_android_sdk/dh92vkp/ https://www.reddit.com/r/androiddev/comments/69rvf4/retropil...
- glibgil 9y agoHow is this not covered by the classpath exception?
- taeric 9y agoAt a guess, because you distributed the code. It is one thing for it to be in the platform and you are using it by virtue of another's actions. If it only works when you personally bundle and distribute the code... Just a guess, though. IANAL and all of that.
- pulse7 9y agoIf I package my Java app together with OpenJDK JRE then GPL code is bundled in my app and I can use "classpath exemption". If I take OpenJDK JRE, fork it, make Retropiler out of it and publish it under "GPL plus classpath exception" and then package my Java app together with Retropiler then GPL code is bundled in my app - it is the same as above. Why I am not subject to the classpath exception in this case?
- pulse7 9y agoI checked again: 1) OpenJDK allows you to fork under a) GPLv2 or b) GPLv2 + Classpath Exception (see http://openjdk.java.net/legal/gplv2+ce.html http://openjdk.java.net/legal/gplv2+ce.html, "If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version." where library=OpenJDK and exception=Classpath Exception). 2) Android's OpenJDK fork is licensed under GPLv2 + Classpath Exception (see https://android.googlesource.com/platform/libcore/+/master/LICENSE https://android.googlesource.com/platform/libcore/+/master/L...) 3) Retropiler OpenJDK runtime is licensed under GPL only (see https://github.com/retropiler/retropiler https://github.com/retropiler/retropiler, "The Java classes in runtime/ module which were copied from AOSP are licensed as GPL.") They could fork OpenJDK and license it with classpath exception which would allow you to (statically or dynamically) bundle your app with OpenJDK under any license. But since they didn't include the classpath exception your app bundling parts of the Retropiler's OpenJDK fork must be under GPL! So you can use it only for open source projects...
- yincrash 9y agoThe classpath exception is when the library is linked. Because Android DEXing involves converting all third party libraries to a single classes.dex file, this is contrary to most definitions of "linked". So using Retropiler will probably out you in violation of the GPL unless you can win in court saying that it is only linked. Edit: technically dalvik and ART actually execute code from .odex and .oat files
- yincrash 9y agoOne thing that might be possible but probably not easy is to force a multidex layout where all the Retropiler code is in a separate dex. I'm not sure how easy it is to force the build system to do this though.