
Retropiler: Java 8 Standard Library Backport for Android - gfx
https://github.com/retropiler/retropiler
======
vesinisa
Quoting 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/retropil...](https://www.reddit.com/r/androiddev/comments/69rvf4/retropiler_java8_standard_library_for_android_sdk/dh92vkp/)

~~~
pulse7
If 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
I 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/L...](https://android.googlesource.com/platform/libcore/+/master/LICENSE))

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...

------
brink
Why aren't Java runtime environments install-able on Android like they are on
almost any other operating system?

~~~
nurettin
Oracle 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.

~~~
pjmlp
It is ironic how so many [1] JDK vendors were able to work together with Sun,
now with Oracle, just Google seems to have some issues following the same
rules and licenses.

But hey, lets fork Java and do no evil.

[1] -
[https://en.wikipedia.org/wiki/List_of_Java_virtual_machines](https://en.wikipedia.org/wiki/List_of_Java_virtual_machines)

~~~
kbenson
Given that Java licensing seems to have been negotiated and was likely very
different per company, the fact that some licensed versions exist doesn't
actually give too much info. There are accounts of what happened when from the
court filings though, and people have distilled that[1].

In any case, I hardly think prolonged failed business negotiations constitute
failing to "do no evil".

1:
[http://www.pcworld.com/article/253666/a_timeline_of_oracles_...](http://www.pcworld.com/article/253666/a_timeline_of_oracles_java_lawsuit_against_google.html)

~~~
pjmlp
Doing a business without the necessary licenses in place, forking the Java
eco-system by creating an implementation that isn't able to run any random
Java library due to partial implementation, is surely the contrary of "do no
evil".

When Java 9 finally gets out, and looking forward to Java 10 roadmap, this
situation is only going to get worse.

~~~
pulse7
Everybody has rights to fork Java. Oracle gave those rights with OpenJDK under
the GPL+classpath exception license. As long as you follow this license, you
are free to do what ever you like with OpenJDK. Essentially it means you must
stay GPL+classpath exception, but you can add/change/remove any part you like.

~~~
pjmlp
Better read it again, it does not apply to embedded systems, because Sun
wanted to sell J2ME licenses.

~~~
pulse7
You are talking about Oracle JDK and it's "field of use" restriction which
prohibits usage on embedded systems (see
[http://www.oracle.com/technetwork/java/javase/terms/license/...](http://www.oracle.com/technetwork/java/javase/terms/license/index.html)).
But I am talking about Open JDK which does not have this restriction (see
[http://openjdk.java.net/legal/gplv2+ce.html](http://openjdk.java.net/legal/gplv2+ce.html))
and can therefore be used by Google for Android.

------
jsiepkes
Since Android N the Java implementation is actually OpenJDK so I guess this is
primarily useful to support older Android versions.

~~~
Filligree
It doesn't use Dalvik anymore?

~~~
jsiepkes
Dalvik 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
They did change runtimes from Dalvik to ART, from Android L on.

------
yincrash
The 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
One 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.

------
leastangle
I thought the Android team is switching to native Java 8 support anyway?

[https://android-developers.googleblog.com/2017/03/future-
of-...](https://android-developers.googleblog.com/2017/03/future-of-
java-8-language-feature.html)

~~~
vesinisa
That 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
According to this table:
[https://developer.android.com/studio/preview/features/java8-...](https://developer.android.com/studio/preview/features/java8-support.html#supported_features)

you can use Lambda expressions and Method References with any Android
version... but without Java 8 libraries...

