Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix IllegalAccessException in MODERN_ASYNC_TASK_EXTRACTOR #1000

Merged
merged 1 commit into from
Jul 12, 2021

Conversation

copybara-service[bot]
Copy link

@copybara-service copybara-service bot commented Jul 5, 2021

Fix IllegalAccessException in MODERN_ASYNC_TASK_EXTRACTOR

Due to Robolectric not instrumenting androidx.* classes by default any more
(which makes all classes public), the following error started appearing during
Robolectric tests that use Espresso:

cannot access a member of class androidx.loader.content.ModernAsyncTask
with modifiers "public static final"

Update MODERN_ASYNC_TASK_EXTRACTOR to use getDeclaredField and
setAccessible(true) when accessing the final THREAD_POOL_EXECUTOR field.

The problem is that ModernAsyncTask is not a public class, it's package
private. Trying to access members of a package private class outside of the
package is not allowed (JLS §6.6.1).

@google-cla google-cla bot added the cla: yes label Jul 5, 2021
@copybara-service copybara-service bot force-pushed the piper_383150341 branch 2 times, most recently from 31b413e to 7d935ee Compare July 12, 2021 15:43
@copybara-service copybara-service bot changed the title Remove references to Compat AsyncTask thread pool Fix IllegalAccessException in MODERN_ASYNC_TASK_EXTRACTOR Jul 12, 2021
Due to Robolectric not instrumenting androidx.* classes by default any more
(which makes all classes public), the following error started appearing during
Robolectric tests that use Espresso:

    cannot access a member of class androidx.loader.content.ModernAsyncTask
    with modifiers "public static final"

Update `MODERN_ASYNC_TASK_EXTRACTOR` to use `getDeclaredField` and
`setAccessible(true)` when accessing the final `THREAD_POOL_EXECUTOR` field.

The problem is that ModernAsyncTask is not a public class, it's package
private. Trying to access members of a package private class outside of the
package is not allowed (JLS §6.6.1).

PiperOrigin-RevId: 384244512
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant