Commit 85ab0956 authored by Skylot's avatar Skylot

core: fix class imports

parent 1b5f0f6a
......@@ -379,12 +379,17 @@ public class ClassGen {
if (classInfo.getPackage().equals(useCls.getPackage()) && !classInfo.isInner()) {
return shortName;
}
if (classInfo.getPackage().equals(useCls.getPackage())) {
fullName = classInfo.getNameWithoutPackage();
// don't add import if class not public (must be accessed using inheritance)
ClassNode classNode = cls.dex().resolveClass(classInfo);
if (classNode != null && !classNode.getAccessFlags().isPublic()) {
return shortName;
}
if (searchCollision(cls.dex(), useCls, shortName)) {
return fullName;
}
if (classInfo.getPackage().equals(useCls.getPackage())) {
fullName = classInfo.getNameWithoutPackage();
}
for (ClassInfo importCls : imports) {
if (!importCls.equals(classInfo)
&& importCls.getShortName().equals(shortName)) {
......
package jadx.samples;
import jadx.samples.otherpkg.A;
/**
* Tests:
* - class B not imported
*/
public class TestImports extends AbstractTest {
public class C extends A {
public B getB() {
return null;
}
}
@Override
public boolean testRun() {
return true;
}
public static void main(String[] args) {
new TestImports().testRun();
}
}
package jadx.samples.otherpkg;
public class A {
protected class B {
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment