Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reduce references to
android.util.Log$TerribleFailure
in ShadowLog
`android.util.Log$TerribleFailure` is a `@hide` class in `android.util.Log`. If tests reference ShadowLog in static blocks or outside of a Robolectric ClassLoader, a NoClassDefFoundError would result. Update TerribleFailureReflector to return a generic Throwable in the `@Constructor` method. Fixes #8957 PiperOrigin-RevId: 621187529
- Loading branch information
Showing
2 changed files
with
27 additions
and
4 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
...tion_tests/dependency-on-stubs/src/test/java/org/robolectric/ShadowLogResolutionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package org.robolectric; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.JUnit4; | ||
import org.robolectric.shadows.ShadowLog; | ||
|
||
/** | ||
* This test attempts to reference ShadowLow from outside of the context of a Robolectric | ||
* environment. ShadowLog contained reflector interfaces that referenced `@hide` classes (e.g. | ||
* TerribleFailure), which cannot be referenced outside of a Robolectric ClassLoader. | ||
* | ||
* @see <a href="https://github.com/robolectric/robolectric/issues/8957">Issue 8957 </a> for more | ||
* details. | ||
*/ | ||
@RunWith(JUnit4.class) | ||
public class ShadowLogResolutionTest { | ||
@Test | ||
public void reference_shadowLog_outsideRobolectric() { | ||
ShadowLog.stream = System.out; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters