From e9958d0fc00cf3820ec2ee51787b0ad0a22768b2 Mon Sep 17 00:00:00 2001 From: Oli Date: Thu, 24 Mar 2022 22:06:53 -0700 Subject: [PATCH 1/2] Don't use default interface method bytecode optimization for target 1.8 --- android/build.gradle | 1 - .../src/main/kotlin/com/uber/rib/core/RouterNavigatorState.kt | 1 - 2 files changed, 2 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index dc30ccae5..2722e5248 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -151,7 +151,6 @@ subprojects { if (isKotlinLibrary) { def extraCompilerArgs = [ - "-Xjvm-default=all" ] if (project.name in moduleFriends.keySet()) { def friendName = moduleFriends[project.name] diff --git a/android/libraries/rib-router-navigator/src/main/kotlin/com/uber/rib/core/RouterNavigatorState.kt b/android/libraries/rib-router-navigator/src/main/kotlin/com/uber/rib/core/RouterNavigatorState.kt index a2ac3b82f..1e4428fa2 100644 --- a/android/libraries/rib-router-navigator/src/main/kotlin/com/uber/rib/core/RouterNavigatorState.kt +++ b/android/libraries/rib-router-navigator/src/main/kotlin/com/uber/rib/core/RouterNavigatorState.kt @@ -19,7 +19,6 @@ package com.uber.rib.core interface RouterNavigatorState { /** @return identifier for a [StackRouterNavigator] state. */ - @JvmDefault fun stateName(): String { return if (this.javaClass.isEnum) { (this as Enum<*>).name From 6ce5538aae0f2eaadf620f3de51ba53f24b03484 Mon Sep 17 00:00:00 2001 From: Oli Date: Tue, 29 Mar 2022 17:24:01 -0700 Subject: [PATCH 2/2] Update fix to rely on jvm-default=enable/@JvmDefault in order to preserve java compatibility: --- android/build.gradle | 2 ++ .../src/main/kotlin/com/uber/rib/core/ActivityDelegate.kt | 8 ++++++++ .../src/main/kotlin/com/uber/rib/core/RxActivityEvents.kt | 2 ++ .../rib-base/src/main/kotlin/com/uber/rib/core/Worker.kt | 2 ++ .../main/kotlin/com/uber/rib/core/RouterNavigatorState.kt | 1 + 5 files changed, 15 insertions(+) diff --git a/android/build.gradle b/android/build.gradle index 2722e5248..2168f4c3e 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -151,6 +151,8 @@ subprojects { if (isKotlinLibrary) { def extraCompilerArgs = [ + // See https://github.com/bazelbuild/bazel/issues/15144 + "-Xjvm-default=enable" ] if (project.name in moduleFriends.keySet()) { def friendName = moduleFriends[project.name] diff --git a/android/libraries/rib-android-core/src/main/kotlin/com/uber/rib/core/ActivityDelegate.kt b/android/libraries/rib-android-core/src/main/kotlin/com/uber/rib/core/ActivityDelegate.kt index 618c92c4f..c91ce8ebd 100644 --- a/android/libraries/rib-android-core/src/main/kotlin/com/uber/rib/core/ActivityDelegate.kt +++ b/android/libraries/rib-android-core/src/main/kotlin/com/uber/rib/core/ActivityDelegate.kt @@ -27,24 +27,31 @@ import androidx.annotation.IntRange */ interface ActivityDelegate { /** @see [Activity.onCreate] */ + @JvmDefault fun onCreate(savedInstanceState: Bundle?) {} /** @see [Activity.onStart] */ + @JvmDefault fun onStart() {} /** @see [Activity.onResume] */ + @JvmDefault fun onResume() {} /** @see [Activity.onPause] */ + @JvmDefault fun onPause() {} /** @see [Activity.onStop] */ + @JvmDefault fun onStop() {} /** @see [Activity.onDestroy] */ + @JvmDefault fun onDestroy() {} /** @see [Activity.onActivityResult] */ + @JvmDefault fun onActivityResult( activity: Activity, requestCode: Int, @@ -53,6 +60,7 @@ interface ActivityDelegate { ) {} /** @see [Activity.onRequestPermissionsResult] */ + @JvmDefault fun onRequestPermissionsResult( activity: Activity, @IntRange(from = 0, to = 255) requestCode: Int, diff --git a/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/RxActivityEvents.kt b/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/RxActivityEvents.kt index 1e83cdfd3..7d3e77529 100644 --- a/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/RxActivityEvents.kt +++ b/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/RxActivityEvents.kt @@ -32,6 +32,7 @@ interface RxActivityEvents { * @param clazz The [ActivityLifecycleEvent] subclass you want. * @return an observable of this activity's lifecycle events. */ + @JvmDefault fun lifecycle(clazz: Class): Observable { return lifecycle() .filter { activityEvent -> clazz.isAssignableFrom(activityEvent.javaClass) } @@ -43,6 +44,7 @@ interface RxActivityEvents { * @param clazz The [ActivityCallbackEvent] subclass you want. * @return an observable of this activity's callbacks events. */ + @JvmDefault fun callbacks(clazz: Class): Observable { return callbacks() .filter { activityEvent -> clazz.isAssignableFrom(activityEvent.javaClass) } diff --git a/android/libraries/rib-base/src/main/kotlin/com/uber/rib/core/Worker.kt b/android/libraries/rib-base/src/main/kotlin/com/uber/rib/core/Worker.kt index 8e1664ed2..241b4a75e 100644 --- a/android/libraries/rib-base/src/main/kotlin/com/uber/rib/core/Worker.kt +++ b/android/libraries/rib-base/src/main/kotlin/com/uber/rib/core/Worker.kt @@ -27,8 +27,10 @@ interface Worker { * * @param lifecycle The lifecycle of the worker to use for subscriptions. */ + @JvmDefault fun onStart(lifecycle: WorkerScopeProvider) {} /** Called when the worker is stopped. */ + @JvmDefault fun onStop() {} } diff --git a/android/libraries/rib-router-navigator/src/main/kotlin/com/uber/rib/core/RouterNavigatorState.kt b/android/libraries/rib-router-navigator/src/main/kotlin/com/uber/rib/core/RouterNavigatorState.kt index 1e4428fa2..a2ac3b82f 100644 --- a/android/libraries/rib-router-navigator/src/main/kotlin/com/uber/rib/core/RouterNavigatorState.kt +++ b/android/libraries/rib-router-navigator/src/main/kotlin/com/uber/rib/core/RouterNavigatorState.kt @@ -19,6 +19,7 @@ package com.uber.rib.core interface RouterNavigatorState { /** @return identifier for a [StackRouterNavigator] state. */ + @JvmDefault fun stateName(): String { return if (this.javaClass.isEnum) { (this as Enum<*>).name