fix: workaround to make method inline deterministic (#1089)

This commit is contained in:
Skylot 2024-08-04 22:46:46 +01:00
parent f9da6e00ed
commit 58e8268126
No known key found for this signature in database
GPG Key ID: 47A4975761262B6A
2 changed files with 25 additions and 4 deletions

View File

@ -125,6 +125,22 @@ public class ProcessClass {
}
}
/**
* Load and process class without its deps
*/
public void forceProcess(ClassNode cls) {
ClassNode topParentClass = cls.getTopParentClass();
if (topParentClass != cls) {
forceProcess(topParentClass);
return;
}
try {
process(cls, false);
} catch (Throwable e) {
throw new JadxRuntimeException("Failed to process class: " + cls.getFullName(), e);
}
}
public void initPasses(RootNode root) {
for (IDexTreeVisitor pass : passes) {
try {

View File

@ -59,12 +59,17 @@ public class InlineMethods extends AbstractVisitor {
}
MethodNode callMth = (MethodNode) callMthDetails;
try {
// TODO: sort inner classes process order by dependencies!
MethodInlineAttr mia = MarkMethodsForInline.process(callMth);
if (mia == null) {
// method not yet loaded => will retry at codegen stage
callMth.getParentClass().reloadAtCodegenStage();
return;
// method is not yet loaded => force process
mth.addDebugComment("Class process forced to load method for inline: " + callMth);
mth.root().getProcessClasses().forceProcess(callMth.getParentClass());
// run check again
mia = MarkMethodsForInline.process(callMth);
if (mia == null) {
mth.addWarnComment("Failed to check method for inline after forced process" + callMth);
return;
}
}
if (mia.notNeeded()) {
return;