Skip to content

ADFA-3784: java.lang.ClassCastException: java.util.Collections cannot be cast to kotlin.collections.EmptyList#1221

Merged
Daniel-ADFA merged 3 commits into
stagefrom
ADFA-3784-fix
Apr 21, 2026
Merged

ADFA-3784: java.lang.ClassCastException: java.util.Collections cannot be cast to kotlin.collections.EmptyList#1221
Daniel-ADFA merged 3 commits into
stagefrom
ADFA-3784-fix

Conversation

@Daniel-ADFA
Copy link
Copy Markdown
Contributor

No description provided.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 21, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 62e43521-ce11-4195-84f5-640e11a1d0fb

📥 Commits

Reviewing files that changed from the base of the PR and between 644e091 and 2fdca0f.

📒 Files selected for processing (1)
  • app/proguard-rules.pro

📝 Walkthrough

Release Notes - ADFA-3784: ClassCastException Fix for Plugin SPI

Summary

Added ProGuard/R8 keep rules for the com.itsaky.androidide.plugins package to prevent runtime ClassCastExceptions when plugins return non-empty collections from interface methods.

Changes

  • Added keep rules for com.itsaky.androidide.plugins classes and interfaces in app/proguard-rules.pro
  • Prevents R8 from narrowing return type signatures of plugin interface methods (e.g., getEditorTabs() returning emptyList()) to EmptyList
  • Ensures plugins can safely return various collection types (listOf(), mutableListOf(), etc.) without triggering CHECKCAST failures at runtime

Risks & Considerations

  • Shrinking Impact: Disables code shrinking for the entire com.itsaky.androidide.plugins package. This increases APK size as some plugin code may not be used but will be retained
  • Obfuscation Bypass: Plugin classes are kept unobfuscated due to dynamic loading via DexClassLoader. This slightly reduces code size optimization benefits
  • Broad Keep Rule: Using wildcard patterns (**) keeps all interfaces and classes in the plugins package without granular control. Future new plugin interfaces will automatically be kept without explicit rules

Affected Components

  • Plugin loading via DexClassLoader
  • Plugin interface implementations and return type handling (UIExtension, EditorTabExtension, DocumentationExtension, BuildActionExtension, SnippetExtension, and all other extension types)
  • Collection type casting in plugin SPI calls

Walkthrough

ProGuard/R8 keep rules were added for the com.itsaky.androidide.plugins package and its interfaces to prevent obfuscation and removal of dynamically-loaded plugin SPI classes during the build process.

Changes

Cohort / File(s) Summary
ProGuard Configuration
app/proguard-rules.pro
Added keep rules to preserve plugin package classes from R8 obfuscation, preventing runtime failures when classes are loaded dynamically via DexClassLoader.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A rabbit hops through build-time rules,
Protecting plugins from R8's tools,
Keep these classes safe and sound,
So dynamic loading can be found!

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title references a ClassCastException issue, but the actual change is a ProGuard rules update for plugin SPI classes - the title appears unrelated to the actual changeset. Update the title to reflect the actual change, such as 'Add ProGuard rules to prevent plugin SPI class removal by R8' or similar that describes the ProGuard rules addition.
Description check ❓ Inconclusive No pull request description was provided by the author, making it impossible to verify if any description content relates to the changeset. Add a description explaining why the ProGuard rules are needed, what problem they solve, and how they address the ClassCastException issue mentioned in the title.
✅ Passed checks (1 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ADFA-3784-fix

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Daniel-ADFA Daniel-ADFA merged commit 76e9df9 into stage Apr 21, 2026
2 checks passed
@Daniel-ADFA Daniel-ADFA deleted the ADFA-3784-fix branch April 21, 2026 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants