未验证 提交 2f301bf1 编写于 作者: S Skylot

fix: don't mark constructor for inline if anonymous class inline is disabled (#1680)

上级 b4892ce1
...@@ -805,8 +805,10 @@ public class ClassNode extends NotificationAttrNode implements ILoadable, ICodeN ...@@ -805,8 +805,10 @@ public class ClassNode extends NotificationAttrNode implements ILoadable, ICodeN
} }
public void addCodegenDep(ClassNode dep) { public void addCodegenDep(ClassNode dep) {
if (!codegenDeps.contains(dep)) {
this.codegenDeps = ListUtils.safeAdd(this.codegenDeps, dep); this.codegenDeps = ListUtils.safeAdd(this.codegenDeps, dep);
} }
}
public int getTotalDepsCount() { public int getTotalDepsCount() {
return dependencies.size() + codegenDeps.size(); return dependencies.size() + codegenDeps.size();
......
package jadx.core.dex.visitors; package jadx.core.dex.visitors;
import jadx.core.Consts;
import jadx.core.dex.attributes.AFlag; import jadx.core.dex.attributes.AFlag;
import jadx.core.dex.info.AccessInfo; import jadx.core.dex.info.AccessInfo;
import jadx.core.dex.nodes.ClassNode; import jadx.core.dex.nodes.ClassNode;
import jadx.core.dex.nodes.MethodNode; import jadx.core.dex.nodes.MethodNode;
import jadx.core.dex.nodes.RootNode; import jadx.core.dex.nodes.RootNode;
import jadx.core.dex.visitors.usage.UsageInfoVisitor; import jadx.core.dex.visitors.usage.UsageInfoVisitor;
import jadx.core.utils.ListUtils;
import jadx.core.utils.exceptions.JadxException; import jadx.core.utils.exceptions.JadxException;
@JadxVisitor( @JadxVisitor(
...@@ -45,7 +45,14 @@ public class ProcessMethodsForInline extends AbstractVisitor { ...@@ -45,7 +45,14 @@ public class ProcessMethodsForInline extends AbstractVisitor {
} }
AccessInfo accessFlags = mth.getAccessFlags(); AccessInfo accessFlags = mth.getAccessFlags();
boolean isSynthetic = accessFlags.isSynthetic() || mth.getName().contains("$"); boolean isSynthetic = accessFlags.isSynthetic() || mth.getName().contains("$");
return isSynthetic && (accessFlags.isStatic() || mth.isConstructor()); return isSynthetic && canInlineMethod(mth, accessFlags);
}
private static boolean canInlineMethod(MethodNode mth, AccessInfo accessFlags) {
if (accessFlags.isStatic()) {
return true;
}
return mth.isConstructor() && mth.root().getArgs().isInlineAnonymousClasses();
} }
private static void fixClassDependencies(MethodNode mth) { private static void fixClassDependencies(MethodNode mth) {
...@@ -54,8 +61,14 @@ public class ProcessMethodsForInline extends AbstractVisitor { ...@@ -54,8 +61,14 @@ public class ProcessMethodsForInline extends AbstractVisitor {
// remove possible cross dependency // remove possible cross dependency
// to force class with inline method to be processed before its usage // to force class with inline method to be processed before its usage
ClassNode useTopCls = useInMth.getTopParentClass(); ClassNode useTopCls = useInMth.getTopParentClass();
parentClass.setDependencies(ListUtils.safeRemoveAndTrim(parentClass.getDependencies(), useTopCls)); if (useTopCls != parentClass) {
parentClass.removeDependency(useTopCls);
useTopCls.addCodegenDep(parentClass); useTopCls.addCodegenDep(parentClass);
if (Consts.DEBUG_USAGE) {
parentClass.addDebugComment("Remove dependency: " + useTopCls + " to inline " + mth);
useTopCls.addDebugComment("Add dependency: " + parentClass + " to inline " + mth);
}
}
} }
} }
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册