Merge "[DO NOT MERGE] Update core to 1.4.0-alpha01" into androidx-master-dev
diff --git a/core/core/src/main/java/androidx/core/os/BuildCompat.java b/core/core/src/main/java/androidx/core/os/BuildCompat.java
index 8de2514..972d204 100644
--- a/core/core/src/main/java/androidx/core/os/BuildCompat.java
+++ b/core/core/src/main/java/androidx/core/os/BuildCompat.java
@@ -53,7 +53,7 @@
     }
 
     /**
-     * Checks if the device is running on a pre-release version of Android O or newer.
+     * Checks if the device is running on a release version of Android O or newer.
      * <p>
      * @return {@code true} if O APIs are available for use, {@code false} otherwise
      * @deprecated Android O is a finalized release and this method is no longer necessary. It will
@@ -66,7 +66,7 @@
     }
 
     /**
-     * Checks if the device is running on a pre-release version of Android O MR1 or newer.
+     * Checks if the device is running on a release version of Android O MR1 or newer.
      * <p>
      * @return {@code true} if O MR1 APIs are available for use, {@code false} otherwise
      * @deprecated Android O MR1 is a finalized release and this method is no longer necessary. It
@@ -79,7 +79,7 @@
     }
 
     /**
-     * Checks if the device is running on a pre-release version of Android P or newer.
+     * Checks if the device is running on a release version of Android P or newer.
      * <p>
      * @return {@code true} if P APIs are available for use, {@code false} otherwise
      * @deprecated Android P is a finalized release and this method is no longer necessary. It
@@ -92,7 +92,7 @@
     }
 
     /**
-     * Checks if the device is running on a pre-release version of Android Q or newer.
+     * Checks if the device is running on release version of Android Q or newer.
      * <p>
      * @return {@code true} if Q APIs are available for use, {@code false} otherwise
      * @deprecated Android Q is a finalized release and this method is no longer necessary. It
@@ -105,17 +105,16 @@
     }
 
     /**
-     * Checks if the device is running on a pre-release version of Android R or newer.
+     * Checks if the device is running on a pre-release version of Android R or a release
+     * version of Android R or newer.
      * <p>
-     * <strong>Note:</strong> This method will return {@code false} on devices running release
-     * versions of Android. When Android R is finalized for release, this method will be deprecated
-     * and all calls should be replaced with {@code Build.VERSION.SDK_INT >= Build.VERSION_CODES.R}.
+     * <strong>Note:</strong> When Android R is finalized for release, this method will be
+     * deprecated and all calls should be replaced with
+     * {@code Build.VERSION.SDK_INT >= Build.VERSION_CODES.R}.
      *
      * @return {@code true} if R APIs are available for use, {@code false} otherwise
      */
     public static boolean isAtLeastR() {
-        return VERSION.CODENAME.length() == 1
-                && VERSION.CODENAME.charAt(0) >= 'R'
-                && VERSION.CODENAME.charAt(0) <= 'Z';
+        return VERSION.SDK_INT >= 30 || VERSION.CODENAME.equals("R");
     }
 }
diff --git a/fragment/fragment-ktx/api/1.3.0-alpha04.txt b/fragment/fragment-ktx/api/1.3.0-alpha04.txt
index ce197c5..2f95225 100644
--- a/fragment/fragment-ktx/api/1.3.0-alpha04.txt
+++ b/fragment/fragment-ktx/api/1.3.0-alpha04.txt
@@ -1,6 +1,11 @@
 // Signature format: 3.0
 package androidx.fragment.app {
 
+  public final class FragmentKt {
+    method public static void setResult(androidx.fragment.app.Fragment, String requestKey, android.os.Bundle? result);
+    method public static void setResultListener(androidx.fragment.app.Fragment, String requestKey, kotlin.jvm.functions.Function2<? super java.lang.String,? super android.os.Bundle,kotlin.Unit>? listener);
+  }
+
   public final class FragmentManagerKt {
     method public static inline void commit(androidx.fragment.app.FragmentManager, boolean allowStateLoss = false, kotlin.jvm.functions.Function1<? super androidx.fragment.app.FragmentTransaction,kotlin.Unit> body);
     method public static inline void commitNow(androidx.fragment.app.FragmentManager, boolean allowStateLoss = false, kotlin.jvm.functions.Function1<? super androidx.fragment.app.FragmentTransaction,kotlin.Unit> body);
diff --git a/fragment/fragment-ktx/api/current.txt b/fragment/fragment-ktx/api/current.txt
index ce197c5..2f95225 100644
--- a/fragment/fragment-ktx/api/current.txt
+++ b/fragment/fragment-ktx/api/current.txt
@@ -1,6 +1,11 @@
 // Signature format: 3.0
 package androidx.fragment.app {
 
+  public final class FragmentKt {
+    method public static void setResult(androidx.fragment.app.Fragment, String requestKey, android.os.Bundle? result);
+    method public static void setResultListener(androidx.fragment.app.Fragment, String requestKey, kotlin.jvm.functions.Function2<? super java.lang.String,? super android.os.Bundle,kotlin.Unit>? listener);
+  }
+
   public final class FragmentManagerKt {
     method public static inline void commit(androidx.fragment.app.FragmentManager, boolean allowStateLoss = false, kotlin.jvm.functions.Function1<? super androidx.fragment.app.FragmentTransaction,kotlin.Unit> body);
     method public static inline void commitNow(androidx.fragment.app.FragmentManager, boolean allowStateLoss = false, kotlin.jvm.functions.Function1<? super androidx.fragment.app.FragmentTransaction,kotlin.Unit> body);
diff --git a/fragment/fragment-ktx/api/public_plus_experimental_1.3.0-alpha04.txt b/fragment/fragment-ktx/api/public_plus_experimental_1.3.0-alpha04.txt
index ce197c5..2f95225 100644
--- a/fragment/fragment-ktx/api/public_plus_experimental_1.3.0-alpha04.txt
+++ b/fragment/fragment-ktx/api/public_plus_experimental_1.3.0-alpha04.txt
@@ -1,6 +1,11 @@
 // Signature format: 3.0
 package androidx.fragment.app {
 
+  public final class FragmentKt {
+    method public static void setResult(androidx.fragment.app.Fragment, String requestKey, android.os.Bundle? result);
+    method public static void setResultListener(androidx.fragment.app.Fragment, String requestKey, kotlin.jvm.functions.Function2<? super java.lang.String,? super android.os.Bundle,kotlin.Unit>? listener);
+  }
+
   public final class FragmentManagerKt {
     method public static inline void commit(androidx.fragment.app.FragmentManager, boolean allowStateLoss = false, kotlin.jvm.functions.Function1<? super androidx.fragment.app.FragmentTransaction,kotlin.Unit> body);
     method public static inline void commitNow(androidx.fragment.app.FragmentManager, boolean allowStateLoss = false, kotlin.jvm.functions.Function1<? super androidx.fragment.app.FragmentTransaction,kotlin.Unit> body);
diff --git a/fragment/fragment-ktx/api/public_plus_experimental_current.txt b/fragment/fragment-ktx/api/public_plus_experimental_current.txt
index ce197c5..2f95225 100644
--- a/fragment/fragment-ktx/api/public_plus_experimental_current.txt
+++ b/fragment/fragment-ktx/api/public_plus_experimental_current.txt
@@ -1,6 +1,11 @@
 // Signature format: 3.0
 package androidx.fragment.app {
 
+  public final class FragmentKt {
+    method public static void setResult(androidx.fragment.app.Fragment, String requestKey, android.os.Bundle? result);
+    method public static void setResultListener(androidx.fragment.app.Fragment, String requestKey, kotlin.jvm.functions.Function2<? super java.lang.String,? super android.os.Bundle,kotlin.Unit>? listener);
+  }
+
   public final class FragmentManagerKt {
     method public static inline void commit(androidx.fragment.app.FragmentManager, boolean allowStateLoss = false, kotlin.jvm.functions.Function1<? super androidx.fragment.app.FragmentTransaction,kotlin.Unit> body);
     method public static inline void commitNow(androidx.fragment.app.FragmentManager, boolean allowStateLoss = false, kotlin.jvm.functions.Function1<? super androidx.fragment.app.FragmentTransaction,kotlin.Unit> body);
diff --git a/fragment/fragment-ktx/api/restricted_1.3.0-alpha04.txt b/fragment/fragment-ktx/api/restricted_1.3.0-alpha04.txt
index ce197c5..2f95225 100644
--- a/fragment/fragment-ktx/api/restricted_1.3.0-alpha04.txt
+++ b/fragment/fragment-ktx/api/restricted_1.3.0-alpha04.txt
@@ -1,6 +1,11 @@
 // Signature format: 3.0
 package androidx.fragment.app {
 
+  public final class FragmentKt {
+    method public static void setResult(androidx.fragment.app.Fragment, String requestKey, android.os.Bundle? result);
+    method public static void setResultListener(androidx.fragment.app.Fragment, String requestKey, kotlin.jvm.functions.Function2<? super java.lang.String,? super android.os.Bundle,kotlin.Unit>? listener);
+  }
+
   public final class FragmentManagerKt {
     method public static inline void commit(androidx.fragment.app.FragmentManager, boolean allowStateLoss = false, kotlin.jvm.functions.Function1<? super androidx.fragment.app.FragmentTransaction,kotlin.Unit> body);
     method public static inline void commitNow(androidx.fragment.app.FragmentManager, boolean allowStateLoss = false, kotlin.jvm.functions.Function1<? super androidx.fragment.app.FragmentTransaction,kotlin.Unit> body);
diff --git a/fragment/fragment-ktx/api/restricted_current.txt b/fragment/fragment-ktx/api/restricted_current.txt
index ce197c5..2f95225 100644
--- a/fragment/fragment-ktx/api/restricted_current.txt
+++ b/fragment/fragment-ktx/api/restricted_current.txt
@@ -1,6 +1,11 @@
 // Signature format: 3.0
 package androidx.fragment.app {
 
+  public final class FragmentKt {
+    method public static void setResult(androidx.fragment.app.Fragment, String requestKey, android.os.Bundle? result);
+    method public static void setResultListener(androidx.fragment.app.Fragment, String requestKey, kotlin.jvm.functions.Function2<? super java.lang.String,? super android.os.Bundle,kotlin.Unit>? listener);
+  }
+
   public final class FragmentManagerKt {
     method public static inline void commit(androidx.fragment.app.FragmentManager, boolean allowStateLoss = false, kotlin.jvm.functions.Function1<? super androidx.fragment.app.FragmentTransaction,kotlin.Unit> body);
     method public static inline void commitNow(androidx.fragment.app.FragmentManager, boolean allowStateLoss = false, kotlin.jvm.functions.Function1<? super androidx.fragment.app.FragmentTransaction,kotlin.Unit> body);
diff --git a/fragment/fragment-ktx/src/androidTest/java/androidx/fragment/app/FragmentResultOwnerTest.kt b/fragment/fragment-ktx/src/androidTest/java/androidx/fragment/app/FragmentResultOwnerTest.kt
index 7af8979..b5a3206 100644
--- a/fragment/fragment-ktx/src/androidTest/java/androidx/fragment/app/FragmentResultOwnerTest.kt
+++ b/fragment/fragment-ktx/src/androidTest/java/androidx/fragment/app/FragmentResultOwnerTest.kt
@@ -82,16 +82,16 @@
                 .isNull()
         }
     }
-}
 
-class ResultFragment : Fragment() {
-    var actualResult: String? = null
+    class ResultFragment : Fragment() {
+        var actualResult: String? = null
 
-    override fun onCreate(savedInstanceState: Bundle?) {
-        super.onCreate(savedInstanceState)
+        override fun onCreate(savedInstanceState: Bundle?) {
+            super.onCreate(savedInstanceState)
 
-        parentFragmentManager.setResultListener("requestKey", this) { _, bundle ->
-            actualResult = bundle.getString("bundleKey")
+            parentFragmentManager.setResultListener("requestKey", this) { _, bundle ->
+                actualResult = bundle.getString("bundleKey")
+            }
         }
     }
-}
\ No newline at end of file
+}
diff --git a/fragment/fragment-ktx/src/androidTest/java/androidx/fragment/app/FragmentTest.kt b/fragment/fragment-ktx/src/androidTest/java/androidx/fragment/app/FragmentTest.kt
new file mode 100644
index 0000000..22b45c1
--- /dev/null
+++ b/fragment/fragment-ktx/src/androidTest/java/androidx/fragment/app/FragmentTest.kt
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.fragment.app
+
+import android.os.Bundle
+import androidx.core.os.bundleOf
+import androidx.test.core.app.ActivityScenario
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import androidx.test.filters.MediumTest
+import androidx.testutils.withActivity
+import com.google.common.truth.Truth.assertWithMessage
+import org.junit.Test
+import org.junit.runner.RunWith
+
+@MediumTest
+@RunWith(AndroidJUnit4::class)
+class FragmentTest {
+
+    @Test
+    fun setFragmentResult() {
+        with(ActivityScenario.launch(TestActivity::class.java)) {
+            val fragment1 = ResultFragment()
+
+            val fm = withActivity {
+                supportFragmentManager
+            }
+
+            withActivity {
+                fm.commitNow {
+                    add(fragment1, null)
+                }
+            }
+            val expectedResult = "resultGood"
+            val fragment2 = SetResultFragment(expectedResult)
+
+            withActivity {
+                fm.commitNow {
+                    add(fragment2, null)
+                }
+            }
+
+            assertWithMessage("The result is incorrect")
+                .that(fragment1.actualResult)
+                .isEqualTo(expectedResult)
+        }
+    }
+
+    class ResultFragment : Fragment() {
+        var actualResult: String? = null
+
+        override fun onCreate(savedInstanceState: Bundle?) {
+            super.onCreate(savedInstanceState)
+
+            setResultListener("requestKey") { _, bundle ->
+                actualResult = bundle.getString("bundleKey")
+            }
+        }
+    }
+
+    class SetResultFragment(val resultString: String) : Fragment() {
+        override fun onStart() {
+            super.onStart()
+
+            setResult("requestKey", bundleOf("bundleKey" to resultString))
+        }
+    }
+}
diff --git a/fragment/fragment-ktx/src/main/java/androidx/fragment/app/Fragment.kt b/fragment/fragment-ktx/src/main/java/androidx/fragment/app/Fragment.kt
new file mode 100644
index 0000000..2819660
--- /dev/null
+++ b/fragment/fragment-ktx/src/main/java/androidx/fragment/app/Fragment.kt
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.fragment.app
+
+import android.os.Bundle
+
+/**
+ * Sets the given result for the [requestKey]. This result will be delivered to a
+ * [FragmentResultListener] that is called given to [setResultListener] with the same [requestKey].
+ * If no [FragmentResultListener] with the same key is set or the Lifecycle associated with the
+ * listener is not at least [androidx.lifecycle.Lifecycle.State.STARTED], the result is stored
+ * until one becomes available, or a null result with the same [requestKey] is set.
+ *
+ * @param requestKey key used to identify the result
+ * @param result the result to be passed to another fragment or `null` if you want to
+ *               clear out any pending result.
+ */
+fun Fragment.setResult(
+    requestKey: String,
+    result: Bundle?
+) = parentFragmentManager.setResult(requestKey, result)
+
+/**
+ * Sets the [FragmentResultListener] for a given [requestKey]. Once this Fragment is
+ * at least in the [androidx.lifecycle.Lifecycle.State.STARTED] state, any results set by
+ * [setResult] using the same [requestKey] will be delivered to the
+ * [FragmentResultListener.onFragmentResult] callback. The callback will remain active until this
+ * Fragment reaches the [androidx.lifecycle.Lifecycle.State.DESTROYED] state or a null
+ * [FragmentResultListener] is set for the same [requestKey].
+ *
+ * @param requestKey requestKey used to store the result
+ * @param listener listener for result changes or `null` to remove any previously
+ *                 registered listener.
+ */
+fun Fragment.setResultListener(
+    requestKey: String,
+    listener: ((resultKey: String, bundle: Bundle) -> Unit)?
+) {
+    parentFragmentManager.setResultListener(requestKey, this, listener)
+}
diff --git a/fragment/fragment/api/1.3.0-alpha04.txt b/fragment/fragment/api/1.3.0-alpha04.txt
index b8b1518..8da71a4 100644
--- a/fragment/fragment/api/1.3.0-alpha04.txt
+++ b/fragment/fragment/api/1.3.0-alpha04.txt
@@ -58,8 +58,8 @@
     method public final String getString(@StringRes int);
     method public final String getString(@StringRes int, java.lang.Object!...);
     method public final String? getTag();
-    method public final androidx.fragment.app.Fragment? getTargetFragment();
-    method public final int getTargetRequestCode();
+    method @Deprecated public final androidx.fragment.app.Fragment? getTargetFragment();
+    method @Deprecated public final int getTargetRequestCode();
     method public final CharSequence getText(@StringRes int);
     method @Deprecated public boolean getUserVisibleHint();
     method public android.view.View? getView();
@@ -141,7 +141,7 @@
     method public void setReturnTransition(Object?);
     method public void setSharedElementEnterTransition(Object?);
     method public void setSharedElementReturnTransition(Object?);
-    method public void setTargetFragment(androidx.fragment.app.Fragment?, int);
+    method @Deprecated public void setTargetFragment(androidx.fragment.app.Fragment?, int);
     method @Deprecated public void setUserVisibleHint(boolean);
     method public boolean shouldShowRequestPermissionRationale(String);
     method public void startActivity(android.content.Intent!);
diff --git a/fragment/fragment/api/current.txt b/fragment/fragment/api/current.txt
index b8b1518..8da71a4 100644
--- a/fragment/fragment/api/current.txt
+++ b/fragment/fragment/api/current.txt
@@ -58,8 +58,8 @@
     method public final String getString(@StringRes int);
     method public final String getString(@StringRes int, java.lang.Object!...);
     method public final String? getTag();
-    method public final androidx.fragment.app.Fragment? getTargetFragment();
-    method public final int getTargetRequestCode();
+    method @Deprecated public final androidx.fragment.app.Fragment? getTargetFragment();
+    method @Deprecated public final int getTargetRequestCode();
     method public final CharSequence getText(@StringRes int);
     method @Deprecated public boolean getUserVisibleHint();
     method public android.view.View? getView();
@@ -141,7 +141,7 @@
     method public void setReturnTransition(Object?);
     method public void setSharedElementEnterTransition(Object?);
     method public void setSharedElementReturnTransition(Object?);
-    method public void setTargetFragment(androidx.fragment.app.Fragment?, int);
+    method @Deprecated public void setTargetFragment(androidx.fragment.app.Fragment?, int);
     method @Deprecated public void setUserVisibleHint(boolean);
     method public boolean shouldShowRequestPermissionRationale(String);
     method public void startActivity(android.content.Intent!);
diff --git a/fragment/fragment/api/public_plus_experimental_1.3.0-alpha04.txt b/fragment/fragment/api/public_plus_experimental_1.3.0-alpha04.txt
index 0012403..40a9baa 100644
--- a/fragment/fragment/api/public_plus_experimental_1.3.0-alpha04.txt
+++ b/fragment/fragment/api/public_plus_experimental_1.3.0-alpha04.txt
@@ -58,8 +58,8 @@
     method public final String getString(@StringRes int);
     method public final String getString(@StringRes int, java.lang.Object!...);
     method public final String? getTag();
-    method public final androidx.fragment.app.Fragment? getTargetFragment();
-    method public final int getTargetRequestCode();
+    method @Deprecated public final androidx.fragment.app.Fragment? getTargetFragment();
+    method @Deprecated public final int getTargetRequestCode();
     method public final CharSequence getText(@StringRes int);
     method @Deprecated public boolean getUserVisibleHint();
     method public android.view.View? getView();
@@ -141,7 +141,7 @@
     method public void setReturnTransition(Object?);
     method public void setSharedElementEnterTransition(Object?);
     method public void setSharedElementReturnTransition(Object?);
-    method public void setTargetFragment(androidx.fragment.app.Fragment?, int);
+    method @Deprecated public void setTargetFragment(androidx.fragment.app.Fragment?, int);
     method @Deprecated public void setUserVisibleHint(boolean);
     method public boolean shouldShowRequestPermissionRationale(String);
     method public void startActivity(android.content.Intent!);
diff --git a/fragment/fragment/api/public_plus_experimental_current.txt b/fragment/fragment/api/public_plus_experimental_current.txt
index 0012403..40a9baa 100644
--- a/fragment/fragment/api/public_plus_experimental_current.txt
+++ b/fragment/fragment/api/public_plus_experimental_current.txt
@@ -58,8 +58,8 @@
     method public final String getString(@StringRes int);
     method public final String getString(@StringRes int, java.lang.Object!...);
     method public final String? getTag();
-    method public final androidx.fragment.app.Fragment? getTargetFragment();
-    method public final int getTargetRequestCode();
+    method @Deprecated public final androidx.fragment.app.Fragment? getTargetFragment();
+    method @Deprecated public final int getTargetRequestCode();
     method public final CharSequence getText(@StringRes int);
     method @Deprecated public boolean getUserVisibleHint();
     method public android.view.View? getView();
@@ -141,7 +141,7 @@
     method public void setReturnTransition(Object?);
     method public void setSharedElementEnterTransition(Object?);
     method public void setSharedElementReturnTransition(Object?);
-    method public void setTargetFragment(androidx.fragment.app.Fragment?, int);
+    method @Deprecated public void setTargetFragment(androidx.fragment.app.Fragment?, int);
     method @Deprecated public void setUserVisibleHint(boolean);
     method public boolean shouldShowRequestPermissionRationale(String);
     method public void startActivity(android.content.Intent!);
diff --git a/fragment/fragment/api/restricted_1.3.0-alpha04.txt b/fragment/fragment/api/restricted_1.3.0-alpha04.txt
index 827c2fd..f1747d0 100644
--- a/fragment/fragment/api/restricted_1.3.0-alpha04.txt
+++ b/fragment/fragment/api/restricted_1.3.0-alpha04.txt
@@ -60,8 +60,8 @@
     method public final String getString(@StringRes int);
     method public final String getString(@StringRes int, java.lang.Object!...);
     method public final String? getTag();
-    method public final androidx.fragment.app.Fragment? getTargetFragment();
-    method public final int getTargetRequestCode();
+    method @Deprecated public final androidx.fragment.app.Fragment? getTargetFragment();
+    method @Deprecated public final int getTargetRequestCode();
     method public final CharSequence getText(@StringRes int);
     method @Deprecated public boolean getUserVisibleHint();
     method public android.view.View? getView();
@@ -145,7 +145,7 @@
     method public void setReturnTransition(Object?);
     method public void setSharedElementEnterTransition(Object?);
     method public void setSharedElementReturnTransition(Object?);
-    method public void setTargetFragment(androidx.fragment.app.Fragment?, int);
+    method @Deprecated public void setTargetFragment(androidx.fragment.app.Fragment?, int);
     method @Deprecated public void setUserVisibleHint(boolean);
     method public boolean shouldShowRequestPermissionRationale(String);
     method public void startActivity(android.content.Intent!);
diff --git a/fragment/fragment/api/restricted_current.txt b/fragment/fragment/api/restricted_current.txt
index 827c2fd..f1747d0 100644
--- a/fragment/fragment/api/restricted_current.txt
+++ b/fragment/fragment/api/restricted_current.txt
@@ -60,8 +60,8 @@
     method public final String getString(@StringRes int);
     method public final String getString(@StringRes int, java.lang.Object!...);
     method public final String? getTag();
-    method public final androidx.fragment.app.Fragment? getTargetFragment();
-    method public final int getTargetRequestCode();
+    method @Deprecated public final androidx.fragment.app.Fragment? getTargetFragment();
+    method @Deprecated public final int getTargetRequestCode();
     method public final CharSequence getText(@StringRes int);
     method @Deprecated public boolean getUserVisibleHint();
     method public android.view.View? getView();
@@ -145,7 +145,7 @@
     method public void setReturnTransition(Object?);
     method public void setSharedElementEnterTransition(Object?);
     method public void setSharedElementReturnTransition(Object?);
-    method public void setTargetFragment(androidx.fragment.app.Fragment?, int);
+    method @Deprecated public void setTargetFragment(androidx.fragment.app.Fragment?, int);
     method @Deprecated public void setUserVisibleHint(boolean);
     method public boolean shouldShowRequestPermissionRationale(String);
     method public void startActivity(android.content.Intent!);
diff --git a/fragment/fragment/src/androidTest/java/androidx/fragment/app/FragmentTransitionTest.kt b/fragment/fragment/src/androidTest/java/androidx/fragment/app/FragmentTransitionTest.kt
index a942c72..10a644c 100644
--- a/fragment/fragment/src/androidTest/java/androidx/fragment/app/FragmentTransitionTest.kt
+++ b/fragment/fragment/src/androidTest/java/androidx/fragment/app/FragmentTransitionTest.kt
@@ -204,6 +204,7 @@
 
     // Test that shared elements transition from one fragment to the next
     // and back during pop.
+    @Suppress("DEPRECATION")
     @Test
     fun sharedElementWithTargetFragment() {
         val fragment1 = setupInitialFragment()
diff --git a/fragment/fragment/src/androidTest/java/androidx/fragment/app/TargetFragmentLifeCycleTest.kt b/fragment/fragment/src/androidTest/java/androidx/fragment/app/TargetFragmentLifeCycleTest.kt
index 43c4770..aef943b 100644
--- a/fragment/fragment/src/androidTest/java/androidx/fragment/app/TargetFragmentLifeCycleTest.kt
+++ b/fragment/fragment/src/androidTest/java/androidx/fragment/app/TargetFragmentLifeCycleTest.kt
@@ -30,6 +30,7 @@
 import org.junit.Test
 import org.junit.runner.RunWith
 
+@Suppress("DEPRECATION")
 @RunWith(AndroidJUnit4::class)
 @MediumTest
 class TargetFragmentLifeCycleTest {
diff --git a/fragment/fragment/src/main/java/androidx/fragment/app/Fragment.java b/fragment/fragment/src/main/java/androidx/fragment/app/Fragment.java
index 345ca07..3eeb9ac 100644
--- a/fragment/fragment/src/main/java/androidx/fragment/app/Fragment.java
+++ b/fragment/fragment/src/main/java/androidx/fragment/app/Fragment.java
@@ -737,8 +737,19 @@
      * @param fragment The fragment that is the target of this one.
      * @param requestCode Optional request code, for convenience if you
      * are going to call back with {@link #onActivityResult(int, int, Intent)}.
+     *
+     * @deprecated Instead of using a target fragment to pass results, the fragment requesting a
+     * result should use
+     * {@link FragmentManager#setResultListener(String, LifecycleOwner, FragmentResultListener)}
+     * to register a {@link FragmentResultListener} with a {@code requestKey} using its
+     * {@link #getParentFragmentManager() parent fragment manager}. The
+     * fragment delivering a result should then call
+     * {@link FragmentManager#setResult(String, Bundle)} using the same {@code requestKey}.
+     * Consider using {@link #setArguments} to pass the {@code requestKey} if you need to support
+     * dynamic request keys.
      */
-    @SuppressWarnings("ReferenceEquality")
+    @SuppressWarnings("ReferenceEquality, deprecation")
+    @Deprecated
     public void setTargetFragment(@Nullable Fragment fragment, int requestCode) {
         // Don't allow a caller to set a target fragment in another FragmentManager,
         // but there's a snag: people do set target fragments before fragments get added.
@@ -754,7 +765,7 @@
 
         // Don't let someone create a cycle.
         for (Fragment check = fragment; check != null; check = check.getTargetFragment()) {
-            if (check == this) {
+            if (check.equals(this)) {
                 throw new IllegalArgumentException("Setting " + fragment + " as the target of "
                         + this + " would create a target cycle");
             }
@@ -776,8 +787,14 @@
 
     /**
      * Return the target fragment set by {@link #setTargetFragment}.
+     *
+     * @deprecated Instead of using a target fragment to pass results, use
+     * {@link FragmentManager#setResult(String, Bundle)} to deliver results to
+     * {@link FragmentResultListener} instances registered by other fragments via
+     * {@link FragmentManager#setResultListener(String, LifecycleOwner, FragmentResultListener)}.
      */
     @Nullable
+    @Deprecated
     final public Fragment getTargetFragment() {
         if (mTarget != null) {
             // Ensure that any Fragment set with setTargetFragment is immediately
@@ -792,7 +809,13 @@
 
     /**
      * Return the target request code set by {@link #setTargetFragment}.
+     *
+     * @deprecated When using the target fragment replacement of
+     * {@link FragmentManager#setResultListener(String, LifecycleOwner, FragmentResultListener)} and
+     * {@link FragmentManager#setResult(String, Bundle)}, consider using {@link #setArguments} to
+     * pass a {@code requestKey} if you need to support dynamic request keys.
      */
+    @Deprecated
     final public int getTargetRequestCode() {
         return mTargetRequestCode;
     }
diff --git a/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/SerializationProcessor.kt b/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/SerializationProcessor.kt
similarity index 78%
rename from serialization/serialization-compiler/src/main/kotlin/androidx/serialization/SerializationProcessor.kt
rename to serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/SerializationProcessor.kt
index 9ba5d6e..8eb9f51 100644
--- a/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/SerializationProcessor.kt
+++ b/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/SerializationProcessor.kt
@@ -14,9 +14,9 @@
  * limitations under the License.
  */
 
-package androidx.serialization
+package androidx.serialization.compiler
 
-import androidx.serialization.compiler.codegen.java.JavaGenerator
+import androidx.serialization.compiler.codegen.CodeGenerator
 import androidx.serialization.compiler.processing.steps.EnumProcessingStep
 import com.google.auto.common.BasicAnnotationProcessor
 import com.google.auto.service.AutoService
@@ -32,13 +32,16 @@
 @IncrementalAnnotationProcessor(ISOLATING)
 class SerializationProcessor : BasicAnnotationProcessor() {
     override fun initSteps(): List<ProcessingStep> {
-        val javaGenerator = JavaGenerator(
+        val codeGenerator = CodeGenerator(
             processingEnv,
-            "androidx.serialization.SerializationProcessor")
-
-        return listOf(
-            EnumProcessingStep(processingEnv, javaGenerator)
+            "androidx.serialization.compiler.SerializationProcessor"
         )
+
+        val enumStep = EnumProcessingStep(processingEnv) { enum ->
+            codeGenerator.generateEnumSerializer(enum).writeTo(processingEnv)
+        }
+
+        return listOf(enumStep)
     }
 
     override fun getSupportedSourceVersion(): SourceVersion = SourceVersion.latest()
diff --git a/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/codegen/CodeGenerator.kt b/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/codegen/CodeGenerator.kt
new file mode 100644
index 0000000..8df0a80
--- /dev/null
+++ b/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/codegen/CodeGenerator.kt
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.serialization.compiler.codegen
+
+import androidx.serialization.compiler.schema.Enum
+import javax.annotation.processing.ProcessingEnvironment
+import androidx.serialization.compiler.codegen.java.javaEnumSerializer
+
+internal class CodeGenerator(
+    val generatedAnnotation: GeneratedAnnotation? = null
+) {
+    constructor(
+        processingEnv: ProcessingEnvironment,
+        generatingClassName: String
+    ) : this(GeneratedAnnotation.fromEnvironment(processingEnv, generatingClassName))
+
+    fun generateEnumSerializer(enum: Enum): GeneratedFile {
+        return GeneratedFile.Java(javaEnumSerializer(enum, generatedAnnotation))
+    }
+}
\ No newline at end of file
diff --git a/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/codegen/GeneratedAnnotation.kt b/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/codegen/GeneratedAnnotation.kt
new file mode 100644
index 0000000..04e816f
--- /dev/null
+++ b/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/codegen/GeneratedAnnotation.kt
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.serialization.compiler.codegen
+
+import androidx.serialization.compiler.processing.ext.packageElement
+import com.google.auto.common.GeneratedAnnotations
+import com.squareup.javapoet.ClassName as JavaClassName
+import com.squareup.javapoet.AnnotationSpec as JavaAnnotationSpec
+import javax.annotation.processing.ProcessingEnvironment
+import javax.lang.model.element.NestingKind
+
+internal class GeneratedAnnotation(
+    val generatingClassName: String,
+    val packageName: String,
+    val simpleName: String = "Generated"
+) {
+    private lateinit var javaAnnotationSpec: JavaAnnotationSpec
+
+    fun toJavaAnnotationSpec(): JavaAnnotationSpec {
+        if (!::javaAnnotationSpec.isInitialized) {
+            javaAnnotationSpec = JavaAnnotationSpec
+                .builder(JavaClassName.get(packageName, simpleName))
+                .addMember("value", "\$S", generatingClassName)
+                .build()
+        }
+
+        return javaAnnotationSpec
+    }
+
+    companion object {
+        fun fromEnvironment(
+            processingEnv: ProcessingEnvironment,
+            generatingClassName: String
+        ): GeneratedAnnotation? {
+            return GeneratedAnnotations.generatedAnnotation(
+                processingEnv.elementUtils,
+                processingEnv.sourceVersion
+            ).orElse(null).let { typeElement ->
+                require(typeElement.nestingKind == NestingKind.TOP_LEVEL) {
+                    "Expected @Generated annotation to be a top-level type"
+                }
+
+                GeneratedAnnotation(
+                    generatingClassName,
+                    typeElement.packageElement.toString(),
+                    typeElement.simpleName.toString()
+                )
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/codegen/GeneratedFile.kt b/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/codegen/GeneratedFile.kt
new file mode 100644
index 0000000..9c191b4
--- /dev/null
+++ b/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/codegen/GeneratedFile.kt
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.serialization.compiler.codegen
+
+import com.squareup.javapoet.JavaFile
+import javax.annotation.processing.ProcessingEnvironment
+
+internal sealed class GeneratedFile {
+    abstract fun writeTo(processingEnv: ProcessingEnvironment)
+
+    class Java(val javaFile: JavaFile) : GeneratedFile() {
+        override fun writeTo(processingEnv: ProcessingEnvironment) {
+            javaFile.writeTo(processingEnv.filer)
+        }
+
+        override fun toString(): String {
+            return javaFile.toString()
+        }
+    }
+}
\ No newline at end of file
diff --git a/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/codegen/java/ClassNames.kt b/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/codegen/java/ClassNames.kt
deleted file mode 100644
index 8d8a07e..0000000
--- a/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/codegen/java/ClassNames.kt
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package androidx.serialization.compiler.codegen.java
-
-import com.squareup.javapoet.AnnotationSpec
-import com.squareup.javapoet.ClassName
-
-private const val RUNTIME_PACKAGE = "androidx.serialization.runtime.internal"
-
-internal val ENUM_SERIALIZER: ClassName = ClassName.get(RUNTIME_PACKAGE, "EnumSerializerV1")
-
-internal val NULLABLE: AnnotationSpec =
-    AnnotationSpec.builder(ClassName.get("androidx.annotation", "Nullable")).build()
-
-internal val NON_NULL: AnnotationSpec =
-    AnnotationSpec.builder(ClassName.get("androidx.annotation", "NonNull")).build()
-
-internal val OVERRIDE: AnnotationSpec =
-    AnnotationSpec.builder(ClassName.get("java.lang", "Override")).build()
diff --git a/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/codegen/java/EnumSerializer.kt b/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/codegen/java/EnumSerializer.kt
index 05d6f43..1dd613ff 100644
--- a/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/codegen/java/EnumSerializer.kt
+++ b/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/codegen/java/EnumSerializer.kt
@@ -17,23 +17,37 @@
 package androidx.serialization.compiler.codegen.java
 
 import androidx.serialization.EnumValue
+import androidx.serialization.compiler.codegen.GeneratedAnnotation
+import androidx.serialization.compiler.codegen.java.ext.buildClass
+import androidx.serialization.compiler.codegen.java.ext.controlFlow
+import androidx.serialization.compiler.codegen.java.ext.field
+import androidx.serialization.compiler.codegen.java.ext.nonNull
+import androidx.serialization.compiler.codegen.java.ext.overrideMethod
+import androidx.serialization.compiler.codegen.java.ext.parameterized
+import androidx.serialization.compiler.codegen.java.ext.switchCase
+import androidx.serialization.compiler.codegen.java.ext.switchDefault
+import androidx.serialization.compiler.codegen.java.ext.toClassName
 import androidx.serialization.compiler.schema.Enum
 import com.squareup.javapoet.ClassName
 import com.squareup.javapoet.JavaFile
 import com.squareup.javapoet.TypeName
-import java.lang.IllegalArgumentException
 import javax.lang.model.element.Modifier.FINAL
 import javax.lang.model.element.Modifier.PUBLIC
 import javax.lang.model.element.Modifier.STATIC
 
 /** Generate an enum serializer implementation. */
-internal fun JavaGenerator.enumSerializer(enum: Enum): JavaFile {
-    val enumClass = ClassName.get(enum.element)
+internal fun javaEnumSerializer(
+    enum: Enum,
+    generatedAnnotation: GeneratedAnnotation? = null
+): JavaFile {
+    val enumClass = enum.element.toClassName()
     val serializer = serializerName(enumClass)
 
     val values = enum.values.sortedBy { it.id }
 
-    return buildClass(serializer, enum.element, PUBLIC, FINAL) {
+    return buildClass(serializer, PUBLIC, FINAL) {
+        generatedAnnotation?.let { addAnnotation(it.toJavaAnnotationSpec()) }
+        addOriginatingElement(enum.element)
         addSuperinterface(ENUM_SERIALIZER.parameterized(enumClass))
 
         field(serializer.nonNull, "INSTANCE", PUBLIC, STATIC, FINAL) {
@@ -53,7 +67,7 @@
 
                 switchDefault {
                     addStatement(
-                        "throw new \$T(\"Enum value \" + value.toString() +\$W" +
+                        "throw new \$T(\"Enum value \" + value.toString()\$W+ " +
                                 "\" does not have a serialization ID.\")",
                         IllegalArgumentException::class.java
                     )
@@ -80,3 +94,6 @@
         }
     }
 }
+
+val ENUM_SERIALIZER: ClassName =
+    ClassName.get("androidx.serialization.runtime.internal", "EnumSerializerV1")
diff --git a/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/codegen/java/JavaGenerator.kt b/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/codegen/java/JavaGenerator.kt
deleted file mode 100644
index 0d3745d..0000000
--- a/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/codegen/java/JavaGenerator.kt
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package androidx.serialization.compiler.codegen.java
-
-import com.google.auto.common.GeneratedAnnotations
-import com.squareup.javapoet.AnnotationSpec
-import com.squareup.javapoet.ClassName
-import com.squareup.javapoet.JavaFile
-import com.squareup.javapoet.TypeSpec
-import javax.annotation.processing.ProcessingEnvironment
-import javax.lang.model.SourceVersion
-import javax.lang.model.element.Element
-import javax.lang.model.element.Modifier
-
-/**
- * Central state holder for Java generation.
- *
- * Individual Java generators are implemented as extension methods.
- */
-internal class JavaGenerator(
-    val sourceVersion: SourceVersion = SourceVersion.latest(),
-    private val generatedAnnotation: AnnotationSpec? = null
-) {
-    constructor(
-        processingEnv: ProcessingEnvironment,
-        generatingClassName: String
-    ) : this (
-        sourceVersion = processingEnv.sourceVersion,
-        generatedAnnotation = GeneratedAnnotations.generatedAnnotation(
-            processingEnv.elementUtils,
-            processingEnv.sourceVersion
-        ).orElse(null)?.let { typeElement ->
-            AnnotationSpec.builder(ClassName.get(typeElement))
-                .addMember("value", "\$S", generatingClassName)
-                .build()
-        }
-    )
-
-    /** Build a class spec as a java file. */
-    inline fun buildClass(
-        className: ClassName,
-        originatingElement: Element,
-        vararg modifiers: Modifier,
-        init: TypeSpec.Builder.() -> Unit
-    ): JavaFile {
-        return buildJavaFile(
-            TypeSpec.classBuilder(className).apply {
-                addOriginatingElement(originatingElement)
-                addModifiers(*modifiers)
-                init()
-            },
-            className
-        )
-    }
-
-    /** Finish a type spec builder, adding a generated annotation if present. */
-    fun buildJavaFile(
-        builder: TypeSpec.Builder,
-        className: ClassName
-    ): JavaFile {
-        val typeSpec = builder.run {
-            generatedAnnotation?.let { addAnnotation(it) }
-            build()
-        }
-        return JavaFile.builder(className.packageName(), typeSpec).indent(INDENTATION).build()
-    }
-
-    private companion object {
-        const val INDENTATION = "    "
-    }
-}
diff --git a/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/codegen/java/JavaPoetExt.kt b/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/codegen/java/JavaPoetExt.kt
deleted file mode 100644
index 84cab13..0000000
--- a/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/codegen/java/JavaPoetExt.kt
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package androidx.serialization.compiler.codegen.java
-
-import com.squareup.javapoet.ClassName
-import com.squareup.javapoet.FieldSpec
-import com.squareup.javapoet.MethodSpec
-import com.squareup.javapoet.ParameterizedTypeName
-import com.squareup.javapoet.TypeName
-import com.squareup.javapoet.TypeSpec
-import javax.lang.model.element.Modifier
-
-/** This type name annotated with NonNull. */
-internal val TypeName.nonNull: TypeName
-    get() {
-        require(!isPrimitive) { "@NonNull is not applicable to primitive type: $this" }
-        require(annotations.none { it.type == NULLABLE.type }) {
-            "@NonNull conflicts with @Nullable present on type: ${withoutAnnotations()}"
-        }
-        return if (annotations.any { it.type == NON_NULL.type }) this else annotated(NON_NULL)
-    }
-
-/** This type name annotated with Nullable. */
-internal val TypeName.nullable: TypeName
-    get() {
-        require(!isPrimitive) { "@Nullable is not applicable to primitive type: $this" }
-        require(annotations.none { it.type == NON_NULL.type }) {
-            "@Nullable conflicts with @NonNull present on type: ${withoutAnnotations()}"
-        }
-        return if (annotations.any { it.type == NULLABLE.type }) this else annotated(NULLABLE)
-    }
-
-/** This class name with type parameters.  */
-internal fun ClassName.parameterized(vararg typeArguments: TypeName): ParameterizedTypeName {
-    return ParameterizedTypeName.get(this, *typeArguments)
-}
-
-/** Type-safe builder for a field. */
-internal inline fun TypeSpec.Builder.field(
-    type: TypeName,
-    name: String,
-    vararg modifiers: Modifier,
-    init: FieldSpec.Builder.() -> Unit
-) {
-    addField(FieldSpec.builder(type, name, *modifiers).apply(init).build())
-}
-
-/** Type-safe builder for a method. */
-internal inline fun TypeSpec.Builder.method(
-    name: String,
-    vararg modifiers: Modifier,
-    init: MethodSpec.Builder.() -> Unit
-) {
-    addMethod(MethodSpec.methodBuilder(name).run {
-        addModifiers(*modifiers)
-        init()
-        build()
-    })
-}
-
-internal inline fun TypeSpec.Builder.overrideMethod(
-    name: String,
-    vararg modifiers: Modifier,
-    init: MethodSpec.Builder.() -> Unit
-) {
-    method(name, *modifiers) {
-        addAnnotation(OVERRIDE)
-        init()
-    }
-}
-
-/** Type-safe builder for a control flow within a method. */
-internal inline fun MethodSpec.Builder.controlFlow(
-    format: String,
-    vararg args: Any?,
-    body: MethodSpec.Builder.() -> Unit
-) {
-    beginControlFlow(format, *args)
-    body()
-    endControlFlow()
-}
-
-/** Type-safe builder for a `case` block within a `switch`. */
-internal inline fun MethodSpec.Builder.switchCase(
-    format: String,
-    vararg args: Any?,
-    body: MethodSpec.Builder.() -> Unit
-) {
-    addCode("case $format:\$>\n", *args)
-    body()
-    addCode("\$<")
-}
-
-/** Type-safe builder for a `default` block within a `switch`. */
-internal inline fun MethodSpec.Builder.switchDefault(body: MethodSpec.Builder.() -> Unit) {
-    addCode("default:\n\$>")
-    body()
-    addCode("\$<")
-}
diff --git a/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/codegen/java/ext/MethodSpecExt.kt b/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/codegen/java/ext/MethodSpecExt.kt
new file mode 100644
index 0000000..4bfdf17
--- /dev/null
+++ b/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/codegen/java/ext/MethodSpecExt.kt
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.serialization.compiler.codegen.java.ext
+
+import com.squareup.javapoet.MethodSpec
+
+/** Type-safe builder for a control flow within a method. */
+internal inline fun MethodSpec.Builder.controlFlow(
+    format: String,
+    vararg args: Any?,
+    body: MethodSpec.Builder.() -> Unit
+) {
+    beginControlFlow(format, *args)
+    body()
+    endControlFlow()
+}
+
+/** Type-safe builder for a `case` block within a `switch`. */
+internal inline fun MethodSpec.Builder.switchCase(
+    format: String,
+    vararg args: Any?,
+    body: MethodSpec.Builder.() -> Unit
+) {
+    addCode("case $format:\$>\n", *args)
+    body()
+    addCode("\$<")
+}
+
+/** Type-safe builder for a `default` block within a `switch`. */
+internal inline fun MethodSpec.Builder.switchDefault(body: MethodSpec.Builder.() -> Unit) {
+    addCode("default:\n\$>")
+    body()
+    addCode("\$<")
+}
diff --git a/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/codegen/java/ext/TypeNameExt.kt b/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/codegen/java/ext/TypeNameExt.kt
new file mode 100644
index 0000000..ce2995c
--- /dev/null
+++ b/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/codegen/java/ext/TypeNameExt.kt
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.serialization.compiler.codegen.java.ext
+
+import com.squareup.javapoet.AnnotationSpec
+import com.squareup.javapoet.ClassName
+import com.squareup.javapoet.ParameterizedTypeName
+import com.squareup.javapoet.TypeName
+import javax.lang.model.element.TypeElement
+
+/** Convert a type element to a class name. */
+internal fun TypeElement.toClassName(): ClassName {
+    return ClassName.get(this)
+}
+
+/** This class name with type parameters.  */
+internal fun ClassName.parameterized(vararg typeArguments: TypeName): ParameterizedTypeName {
+    return ParameterizedTypeName.get(this, *typeArguments)
+}
+
+/** This type name annotated with NonNull. */
+internal val TypeName.nonNull: TypeName
+    get() {
+        require(!isPrimitive) { "@NonNull is not applicable to primitive type: $this" }
+        require(annotations.none { it.type == NULLABLE.type }) {
+            "@NonNull conflicts with @Nullable present on type: ${withoutAnnotations()}"
+        }
+        return if (annotations.any { it.type == NON_NULL.type }) this else annotated(
+            NON_NULL
+        )
+    }
+
+private val NON_NULL: AnnotationSpec =
+    AnnotationSpec.builder(ClassName.get("androidx.annotation", "NonNull")).build()
+
+/** This type name annotated with Nullable. */
+internal val TypeName.nullable: TypeName
+    get() {
+        require(!isPrimitive) { "@Nullable is not applicable to primitive type: $this" }
+        require(annotations.none { it.type == NON_NULL.type }) {
+            "@Nullable conflicts with @NonNull present on type: ${withoutAnnotations()}"
+        }
+        return if (annotations.any { it.type == NULLABLE.type }) this else annotated(NULLABLE)
+    }
+
+private val NULLABLE: AnnotationSpec =
+    AnnotationSpec.builder(ClassName.get("androidx.annotation", "Nullable")).build()
\ No newline at end of file
diff --git a/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/codegen/java/ext/TypeSpecExt.kt b/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/codegen/java/ext/TypeSpecExt.kt
new file mode 100644
index 0000000..f6002ac
--- /dev/null
+++ b/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/codegen/java/ext/TypeSpecExt.kt
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.serialization.compiler.codegen.java.ext
+
+import com.squareup.javapoet.AnnotationSpec
+import com.squareup.javapoet.ClassName
+import com.squareup.javapoet.FieldSpec
+import com.squareup.javapoet.JavaFile
+import com.squareup.javapoet.MethodSpec
+import com.squareup.javapoet.TypeName
+import com.squareup.javapoet.TypeSpec
+import javax.lang.model.element.Modifier
+
+/** Builds a new class type spec. */
+internal inline fun buildClass(
+    className: ClassName,
+    vararg modifiers: Modifier,
+    init: TypeSpec.Builder.() -> Unit
+): JavaFile {
+    return TypeSpec.classBuilder(className.topLevelClassName()).run {
+        addModifiers(*modifiers)
+        init()
+        build()
+    }.toJavaFile(className.packageName())
+}
+
+internal fun TypeSpec.toJavaFile(packageName: String): JavaFile {
+    return JavaFile.builder(packageName, this).indent(INDENTATION).build()
+}
+
+private const val INDENTATION = "    "
+
+/** Type-safe builder for a field. */
+internal inline fun TypeSpec.Builder.field(
+    type: TypeName,
+    name: String,
+    vararg modifiers: Modifier,
+    init: FieldSpec.Builder.() -> Unit
+) {
+    addField(FieldSpec.builder(type, name, *modifiers).apply(init).build())
+}
+
+/** Type-safe builder for a method. */
+internal inline fun TypeSpec.Builder.method(
+    name: String,
+    vararg modifiers: Modifier,
+    init: MethodSpec.Builder.() -> Unit
+) {
+    addMethod(MethodSpec.methodBuilder(name).run {
+        addModifiers(*modifiers)
+        init()
+        build()
+    })
+}
+
+internal inline fun TypeSpec.Builder.overrideMethod(
+    name: String,
+    vararg modifiers: Modifier,
+    init: MethodSpec.Builder.() -> Unit
+) {
+    method(name, *modifiers) {
+        addAnnotation(OVERRIDE)
+        init()
+    }
+}
+
+private val OVERRIDE: AnnotationSpec =
+    AnnotationSpec.builder(ClassName.get("java.lang", "Override")).build()
\ No newline at end of file
diff --git a/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/processing/AnnotationMirrorExt.kt b/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/processing/ext/AnnotationMirrorExt.kt
similarity index 94%
rename from serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/processing/AnnotationMirrorExt.kt
rename to serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/processing/ext/AnnotationMirrorExt.kt
index e8cf3d7..0f8cd75 100644
--- a/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/processing/AnnotationMirrorExt.kt
+++ b/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/processing/ext/AnnotationMirrorExt.kt
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package androidx.serialization.compiler.processing
+package androidx.serialization.compiler.processing.ext
 
 import com.google.auto.common.AnnotationMirrors
 import javax.lang.model.element.AnnotationMirror
diff --git a/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/processing/AnnotationValueExt.kt b/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/processing/ext/AnnotationValueExt.kt
similarity index 97%
rename from serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/processing/AnnotationValueExt.kt
rename to serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/processing/ext/AnnotationValueExt.kt
index a99baef..84df736 100644
--- a/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/processing/AnnotationValueExt.kt
+++ b/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/processing/ext/AnnotationValueExt.kt
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package androidx.serialization.compiler.processing
+package androidx.serialization.compiler.processing.ext
 
 import javax.lang.model.element.AnnotationMirror
 import javax.lang.model.element.AnnotationValue
diff --git a/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/processing/ElementExt.kt b/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/processing/ext/ElementExt.kt
similarity index 97%
rename from serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/processing/ElementExt.kt
rename to serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/processing/ext/ElementExt.kt
index 3d918d1..6115b38 100644
--- a/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/processing/ElementExt.kt
+++ b/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/processing/ext/ElementExt.kt
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package androidx.serialization.compiler.processing
+package androidx.serialization.compiler.processing.ext
 
 import com.google.auto.common.MoreElements
 import javax.lang.model.element.AnnotationMirror
diff --git a/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/processing/ProcessingExt.kt b/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/processing/ext/MessagerExt.kt
similarity index 84%
rename from serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/processing/ProcessingExt.kt
rename to serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/processing/ext/MessagerExt.kt
index 5b7f7a8..84a1f7b 100644
--- a/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/processing/ProcessingExt.kt
+++ b/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/processing/ext/MessagerExt.kt
@@ -14,10 +14,9 @@
  * limitations under the License.
  */
 
-package androidx.serialization.compiler.processing
+package androidx.serialization.compiler.processing.ext
 
 import javax.annotation.processing.Messager
-import javax.annotation.processing.ProcessingEnvironment
 import javax.lang.model.element.AnnotationMirror
 import javax.lang.model.element.AnnotationValue
 import javax.lang.model.element.Element
@@ -25,11 +24,6 @@
 import javax.tools.Diagnostic.Kind.WARNING
 import kotlin.reflect.KClass
 
-/** Determine if a qualified class name is present in the processing environment. */
-internal fun ProcessingEnvironment.isClassPresent(qualifiedName: String): Boolean {
-    return elementUtils.getTypeElement(qualifiedName) != null
-}
-
 /** Print [message] as a warning with optional positional information. */
 internal inline fun Messager.warn(
     element: Element? = null,
diff --git a/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/processing/ProcessReserved.kt b/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/processing/parsers/ParseReserved.kt
similarity index 81%
rename from serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/processing/ProcessReserved.kt
rename to serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/processing/parsers/ParseReserved.kt
index 425d0d0..b0a0d3e 100644
--- a/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/processing/ProcessReserved.kt
+++ b/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/processing/parsers/ParseReserved.kt
@@ -14,9 +14,14 @@
  * limitations under the License.
  */
 
-package androidx.serialization.compiler.processing
+package androidx.serialization.compiler.processing.parsers
 
 import androidx.serialization.Reserved.IdRange
+import androidx.serialization.compiler.processing.ext.asAnnotationMirror
+import androidx.serialization.compiler.processing.ext.asInt
+import androidx.serialization.compiler.processing.ext.asList
+import androidx.serialization.compiler.processing.ext.asString
+import androidx.serialization.compiler.processing.ext.get
 import androidx.serialization.schema.Reserved
 import javax.lang.model.element.TypeElement
 import androidx.serialization.Reserved as ReservedAnnotation
@@ -28,7 +33,7 @@
  * [IdRange] with its `from` greater than its `to`, it reverses them before converting them to an
  * [IntRange], reserving the same range of IDs as if they had been correctly placed.
  */
-internal fun processReserved(element: TypeElement): Reserved {
+internal fun parseReserved(element: TypeElement): Reserved {
     return when (val reserved = element[ReservedAnnotation::class]) {
         null -> Reserved.empty()
         else -> Reserved(
diff --git a/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/processing/steps/EnumProcessingStep.kt b/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/processing/steps/EnumProcessingStep.kt
index 7505f72..4b2d008 100644
--- a/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/processing/steps/EnumProcessingStep.kt
+++ b/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/processing/steps/EnumProcessingStep.kt
@@ -17,17 +17,16 @@
 package androidx.serialization.compiler.processing.steps
 
 import androidx.serialization.EnumValue
-import androidx.serialization.compiler.codegen.java.JavaGenerator
-import androidx.serialization.compiler.codegen.java.enumSerializer
-import androidx.serialization.compiler.processing.asInt
-import androidx.serialization.compiler.processing.asTypeElement
-import androidx.serialization.compiler.processing.asVariableElement
-import androidx.serialization.compiler.processing.error
-import androidx.serialization.compiler.processing.get
-import androidx.serialization.compiler.processing.isVisibleToPackage
-import androidx.serialization.compiler.processing.isPrivate
-import androidx.serialization.compiler.processing.processReserved
+import androidx.serialization.compiler.processing.ext.asInt
+import androidx.serialization.compiler.processing.ext.asTypeElement
+import androidx.serialization.compiler.processing.ext.asVariableElement
+import androidx.serialization.compiler.processing.ext.error
+import androidx.serialization.compiler.processing.ext.get
+import androidx.serialization.compiler.processing.ext.isPrivate
+import androidx.serialization.compiler.processing.ext.isVisibleToPackage
+import androidx.serialization.compiler.processing.parsers.parseReserved
 import androidx.serialization.compiler.schema.Enum
+import androidx.serialization.compiler.schema.ext.toTypeName
 import com.google.auto.common.BasicAnnotationProcessor.ProcessingStep
 import com.google.common.collect.SetMultimap
 import javax.annotation.processing.Messager
@@ -40,8 +39,7 @@
 /** Processing step that parses and validates enums, and generates enum coders. */
 internal class EnumProcessingStep(
     private val processingEnv: ProcessingEnvironment,
-    private val javaGenerator: JavaGenerator,
-    private val onEnum: ((Enum) -> Unit)? = null
+    private val onEnum: (Enum) -> Unit
 ) : ProcessingStep {
     private val messager: Messager = processingEnv.messager
 
@@ -90,7 +88,7 @@
      * This method operates by validating that the enum class is not private, then walking its
      * enum constants. It validates that all constants have an [EnumValue] annotation, and then
      * reads [EnumValue.id] and constructs an [Enum] and dispatches it to [onEnum]. It fills
-     * [Enum.reserved] using [processReserved].
+     * [Enum.reserved] using [parseReserved].
      */
     private fun processEnumClass(enumClass: TypeElement) {
         check(enumClass.kind == ElementKind.ENUM) {
@@ -114,14 +112,19 @@
             hasError = true
         }
 
-        val values = mutableSetOf<Enum.Value>()
+        val values = mutableListOf<Enum.Value>()
 
         for (element in enumClass.enclosedElements) {
             if (element.kind == ENUM_CONSTANT) {
                 val annotation = element[EnumValue::class]
 
                 if (annotation != null) {
-                    values += Enum.Value(element.asVariableElement(), annotation["value"].asInt())
+                    values += Enum.Value(
+                        id = annotation["value"].asInt(),
+                        name = element.simpleName.toString(),
+                        element = element.asVariableElement(),
+                        annotation = annotation
+                    )
                 } else {
                     messager.error(element) {
                         "To avoid unexpected behavior, all enum constants in a serializable " +
@@ -133,9 +136,7 @@
         }
 
         if (!hasError) {
-            val enum = Enum(enumClass, values, processReserved(enumClass))
-            onEnum?.invoke(enum)
-            javaGenerator.enumSerializer(enum).writeTo(processingEnv.filer)
+            onEnum(Enum(enumClass.toTypeName(), values, parseReserved(enumClass), enumClass))
         }
     }
 }
diff --git a/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/schema/Enum.kt b/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/schema/Enum.kt
new file mode 100644
index 0000000..3615733
--- /dev/null
+++ b/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/schema/Enum.kt
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.serialization.compiler.schema
+
+import androidx.serialization.schema.Reserved
+import androidx.serialization.schema.TypeName
+import javax.lang.model.element.AnnotationMirror
+import javax.lang.model.element.TypeElement
+import javax.lang.model.element.VariableElement
+
+internal class Enum(
+    override val name: TypeName,
+    override val values: List<Value>,
+    override val reserved: Reserved,
+    val element: TypeElement
+) : androidx.serialization.schema.Enum {
+    class Value(
+        override val id: Int,
+        override val name: String,
+        val element: VariableElement,
+        val annotation: AnnotationMirror
+    ) : androidx.serialization.schema.Enum.Value
+}
diff --git a/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/schema/FieldAccessor.kt b/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/schema/FieldAccessor.kt
deleted file mode 100644
index 7b43ff7..0000000
--- a/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/schema/FieldAccessor.kt
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package androidx.serialization.compiler.schema
-
-import javax.lang.model.element.Element
-import javax.lang.model.element.ExecutableElement
-import javax.lang.model.element.VariableElement
-
-/** Things that can access a message field. */
-internal sealed class FieldAccessor {
-    abstract val element: Element
-}
-
-/** Things that can read a message field. */
-internal sealed class FieldReader : FieldAccessor()
-
-/** Things that can set or update a message field. */
-internal sealed class FieldWriter : FieldAccessor()
-
-/** Things that can set a field at construction time. */
-internal sealed class FieldCreator : FieldWriter()
-
-/** Things that can update a field after construction. */
-internal sealed class FieldUpdater : FieldWriter()
-
-/** An open or final field. */
-internal data class FieldFieldReader(override val element: VariableElement) : FieldReader()
-
-/** A getter method. */
-internal data class GetterFieldReader(override val element: ExecutableElement) : FieldReader()
-
-/** An open field. */
-internal data class FieldFieldUpdater(override val element: VariableElement) : FieldUpdater()
-
-/** A setter method. */
-internal data class SetterFieldUpdater(override val element: ExecutableElement) : FieldUpdater()
-
-/** A constructor parameter. */
-internal data class ConstructorFieldCreator(
-    override val element: VariableElement,
-    val position: Int,
-    val constructorElement: ExecutableElement
-) : FieldCreator()
diff --git a/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/schema/Schema.kt b/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/schema/Schema.kt
deleted file mode 100644
index 90f09ed..0000000
--- a/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/schema/Schema.kt
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package androidx.serialization.compiler.schema
-
-import androidx.serialization.schema.ComplexType
-import androidx.serialization.schema.Enum as SchemaEnum
-import androidx.serialization.schema.Message as SchemaMessage
-import androidx.serialization.schema.Reserved
-import androidx.serialization.schema.Service as SchemaService
-import androidx.serialization.schema.Service.Action.Mode.BLOCKING
-import androidx.serialization.schema.Type
-import androidx.serialization.schema.TypeName
-import javax.lang.model.element.ExecutableElement
-import javax.lang.model.element.TypeElement
-import javax.lang.model.element.VariableElement
-
-/** Base type for schema compiled from the processing environment. */
-internal sealed class ProcessingType : ComplexType {
-    /** Type element this Serialization type is derived from. */
-    abstract val element: TypeElement
-}
-
-internal data class Enum(
-    override val element: TypeElement,
-    override val values: Set<Value> = emptySet(),
-    override val reserved: Reserved = Reserved.empty(),
-    override val name: TypeName = element.toTypeName()
-) : ProcessingType(), SchemaEnum {
-    data class Value(
-        /** Element representing the annotated enum constant. */
-        val element: VariableElement,
-        override val id: Int,
-        override val name: String = element.simpleName.toString()
-    ) : SchemaEnum.Value
-}
-
-internal data class Message(
-    override val element: TypeElement,
-    override val fields: Set<Field> = emptySet(),
-    override val reserved: Reserved = Reserved.empty(),
-    override val name: TypeName = element.toTypeName()
-) : ProcessingType(), SchemaMessage {
-    data class Field(
-        override val id: Int,
-        override val name: String,
-        override val type: Type,
-        /** Accessor for reading this field. */
-        val reader: FieldReader,
-        /** Accessor for writing to this field. */
-        val writer: FieldWriter,
-        /** Whether a field should be set to null instead of a default instance when omitted. */
-        val nullable: Boolean = false
-    ) : SchemaMessage.Field
-}
-
-internal data class Service(
-    override val element: TypeElement,
-    override val actions: Set<Action> = emptySet(),
-    override val reserved: Reserved = Reserved.empty(),
-    override val name: TypeName = element.toTypeName(),
-    override val descriptor: String = name.canonicalName
-) : ProcessingType(), SchemaService {
-    data class Action(
-        /** Element representing the annotated action method. */
-        val element: ExecutableElement,
-        override val id: Int,
-        override val name: String = element.simpleName.toString(),
-        override val mode: SchemaService.Action.Mode = BLOCKING,
-        override val request: Message? = null,
-        override val response: Message? = null
-    ) : SchemaService.Action
-}
diff --git a/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/schema/TypeNameExt.kt b/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/schema/ext/TypeNameExt.kt
similarity index 96%
rename from serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/schema/TypeNameExt.kt
rename to serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/schema/ext/TypeNameExt.kt
index 285a73c..b0a3968 100644
--- a/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/schema/TypeNameExt.kt
+++ b/serialization/serialization-compiler/src/main/kotlin/androidx/serialization/compiler/schema/ext/TypeNameExt.kt
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package androidx.serialization.compiler.schema
+package androidx.serialization.compiler.schema.ext
 
 import androidx.serialization.schema.TypeName
 import javax.lang.model.element.Element
diff --git a/serialization/serialization-compiler/src/test/kotlin/androidx/serialization/compiler/EnumSerializerTest.kt b/serialization/serialization-compiler/src/test/kotlin/androidx/serialization/compiler/EnumSerializerTest.kt
new file mode 100644
index 0000000..0827a49
--- /dev/null
+++ b/serialization/serialization-compiler/src/test/kotlin/androidx/serialization/compiler/EnumSerializerTest.kt
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.serialization.compiler
+
+import com.google.testing.compile.Compilation
+import com.google.testing.compile.CompilationSubject.assertThat
+import com.google.testing.compile.Compiler.javac
+import com.google.testing.compile.JavaFileObjects
+import org.junit.Test
+import javax.tools.JavaFileObject
+
+/** Integration tests for enum serializer generation. */
+class EnumSerializerTest {
+    @Test
+    fun test() {
+        val enum = JavaFileObjects.forSourceString("com.example.TestEnum", """
+            package com.example;
+            
+            import androidx.serialization.EnumValue;
+            
+            public enum TestEnum {
+                @EnumValue(EnumValue.DEFAULT)
+                DEFAULT,
+                @EnumValue(1)
+                ONE,
+                @EnumValue(2)
+                TWO
+            }
+        """.trimIndent())
+
+        /* ktlint-disable max-line-length */
+        val serializer = JavaFileObjects.forSourceString("com.example.TestEnumSerializer", """
+            package com.example;
+
+            import androidx.annotation.NonNull;
+            import androidx.serialization.runtime.internal.EnumSerializerV1;
+            import java.lang.IllegalArgumentException;
+            import java.lang.Override;
+            import javax.annotation.processing.Generated;
+
+            @Generated("androidx.serialization.compiler.SerializationProcessor")
+            public final class TestEnumSerializer implements EnumSerializerV1<TestEnum> {
+                public static final @NonNull TestEnumSerializer INSTANCE = new TestEnumSerializer();
+
+                @Override
+                public int encode(@NonNull TestEnum value) {
+                    switch (value) {
+                        case DEFAULT:
+                            return 0;
+                        case ONE:
+                            return 1;
+                        case TWO:
+                            return 2;
+                        default:
+                            throw new IllegalArgumentException("Enum value " + value.toString()
+                                    + " does not have a serialization ID.");
+                    }
+                }
+
+                @Override
+                public @NonNull TestEnum decode(int value) {
+                    switch (value) {
+                        case 1:
+                            return TestEnum.ONE;
+                        case 2:
+                            return TestEnum.TWO;
+                        default:
+                            return TestEnum.DEFAULT;
+                    }
+                }
+            }
+        """.trimIndent())
+        /* ktlint-enable max-line-length */
+
+        assertThat(compile(enum))
+            .generatedSourceFile("com.example.TestEnumSerializer")
+            .hasSourceEquivalentTo(serializer)
+    }
+
+    private fun compile(vararg sources: JavaFileObject): Compilation {
+        return javac().withProcessors(SerializationProcessor()).compile(*sources)
+    }
+}
\ No newline at end of file
diff --git a/serialization/serialization-compiler/src/test/kotlin/androidx/serialization/SerializationProcessorTest.kt b/serialization/serialization-compiler/src/test/kotlin/androidx/serialization/compiler/SerializationProcessorTest.kt
similarity index 96%
rename from serialization/serialization-compiler/src/test/kotlin/androidx/serialization/SerializationProcessorTest.kt
rename to serialization/serialization-compiler/src/test/kotlin/androidx/serialization/compiler/SerializationProcessorTest.kt
index 1a670da..53a00ae 100644
--- a/serialization/serialization-compiler/src/test/kotlin/androidx/serialization/SerializationProcessorTest.kt
+++ b/serialization/serialization-compiler/src/test/kotlin/androidx/serialization/compiler/SerializationProcessorTest.kt
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package androidx.serialization
+package androidx.serialization.compiler
 
 import com.google.testing.compile.Compilation
 import com.google.testing.compile.CompilationSubject.assertThat
diff --git a/serialization/serialization-compiler/src/test/kotlin/androidx/serialization/compiler/TestElements.kt b/serialization/serialization-compiler/src/test/kotlin/androidx/serialization/compiler/TestElements.kt
deleted file mode 100644
index 37b1c12..0000000
--- a/serialization/serialization-compiler/src/test/kotlin/androidx/serialization/compiler/TestElements.kt
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Copyright 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package androidx.serialization.compiler
-
-import javax.lang.model.element.AnnotationMirror
-import javax.lang.model.element.Element
-import javax.lang.model.element.ElementKind
-import javax.lang.model.element.ElementVisitor
-import javax.lang.model.element.Modifier
-import javax.lang.model.element.Name
-import javax.lang.model.element.NestingKind
-import javax.lang.model.element.PackageElement
-import javax.lang.model.element.TypeElement
-import javax.lang.model.element.TypeParameterElement
-import javax.lang.model.element.VariableElement
-import javax.lang.model.type.TypeMirror
-
-/**
- * Generates a test implementation of [TypeElement].
- *
- * This allows testing code generation in isolation without a processing environment. The
- * [TypeElement.getEnclosingElement] of the returned type will be an appropriate package element
- * or a hierarchy of nested type elements if more than one simple name is supplied.
- */
-internal fun testTypeElement(
-    packageName: String,
-    vararg simpleNames: String,
-    kind: ElementKind = ElementKind.CLASS,
-    modifiers: Set<Modifier> = emptySet()
-): TypeElement {
-    require(simpleNames.isNotEmpty())
-    var qualifiedName = "$packageName.${simpleNames.first()}"
-    var cursor = TestTypeElement(
-        enclosingElement = TestPackageElement(packageName),
-        nestingKind = NestingKind.TOP_LEVEL,
-        simpleName = simpleNames.first(),
-        qualifiedName = qualifiedName,
-        modifiers = modifiers,
-        kind = kind
-    )
-
-    for (i in 1 until simpleNames.size) {
-        qualifiedName = "$qualifiedName.${simpleNames[i]}"
-        cursor = TestTypeElement(
-            enclosingElement = cursor,
-            nestingKind = NestingKind.MEMBER,
-            simpleName = simpleNames[i],
-            qualifiedName = qualifiedName,
-            modifiers = modifiers,
-            kind = kind
-        )
-    }
-
-    return cursor
-}
-
-/** Generates a test implementation of [VariableElement]. */
-internal fun testVariableElement(
-    simpleName: String,
-    kind: ElementKind,
-    enclosingElement: Element? = null,
-    vararg modifiers: Modifier
-): VariableElement {
-    return TestVariableElement(
-        simpleName,
-        enclosingElement,
-        kind,
-        modifiers.toSet()
-    )
-}
-
-private class TestName(
-    private val name: String
-) : Name, CharSequence by name {
-    override fun contentEquals(cs: CharSequence): Boolean = name.contentEquals(cs)
-    override fun toString(): String = name
-}
-
-private abstract class AbstractTestElement(
-    simpleName: String,
-    private val enclosingElement: Element?,
-    private val kind: ElementKind,
-    private val modifiers: Set<Modifier>
-) : Element {
-    private val enclosedElements = mutableListOf<AbstractTestElement>()
-    private val simpleName = TestName(simpleName)
-
-    init {
-        enclosingElement?.let {
-            when (it) { is AbstractTestElement -> it.enclosedElements += this }
-        }
-    }
-
-    override fun getModifiers(): Set<Modifier> = modifiers
-    override fun getSimpleName(): Name = simpleName
-    override fun getKind(): ElementKind = kind
-    override fun getEnclosingElement(): Element? = enclosingElement
-    override fun getEnclosedElements(): List<Element> = enclosedElements
-
-    override fun getAnnotationMirrors() = emptyList<AnnotationMirror>()
-
-    override fun asType(): TypeMirror {
-        throw UnsupportedOperationException("Test Element implementation")
-    }
-
-    override fun <A : Annotation> getAnnotationsByType(annotationType: Class<A>): Array<A> {
-        notImplemented()
-    }
-
-    override fun <A : Annotation> getAnnotation(annotationType: Class<A>): A {
-        notImplemented()
-    }
-
-    protected fun notImplemented(): Nothing {
-        throw UnsupportedOperationException(
-            "Test implementation of ${this::class.java.simpleName} does not implement this method"
-        )
-    }
-}
-
-private class TestPackageElement(
-    qualifiedName: String
-) : PackageElement, AbstractTestElement(
-    simpleName = qualifiedName.split(".").last(),
-    enclosingElement = null,
-    kind = ElementKind.PACKAGE,
-    modifiers = emptySet()
-) {
-    private val qualifiedName = TestName(qualifiedName)
-
-    override fun isUnnamed(): Boolean = qualifiedName.isEmpty()
-    override fun getQualifiedName(): Name = qualifiedName
-
-    override fun <R, P> accept(v: ElementVisitor<R, P>, p: P): R {
-        return v.visitPackage(this, p)
-    }
-}
-
-private class TestTypeElement(
-    simpleName: String,
-    qualifiedName: String,
-    enclosingElement: Element?,
-    kind: ElementKind,
-    modifiers: Set<Modifier>,
-    private val nestingKind: NestingKind = NestingKind.TOP_LEVEL
-) : TypeElement, AbstractTestElement(simpleName, enclosingElement, kind, modifiers) {
-    private val qualifiedNameAsName = TestName(qualifiedName)
-
-    override fun getQualifiedName(): Name = qualifiedNameAsName
-    override fun getNestingKind(): NestingKind = nestingKind
-
-    override fun getSuperclass(): TypeMirror = notImplemented()
-    override fun getTypeParameters(): List<TypeParameterElement> = notImplemented()
-    override fun getInterfaces(): List<TypeMirror> = notImplemented()
-
-    override fun <R, P> accept(v: ElementVisitor<R, P>, p: P): R {
-        return v.visitType(this, p)
-    }
-}
-
-private class TestVariableElement(
-    simpleName: String,
-    enclosingElement: Element?,
-    kind: ElementKind,
-    modifiers: Set<Modifier>
-) : VariableElement, AbstractTestElement(simpleName, enclosingElement, kind, modifiers) {
-    override fun getConstantValue(): Any = notImplemented()
-
-    override fun <R, P> accept(v: ElementVisitor<R, P>, p: P): R {
-        return v.visitVariable(this, p)
-    }
-}
diff --git a/serialization/serialization-compiler/src/test/kotlin/androidx/serialization/compiler/TestSchema.kt b/serialization/serialization-compiler/src/test/kotlin/androidx/serialization/compiler/TestSchema.kt
deleted file mode 100644
index 4376cb2..0000000
--- a/serialization/serialization-compiler/src/test/kotlin/androidx/serialization/compiler/TestSchema.kt
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package androidx.serialization.compiler
-
-import androidx.serialization.compiler.schema.Enum
-import androidx.serialization.schema.Reserved
-import javax.lang.model.element.ElementKind.ENUM_CONSTANT
-
-/** Generates a customizable [Enum] for testing code generation. */
-internal fun testEnum(
-    packageName: String = "com.example",
-    vararg simpleNames: String = Array(1) { "TestEnum" },
-    values: Map<Int, String> = mapOf(
-        0 to "DEFAULT",
-        1 to "ONE",
-        2 to "TWO"
-    ),
-    reserved: Reserved = Reserved.empty()
-): Enum {
-    val typeElement = testTypeElement(packageName, *simpleNames)
-    return Enum(
-        typeElement,
-        values.mapTo(mutableSetOf()) { (id, name) ->
-            Enum.Value(testVariableElement(name, ENUM_CONSTANT, typeElement), id)
-        },
-        reserved
-    )
-}
diff --git a/serialization/serialization-compiler/src/test/kotlin/androidx/serialization/compiler/codegen/java/EnumSerializerTest.kt b/serialization/serialization-compiler/src/test/kotlin/androidx/serialization/compiler/codegen/java/EnumSerializerTest.kt
deleted file mode 100644
index f7025b4..0000000
--- a/serialization/serialization-compiler/src/test/kotlin/androidx/serialization/compiler/codegen/java/EnumSerializerTest.kt
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package androidx.serialization.compiler.codegen.java
-
-import androidx.serialization.compiler.testEnum
-import com.google.common.truth.Truth.assertThat
-import org.junit.Test
-
-/** Unit tests for [enumSerializer]. */
-class EnumSerializerTest {
-    @Test
-    fun testFullClass() {
-        /* ktlint-disable max-line-length */
-        assertThat(testJavaGenerator(this::class).enumSerializer(testEnum()).toString())
-            .contains("""
-                @Generated("androidx.serialization.compiler.codegen.java.EnumSerializerTest")
-                public final class TestEnumSerializer implements EnumSerializerV1<TestEnum> {
-                    public static final @NonNull TestEnumSerializer INSTANCE = new TestEnumSerializer();
-
-                    @Override
-                    public int encode(@NonNull TestEnum value) {
-                        switch (value) {
-                            case DEFAULT:
-                                return 0;
-                            case ONE:
-                                return 1;
-                            case TWO:
-                                return 2;
-                            default:
-                                throw new IllegalArgumentException("Enum value " + value.toString() +
-                                        " does not have a serialization ID.");
-                        }
-                    }
-
-                    @Override
-                    public @NonNull TestEnum decode(int value) {
-                        switch (value) {
-                            case 1:
-                                return TestEnum.ONE;
-                            case 2:
-                                return TestEnum.TWO;
-                            default:
-                                return TestEnum.DEFAULT;
-                        }
-                    }
-                }
-            """.trimIndent())
-        /* ktlint-enable max-line-length */
-    }
-}
diff --git a/serialization/serialization-compiler/src/test/kotlin/androidx/serialization/compiler/codegen/java/TestJavaGenerator.kt b/serialization/serialization-compiler/src/test/kotlin/androidx/serialization/compiler/codegen/java/TestJavaGenerator.kt
deleted file mode 100644
index bc167e5..0000000
--- a/serialization/serialization-compiler/src/test/kotlin/androidx/serialization/compiler/codegen/java/TestJavaGenerator.kt
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package androidx.serialization.compiler.codegen.java
-
-import com.squareup.javapoet.AnnotationSpec
-import com.squareup.javapoet.ClassName
-import javax.lang.model.SourceVersion
-import javax.lang.model.SourceVersion.RELEASE_8
-import kotlin.reflect.KClass
-
-internal fun testJavaGenerator(
-    generatingClass: KClass<*>,
-    sourceVersion: SourceVersion = SourceVersion.latest()
-): JavaGenerator {
-
-    val packageName = if (sourceVersion <= RELEASE_8) {
-        "javax.annotation.processing"
-    } else {
-        "javax.annotation"
-    }
-
-    val generatedAnnotation = AnnotationSpec.builder(ClassName.get(packageName, "Generated"))
-        .addMember("value", "\$S", generatingClass.java.canonicalName)
-        .build()
-
-    return JavaGenerator(sourceVersion, generatedAnnotation)
-}
diff --git a/serialization/serialization-compiler/src/test/kotlin/androidx/serialization/compiler/processing/ProcessReservedTest.kt b/serialization/serialization-compiler/src/test/kotlin/androidx/serialization/compiler/processing/parsers/ParseReservedTest.kt
similarity index 86%
rename from serialization/serialization-compiler/src/test/kotlin/androidx/serialization/compiler/processing/ProcessReservedTest.kt
rename to serialization/serialization-compiler/src/test/kotlin/androidx/serialization/compiler/processing/parsers/ParseReservedTest.kt
index af484b2d..b29c05a 100644
--- a/serialization/serialization-compiler/src/test/kotlin/androidx/serialization/compiler/processing/ProcessReservedTest.kt
+++ b/serialization/serialization-compiler/src/test/kotlin/androidx/serialization/compiler/processing/parsers/ParseReservedTest.kt
@@ -14,9 +14,9 @@
  * limitations under the License.
  */
 
-package androidx.serialization.compiler.processing
+package androidx.serialization.compiler.processing.parsers
 
-import androidx.serialization.compiler.testTypeElement
+import androidx.serialization.compiler.processing.ext.asTypeElement
 import androidx.serialization.schema.Reserved
 import com.google.auto.common.BasicAnnotationProcessor
 import com.google.auto.common.BasicAnnotationProcessor.ProcessingStep
@@ -29,14 +29,8 @@
 import javax.lang.model.SourceVersion
 import javax.lang.model.element.Element
 
-/** Unit tests for [processReserved]. */
-class ProcessReservedTest {
-    @Test
-    fun testEmpty() {
-        val typeElement = testTypeElement("com.example", "Test")
-        assertThat(processReserved(typeElement)).isSameInstanceAs(Reserved.empty())
-    }
-
+/** Unit tests for [parseReserved]. */
+class ParseReservedTest {
     @Test
     fun testIds() {
         assertThat(compile("@Reserved(ids = {1, 2, 3})").ids).containsExactly(1, 2, 3)
@@ -60,7 +54,8 @@
     }
 
     private fun compile(reserved: String): Reserved {
-        val processor = ReservedProcessor()
+        val processor =
+            ReservedProcessor()
         val source = JavaFileObjects.forSourceString("TestClass", """
             import androidx.serialization.Reserved;
             
@@ -82,7 +77,7 @@
             elementsByAnnotation: SetMultimap<Class<out Annotation>, Element>
         ): Set<Element> {
             elementsByAnnotation[androidx.serialization.Reserved::class.java].forEach {
-                onReserved(processReserved(it.asTypeElement()))
+                onReserved(parseReserved(it.asTypeElement()))
             }
 
             return emptySet()
diff --git a/serialization/serialization-compiler/src/test/kotlin/androidx/serialization/compiler/processing/steps/EnumProcessingStepTest.kt b/serialization/serialization-compiler/src/test/kotlin/androidx/serialization/compiler/processing/steps/EnumProcessingStepTest.kt
index 28a6106..5662eb4 100644
--- a/serialization/serialization-compiler/src/test/kotlin/androidx/serialization/compiler/processing/steps/EnumProcessingStepTest.kt
+++ b/serialization/serialization-compiler/src/test/kotlin/androidx/serialization/compiler/processing/steps/EnumProcessingStepTest.kt
@@ -16,7 +16,6 @@
 
 package androidx.serialization.compiler.processing.steps
 
-import androidx.serialization.compiler.codegen.java.JavaGenerator
 import androidx.serialization.compiler.schema.Enum
 import androidx.serialization.schema.Reserved
 import com.google.auto.common.BasicAnnotationProcessor
@@ -124,26 +123,6 @@
                     "annotated with @EnumValue")
     }
 
-    @Test
-    fun testSerializerGeneration() {
-        val testEnum = JavaFileObjects.forSourceString("com.example.Test", """
-            package com.example;
-            import androidx.serialization.EnumValue;
-            
-            public enum Test {
-                @EnumValue(EnumValue.DEFAULT)
-                DEFAULT,
-                @EnumValue(1)
-                ONE,
-                @EnumValue(2)
-                TWO
-            }
-        """.trimIndent())
-
-        assertThat(compile(testEnum))
-            .generatedSourceFile("com.example.TestSerializer")
-    }
-
     private fun compile(vararg sources: JavaFileObject): Compilation {
         return javac().withProcessors(SchemaCompilationProcessor()).compile(*sources)
     }
@@ -160,8 +139,7 @@
         lateinit var enum: Enum
 
         override fun initSteps(): List<ProcessingStep> {
-            val javaGenerator = JavaGenerator(processingEnv, this::class.java.canonicalName)
-            return listOf(EnumProcessingStep(processingEnv, javaGenerator) { enum = it })
+            return listOf(EnumProcessingStep(processingEnv) { enum = it })
     }
 
         override fun getSupportedSourceVersion(): SourceVersion {