use of jadx.core.dex.nodes.ClassNode in project jadx by skylot.
the class TestSwitchReturnFromCase method test.
@Test
public void test() {
ClassNode cls = getClassNode(TestCls.class);
String code = cls.getCode().toString();
assertThat(code, containsString("switch (a % 4) {"));
assertEquals(5, count(code, "case "));
assertEquals(3, count(code, "break;"));
assertThat(code, containsOne("s = \"1\";"));
assertThat(code, containsOne("s = \"2\";"));
assertThat(code, containsOne("s = \"4\";"));
assertThat(code, containsOne("s = \"5\";"));
}
use of jadx.core.dex.nodes.ClassNode in project jadx by skylot.
the class TestSwitchWithFallThroughCase2 method test.
@Test
public void test() {
ClassNode cls = getClassNode(TestCls.class);
String code = cls.getCode().toString();
assertThat(code, containsOne("switch (a % 4) {"));
assertThat(code, containsOne("if (a == 5 && b) {"));
assertThat(code, containsOne("if (b) {"));
}
use of jadx.core.dex.nodes.ClassNode in project jadx by skylot.
the class ClassGen method searchCollision.
private static boolean searchCollision(DexNode dex, ClassInfo useCls, ClassInfo searchCls) {
if (useCls == null) {
return false;
}
String shortName = searchCls.getShortName();
if (useCls.getShortName().equals(shortName)) {
return true;
}
ClassNode classNode = dex.resolveClass(useCls);
if (classNode != null) {
for (ClassNode inner : classNode.getInnerClasses()) {
if (inner.getShortName().equals(shortName) && !inner.getAlias().equals(searchCls)) {
return true;
}
}
}
return searchCollision(dex, useCls.getParentClass(), searchCls);
}
use of jadx.core.dex.nodes.ClassNode in project jadx by skylot.
the class ClassGen method addInnerClasses.
private void addInnerClasses(CodeWriter code, ClassNode cls) throws CodegenException {
for (ClassNode innerCls : cls.getInnerClasses()) {
if (innerCls.contains(AFlag.DONT_GENERATE) || innerCls.contains(AFlag.ANONYMOUS_CLASS)) {
continue;
}
ClassGen inClGen = new ClassGen(innerCls, getParentGen());
code.newLine();
inClGen.addClassCode(code);
imports.addAll(inClGen.getImports());
}
}
use of jadx.core.dex.nodes.ClassNode in project jadx by skylot.
the class InsnGen method makeConstructor.
private void makeConstructor(ConstructorInsn insn, CodeWriter code) throws CodegenException {
ClassNode cls = mth.dex().resolveClass(insn.getClassType());
if (cls != null && cls.contains(AFlag.ANONYMOUS_CLASS) && !fallback) {
inlineAnonymousConstr(code, cls, insn);
return;
}
if (insn.isSelf()) {
throw new JadxRuntimeException("Constructor 'self' invoke must be removed!");
}
if (insn.isSuper()) {
code.add("super");
} else if (insn.isThis()) {
code.add("this");
} else {
code.add("new ");
useClass(code, insn.getClassType());
}
MethodNode callMth = mth.dex().resolveMethod(insn.getCallMth());
generateMethodArguments(code, insn, 0, callMth);
}
Aggregations