From 443328d1c3e0e236900b805f52a380d0d501d7f3 Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Thu, 17 Feb 2022 11:39:25 -0800 Subject: Log ImageConverter initialization problems as errors rather than warnings Test: existing Bug: 220022493 Change-Id: I2501c5c227f1ebc528d99e52c0c0a66db8163d27 --- emulator/src/com/android/emulator/ImageConverter.java | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) (limited to 'emulator') diff --git a/emulator/src/com/android/emulator/ImageConverter.java b/emulator/src/com/android/emulator/ImageConverter.java index da76517a860..53a45d2fe5e 100644 --- a/emulator/src/com/android/emulator/ImageConverter.java +++ b/emulator/src/com/android/emulator/ImageConverter.java @@ -20,7 +20,6 @@ import static com.android.tools.idea.util.StudioPathManager.isRunningFromSources import com.android.tools.idea.protobuf.ByteString; import com.android.tools.idea.protobuf.UnsafeByteOperations; import com.android.tools.idea.util.StudioPathManager; -import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.PathManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.SystemInfo; @@ -43,7 +42,7 @@ public class ImageConverter { initByteStringFields(); } catch (Throwable e) { - logError("Native image converter library is not available", e); + logger().error("Native image converter library is not available", e); } } @@ -150,19 +149,10 @@ public class ImageConverter { offsetField = byteStringClass.getDeclaredField("bytesOffset"); offsetField.setAccessible(true); } - catch (NoSuchFieldException e) { - logError("Unable to access fields of " + byteStringClass.getName(), e); + catch (ReflectiveOperationException | RuntimeException e) { bytesField = null; offsetField = null; - } - } - - private static void logError(@NotNull String message, @NotNull Throwable e) { - if (ApplicationManager.getApplication() == null || ApplicationManager.getApplication().isUnitTestMode()) { - logger().error(message, e); // Test mode. - } - else { - logger().warn(message, e); + throw new RuntimeException("Unable to access fields of " + byteStringClass.getName(), e); } } -- cgit v1.2.3