The programmer can save state across instances of an Activity by returning the desired object in onRetainNonConfigurationInstance and can retrieve the saved state by calling getLastNonConfigurationInstance. The mechanism for saving this state inside the Android library is quite complicated, but we could model this saving mechanism in a simple way using a special static field that is written in onRetainNonConfigurationInstance and read instead of calling getLastNonConfigurationInstance. We should add an automated bytecode instrumentation pass that implements this transformation.