From 6c7dddbd7f8c4c3aac4aaebc779f331c27d6bd84 Mon Sep 17 00:00:00 2001 From: Googler Date: Wed, 8 Feb 2023 16:30:12 +0000 Subject: [PATCH] Fix tests affected by Robolectric's constructor visibility bug Previously, Robolectric's instrumentation updated all constructors to be public. This caused two main types of problems: 1) When non-public constructors were made public and added to the Android API, Robolectric allowed tests to incorrectly use the constructors on older SDK levels (where they were non-public). This most commonly occurs for AccessibiltyEvent and AccessibilityNodeInfo. 2) When reflection was used to instantiate classes that were instrumented by Robolectric, all constructors were accessible. Fix issues across Google3 Robolectric tests that were affected by this issue. A forthcoming change will fix the instrumentation in Robolectric to prevent this type of issue from occurring. Tested: TAP --sample ran all affected tests and none failed http://test/OCL:507861075:BASE:507805409:1675803313108:f2128fa4 PiperOrigin-RevId: 508087822 --- .../exoplayer/mediacodec/AsynchronousMediaCodecAdapterTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/mediacodec/AsynchronousMediaCodecAdapterTest.java b/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/mediacodec/AsynchronousMediaCodecAdapterTest.java index 98707a3226..c8134f567d 100644 --- a/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/mediacodec/AsynchronousMediaCodecAdapterTest.java +++ b/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/mediacodec/AsynchronousMediaCodecAdapterTest.java @@ -192,6 +192,7 @@ public class AsynchronousMediaCodecAdapterTest { Constructor constructor = MediaCodec.CodecException.class.getDeclaredConstructor( Integer.TYPE, Integer.TYPE, String.class); + constructor.setAccessible(true); return constructor.newInstance( /* errorCode= */ 0, /* actionCode= */ 0, /* detailMessage= */ "error from codec"); }