private void deobfJar(File inJar, File outJar, File srg, Collection<File> ats) throws IOException
{
getLogger().debug("INPUT: " + inJar);
getLogger().debug("OUTPUT: " + outJar);
// load mapping
JarMapping mapping = new JarMapping();
mapping.loadMappings(srg);
final Map<String, String> renames = Maps.newHashMap();
for (File f : new File[]{ getFieldCsv(), getMethodCsv() })
{
if (f == null) continue;
Files.readLines(f, Charsets.UTF_8, new LineProcessor<String>()
{
@Override
public boolean processLine(String line) throws IOException
{
String[] pts = line.split(",");
if (!"searge".equals(pts[0]))
{
renames.put(pts[0], pts[1]);
}
return true;
}
@Override public String getResult() { return null; }
});
}
// load in ATs
AccessMap accessMap = new AccessMap() {
@Override
public void addAccessChange(String symbolString, String accessString)
{
String[] pts = symbolString.split(" ");
if (pts.length >= 2)
{
int idx = pts[1].indexOf('(');
String start = pts[1];
String end = "";
if (idx != -1)
{
start = pts[1].substring(0, idx);
end = pts[1].substring(idx);
}
String rename = renames.get(start);
if (rename != null)
{
pts[1] = rename + end;
}
}
String joinedString = Joiner.on('.').join(pts);
super.addAccessChange(joinedString, accessString);
}
};
getLogger().info("Using AccessTransformers...");
for (File at : ats)
{
getLogger().info("" + at);
accessMap.loadAccessTransformer(at);
}
// make a processor out of the ATS and mappings.
RemapperProcessor srgProcessor = new RemapperProcessor(null, mapping, null);
RemapperProcessor atProcessor = new RemapperProcessor(null, null, accessMap);
// make remapper
JarRemapper remapper = new JarRemapper(srgProcessor, mapping, atProcessor);
// load jar
Jar input = Jar.init(inJar);
// ensure that inheritance provider is used
JointProvider inheritanceProviders = new JointProvider();
inheritanceProviders.add(new JarProvider(input));
mapping.setFallbackInheritanceProvider(inheritanceProviders);
// remap jar
remapper.remapJar(input, outJar);
}