Commit efd8bd13 authored by Skylot's avatar Skylot

core: rename classes in default package

parent 051bb63a
...@@ -79,6 +79,11 @@ public class RenameVisitor extends AbstractVisitor { ...@@ -79,6 +79,11 @@ public class RenameVisitor extends AbstractVisitor {
if (newShortName != null) { if (newShortName != null) {
classInfo.rename(cls.dex(), classInfo.makeFullClsName(newShortName, true)); classInfo.rename(cls.dex(), classInfo.makeFullClsName(newShortName, true));
} }
if (classInfo.getAlias().getPackage().isEmpty()) {
String fullName = classInfo.makeFullClsName(classInfo.getAlias().getShortName(), true);
String newFullName = Consts.DEFAULT_PACKAGE_NAME + "." + fullName;
classInfo.rename(cls.dex(), newFullName);
}
} }
private void checkFields(ClassNode cls) { private void checkFields(ClassNode cls) {
......
...@@ -29,17 +29,17 @@ import java.lang.reflect.Modifier; ...@@ -29,17 +29,17 @@ import java.lang.reflect.Modifier;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.net.URL; import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.jar.JarOutputStream; import java.util.jar.JarOutputStream;
import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.Matchers.empty;
import static org.junit.Assert.assertEquals; import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertNotEquals; import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat; import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
...@@ -86,8 +86,8 @@ public abstract class IntegrationTest extends TestUtils { ...@@ -86,8 +86,8 @@ public abstract class IntegrationTest extends TestUtils {
root.getResourcesNames().putAll(resMap); root.getResourcesNames().putAll(resMap);
ClassNode cls = root.searchClassByName(clsName); ClassNode cls = root.searchClassByName(clsName);
assertNotNull("Class not found: " + clsName, cls); assertThat("Class not found: " + clsName, cls, notNullValue());
assertEquals(cls.getFullName(), clsName); assertThat(clsName, is(cls.getClassInfo().getFullName()));
if (unloadCls) { if (unloadCls) {
decompile(d, cls); decompile(d, cls);
...@@ -214,7 +214,7 @@ public abstract class IntegrationTest extends TestUtils { ...@@ -214,7 +214,7 @@ public abstract class IntegrationTest extends TestUtils {
Throwable cause = ie.getCause(); Throwable cause = ie.getCause();
if (cause instanceof AssertionError) { if (cause instanceof AssertionError) {
System.err.println(msg); System.err.println(msg);
throw ((AssertionError) cause); throw (AssertionError) cause;
} else { } else {
cause.printStackTrace(); cause.printStackTrace();
fail(msg + cause.getMessage()); fail(msg + cause.getMessage());
...@@ -283,7 +283,7 @@ public abstract class IntegrationTest extends TestUtils { ...@@ -283,7 +283,7 @@ public abstract class IntegrationTest extends TestUtils {
list = compileClass(cls); list = compileClass(cls);
} }
} }
assertNotEquals("File list is empty", 0, list.size()); assertThat("File list is empty", list, not(empty()));
File temp = createTempFile(".jar"); File temp = createTempFile(".jar");
JarOutputStream jo = new JarOutputStream(new FileOutputStream(temp)); JarOutputStream jo = new JarOutputStream(new FileOutputStream(temp));
...@@ -354,11 +354,12 @@ public abstract class IntegrationTest extends TestUtils { ...@@ -354,11 +354,12 @@ public abstract class IntegrationTest extends TestUtils {
if (!file.exists()) { if (!file.exists()) {
file = new File(TEST_DIRECTORY2, fileName); file = new File(TEST_DIRECTORY2, fileName);
} }
assertTrue("Test source file not found: " + fileName, file.exists()); assertThat("Test source file not found: " + fileName, file.exists(), is(true));
List<File> compileFileList = Collections.singletonList(file);
File outTmp = createTempDir("jadx-tmp-classes"); File outTmp = createTempDir("jadx-tmp-classes");
outTmp.deleteOnExit(); outTmp.deleteOnExit();
List<File> files = StaticCompiler.compile(Arrays.asList(file), outTmp, withDebugInfo); List<File> files = StaticCompiler.compile(compileFileList, outTmp, withDebugInfo);
// remove classes which are parents for test class // remove classes which are parents for test class
Iterator<File> iterator = files.iterator(); Iterator<File> iterator = files.iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
......
...@@ -46,7 +46,7 @@ public class JadxSettingsAdapter { ...@@ -46,7 +46,7 @@ public class JadxSettingsAdapter {
if (settings == null) { if (settings == null) {
return new JadxSettings(); return new JadxSettings();
} }
LOG.info("Loaded settings: {}", makeString(settings)); LOG.debug("Loaded settings: {}", makeString(settings));
return settings; return settings;
} catch (Exception e) { } catch (Exception e) {
LOG.error("Error load settings", e); LOG.error("Error load settings", e);
......
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