Bug 1485439 - Upgrade to Java 8. r=nalexander,jchen
authorJan Henning <jh+bugzilla@buttercookie.de>
Wed, 22 Aug 2018 21:15:42 +0200
changeset 490731 d81912697dac6aa17bca81962160ff379e1478dc
parent 490730 e3e41bd5523ef78edc0866c05a7c5569f759f7a6
child 490732 fa6197b504ffc2d40816a70272d5e968cf0a54a6
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnalexander, jchen
bugs1485439
milestone64.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1485439 - Upgrade to Java 8. r=nalexander,jchen Doing so allow to use try-with-resources on all API levels supported by us, not just starting from API19. Unfortunately this step also introduces some additional ambiguities in overload resolution, which means that one of GeckoResult's "then" overloads needs to be renamed. Differential Revision: https://phabricator.services.mozilla.com/D4887
build.gradle
mobile/android/app/build.gradle
mobile/android/config/proguard/proguard-robocop.cfg
mobile/android/geckoview/build.gradle
mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/GeckoResultTest.java
mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoResult.java
mobile/android/geckoview_example/build.gradle
mobile/android/thirdparty/build.gradle
--- a/build.gradle
+++ b/build.gradle
@@ -141,17 +141,17 @@ afterEvaluate {
         }
     }
 }
 
 apply plugin: 'idea'
 
 idea {
     project {
-        languageLevel = '1.7'
+        languageLevel = '1.8'
     }
 
     module {
         // Object directories take a huge amount of time for IntelliJ to index.
         // Exclude them.  Convention is that object directories start with obj.
         // IntelliJ is clever and will not exclude the parts of the object
         // directory that are referenced, if there are any.  In practice,
         // indexing the entirety of the tree is taking too long, so exclude all
--- a/mobile/android/app/build.gradle
+++ b/mobile/android/app/build.gradle
@@ -31,18 +31,18 @@ android {
 
     aaptOptions {
         // The omnijar is already a compressed file itself and Gecko expects it to be
         // STORED within the APK rather than DEFLATED.
         noCompress 'ja'
     }
 
     compileOptions {
-        sourceCompatibility JavaVersion.VERSION_1_7
-        targetCompatibility JavaVersion.VERSION_1_7
+        sourceCompatibility JavaVersion.VERSION_1_8
+        targetCompatibility JavaVersion.VERSION_1_8
     }
 
     dexOptions {
         javaMaxHeapSize "2g"
         jumboMode = true
     }
 
     lintOptions {
@@ -66,16 +66,17 @@ android {
         // unfortunate side effect of Proguarding the instrumentation (Robocop) APK, but nothing
         // uses runtime inspection or class-loading with that APK, so it shouldn't be a problem.
         def configureMinifyClosure = {
             // Bug 1229269: we can't yet shrinkResources effectively.  Be sure
             // to use -stripped.ap_ after enabling this.
             // shrinkResources true
             minifyEnabled true
             proguardFile "${topsrcdir}/mobile/android/config/proguard/proguard.cfg"
+            testProguardFile "${topsrcdir}/mobile/android/config/proguard/proguard-robocop.cfg"
         }
         release configureMinifyClosure
         if (mozconfig.substs.MOZILLA_OFFICIAL) {
             debug configureMinifyClosure
         }
 
         def isDebuggable = (!mozconfig.substs.MOZILLA_OFFICIAL) || (mozconfig.substs.NIGHTLY_BUILD && mozconfig.substs.MOZ_DEBUG)
         debug {
new file mode 100644
--- /dev/null
+++ b/mobile/android/config/proguard/proguard-robocop.cfg
@@ -0,0 +1,2 @@
+# Android issue #77785017: Desugar runtime not in Proguard libraryjars for test variants
+-dontwarn com.google.devtools.build.android.desugar.runtime.**
--- a/mobile/android/geckoview/build.gradle
+++ b/mobile/android/geckoview/build.gradle
@@ -108,18 +108,18 @@ android {
         // This makes no sense for GeckoView and should be removed as soon as possible.
         buildConfigField 'boolean', 'MOZILLA_OFFICIAL', mozconfig.substs.MOZILLA_OFFICIAL ? 'true' : 'false';
     }
 
     project.configureProductFlavors.delegate = it
     project.configureProductFlavors()
 
     compileOptions {
-        sourceCompatibility JavaVersion.VERSION_1_7
-        targetCompatibility JavaVersion.VERSION_1_7
+        sourceCompatibility JavaVersion.VERSION_1_8
+        targetCompatibility JavaVersion.VERSION_1_8
     }
 
     dexOptions {
         javaMaxHeapSize "2g"
     }
 
     lintOptions {
         abortOnError false
--- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/GeckoResultTest.java
+++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/GeckoResultTest.java
@@ -203,17 +203,17 @@ public class GeckoResultTest {
         final Throwable boom = new Exception("boom");
         final Thread thread = new Thread() {
             @Override
             public void run() {
                 deferred.completeExceptionally(boom);
             }
         };
 
-        deferred.then(new OnExceptionListener<Void>() {
+        deferred.exceptionally(new OnExceptionListener<Void>() {
             @Override
             public GeckoResult<Void> onException(Throwable error) {
                 assertThat("Exception should match", error, equalTo(boom));
                 assertThat("Thread should match", Thread.currentThread(),
                         equalTo(Looper.getMainLooper().getThread()));
                 done();
                 return null;
             }
@@ -241,40 +241,40 @@ public class GeckoResultTest {
                 return GeckoResult.fromValue(42.0f);
             }
         }).then(new OnValueListener<Float, Float>() {
             @Override
             public GeckoResult<Float> onValue(Float value) {
                 assertThat("Value should match", value, equalTo(42.0f));
                 return GeckoResult.fromException(new Exception("boom"));
             }
-        }).then(new OnExceptionListener<Void>() {
+        }).exceptionally(new OnExceptionListener<Void>() {
             @Override
             public GeckoResult<Void> onException(Throwable error) {
                 assertThat("Error message should match", error.getMessage(), equalTo("boom"));
                 throw new MockException();
             }
-        }).then(new OnExceptionListener<Void>() {
+        }).exceptionally(new OnExceptionListener<Void>() {
             @Override
             public GeckoResult<Void> onException(Throwable exception) {
                 assertThat("Exception should be MockException", exception, instanceOf(MockException.class));
                 done();
                 return null;
             }
         });
 
         waitUntilDone();
     }
 
     @UiThreadTest
     @Test
     public void then_propagatedValue() {
         // The first GeckoResult only has an exception listener, so when the value 42 is
         // propagated to subsequent GeckoResult instances, the propagated value is coerced to null.
-        GeckoResult.fromValue(42).then(new OnExceptionListener<String>() {
+        GeckoResult.fromValue(42).exceptionally(new OnExceptionListener<String>() {
             @Override
             public GeckoResult<String> onException(Throwable exception) throws Throwable {
                 return null;
             }
         }).then(new OnValueListener<String, Void>() {
             @Override
             public GeckoResult<Void> onValue(String value) throws Throwable {
                 assertThat("Propagated value is null", value, nullValue());
@@ -325,17 +325,17 @@ public class GeckoResultTest {
             public GeckoResult<String> onValue(Integer value) throws Exception {
                 throw new MockException();
             }
         }).then(new OnValueListener<String, Void>() {
             @Override
             public GeckoResult<Void> onValue(String value) throws Throwable {
                 return null;
             }
-        }).then(new OnExceptionListener<Void>() {
+        }).exceptionally(new OnExceptionListener<Void>() {
             @Override
             public GeckoResult<Void> onException(Throwable exception) throws Throwable {
                 assertThat("Exception should be expected",
                            exception, instanceOf(MockException.class));
                 done();
                 return null;
             }
         });
--- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoResult.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoResult.java
@@ -246,17 +246,17 @@ public class GeckoResult<T> {
     /**
      * Convenience method for {@link #then(OnValueListener, OnExceptionListener)}.
      *
      * @param exceptionListener An instance of {@link OnExceptionListener}, called when the
      *                          {@link GeckoResult} is completed with an {@link Exception}.
      * @param <U> Type of the new result that is returned by the listener.
      * @return A new {@link GeckoResult} that the listener will complete.
      */
-    public @NonNull <U> GeckoResult<U> then(@NonNull final OnExceptionListener<U> exceptionListener) {
+    public @NonNull <U> GeckoResult<U> exceptionally(@NonNull final OnExceptionListener<U> exceptionListener) {
         return then(null, exceptionListener);
     }
 
     /**
      * Adds listeners to be called when the {@link GeckoResult} is completed either with
      * a value or {@link Throwable}. Listeners will be invoked on the thread where the
      * {@link GeckoResult} was created, which must have a {@link Looper} installed.
      *
--- a/mobile/android/geckoview_example/build.gradle
+++ b/mobile/android/geckoview_example/build.gradle
@@ -12,16 +12,21 @@ android {
         minSdkVersion project.ext.minSdkVersion
         manifestPlaceholders = project.ext.manifestPlaceholders
 
         applicationId "org.mozilla.geckoview_example"
         versionCode 1
         versionName "1.0"
     }
 
+    compileOptions {
+        sourceCompatibility JavaVersion.VERSION_1_8
+        targetCompatibility JavaVersion.VERSION_1_8
+    }
+
     buildTypes {
         release {
             minifyEnabled false
             proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
         }
     }
 
     project.configureProductFlavors.delegate = it
--- a/mobile/android/thirdparty/build.gradle
+++ b/mobile/android/thirdparty/build.gradle
@@ -7,18 +7,18 @@ android {
 
     defaultConfig {
         targetSdkVersion project.ext.targetSdkVersion
         minSdkVersion project.ext.minSdkVersion
         manifestPlaceholders = project.ext.manifestPlaceholders
     }
 
     compileOptions {
-        sourceCompatibility JavaVersion.VERSION_1_7
-        targetCompatibility JavaVersion.VERSION_1_7
+        sourceCompatibility JavaVersion.VERSION_1_8
+        targetCompatibility JavaVersion.VERSION_1_8
     }
 
     lintOptions {
         abortOnError false
     }
 
     sourceSets {
         main {