diff options
| author | Andreas Gampe <agampe@google.com> | 2016-08-09 20:44:04 -0700 |
|---|---|---|
| committer | Andreas Gampe <agampe@google.com> | 2016-08-10 11:46:14 -0700 |
| commit | e7bc152c20a21dfa76bdf0f2f129fc0ccf38761d (patch) | |
| tree | 659d1fd08a52725217ab94b22e24dc25bcf677c0 /core/java | |
| parent | c1aac02a37f334ba04d7b2b3a5a3417c3ebe2a38 (diff) | |
Zygote: allow system server compilation to fail
Do not terminate when the system server classpath cannot be
compiled. This can be the case in fallback mode, e.g., when
a device ran out of space.
Bug: 30765660
Change-Id: I3aca3f2f789e2201e4019e1bf04d239ab54b0d3d
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/com/android/internal/os/ZygoteInit.java | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/core/java/com/android/internal/os/ZygoteInit.java b/core/java/com/android/internal/os/ZygoteInit.java index 73a3a0be32e1..68299615b5b9 100644 --- a/core/java/com/android/internal/os/ZygoteInit.java +++ b/core/java/com/android/internal/os/ZygoteInit.java @@ -586,21 +586,42 @@ public class ZygoteInit { // System server is fully AOTed and never profiled // for profile guided compilation. // TODO: Make this configurable between INTERPRET_ONLY, SPEED, SPACE and EVERYTHING? - final int dexoptNeeded = DexFile.getDexOptNeeded( + + int dexoptNeeded; + try { + dexoptNeeded = DexFile.getDexOptNeeded( classPathElement, instructionSet, "speed", false /* newProfile */); + } catch (FileNotFoundException ignored) { + // Do not add to the classpath. + Log.w(TAG, "Missing classpath element for system server: " + classPathElement); + continue; + } catch (IOException e) { + // Not fully clear what to do here as we don't know the cause of the + // IO exception. Add to the classpath to be conservative, but don't + // attempt to compile it. + Log.w(TAG, "Error checking classpath element for system server: " + + classPathElement, e); + dexoptNeeded = DexFile.NO_DEXOPT_NEEDED; + } + if (dexoptNeeded != DexFile.NO_DEXOPT_NEEDED) { - installer.dexopt(classPathElement, Process.SYSTEM_UID, instructionSet, - dexoptNeeded, 0 /*dexFlags*/, "speed", null /*volumeUuid*/, - sharedLibraries); + try { + installer.dexopt(classPathElement, Process.SYSTEM_UID, instructionSet, + dexoptNeeded, 0 /*dexFlags*/, "speed", null /*volumeUuid*/, + sharedLibraries); + } catch (InstallerException e) { + // Ignore (but log), we need this on the classpath for fallback mode. + Log.w(TAG, "Failed compiling classpath element for system server: " + + classPathElement, e); + } } + if (!sharedLibraries.isEmpty()) { sharedLibraries += ":"; } sharedLibraries += classPathElement; } - } catch (IOException | InstallerException e) { - throw new RuntimeException("Error starting system_server", e); } finally { installer.disconnect(); } |
