Skip to content

Commit

Permalink
Don't use default interface method bytecode optimization for target 1…
Browse files Browse the repository at this point in the history
….8 (#495)

* Don't use default interface method bytecode optimization for target 1.8

* Update fix to rely on jvm-default=enable/@JvmDefault in order to preserve java compatibility:
  • Loading branch information
oliviernotteghem authored Mar 30, 2022
1 parent 3c17c9a commit 4bc63de
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ subprojects {

if (isKotlinLibrary) {
def extraCompilerArgs = [
"-Xjvm-default=all"
// See https://github.com/bazelbuild/bazel/issues/15144
"-Xjvm-default=enable"
]
if (project.name in moduleFriends.keySet()) {
def friendName = moduleFriends[project.name]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -53,6 +60,7 @@ interface ActivityDelegate {
) {}

/** @see [Activity.onRequestPermissionsResult] */
@JvmDefault
fun onRequestPermissionsResult(
activity: Activity,
@IntRange(from = 0, to = 255) requestCode: Int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ interface RxActivityEvents {
* @param clazz The [ActivityLifecycleEvent] subclass you want.
* @return an observable of this activity's lifecycle events.
*/
@JvmDefault
fun <T : ActivityLifecycleEvent> lifecycle(clazz: Class<T>): Observable<T> {
return lifecycle()
.filter { activityEvent -> clazz.isAssignableFrom(activityEvent.javaClass) }
Expand All @@ -43,6 +44,7 @@ interface RxActivityEvents {
* @param clazz The [ActivityCallbackEvent] subclass you want.
* @return an observable of this activity's callbacks events.
*/
@JvmDefault
fun <T : ActivityCallbackEvent> callbacks(clazz: Class<T>): Observable<T> {
return callbacks()
.filter { activityEvent -> clazz.isAssignableFrom(activityEvent.javaClass) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}
}

0 comments on commit 4bc63de

Please sign in to comment.