Skip to content

Recover suspend ABI without kotlin.Metadata - #25

Merged
asLody merged 1 commit into
asLody:mainfrom
LLeavesG:fix/suspend-abi-without-metadata
Aug 16, 2026
Merged

Recover suspend ABI without kotlin.Metadata#25
asLody merged 1 commit into
asLody:mainfrom
LLeavesG:fix/suspend-abi-without-metadata

Conversation

@LLeavesG

Copy link
Copy Markdown
Contributor

Summary

Language selection used only @kotlin.Metadata. R8 often strips that annotation but leaves the DEX SourceFile (.kt), the same attribute JADX uses to recover Kotlin file names. Those classes were decompiled as Java and kept a raw Continuation last parameter.

  • treat SourceFile ending in .kt / .kts as Kotlin when metadata is absent
  • recover suspend from the JVM shape Object foo(..., Continuation) when the continuation parameter is unused in the body
  • skip ContinuationImpl bridges (create, invokeSuspend, and invoke on classes that declare invokeSuspend)

This does not reconstruct switch(label) / COROUTINE_SUSPENDED state-machine bodies. Methods that still pass the continuation through keep the parameter on purpose.

Validation

  • cargo fmt --all -- --check
  • cargo test -p dexdec --lib (language + ABI unit tests)
  • cargo test -p dexdec --test expected_test
  • Stripped-metadata sample: 150/150, Java-only → 104 Kotlin files from SourceFile
  • Metadata sample: existing suspend kept; one extra unused-continuation emit recovered
  • finally / synchronized / goto / brace-balance unchanged vs main

Review notes

Standalone. No overlap with the FunctionN or naming PRs. Merge order is free; the three were also verified stacked together.

R8 often strips @kotlin.Metadata but leaves the DEX SourceFile (.kt),
the same attribute JADX uses to recover Kotlin file names. Treat that as
Kotlin, then recognize the Continuation-last / Object-return JVM shape
so unused continuation parameters become suspend instead of a raw Java
Continuation argument. Skip ContinuationImpl create/invoke bridges.
@asLody
asLody merged commit 0e0a487 into asLody:main Aug 16, 2026
1 check passed
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