Repository navigation
fix: don't mark a method's throws as visited before its blocks are loaded - #3028
Merged
skylot merged 1 commit intoOct 24, 2026
Merged
Conversation
skylot
approved these changes
Oct 24, 2026
Owner
There was a problem hiding this comment.
Thanks.
I need to mention that this is only a workaround, and proper fix will require new scanner implementation, check this comment last part for details.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
MethodThrowsVisitor.visitsets the visited flag and then reads the method's blocks . when it is reached through a call from another class that is processed first , the callee's class isn't loaded yet , its blocks are null , nothing is collected , and the flag stays set . when the callee's own class is processed later the visit is skipped , so the method never gets itsthrowsdeclaration even though it throws a checked exception . the output then doesn't compile .this happens with a dependency cycle :
Adepends onB,Bis processed first as a dependency ofA, and its call toA.check()visitsA.checkbeforeAis loaded . the flag is now only set once the blocks exist , soA.checkis analyzed whenAis processed .found by decompiling the apk from #2892 . single threaded the output was stable but
android.ext.qt.a(String, int, String)came out withoutthrows InterruptedException, although it callsFutureTask.get(long, TimeUnit)and only catchesExecutionExceptionandTimeoutException.luaj.lib.OsLib.a(String)throwsnew IOException(...)and had nothrowseither . with this change 10 methods in 3 classes get theirthrowsand nothing else in the 813 classes changes . with-j 8thethrowsclauses used to differ between two runs of the same build , with the change two runs are identical .the new smali test is the cycle above and fails without the change . jadx-core tests : 1034 passed .
one thing this does not fix : a caller that is analyzed before its callee still doesn't see the callee's
throws,B.useandA.runin the test stay without it . that needs the analysis to wait for the callee , which is a bigger change , happy to look at it if you want it .