Revert "Close issue #3 - static and private inheritance"
This reverts commit 33d8d24d7e
.
This commit is contained in:
parent
33d8d24d7e
commit
6d9552101f
@ -73,7 +73,7 @@ public class JarComparer extends ClassVisitor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) {
|
public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) {
|
||||||
Ownable field = new Ownable(NodeType.FIELD, myName, name, desc, access);
|
Ownable field = new Ownable(NodeType.FIELD, myName, name, desc);
|
||||||
fields.add(field);
|
fields.add(field);
|
||||||
return null; // No need to get more info about a field!
|
return null; // No need to get more info about a field!
|
||||||
}
|
}
|
||||||
@ -82,7 +82,7 @@ public class JarComparer extends ClassVisitor {
|
|||||||
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
|
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
|
||||||
// Check for initializers
|
// Check for initializers
|
||||||
if (!name.equals("<init>") && !name.equals("<clinit>")) {
|
if (!name.equals("<init>") && !name.equals("<clinit>")) {
|
||||||
Ownable method = new Ownable(NodeType.METHOD, myName, name, desc, access);
|
Ownable method = new Ownable(NodeType.METHOD, myName, name, desc);
|
||||||
methods.add(method);
|
methods.add(method);
|
||||||
}
|
}
|
||||||
// FIXME: Scan return types too!
|
// FIXME: Scan return types too!
|
||||||
|
@ -39,15 +39,14 @@ import net.md_5.specialsource.transformer.MethodDescriptor;
|
|||||||
import net.md_5.specialsource.transformer.ChainingTransformer;
|
import net.md_5.specialsource.transformer.ChainingTransformer;
|
||||||
import net.md_5.specialsource.transformer.MappingTransformer;
|
import net.md_5.specialsource.transformer.MappingTransformer;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.lang.reflect.Modifier;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class JarMapping {
|
public class JarMapping {
|
||||||
|
|
||||||
public final LinkedHashMap<String, String> packages = new LinkedHashMap<String, String>();
|
public final LinkedHashMap<String, String> packages = new LinkedHashMap<String, String>();
|
||||||
public final Map<String, String> classes = new HashMap<String, String>();
|
public final Map<String, String> classes = new HashMap<String, String>();
|
||||||
public final Map<String, Ownable> fields = new HashMap<String, Ownable>();
|
public final Map<String, String> fields = new HashMap<String, String>();
|
||||||
public final Map<String, Ownable> methods = new HashMap<String, Ownable>();
|
public final Map<String, String> methods = new HashMap<String, String>();
|
||||||
private InheritanceMap inheritanceMap = new InheritanceMap();
|
private InheritanceMap inheritanceMap = new InheritanceMap();
|
||||||
private InheritanceProvider fallbackInheritanceProvider = null;
|
private InheritanceProvider fallbackInheritanceProvider = null;
|
||||||
private Set<String> excludedPackages = new HashSet<String>();
|
private Set<String> excludedPackages = new HashSet<String>();
|
||||||
@ -91,14 +90,10 @@ public class JarMapping {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Ownable tryClimb(Map<String, Ownable> map, NodeType type, String owner, String name) {
|
public String tryClimb(Map<String, String> map, NodeType type, String owner, String name) {
|
||||||
String key = owner + "/" + name;
|
String key = owner + "/" + name;
|
||||||
|
|
||||||
Ownable mapped = map.get(key);
|
String mapped = map.get(key);
|
||||||
if (mapped != null && (Modifier.isPrivate(mapped.getAccess()) || Modifier.isStatic(mapped.getAccess()))) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mapped == null) {
|
if (mapped == null) {
|
||||||
Collection<String> parents = null;
|
Collection<String> parents = null;
|
||||||
|
|
||||||
@ -300,13 +295,13 @@ public class JarMapping {
|
|||||||
String oldClassName = inputTransformer.transformClassName(tokens[0]);
|
String oldClassName = inputTransformer.transformClassName(tokens[0]);
|
||||||
String oldFieldName = inputTransformer.transformFieldName(tokens[0], tokens[1]);
|
String oldFieldName = inputTransformer.transformFieldName(tokens[0], tokens[1]);
|
||||||
String newFieldName = outputTransformer.transformFieldName(tokens[0], tokens[2]);
|
String newFieldName = outputTransformer.transformFieldName(tokens[0], tokens[2]);
|
||||||
fields.put(oldClassName + "/" + oldFieldName, new Ownable(NodeType.FIELD, newFieldName));
|
fields.put(oldClassName + "/" + oldFieldName, newFieldName);
|
||||||
} else if (tokens.length == 4) {
|
} else if (tokens.length == 4) {
|
||||||
String oldClassName = inputTransformer.transformClassName(tokens[0]);
|
String oldClassName = inputTransformer.transformClassName(tokens[0]);
|
||||||
String oldMethodName = inputTransformer.transformMethodName(tokens[0], tokens[1], tokens[2]);
|
String oldMethodName = inputTransformer.transformMethodName(tokens[0], tokens[1], tokens[2]);
|
||||||
String oldMethodDescriptor = inputTransformer.transformMethodDescriptor(tokens[2]);
|
String oldMethodDescriptor = inputTransformer.transformMethodDescriptor(tokens[2]);
|
||||||
String newMethodName = outputTransformer.transformMethodName(tokens[0], tokens[3], tokens[2]);
|
String newMethodName = outputTransformer.transformMethodName(tokens[0], tokens[3], tokens[2]);
|
||||||
methods.put(oldClassName + "/" + oldMethodName + " " + oldMethodDescriptor, new Ownable(NodeType.METHOD, newMethodName));
|
methods.put(oldClassName + "/" + oldMethodName + " " + oldMethodDescriptor, newMethodName);
|
||||||
} else {
|
} else {
|
||||||
throw new IOException("Invalid csrg file line, token count " + tokens.length + " unexpected in " + line);
|
throw new IOException("Invalid csrg file line, token count " + tokens.length + " unexpected in " + line);
|
||||||
}
|
}
|
||||||
@ -409,7 +404,7 @@ public class JarMapping {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fields.put(oldClassName + "/" + oldFieldName, new Ownable(NodeType.FIELD, newFieldName));
|
fields.put(oldClassName + "/" + oldFieldName, newFieldName);
|
||||||
} else if (kind.equals("MD:")) {
|
} else if (kind.equals("MD:")) {
|
||||||
String oldFull = tokens[1];
|
String oldFull = tokens[1];
|
||||||
String newFull = tokens[3];
|
String newFull = tokens[3];
|
||||||
@ -444,7 +439,7 @@ public class JarMapping {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
methods.put(oldClassName + "/" + oldMethodName + " " + oldMethodDescriptor, new Ownable(NodeType.METHOD, newMethodName));
|
methods.put(oldClassName + "/" + oldMethodName + " " + oldMethodDescriptor, newMethodName);
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException("Unable to parse srg file, unrecognized mapping type in line=" + line);
|
throw new IllegalArgumentException("Unable to parse srg file, unrecognized mapping type in line=" + line);
|
||||||
}
|
}
|
||||||
@ -487,7 +482,7 @@ public class JarMapping {
|
|||||||
Ownable oldField = oldJar.fields.get(i);
|
Ownable oldField = oldJar.fields.get(i);
|
||||||
Ownable newField = newJar.fields.get(i);
|
Ownable newField = newJar.fields.get(i);
|
||||||
String key = oldField.owner + "/" + oldField.name;
|
String key = oldField.owner + "/" + oldField.name;
|
||||||
fields.put(key, newField);
|
fields.put(key, newField.name);
|
||||||
|
|
||||||
if (full || !oldField.name.equals(newField.name)) {
|
if (full || !oldField.name.equals(newField.name)) {
|
||||||
srgWriter.addFieldMap(oldField, newField);
|
srgWriter.addFieldMap(oldField, newField);
|
||||||
@ -497,7 +492,7 @@ public class JarMapping {
|
|||||||
Ownable oldMethod = oldJar.methods.get(i);
|
Ownable oldMethod = oldJar.methods.get(i);
|
||||||
Ownable newMethod = newJar.methods.get(i);
|
Ownable newMethod = newJar.methods.get(i);
|
||||||
String key = oldMethod.owner + "/" + oldMethod.name + " " + oldMethod.descriptor;
|
String key = oldMethod.owner + "/" + oldMethod.name + " " + oldMethod.descriptor;
|
||||||
methods.put(key, newMethod);
|
methods.put(key, newMethod.name);
|
||||||
|
|
||||||
MethodDescriptor methodDescriptorTransformer = new MethodDescriptor(null, classes);
|
MethodDescriptor methodDescriptorTransformer = new MethodDescriptor(null, classes);
|
||||||
String oldDescriptor = methodDescriptorTransformer.transform(oldMethod.descriptor);
|
String oldDescriptor = methodDescriptorTransformer.transform(oldMethod.descriptor);
|
||||||
|
@ -150,14 +150,14 @@ public class JarRemapper extends Remapper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String mapFieldName(String owner, String name, String desc) {
|
public String mapFieldName(String owner, String name, String desc) {
|
||||||
Ownable mapped = jarMapping.tryClimb(jarMapping.fields, NodeType.FIELD, owner, name);
|
String mapped = jarMapping.tryClimb(jarMapping.fields, NodeType.FIELD, owner, name);
|
||||||
return mapped == null ? name : mapped.name;
|
return mapped == null ? name : mapped;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String mapMethodName(String owner, String name, String desc) {
|
public String mapMethodName(String owner, String name, String desc) {
|
||||||
Ownable mapped = jarMapping.tryClimb(jarMapping.methods, NodeType.METHOD, owner, name + " " + desc);
|
String mapped = jarMapping.tryClimb(jarMapping.methods, NodeType.METHOD, owner, name + " " + desc);
|
||||||
return mapped == null ? name : mapped.name;
|
return mapped == null ? name : mapped;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -29,23 +29,16 @@
|
|||||||
package net.md_5.specialsource;
|
package net.md_5.specialsource;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A class which can be used to represent a field, method, or anything else
|
* A class which can be used to represent a field, method, or anything else
|
||||||
* which has an owner, a name and a descriptor.
|
* which has an owner, a name and a descriptor.
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class Ownable {
|
public class Ownable {
|
||||||
|
|
||||||
public final NodeType type;
|
public final NodeType type;
|
||||||
public final String owner;
|
public final String owner;
|
||||||
public final String name;
|
public final String name;
|
||||||
public final String descriptor;
|
public final String descriptor;
|
||||||
public final int access;
|
|
||||||
|
|
||||||
public Ownable(NodeType type, String name) {
|
|
||||||
this(type, null, name, null, -1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -227,12 +227,12 @@ public class RemapperPreprocessor {
|
|||||||
}
|
}
|
||||||
String className = ((Type) ldcClass.cst).getInternalName();
|
String className = ((Type) ldcClass.cst).getInternalName();
|
||||||
|
|
||||||
Ownable newName = jarMapping.tryClimb(jarMapping.fields, NodeType.FIELD, className, fieldName);
|
String newName = jarMapping.tryClimb(jarMapping.fields, NodeType.FIELD, className, fieldName);
|
||||||
logR("Remapping " + className + "/" + fieldName + " -> " + newName);
|
logR("Remapping " + className + "/" + fieldName + " -> " + newName);
|
||||||
|
|
||||||
if (newName != null) {
|
if (newName != null) {
|
||||||
// Change the string literal to the correct name
|
// Change the string literal to the correct name
|
||||||
ldcField.cst = newName.name;
|
ldcField.cst = newName;
|
||||||
//ldcClass.cst = className; // not remapped here - taken care of by JarRemapper
|
//ldcClass.cst = className; // not remapped here - taken care of by JarRemapper
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user