Allow standalone access transformer, fix a few bugs.
This commit is contained in:
parent
2c048232d3
commit
1762c76706
@ -175,12 +175,16 @@ public class AccessMap {
|
||||
public int applyMethodAccess(String className, String methodName, String methodDesc, int access) {
|
||||
int old = access;
|
||||
|
||||
if (className.contains("FileConversionException")){
|
||||
System.out.println("");
|
||||
}
|
||||
|
||||
access = apply("**", access);
|
||||
access = apply("*/* ()", access);
|
||||
access = apply(className + "/* ()", access);
|
||||
access = apply(className + "/" + methodName + " " + methodDesc, access);
|
||||
|
||||
//System.out.println("AT: method: "+className+"/"+methodName+" "+methodDesc+" "+old+" -> "+access);
|
||||
if (access!= old) System.out.println("AT: method: "+className+"/"+methodName+" "+methodDesc+" "+old+" -> "+access);
|
||||
|
||||
return access;
|
||||
}
|
||||
|
@ -80,11 +80,9 @@ public class JarComparer extends ClassVisitor {
|
||||
|
||||
@Override
|
||||
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
|
||||
// Check for initializers
|
||||
if (!name.equals("<init>") && !name.equals("<clinit>")) {
|
||||
Ownable method = new Ownable(NodeType.METHOD, myName, name, desc, access);
|
||||
methods.add(method);
|
||||
}
|
||||
|
||||
// FIXME: Scan return types too!
|
||||
for (Type t : Type.getArgumentTypes(desc)) {
|
||||
visitType(t);
|
||||
|
@ -409,7 +409,13 @@ public class JarMapping {
|
||||
return;
|
||||
}
|
||||
|
||||
fields.put(oldClassName + "/" + oldFieldName, newFieldName);
|
||||
String oldEntry = oldClassName + "/" + oldFieldName;
|
||||
if (fields.containsKey(oldEntry) && !newFieldName.equals(fields.get(oldEntry))) {
|
||||
throw new IllegalArgumentException("Duplicate field mapping: " + oldEntry + " ->" + newFieldName
|
||||
+ " but already mapped to " + fields.get(oldEntry) + " in line=" + line);
|
||||
}
|
||||
|
||||
fields.put(oldEntry, newFieldName);
|
||||
} else if (kind.equals("MD:")) {
|
||||
String oldFull = tokens[1];
|
||||
String newFull = tokens[3];
|
||||
@ -444,7 +450,13 @@ public class JarMapping {
|
||||
return;
|
||||
}
|
||||
|
||||
methods.put(oldClassName + "/" + oldMethodName + " " + oldMethodDescriptor, newMethodName);
|
||||
String oldEntry = oldClassName + "/" + oldMethodName + " " + oldMethodDescriptor;
|
||||
if (methods.containsKey(oldEntry) && !newMethodName.equals(methods.get(oldEntry))) {
|
||||
throw new IllegalArgumentException("Duplicate method mapping: " + oldEntry + " ->" + newMethodName
|
||||
+ " but already mapped to " + methods.get(oldEntry) + " in line=" + line);
|
||||
}
|
||||
|
||||
methods.put(oldEntry, newMethodName);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unable to parse srg file, unrecognized mapping type in line=" + line);
|
||||
}
|
||||
@ -483,9 +495,11 @@ public class JarMapping {
|
||||
for (int i = 0; i < oldJar.classes.size(); i++) {
|
||||
String oldClass = oldJar.classes.get(i);
|
||||
String newClass = newJar.classes.get(i);
|
||||
classes.put(oldClass, newClass); // always output class names (no duplicate check)
|
||||
if (full || !oldClass.equals(newClass)) {
|
||||
classes.put(oldClass, newClass);
|
||||
srgWriter.addClassMap(oldClass, newClass);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < oldJar.fields.size(); i++) {
|
||||
Ownable oldField = oldJar.fields.get(i);
|
||||
Ownable newField = newJar.fields.get(i);
|
||||
|
@ -67,6 +67,10 @@ public class SpecialSource {
|
||||
.withRequiredArg()
|
||||
.ofType(String.class);
|
||||
|
||||
acceptsAll(asList("access-transformer"), "Access transformer file")
|
||||
.withRequiredArg()
|
||||
.ofType(File.class);
|
||||
|
||||
acceptsAll(asList("s", "srg-out"), "Mapping file output")
|
||||
.withRequiredArg()
|
||||
.ofType(File.class);
|
||||
@ -234,6 +238,12 @@ public class SpecialSource {
|
||||
inheritanceProviders.add(inheritanceMap);
|
||||
}
|
||||
|
||||
RemapperProcessor accessMapper = null;
|
||||
if (options.has("access-transformer")) {
|
||||
AccessMap access = new AccessMap();
|
||||
access.loadAccessTransformer((File) options.valueOf("access-transformer"));
|
||||
accessMapper = new RemapperProcessor(null, jarMapping, access);
|
||||
}
|
||||
|
||||
if (options.has("in-jar")) {
|
||||
if (!options.has("out-jar")) {
|
||||
@ -255,7 +265,7 @@ public class SpecialSource {
|
||||
inheritanceProviders.add(new JarProvider(jar3));
|
||||
|
||||
log("Remapping final jar");
|
||||
JarRemapper jarRemapper = new JarRemapper(jarMapping);
|
||||
JarRemapper jarRemapper = new JarRemapper(null, jarMapping, accessMapper);
|
||||
jarRemapper.remapJar(jar3, (File) options.valueOf("out-jar"));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user