Example usage for org.objectweb.asm.commons Remapper mapType

List of usage examples for org.objectweb.asm.commons Remapper mapType

Introduction

In this page you can find the example usage for org.objectweb.asm.commons Remapper mapType.

Prototype

public String mapType(final String internalName) 

Source Link

Document

Returns the given internal name, remapped with #map(String) .

Usage

From source file:keepcalm.mods.bukkit.Method.java

License:Open Source License

/**
 * @param args//from  ww w  .java  2s . c  o m
 * @throws IOException 
 */
public static void main(File file, InputStream srgStream) throws IOException {
    String strInputFilename = file.getAbsolutePath();
    String strOutputFilename = file.getParentFile().getAbsolutePath() + "/ported_" + file.getName();
    //List<String> listInputSrg=new LinkedList<String>();
    List<String> listInputInheritance = new LinkedList<String>();
    List<ParseEntry> listTranslate = new LinkedList<ParseEntry>();
    /*for (int i=0; i<args.length; i++) {
       if (args[i].equals("--srg"))
    listInputSrg.add(args[++i]);
       else if (args[i].equals("--inheritance") || args[i].equals("--inh"))
    listInputInheritance.add(args[++i]);
       else if (args[i].equals("--in"))
    strInputFilename=args[++i];
       else if (args[i].equals("--out"))
    strOutputFilename=args[++i];
       else if (args[i].equals("--translate")) {
    String a=args[++i];
    String b=args[++i];
    listTranslate.add(new ParseEntry(a,b));
    listInputInheritance.add(a);
       }
    }
     */ if (strInputFilename != null && strOutputFilename != null) {
        listTranslate.add(new ParseEntry(strInputFilename, strOutputFilename));
        strInputFilename = strOutputFilename = null;
    }
    /*   if (strInputFilename!=null || strOutputFilename!=null || listTranslate.size()<1) {
      System.err.println("Usage: java -jar srgtool.jar apply [options]");
      System.err.println("Options:");
      System.err.println("--srg <srg file>\tLoads the SRG file");
      System.err.println("--inheritance <jar/zip>\tLoads inheritance map from jar");
      System.err.println("--in <jar/zip>");
      System.err.println("--out <jar/zip>");
      return;
    }
     */
    if (strInputFilename != null)
        listInputInheritance.add(strInputFilename);
    Map<String, MappedClass> mapClasses = new TreeMap<String, MappedClass>();
    Map<String, String> mapPackages = new TreeMap<String, String>();
    //for (String srg : listInputSrg) {
    System.out.println("Reading SRG!");

    BufferedReader brSrg = new BufferedReader(new InputStreamReader(srgStream));
    String strLine;
    while ((strLine = brSrg.readLine()) != null) {
        //System.out.println("Line: " + strLine);
        String arrLine[] = strLine.split(" ");
        if (arrLine[0].equals("PK:")) {
            mapPackages.put(arrLine[1], arrLine[2]);
        } else if (arrLine[0].equals("CL:")) {
            String strFrom = arrLine[1];
            String strTo = arrLine[2];
            MappedClass mappedCurrent = mapClasses.get(strFrom);
            if (mappedCurrent == null) {
                mapClasses.put(strFrom, new MappedClass(strTo));
            } else {
                if (!mappedCurrent.strNewName.equals(strTo)) {
                    System.err.println("ERROR: Mismatching mappings found");
                    return;
                }
            }
        } else if (arrLine[0].equals("FD:")) {
            String strFrom = arrLine[1];
            String strTo = arrLine[2];
            int nSplitFrom = strFrom.lastIndexOf('/');
            int nSplitTo = strTo.lastIndexOf('/');
            if (nSplitFrom == -1 || nSplitTo == -1) {
                System.err.println("ERROR: Invalid field specification: '" + strLine);
                return;
            }
            String strFromClass = strFrom.substring(0, nSplitFrom);
            strFrom = strFrom.substring(nSplitFrom + 1);
            String strToClass = strTo.substring(0, nSplitTo);
            strTo = strTo.substring(nSplitTo + 1);
            MappedClass mappedCurrent = mapClasses.get(strFromClass);
            if (strFromClass.equals(strToClass) && mappedCurrent == null) {
                mapClasses.put(strFromClass, mappedCurrent = new MappedClass(strToClass));
            }
            if (mappedCurrent == null || !mappedCurrent.strNewName.equals(strToClass)) {
                System.err.println("ERROR: Class mapping invalid or non-existant on field");
                System.err.println("Line: " + strLine);
                System.err.println(strFromClass + " -> " + strToClass + " should have been "
                        + ((mappedCurrent == null) ? "null" : mappedCurrent.strNewName));
                return;
            }
            mappedCurrent.mapFields.put(strFrom, strTo);
        } else if (arrLine[0].equals("MD:")) {
            String strFrom = arrLine[1];
            String strFromArguments = arrLine[2];
            String strTo = arrLine[3];
            //String strToArguments=arrLine[4];
            int nSplitFrom = strFrom.lastIndexOf('/');
            int nSplitTo = strTo.lastIndexOf('/');
            if (nSplitFrom == -1 || nSplitTo == -1) {
                System.err.println("ERROR: Invalid method specification: '" + strLine);
                return;
            }
            String strFromClass = strFrom.substring(0, nSplitFrom);
            strFrom = strFrom.substring(nSplitFrom + 1);
            String strToClass = strTo.substring(0, nSplitTo);
            strTo = strTo.substring(nSplitTo + 1);
            MappedClass mappedCurrent = mapClasses.get(strFromClass);
            if (strFromClass.equals(strToClass) && mappedCurrent == null) {
                mapClasses.put(strFromClass, mappedCurrent = new MappedClass(strToClass));
            }
            if (mappedCurrent == null || !mappedCurrent.strNewName.equals(strToClass)) {
                System.err.println("ERROR: Class mapping invalid or non-existant on method");
                System.err.println("Line: " + strLine);
                System.err.println(strFromClass + " -> " + strToClass + " should have been "
                        + ((mappedCurrent == null) ? "null" : mappedCurrent.strNewName));
                return;
            }
            //NOTE: arguments not saved, will be mapped automagically.
            mappedCurrent.mapMethods.put(new Method(strFrom, strFromArguments), strTo);
        }
    }
    //}
    System.out.println("Class map loaded of " + mapClasses.size() + " classes");
    Map<String, ClassInfo> mapClassInheritance = new HashMap<String, ClassInfo>();
    for (String inherit : listInputInheritance) {
        System.out.println("Parsing inheritance in " + inherit);
        //System.out.println("Parsing inheritance in "+inherit);
        ZipFile zipInherit = new ZipFile(inherit);
        Enumeration<? extends ZipEntry> entries = zipInherit.entries();
        while (entries.hasMoreElements()) {
            ZipEntry entry = entries.nextElement();
            if (entry.isDirectory())
                continue;
            if (entry.getName().endsWith(".class")) {
                ClassReader cr = new ClassReader(zipInherit.getInputStream(entry));
                InheritanceMapClassVisitor cvInheritance = new InheritanceMapClassVisitor();
                cr.accept(cvInheritance, 0);
                mapClassInheritance.put(cvInheritance.strName, cvInheritance.info);
            }
        }
        zipInherit.close();
    }
    System.out.println("Inheritance map loaded of " + mapClassInheritance.size() + " classes");

    for (ParseEntry e : listTranslate) {
        System.out.println("Translating " + e.strInputFilename + " -> " + e.strOutputFilename);

        ZipFile zipInput = new ZipFile(e.strInputFilename);

        ZipOutputStream zipOutput = new ZipOutputStream(new FileOutputStream(e.strOutputFilename));
        Enumeration<? extends ZipEntry> entries = zipInput.entries();
        while (entries.hasMoreElements()) {
            ZipEntry entry = entries.nextElement();
            if (entry.isDirectory())
                continue;
            if (entry.getName().endsWith(".class")) {
                ClassReader cr = new ClassReader(zipInput.getInputStream(entry));
                ClassWriter cw = new ClassWriter(0);
                Remapper remapper = new MyRemapper(mapClasses, mapClassInheritance, mapPackages);
                RemappingClassAdapter ca = new RemappingClassAdapter(cw, remapper);
                cr.accept(ca, ClassReader.EXPAND_FRAMES);
                byte[] bOutput = cw.toByteArray();
                String strName = entry.getName();
                strName = strName.substring(0, strName.lastIndexOf('.'));
                strName = remapper.mapType(strName);

                ZipEntry entryCopy = new ZipEntry(strName + ".class");
                entryCopy.setCompressedSize(-1);
                entryCopy.setSize(bOutput.length);
                zipOutput.putNextEntry(entryCopy);
                zipOutput.write(bOutput);
                zipOutput.closeEntry();
            } else {
                ZipEntry entryCopy = new ZipEntry(entry);
                entryCopy.setCompressedSize(-1);
                zipOutput.putNextEntry(entryCopy);
                InputStream is = zipInput.getInputStream(entry);
                byte[] buffer = new byte[1024];
                int read = 0;
                while ((read = is.read(buffer)) != -1)
                    zipOutput.write(buffer, 0, read);
                zipOutput.closeEntry();
            }
        }
        zipInput.close();
        zipOutput.close();
    }
    System.out.println("Done!");
}

From source file:nl.hardijzer.fw.applysrg.Method.java

License:Open Source License

/**
 * @param args//from w w w .ja  v  a2s  . co m
 * @throws IOException 
 */
public static void main(String[] args) throws IOException {
    String strInputFilename = null;
    String strOutputFilename = null;
    List<String> listInputSrg = new LinkedList<String>();
    List<String> listInputInheritance = new LinkedList<String>();
    List<ParseEntry> listTranslate = new LinkedList<ParseEntry>();
    for (int i = 0; i < args.length; i++) {
        if (args[i].equals("--srg"))
            listInputSrg.add(args[++i]);
        else if (args[i].equals("--inheritance") || args[i].equals("--inh"))
            listInputInheritance.add(args[++i]);
        else if (args[i].equals("--in"))
            strInputFilename = args[++i];
        else if (args[i].equals("--out"))
            strOutputFilename = args[++i];
        else if (args[i].equals("--translate")) {
            String a = args[++i];
            String b = args[++i];
            listTranslate.add(new ParseEntry(a, b));
            listInputInheritance.add(a);
        }
    }
    if (strInputFilename != null && strOutputFilename != null) {
        listTranslate.add(new ParseEntry(strInputFilename, strOutputFilename));
        strInputFilename = strOutputFilename = null;
    }
    if (strInputFilename != null || strOutputFilename != null || listTranslate.size() < 1) {
        System.err.println("Usage: java -jar srgtool.jar apply [options]");
        System.err.println("Options:");
        System.err.println("--srg <srg file>\tLoads the SRG file");
        System.err.println("--inheritance <jar/zip>\tLoads inheritance map from jar");
        System.err.println("--in <jar/zip>");
        System.err.println("--out <jar/zip>");
        return;
    }

    if (strInputFilename != null)
        listInputInheritance.add(strInputFilename);

    Map<String, MappedClass> mapClasses = new TreeMap<String, MappedClass>();
    Map<String, String> mapPackages = new TreeMap<String, String>();
    for (String srg : listInputSrg) {
        System.out.println("Reading SRG: " + srg);
        BufferedReader brSrg = new BufferedReader(new FileReader(srg));
        String strLine;
        while ((strLine = brSrg.readLine()) != null) {
            String arrLine[] = strLine.split(" ");
            if (arrLine[0].equals("PK:")) {
                mapPackages.put(arrLine[1], arrLine[2]);
            } else if (arrLine[0].equals("CL:")) {
                String strFrom = arrLine[1];
                String strTo = arrLine[2];
                MappedClass mappedCurrent = mapClasses.get(strFrom);
                if (mappedCurrent == null) {
                    mapClasses.put(strFrom, new MappedClass(strTo));
                } else {
                    if (!mappedCurrent.strNewName.equals(strTo)) {
                        System.err.println("ERROR: Mismatching mappings found");
                        return;
                    }
                }
            } else if (arrLine[0].equals("FD:")) {
                String strFrom = arrLine[1];
                String strTo = arrLine[2];
                int nSplitFrom = strFrom.lastIndexOf('/');
                int nSplitTo = strTo.lastIndexOf('/');
                if (nSplitFrom == -1 || nSplitTo == -1) {
                    System.err.println("ERROR: Invalid field specification: '" + strLine);
                    return;
                }
                String strFromClass = strFrom.substring(0, nSplitFrom);
                strFrom = strFrom.substring(nSplitFrom + 1);
                String strToClass = strTo.substring(0, nSplitTo);
                strTo = strTo.substring(nSplitTo + 1);
                MappedClass mappedCurrent = mapClasses.get(strFromClass);
                if (strFromClass.equals(strToClass) && mappedCurrent == null) {
                    mapClasses.put(strFromClass, mappedCurrent = new MappedClass(strToClass));
                }
                if (mappedCurrent == null || !mappedCurrent.strNewName.equals(strToClass)) {
                    System.err.println("ERROR: Class mapping invalid or non-existant on field");
                    System.err.println("Line: " + strLine);
                    System.err.println(strFromClass + " -> " + strToClass + " should have been "
                            + ((mappedCurrent == null) ? "null" : mappedCurrent.strNewName));
                    return;
                }
                mappedCurrent.mapFields.put(strFrom, strTo);
            } else if (arrLine[0].equals("MD:")) {
                String strFrom = arrLine[1];
                String strFromArguments = arrLine[2];
                String strTo = arrLine[3];
                String strToArguments = arrLine[4];
                int nSplitFrom = strFrom.lastIndexOf('/');
                int nSplitTo = strTo.lastIndexOf('/');
                if (nSplitFrom == -1 || nSplitTo == -1) {
                    System.err.println("ERROR: Invalid method specification: '" + strLine);
                    return;
                }
                String strFromClass = strFrom.substring(0, nSplitFrom);
                strFrom = strFrom.substring(nSplitFrom + 1);
                String strToClass = strTo.substring(0, nSplitTo);
                strTo = strTo.substring(nSplitTo + 1);
                MappedClass mappedCurrent = mapClasses.get(strFromClass);
                if (strFromClass.equals(strToClass) && mappedCurrent == null) {
                    mapClasses.put(strFromClass, mappedCurrent = new MappedClass(strToClass));
                }
                if (mappedCurrent == null || !mappedCurrent.strNewName.equals(strToClass)) {
                    System.err.println("ERROR: Class mapping invalid or non-existant on method");
                    System.err.println("Line: " + strLine);
                    System.err.println(strFromClass + " -> " + strToClass + " should have been "
                            + ((mappedCurrent == null) ? "null" : mappedCurrent.strNewName));
                    return;
                }
                //NOTE: arguments not saved, will be mapped automagically.
                mappedCurrent.mapMethods.put(new Method(strFrom, strFromArguments), strTo);
            }
        }
    }
    System.out.println("Class map loaded of " + mapClasses.size() + " classes");
    Map<String, ClassInfo> mapClassInheritance = new HashMap<String, ClassInfo>();
    for (String inherit : listInputInheritance) {
        System.out.println("Parsing inheritance in " + inherit);
        //System.out.println("Parsing inheritance in "+inherit);
        ZipFile zipInherit = new ZipFile(inherit);
        Enumeration<? extends ZipEntry> entries = zipInherit.entries();
        while (entries.hasMoreElements()) {
            ZipEntry entry = entries.nextElement();
            if (entry.isDirectory())
                continue;
            if (entry.getName().endsWith(".class")) {
                ClassReader cr = new ClassReader(zipInherit.getInputStream(entry));
                InheritanceMapClassVisitor cvInheritance = new InheritanceMapClassVisitor(Opcodes.ASM5);
                cr.accept(cvInheritance, 0);
                mapClassInheritance.put(cvInheritance.strName, cvInheritance.info);
            }
        }
        zipInherit.close();
    }
    System.out.println("Inheritance map loaded of " + mapClassInheritance.size() + " classes");

    for (ParseEntry e : listTranslate) {
        System.out.println("Translating " + e.strInputFilename + " -> " + e.strOutputFilename);

        ZipFile zipInput = new ZipFile(e.strInputFilename);

        ZipOutputStream zipOutput = new ZipOutputStream(new FileOutputStream(e.strOutputFilename));
        Enumeration<? extends ZipEntry> entries = zipInput.entries();
        while (entries.hasMoreElements()) {
            ZipEntry entry = entries.nextElement();
            if (entry.isDirectory())
                continue;
            if (entry.getName().endsWith(".class")) {
                ClassReader cr = new ClassReader(zipInput.getInputStream(entry));
                ClassWriter cw = new ClassWriter(0);
                Remapper remapper = new MyRemapper(mapClasses, mapClassInheritance, mapPackages);
                RemappingClassAdapter ca = new RemappingClassAdapter(cw, remapper);
                cr.accept(ca, ClassReader.EXPAND_FRAMES);
                byte[] bOutput = cw.toByteArray();
                String strName = entry.getName();
                strName = strName.substring(0, strName.lastIndexOf('.'));
                strName = remapper.mapType(strName);

                ZipEntry entryCopy = new ZipEntry(strName + ".class");
                entryCopy.setCompressedSize(-1);
                entryCopy.setSize(bOutput.length);
                zipOutput.putNextEntry(entryCopy);
                zipOutput.write(bOutput);
                zipOutput.closeEntry();
            } else {
                ZipEntry entryCopy = new ZipEntry(entry);
                entryCopy.setCompressedSize(-1);
                zipOutput.putNextEntry(entryCopy);
                InputStream is = zipInput.getInputStream(entry);
                byte[] buffer = new byte[1024];
                int read = 0;
                while ((read = is.read(buffer)) != -1)
                    zipOutput.write(buffer, 0, read);
                zipOutput.closeEntry();
            }
        }
        zipInput.close();
        zipOutput.close();
    }
    System.out.println("Done!");
}

From source file:nova.core.wrapper.mc.forge.v17.asm.lib.ObfMapping.java

License:Open Source License

public ObfMapping map(Remapper mapper) {
    if (isMethod()) {
        s_name = mapper.mapMethodName(s_owner, s_name, s_desc);
    } else if (isField()) {
        s_name = mapper.mapFieldName(s_owner, s_name, s_desc);
    }//from ww w  . j a  v a 2s.  c  o m

    s_owner = mapper.mapType(s_owner);

    if (isMethod()) {
        s_desc = mapper.mapMethodDesc(s_desc);
    } else if (s_desc.length() > 0) {
        s_desc = mapper.mapDesc(s_desc);
    }

    return this;
}

From source file:org.bukkit.plugin.java.Method.java

License:Open Source License

/**
 * @param args// ww w. ja  v a 2 s.  c  o m
 * @throws IOException 
 */
public static void main(File file, InputStream srgStream) throws IOException {
    String strInputFilename = file.getAbsolutePath();
    String strOutputFilename = file.getParentFile().getAbsolutePath() + "/ported_" + file.getName();
    List<String> listInputSrg = new LinkedList<String>();
    List<String> listInputInheritance = new LinkedList<String>();
    listInputInheritance.add(strInputFilename);
    List<ParseEntry> listTranslate = new LinkedList<ParseEntry>();
    /*for (int i=0; i<args.length; i++) {
       if (args[i].equals("--srg"))
    listInputSrg.add(args[++i]);
       else if (args[i].equals("--inheritance") || args[i].equals("--inh"))
    listInputInheritance.add(args[++i]);
       else if (args[i].equals("--in"))
    strInputFilename=args[++i];
       else if (args[i].equals("--out"))
    strOutputFilename=args[++i];
       else if (args[i].equals("--translate")) {
    String a=args[++i];
    String b=args[++i];
    listTranslate.add(new ParseEntry(a,b));
    listInputInheritance.add(a);
       }
    }
     */ if (strInputFilename != null && strOutputFilename != null) {
        listTranslate.add(new ParseEntry(strInputFilename, strOutputFilename));
        strInputFilename = strOutputFilename = null;
    }
    /*   if (strInputFilename!=null || strOutputFilename!=null || listTranslate.size()<1) {
      System.err.println("Usage: java -jar srgtool.jar apply [options]");
      System.err.println("Options:");
      System.err.println("--srg <srg file>\tLoads the SRG file");
      System.err.println("--inheritance <jar/zip>\tLoads inheritance map from jar");
      System.err.println("--in <jar/zip>");
      System.err.println("--out <jar/zip>");
      return;
    }
     */
    Map<String, MappedClass> mapClasses = new TreeMap<String, MappedClass>();
    Map<String, String> mapPackages = new TreeMap<String, String>();
    //for (String srg : listInputSrg) {
    ApplySrg.infoLog("Reading SRG!");

    BufferedReader brSrg = new BufferedReader(new InputStreamReader(srgStream));
    String strLine;
    while ((strLine = brSrg.readLine()) != null) {
        String arrLine[] = strLine.split(" ");
        if (arrLine[0].equals("PK:")) {
            mapPackages.put(arrLine[1], arrLine[2]);
        } else if (arrLine[0].equals("CL:")) {
            String strFrom = arrLine[1];
            String strTo = arrLine[2];
            MappedClass mappedCurrent = mapClasses.get(strFrom);
            if (mappedCurrent == null) {
                mapClasses.put(strFrom, new MappedClass(strTo));
            } else {
                if (!mappedCurrent.strNewName.equals(strTo)) {
                    System.err.println("ERROR: Mismatching mappings found");
                    return;
                }
            }
        } else if (arrLine[0].equals("FD:")) {
            String strFrom = arrLine[1];
            String strTo = arrLine[2];
            int nSplitFrom = strFrom.lastIndexOf('/');
            int nSplitTo = strTo.lastIndexOf('/');
            if (nSplitFrom == -1 || nSplitTo == -1) {
                System.err.println("ERROR: Invalid field specification: '" + strLine);
                return;
            }
            String strFromClass = strFrom.substring(0, nSplitFrom);
            strFrom = strFrom.substring(nSplitFrom + 1);
            String strToClass = strTo.substring(0, nSplitTo);
            strTo = strTo.substring(nSplitTo + 1);
            MappedClass mappedCurrent = mapClasses.get(strFromClass);
            if (strFromClass.equals(strToClass) && mappedCurrent == null) {
                mapClasses.put(strFromClass, mappedCurrent = new MappedClass(strToClass));
            }
            if (mappedCurrent == null || !mappedCurrent.strNewName.equals(strToClass)) {
                System.err.println("ERROR: Class mapping invalid or non-existant on field");
                System.err.println("Line: " + strLine);
                System.err.println(strFromClass + " -> " + strToClass + " should have been "
                        + ((mappedCurrent == null) ? "null" : mappedCurrent.strNewName));
                return;
            }
            mappedCurrent.mapFields.put(strFrom, strTo);
        } else if (arrLine[0].equals("MD:")) {
            String strFrom = arrLine[1];
            String strFromArguments = arrLine[2];
            String strTo = arrLine[3];
            String strToArguments = arrLine[4];
            int nSplitFrom = strFrom.lastIndexOf('/');
            int nSplitTo = strTo.lastIndexOf('/');
            if (nSplitFrom == -1 || nSplitTo == -1) {
                System.err.println("ERROR: Invalid method specification: '" + strLine);
                return;
            }
            String strFromClass = strFrom.substring(0, nSplitFrom);
            strFrom = strFrom.substring(nSplitFrom + 1);
            String strToClass = strTo.substring(0, nSplitTo);
            strTo = strTo.substring(nSplitTo + 1);
            MappedClass mappedCurrent = mapClasses.get(strFromClass);
            if (strFromClass.equals(strToClass) && mappedCurrent == null) {
                mapClasses.put(strFromClass, mappedCurrent = new MappedClass(strToClass));
            }
            if (mappedCurrent == null || !mappedCurrent.strNewName.equals(strToClass)) {
                System.err.println("ERROR: Class mapping invalid or non-existant on method");
                System.err.println("Line: " + strLine);
                System.err.println(strFromClass + " -> " + strToClass + " should have been "
                        + ((mappedCurrent == null) ? "null" : mappedCurrent.strNewName));
                return;
            }
            //NOTE: arguments not saved, will be mapped automagically.
            mappedCurrent.mapMethods.put(new Method(strFrom, strFromArguments), strTo);
        }
    }
    //}
    ApplySrg.infoLog("Class map loaded of " + mapClasses.size() + " classes");
    if (DEBUG_PLUGINREMAP) {
        for (Map.Entry<String, MappedClass> entry : mapClasses.entrySet()) {
            ApplySrg.debugLog(" class " + entry.getKey() + " -> " + entry.getValue().strNewName);
            for (Map.Entry<String, String> fieldEntry : entry.getValue().mapFields.entrySet()) {
                ApplySrg.debugLog("  field " + fieldEntry.getKey() + " -> " + fieldEntry.getValue());
            }
            for (Map.Entry<Method, String> methodEntry : entry.getValue().mapMethods.entrySet()) {
                ApplySrg.debugLog("  method " + methodEntry.getKey().name + " " + methodEntry.getKey().desc
                        + " -> " + methodEntry.getValue());
            }
        }
    }
    Map<String, ClassInfo> mapClassInheritance = new HashMap<String, ClassInfo>();
    for (String inherit : listInputInheritance) {
        ApplySrg.infoLog("Parsing inheritance in " + inherit);
        ZipFile zipInherit = new ZipFile(inherit);
        Enumeration<? extends ZipEntry> entries = zipInherit.entries();
        while (entries.hasMoreElements()) {
            ZipEntry entry = entries.nextElement();
            if (entry.isDirectory())
                continue;
            if (entry.getName().endsWith(".class")) {
                ClassReader cr = new ClassReader(zipInherit.getInputStream(entry));
                InheritanceMapClassVisitor cvInheritance = new InheritanceMapClassVisitor();
                cr.accept(cvInheritance, 0);
                mapClassInheritance.put(cvInheritance.strName, cvInheritance.info);
            }
        }
        zipInherit.close();
    }
    ApplySrg.infoLog("Inheritance map loaded of " + mapClassInheritance.size() + " classes");
    if (DEBUG_PLUGINREMAP) {
        for (String className : mapClassInheritance.keySet()) {
            ApplySrg.debugLog(" inheritance map class " + className);
            ClassInfo info = mapClassInheritance.get(className);
            for (String inherit : info.setInheritance) {
                ApplySrg.debugLog("  inherit " + inherit);
            }
        }
    }

    for (ParseEntry e : listTranslate) {
        ApplySrg.infoLog("Translating " + e.strInputFilename + " -> " + e.strOutputFilename);

        ZipFile zipInput = new ZipFile(e.strInputFilename);

        ZipOutputStream zipOutput = new ZipOutputStream(new FileOutputStream(e.strOutputFilename));
        Enumeration<? extends ZipEntry> entries = zipInput.entries();
        while (entries.hasMoreElements()) {
            ZipEntry entry = entries.nextElement();
            if (entry.isDirectory())
                continue;
            if (entry.getName().endsWith(".class")) {
                ClassReader cr = new ClassReader(zipInput.getInputStream(entry));
                ClassWriter cw = new ClassWriter(0);
                Remapper remapper = new MyRemapper(mapClasses, mapClassInheritance, mapPackages);
                RemappingClassAdapter ca = new RemappingClassAdapter(cw, remapper);
                cr.accept(ca, ClassReader.EXPAND_FRAMES);
                byte[] bOutput = cw.toByteArray();
                String strName = entry.getName();
                strName = strName.substring(0, strName.lastIndexOf('.'));
                strName = remapper.mapType(strName);

                ZipEntry entryCopy = new ZipEntry(strName + ".class");
                entryCopy.setCompressedSize(-1);
                entryCopy.setSize(bOutput.length);
                zipOutput.putNextEntry(entryCopy);
                zipOutput.write(bOutput);
                zipOutput.closeEntry();
            } else {
                ZipEntry entryCopy = new ZipEntry(entry);
                entryCopy.setCompressedSize(-1);
                zipOutput.putNextEntry(entryCopy);
                InputStream is = zipInput.getInputStream(entry);
                byte[] buffer = new byte[1024];
                int read = 0;
                while ((read = is.read(buffer)) != -1)
                    zipOutput.write(buffer, 0, read);
                zipOutput.closeEntry();
            }
        }
        zipInput.close();
        zipOutput.close();
    }
    ApplySrg.infoLog("Done!");
}