diff --git a/src/main/java/org/spongepowered/asm/mixin/transformer/ClassInfo.java b/src/main/java/org/spongepowered/asm/mixin/transformer/ClassInfo.java
index a86fa7ee..14ee1f78 100644
--- a/src/main/java/org/spongepowered/asm/mixin/transformer/ClassInfo.java
+++ b/src/main/java/org/spongepowered/asm/mixin/transformer/ClassInfo.java
@@ -52,80 +52,80 @@ import com.google.common.collect.ImmutableSet;
/**
* Information about a class, used as a way of keeping track of class hierarchy
* information needed to support more complex mixin behaviour such as detached
- * superclass and mixin inheritance.
+ * superclass and mixin inheritance.
*/
public class ClassInfo extends TreeInfo {
-
+
public static final int INCLUDE_PRIVATE = 0x0002;
public static final int INCLUDE_STATIC = 0x0008;
-
+
/**
*
To all intents and purposes, the "real" class hierarchy and the mixin
* class hierarchy exist in parallel, this means that for some hierarchy
* validation operations we need to walk across to the other
* hierarchy in order to allow meaningful validation to occur.
- *
+ *
* This enum defines the type of traversal operations which are allowed
* for a particular lookup.
- *
+ *
* Each traversal type has a next property which defines
* the traversal type to use on the next step of the hierarchy
- * validation. For example, the type {@link #IMMEDIATE} which requires an
+ * validation. For example, the type {@link #IMMEDIATE} which requires an
* immediate match falls through to {@link #NONE} on the next step, which
* prevents further traversals from occurring in the lookup.
*/
public static enum Traversal {
-
+
/**
* No traversals are allowed.
*/
NONE(null, false),
-
+
/**
* Traversal is allowed at all stages.
*/
ALL(null, true),
-
+
/**
* Traversal is allowed at the bottom of the hierarchy but no further.
*/
IMMEDIATE(Traversal.NONE, true),
-
+
/**
* Traversal is allowed only on superclasses and not at the bottom of
* the hierarchy.
*/
SUPER(Traversal.ALL, false);
-
+
private final Traversal next;
-
+
private final boolean traverse;
-
+
private Traversal(Traversal next, boolean traverse) {
this.next = next != null ? next : this;
this.traverse = traverse;
}
-
+
public Traversal next() {
return this.next;
}
-
+
public boolean canTraverse() {
return this.traverse;
}
}
-
+
/**
* Information about frames in a method
*/
public static class FrameData {
-
+
private static final String[] FRAMETYPES = { "NEW", "FULL", "APPEND", "CHOP", "SAME", "SAME1" };
-
+
public final int index;
-
+
public final int type;
-
+
public final int locals;
FrameData(int index, int type, int locals) {
@@ -133,13 +133,13 @@ public class ClassInfo extends TreeInfo {
this.type = type;
this.locals = locals;
}
-
+
FrameData(int index, FrameNode frameNode) {
this.index = index;
this.type = frameNode.type;
this.locals = frameNode.local != null ? frameNode.local.size() : 0;
}
-
+
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@@ -148,54 +148,54 @@ public class ClassInfo extends TreeInfo {
return String.format("FrameData[index=%d, type=%s, locals=%d]", this.index, FrameData.FRAMETYPES[this.type + 1], this.locals);
}
}
-
+
/**
* Information about a member in this class
*/
abstract static class Member {
-
+
static enum Type {
METHOD,
FIELD
}
-
+
/**
- * Member type
+ * Member type
*/
private final Type type;
-
+
/**
- * The original name of the member
+ * The original name of the member
*/
private final String memberName;
-
+
/**
* The member's signature
*/
private final String memberDesc;
-
+
/**
* True if this member was injected by a mixin, false if it was
* originally part of the class
*/
private final boolean isInjected;
-
+
/**
* Access modifiers
*/
private final int modifiers;
-
+
/**
* Current name of the member, may be different from {@link #memberName}
* if the member has been renamed
*/
private String currentName;
-
+
protected Member(Member member) {
this(member.type, member.memberName, member.memberDesc, member.modifiers, member.isInjected);
this.currentName = member.currentName;
}
-
+
protected Member(Type type, String name, String desc, int access) {
this(type, name, desc, access, false);
}
@@ -208,23 +208,23 @@ public class ClassInfo extends TreeInfo {
this.currentName = name;
this.modifiers = access;
}
-
+
public String getOriginalName() {
return this.memberName;
}
-
+
public String getName() {
return this.currentName;
}
-
+
public String getDesc() {
return this.memberDesc;
}
-
+
public boolean isInjected() {
return this.isInjected;
}
-
+
public boolean isRenamed() {
return this.currentName != this.memberName;
}
@@ -236,7 +236,7 @@ public class ClassInfo extends TreeInfo {
public boolean isStatic() {
return (this.modifiers & Opcodes.ACC_STATIC) != 0;
}
-
+
public boolean matchesFlags(int flags) {
return (((~this.modifiers | (flags & ClassInfo.INCLUDE_PRIVATE)) & ClassInfo.INCLUDE_PRIVATE) != 0
&& ((~this.modifiers | (flags & ClassInfo.INCLUDE_STATIC)) & ClassInfo.INCLUDE_STATIC) != 0);
@@ -244,7 +244,7 @@ public class ClassInfo extends TreeInfo {
// Abstract because this has to be static in order to contain the enum
public abstract ClassInfo getOwner();
-
+
public int getAccess() {
return this.modifiers;
}
@@ -252,45 +252,45 @@ public class ClassInfo extends TreeInfo {
public void renameTo(String name) {
this.currentName = name;
}
-
+
public boolean equals(String name, String desc) {
return (this.memberName.equals(name)
|| this.currentName.equals(name))
&& this.memberDesc.equals(desc);
}
-
+
@Override
public boolean equals(Object obj) {
if (!(obj instanceof Member)) {
return false;
}
-
+
Member other = (Member)obj;
- return (other.memberName.equals(this.memberName)
+ return (other.memberName.equals(this.memberName)
|| other.currentName.equals(this.currentName))
&& other.memberDesc.equals(this.memberDesc);
}
-
+
@Override
public int hashCode() {
return this.toString().hashCode();
}
-
+
@Override
public String toString() {
return this.memberName + this.memberDesc;
}
-
+
public boolean isAbstract() {
return (this.modifiers & Opcodes.ACC_ABSTRACT) != 0;
}
}
-
+
/**
* A method
*/
public class Method extends Member {
-
+
private final List frames;
public Method(Member member) {
@@ -301,12 +301,12 @@ public class ClassInfo extends TreeInfo {
public Method(MethodNode method) {
this(method, false);
}
-
+
public Method(MethodNode method, boolean injected) {
super(Type.METHOD, method.name, method.desc, method.access, injected);
this.frames = this.gatherFrames(method);
}
-
+
public Method(String name, String desc) {
super(Type.METHOD, name, desc, Opcodes.ACC_PUBLIC, false);
this.frames = null;
@@ -321,7 +321,7 @@ public class ClassInfo extends TreeInfo {
super(Type.METHOD, name, desc, access, injected);
this.frames = null;
}
-
+
private List gatherFrames(MethodNode method) {
List frames = new ArrayList();
for (Iterator iter = method.instructions.iterator(); iter.hasNext();) {
@@ -332,7 +332,7 @@ public class ClassInfo extends TreeInfo {
}
return frames;
}
-
+
public List getFrames() {
return this.frames;
}
@@ -340,58 +340,58 @@ public class ClassInfo extends TreeInfo {
@Override
public ClassInfo getOwner() {
return ClassInfo.this;
- }
+ }
@Override
public boolean equals(Object obj) {
if (!(obj instanceof Method)) {
return false;
}
-
+
return super.equals(obj);
}
}
-
+
/**
* A field
*/
class Field extends Member {
-
+
public Field(Member member) {
super(member);
}
-
+
public Field(FieldNode field) {
this(field, false);
}
-
+
public Field(FieldNode field, boolean injected) {
super(Type.FIELD, field.name, field.desc, field.access, injected);
}
-
+
public Field(String name, String desc, int access) {
super(Type.FIELD, name, desc, access, false);
}
-
+
public Field(String name, String desc, int access, boolean injected) {
super(Type.FIELD, name, desc, access, injected);
}
-
+
@Override
public ClassInfo getOwner() {
return ClassInfo.this;
- }
-
+ }
+
@Override
public boolean equals(Object obj) {
if (!(obj instanceof Field)) {
return false;
}
-
+
return super.equals(obj);
}
}
-
+
private static final Logger logger = LogManager.getLogger("mixin");
private static final String JAVA_LANG_OBJECT = "java/lang/Object";
@@ -401,90 +401,90 @@ public class ClassInfo extends TreeInfo {
* information we generate
*/
private static final Map cache = new HashMap();
-
+
private static final ClassInfo OBJECT = new ClassInfo();
-
+
static {
ClassInfo.cache.put(ClassInfo.JAVA_LANG_OBJECT, ClassInfo.OBJECT);
}
-
+
/**
* Class name (binary name)
*/
private final String name;
-
+
/**
* Class superclass name (binary name)
*/
private final String superName;
-
+
/**
* Outer class name
*/
private final String outerName;
-
+
/**
* True either if this is not an inner class or if it is an inner class but
* does not contain a reference to its outer class.
*/
private final boolean isProbablyStatic;
-
+
/**
* Interfaces
*/
private final Set interfaces;
-
+
/**
- * Public and protected methods (instance) methods in this class
+ * Public and protected methods (instance) methods in this class
*/
private final Set methods;
-
+
/**
* Public and protected fields in this class
*/
private final Set fields;
-
+
/**
* Mixins which target this class
*/
private final Set mixins = new HashSet();
-
+
/**
- * Map of mixin types to corresponding supertypes, to avoid repeated
- * lookups
+ * Map of mixin types to corresponding supertypes, to avoid repeated
+ * lookups
*/
private final Map correspondingTypes = new HashMap();
-
+
/**
- * Mixin info if this class is a mixin itself
+ * Mixin info if this class is a mixin itself
*/
private final MixinInfo mixin;
-
+
/**
- * True if this is a mixin rather than a class
+ * True if this is a mixin rather than a class
*/
private final boolean isMixin;
-
+
/**
- * True if this is an interface
+ * True if this is an interface
*/
private final boolean isInterface;
-
+
/**
* Access flags
*/
private final int access;
-
+
/**
- * Superclass reference, not initialised until required
+ * Superclass reference, not initialised until required
*/
private ClassInfo superClass;
-
+
/**
- * Outer class reference, not initialised until required
+ * Outer class reference, not initialised until required
*/
private ClassInfo outerClass;
-
+
/**
* Private constructor used to initialise the ClassInfo for {@link Object}
*/
@@ -513,10 +513,10 @@ public class ClassInfo extends TreeInfo {
this.isMixin = false;
this.mixin = null;
}
-
+
/**
* Initialise a ClassInfo from the supplied {@link ClassNode}
- *
+ *
* @param classNode Class node to inspect
*/
private ClassInfo(ClassNode classNode) {
@@ -531,7 +531,7 @@ public class ClassInfo extends TreeInfo {
this.mixin = this.isMixin ? ((MixinClassNode)classNode).getMixin() : null;
this.interfaces.addAll(classNode.interfaces);
-
+
for (MethodNode method : classNode.methods) {
this.addMethod(method, this.isMixin);
}
@@ -548,18 +548,18 @@ public class ClassInfo extends TreeInfo {
outerName = outerName.substring(1, outerName.length() - 1);
}
}
- }
-
+ }
+
if ((field.access & Opcodes.ACC_STATIC) == 0) {
this.fields.add(new Field(field, this.isMixin));
}
}
}
-
+
this.isProbablyStatic = isProbablyStatic;
this.outerName = outerName;
}
-
+
void addInterface(String iface) {
this.interfaces.add(iface);
}
@@ -573,7 +573,7 @@ public class ClassInfo extends TreeInfo {
this.methods.add(new Method(method, injected));
}
}
-
+
/**
* Add a mixin which targets this class
*/
@@ -583,21 +583,21 @@ public class ClassInfo extends TreeInfo {
}
this.mixins.add(mixin);
}
-
+
/**
* Get all mixins which target this class
*/
public Set getMixins() {
return Collections.unmodifiableSet(this.mixins);
}
-
+
/**
* Get whether this class is a mixin
*/
public boolean isMixin() {
return this.isMixin;
}
-
+
/**
* Get whether this class has ACC_PUBLIC
*/
@@ -618,58 +618,58 @@ public class ClassInfo extends TreeInfo {
public boolean isSynthetic() {
return (this.access & Opcodes.ACC_SYNTHETIC) != 0;
}
-
+
/**
- * Get whether this class is probably static (or is not an inner class)
+ * Get whether this class is probably static (or is not an inner class)
*/
public boolean isProbablyStatic() {
return this.isProbablyStatic;
}
-
+
/**
* Get whether this class is an inner class
*/
public boolean isInner() {
return this.outerName != null;
}
-
+
/**
* Get whether this is an interface or not
*/
public boolean isInterface() {
return this.isInterface;
}
-
+
/**
* Returns the answer to life, the universe and everything
*/
public Set getInterfaces() {
return Collections.unmodifiableSet(this.interfaces);
}
-
+
@Override
public String toString() {
return this.name;
}
-
+
public int getAccess() {
return this.access;
}
-
+
/**
* Get the class name (binary name)
*/
public String getName() {
return this.name;
}
-
+
/**
* Get the superclass name (binary name)
*/
public String getSuperName() {
return this.superName;
}
-
+
/**
* Get the superclass info, can return null if the superclass cannot be
* resolved
@@ -678,17 +678,17 @@ public class ClassInfo extends TreeInfo {
if (this.superClass == null && this.superName != null) {
this.superClass = ClassInfo.forName(this.superName);
}
-
+
return this.superClass;
}
-
+
/**
* Get the name of the outer class, or null if this is not an inner class
*/
public String getOuterName() {
return this.outerName;
}
-
+
/**
* Get the outer class info, can return null if the outer class cannot be
* resolved or if this is not an inner class
@@ -697,10 +697,10 @@ public class ClassInfo extends TreeInfo {
if (this.outerClass == null && this.outerName != null) {
this.outerClass = ClassInfo.forName(this.outerName);
}
-
+
return this.outerClass;
}
-
+
/**
* Class targets
*/
@@ -711,55 +711,57 @@ public class ClassInfo extends TreeInfo {
targets.addAll(this.mixin.getTargets());
return targets;
}
-
+
return ImmutableList.of(this);
}
-
+
/**
* Get class/interface methods
- *
+ *
* @return read-only view of class methods
*/
public Set getMethods() {
return Collections.unmodifiableSet(this.methods);
}
-
+
/**
* If this is an interface, returns a set containing all methods in this
* interface and all super interfaces. If this is a class, returns a set
* containing all methods for all interfaces implemented by this class and
* all super interfaces of those interfaces.
- *
+ *
+ * @param includeMixins Whether to include methods from mixins targeting this class info
* @return read-only view of class methods
*/
- public Set getInterfaceMethods() {
+ public Set getInterfaceMethods(boolean includeMixins) {
Set methods = new HashSet();
- ClassInfo superClass = this.addMethodsRecursive(methods);
+ ClassInfo superClass = this.addMethodsRecursive(methods, includeMixins);
if (!this.isInterface) {
while (superClass != null && superClass != ClassInfo.OBJECT) {
- superClass = superClass.addMethodsRecursive(methods);
+ superClass = superClass.addMethodsRecursive(methods, includeMixins);
}
}
-
+
// Remove default methods.
for (Iterator it = methods.iterator(); it.hasNext();) {
if (!it.next().isAbstract()) {
it.remove();
}
}
-
+
return Collections.unmodifiableSet(methods);
}
/**
* Recursive function used by {@link #getInterfaceMethods} to add all
* interface methods to the supplied set
- *
+ *
* @param methods Method set to add to
+ * @param includeMixins Whether to include methods from mixins targeting this class info
* @return superclass reference, used to make the code above more fluent
*/
- private ClassInfo addMethodsRecursive(Set methods) {
+ private ClassInfo addMethodsRecursive(Set methods, boolean includeMixins) {
if (this.isInterface) {
for (Method method : this.methods) {
// Default methods take priority. They are removed later.
@@ -769,22 +771,22 @@ public class ClassInfo extends TreeInfo {
}
methods.add(method);
}
- } else if (!this.isMixin) {
+ } else if (!this.isMixin && includeMixins) {
for (MixinInfo mixin : this.mixins) {
- mixin.getClassInfo().addMethodsRecursive(methods);
+ mixin.getClassInfo().addMethodsRecursive(methods, includeMixins);
}
}
-
+
for (String iface : this.interfaces) {
- ClassInfo.forName(iface).addMethodsRecursive(methods);
+ ClassInfo.forName(iface).addMethodsRecursive(methods, includeMixins);
}
-
+
return this.getSuperClass();
}
-
+
/**
* Test whether this class has the specified superclass in its hierarchy
- *
+ *
* @param superClass Name of the superclass to search for in the hierarchy
* @return true if the specified class appears in the class's hierarchy
* anywhere
@@ -795,7 +797,7 @@ public class ClassInfo extends TreeInfo {
/**
* Test whether this class has the specified superclass in its hierarchy
- *
+ *
* @param superClass Name of the superclass to search for in the hierarchy
* @param traversal Traversal type to allow during this lookup
* @return true if the specified class appears in the class's hierarchy
@@ -805,13 +807,13 @@ public class ClassInfo extends TreeInfo {
if (ClassInfo.JAVA_LANG_OBJECT.equals(superClass)) {
return true;
}
-
+
return this.findSuperClass(superClass, traversal) != null;
}
-
+
/**
* Test whether this class has the specified superclass in its hierarchy
- *
+ *
* @param superClass Superclass to search for in the hierarchy
* @return true if the specified class appears in the class's hierarchy
* anywhere
@@ -822,7 +824,7 @@ public class ClassInfo extends TreeInfo {
/**
* Test whether this class has the specified superclass in its hierarchy
- *
+ *
* @param superClass Superclass to search for in the hierarchy
* @param traversal Traversal type to allow during this lookup
* @return true if the specified class appears in the class's hierarchy
@@ -839,9 +841,9 @@ public class ClassInfo extends TreeInfo {
/**
* Search for the specified superclass in this class's hierarchy. If found
* returns the ClassInfo, otherwise returns null
- *
+ *
* @param superClass Superclass name to search for
- * @return Matched superclass or null if not found
+ * @return Matched superclass or null if not found
*/
public ClassInfo findSuperClass(String superClass) {
return this.findSuperClass(superClass, Traversal.NONE);
@@ -850,10 +852,10 @@ public class ClassInfo extends TreeInfo {
/**
* Search for the specified superclass in this class's hierarchy. If found
* returns the ClassInfo, otherwise returns null
- *
+ *
* @param superClass Superclass name to search for
* @param traversal Traversal type to allow during this lookup
- * @return Matched superclass or null if not found
+ * @return Matched superclass or null if not found
*/
public ClassInfo findSuperClass(String superClass, Traversal traversal) {
ClassInfo superClassInfo = this.getSuperClass();
@@ -879,7 +881,7 @@ public class ClassInfo extends TreeInfo {
}
}
}
-
+
return null;
}
@@ -888,7 +890,7 @@ public class ClassInfo extends TreeInfo {
* specified mixin. This is used during mixin application to translate a
* mixin reference to a "real class" reference in the context of this
* class.
- *
+ *
* @param mixin Mixin class to search for
* @return corresponding (target) class for the specified mixin or null if
* no corresponding mixin was found
@@ -897,7 +899,7 @@ public class ClassInfo extends TreeInfo {
if (mixin == null || !mixin.isMixin || this.isMixin) {
return null;
}
-
+
ClassInfo correspondingType = this.correspondingTypes.get(mixin);
if (correspondingType == null) {
correspondingType = this.findSuperTypeForMixin(mixin);
@@ -912,24 +914,24 @@ public class ClassInfo extends TreeInfo {
*/
private ClassInfo findSuperTypeForMixin(ClassInfo mixin) {
ClassInfo superClass = this;
-
+
while (superClass != null && superClass != ClassInfo.OBJECT) {
for (MixinInfo minion : superClass.mixins) {
if (minion.getClassInfo().equals(mixin)) {
return superClass;
}
}
-
+
superClass = superClass.getSuperClass();
}
-
+
return null;
}
/**
* Find out whether this (mixin) class has another mixin in its superclass
* hierarchy. This method always returns false for non-mixin classes.
- *
+ *
* @return true if and only if one or more mixins are found in the hierarchy
* of this mixin
*/
@@ -937,9 +939,9 @@ public class ClassInfo extends TreeInfo {
if (!this.isMixin) {
return false;
}
-
+
ClassInfo superClass = this.getSuperClass();
-
+
while (superClass != null && superClass != ClassInfo.OBJECT) {
if (superClass.isMixin) {
return true;
@@ -949,12 +951,12 @@ public class ClassInfo extends TreeInfo {
return false;
}
-
+
/**
* Find out whether this (non-mixin) class has a mixin targetting
* any of its superclasses. This method always returns false for
* mixin classes.
- *
+ *
* @return true if and only if one or more classes in this class's hierarchy
* are targetted by a mixin
*/
@@ -962,22 +964,22 @@ public class ClassInfo extends TreeInfo {
if (this.isMixin) {
return false;
}
-
+
ClassInfo superClass = this.getSuperClass();
-
+
while (superClass != null && superClass != ClassInfo.OBJECT) {
if (superClass.mixins.size() > 0) {
return true;
}
superClass = superClass.getSuperClass();
}
-
+
return false;
}
/**
* Finds the specified private or protected method in this class's hierarchy
- *
+ *
* @param method Method to search for
* @param includeThisClass True to return this class if the method exists
* here, or false to search only superclasses
@@ -989,7 +991,7 @@ public class ClassInfo extends TreeInfo {
/**
* Finds the specified private or protected method in this class's hierarchy
- *
+ *
* @param method Method to search for
* @param includeThisClass True to return this class if the method exists
* here, or false to search only superclasses
@@ -999,10 +1001,10 @@ public class ClassInfo extends TreeInfo {
public Method findMethodInHierarchy(MethodNode method, boolean includeThisClass, int flags) {
return this.findMethodInHierarchy(method.name, method.desc, includeThisClass, Traversal.NONE, flags);
}
-
+
/**
* Finds the specified public or protected method in this class's hierarchy
- *
+ *
* @param method Method to search for
* @param includeThisClass True to return this class if the method exists
* here, or false to search only superclasses
@@ -1011,10 +1013,10 @@ public class ClassInfo extends TreeInfo {
public Method findMethodInHierarchy(MethodInsnNode method, boolean includeThisClass) {
return this.findMethodInHierarchy(method.name, method.desc, includeThisClass, Traversal.NONE);
}
-
+
/**
* Finds the specified public or protected method in this class's hierarchy
- *
+ *
* @param method Method to search for
* @param includeThisClass True to return this class if the method exists
* here, or false to search only superclasses
@@ -1024,10 +1026,10 @@ public class ClassInfo extends TreeInfo {
public Method findMethodInHierarchy(MethodInsnNode method, boolean includeThisClass, int flags) {
return this.findMethodInHierarchy(method.name, method.desc, includeThisClass, Traversal.NONE, flags);
}
-
+
/**
* Finds the specified public or protected method in this class's hierarchy
- *
+ *
* @param name Method name to search for
* @param desc Method descriptor
* @param includeThisClass True to return this class if the method exists
@@ -1040,7 +1042,7 @@ public class ClassInfo extends TreeInfo {
/**
* Finds the specified public or protected method in this class's hierarchy
- *
+ *
* @param name Method name to search for
* @param desc Method descriptor
* @param includeThisClass True to return this class if the method exists
@@ -1051,10 +1053,10 @@ public class ClassInfo extends TreeInfo {
public Method findMethodInHierarchy(String name, String desc, boolean includeThisClass, Traversal traversal) {
return this.findMethodInHierarchy(name, desc, includeThisClass, traversal, 0);
}
-
+
/**
* Finds the specified public or protected method in this class's hierarchy
- *
+ *
* @param name Method name to search for
* @param desc Method descriptor
* @param includeThisClass True to return this class if the method exists
@@ -1066,10 +1068,10 @@ public class ClassInfo extends TreeInfo {
public Method findMethodInHierarchy(String name, String desc, boolean includeThisClass, Traversal traversal, int flags) {
return this.findInHierarchy(name, desc, includeThisClass, traversal, flags, Type.METHOD);
}
-
+
/**
* Finds the specified private or protected field in this class's hierarchy
- *
+ *
* @param field Field to search for
* @param includeThisClass True to return this class if the field exists
* here, or false to search only superclasses
@@ -1078,10 +1080,10 @@ public class ClassInfo extends TreeInfo {
public Field findFieldInHierarchy(FieldNode field, boolean includeThisClass) {
return this.findFieldInHierarchy(field.name, field.desc, includeThisClass, Traversal.NONE);
}
-
+
/**
* Finds the specified private or protected field in this class's hierarchy
- *
+ *
* @param field Field to search for
* @param includeThisClass True to return this class if the field exists
* here, or false to search only superclasses
@@ -1091,10 +1093,10 @@ public class ClassInfo extends TreeInfo {
public Field findFieldInHierarchy(FieldNode field, boolean includeThisClass, int flags) {
return this.findFieldInHierarchy(field.name, field.desc, includeThisClass, Traversal.NONE, flags);
}
-
+
/**
* Finds the specified public or protected field in this class's hierarchy
- *
+ *
* @param field Field to search for
* @param includeThisClass True to return this class if the field exists
* here, or false to search only superclasses
@@ -1103,10 +1105,10 @@ public class ClassInfo extends TreeInfo {
public Field findFieldInHierarchy(FieldInsnNode field, boolean includeThisClass) {
return this.findFieldInHierarchy(field.name, field.desc, includeThisClass, Traversal.NONE);
}
-
+
/**
* Finds the specified public or protected field in this class's hierarchy
- *
+ *
* @param field Field to search for
* @param includeThisClass True to return this class if the field exists
* here, or false to search only superclasses
@@ -1116,10 +1118,10 @@ public class ClassInfo extends TreeInfo {
public Field findFieldInHierarchy(FieldInsnNode field, boolean includeThisClass, int flags) {
return this.findFieldInHierarchy(field.name, field.desc, includeThisClass, Traversal.NONE, flags);
}
-
+
/**
* Finds the specified public or protected field in this class's hierarchy
- *
+ *
* @param name Field name to search for
* @param desc Field descriptor
* @param includeThisClass True to return this class if the field exists
@@ -1132,7 +1134,7 @@ public class ClassInfo extends TreeInfo {
/**
* Finds the specified public or protected field in this class's hierarchy
- *
+ *
* @param name Field name to search for
* @param desc Field descriptor
* @param includeThisClass True to return this class if the field exists
@@ -1143,10 +1145,10 @@ public class ClassInfo extends TreeInfo {
public Field findFieldInHierarchy(String name, String desc, boolean includeThisClass, Traversal traversal) {
return this.findFieldInHierarchy(name, desc, includeThisClass, traversal, 0);
}
-
+
/**
* Finds the specified public or protected field in this class's hierarchy
- *
+ *
* @param name Field name to search for
* @param desc Field descriptor
* @param includeThisClass True to return this class if the field exists
@@ -1158,11 +1160,11 @@ public class ClassInfo extends TreeInfo {
public Field findFieldInHierarchy(String name, String desc, boolean includeThisClass, Traversal traversal, int flags) {
return this.findInHierarchy(name, desc, includeThisClass, traversal, flags, Type.FIELD);
}
-
+
/**
* Finds a public or protected member in the hierarchy of this class which
- * matches the supplied details
- *
+ * matches the supplied details
+ *
* @param name Member name to search
* @param desc Member descriptor
* @param includeThisClass True to return this class if the field exists
@@ -1178,17 +1180,17 @@ public class ClassInfo extends TreeInfo {
if (member != null) {
return member;
}
-
+
if (traversal.canTraverse()) {
for (MixinInfo mixin : this.mixins) {
M mixinMember = mixin.getClassInfo().findMember(name, desc, flags, type);
if (mixinMember != null) {
return this.cloneMember(mixinMember);
}
- }
+ }
}
}
-
+
ClassInfo superClassInfo = this.getSuperClass();
if (superClassInfo != null) {
for (ClassInfo superTarget : superClassInfo.getTargets()) {
@@ -1198,16 +1200,16 @@ public class ClassInfo extends TreeInfo {
}
}
}
-
+
return null;
}
-
+
/**
* Effectively a clone method for member, placed here so that the enclosing
* instance for the inner class is this class and not the enclosing instance
- * of the existing class. Basically creates a cloned member with this
+ * of the existing class. Basically creates a cloned member with this
* ClassInfo as its parent.
- *
+ *
* @param member
* @return
*/
@@ -1216,23 +1218,23 @@ public class ClassInfo extends TreeInfo {
if (member instanceof Method) {
return (M)new Method(member);
}
-
+
return (M)new Field(member);
}
-
+
/**
* Finds the specified public or protected method in this class
- *
+ *
* @param method Method to search for
* @return the method object or null if the method could not be resolved
*/
public Method findMethod(MethodNode method) {
return this.findMethod(method.name, method.desc, method.access);
}
-
+
/**
* Finds the specified public or protected method in this class
- *
+ *
* @param method Method to search for
* @param flags search flags
* @return the method object or null if the method could not be resolved
@@ -1240,20 +1242,20 @@ public class ClassInfo extends TreeInfo {
public Method findMethod(MethodNode method, int flags) {
return this.findMethod(method.name, method.desc, flags);
}
-
+
/**
* Finds the specified public or protected method in this class
- *
+ *
* @param method Method to search for
* @return the method object or null if the method could not be resolved
*/
public Method findMethod(MethodInsnNode method) {
return this.findMethod(method.name, method.desc, 0);
}
-
+
/**
* Finds the specified public or protected method in this class
- *
+ *
* @param method Method to search for
* @param flags search flags
* @return the method object or null if the method could not be resolved
@@ -1261,10 +1263,10 @@ public class ClassInfo extends TreeInfo {
public Method findMethod(MethodInsnNode method, int flags) {
return this.findMethod(method.name, method.desc, flags);
}
-
+
/**
* Finds the specified public or protected method in this class
- *
+ *
* @param name Method name to search for
* @param desc Method signature to search for
* @param flags search flags
@@ -1273,20 +1275,20 @@ public class ClassInfo extends TreeInfo {
public Method findMethod(String name, String desc, int flags) {
return this.findMember(name, desc, flags, Type.METHOD);
}
-
+
/**
* Finds the specified field in this class
- *
+ *
* @param field Field to search for
* @return the field object or null if the field could not be resolved
*/
public Field findField(FieldNode field) {
return this.findField(field.name, field.desc, field.access);
}
-
+
/**
* Finds the specified public or protected method in this class
- *
+ *
* @param field Field to search for
* @param flags search flags
* @return the field object or null if the field could not be resolved
@@ -1294,10 +1296,10 @@ public class ClassInfo extends TreeInfo {
public Field findField(FieldInsnNode field, int flags) {
return this.findField(field.name, field.desc, flags);
}
-
+
/**
* Finds the specified field in this class
- *
+ *
* @param name Field name to search for
* @param desc Field signature to search for
* @param flags search flags
@@ -1309,7 +1311,7 @@ public class ClassInfo extends TreeInfo {
/**
* Finds the specified member in this class
- *
+ *
* @param name Field name to search for
* @param desc Field signature to search for
* @param flags search flags
@@ -1319,13 +1321,13 @@ public class ClassInfo extends TreeInfo {
private M findMember(String name, String desc, int flags, Type memberType) {
@SuppressWarnings("unchecked")
Set members = (Set)(memberType == Type.METHOD ? this.methods : this.fields);
-
+
for (M member : members) {
if (member.equals(name, desc) && member.matchesFlags(flags)) {
return member;
}
}
-
+
return null;
}
@@ -1339,7 +1341,7 @@ public class ClassInfo extends TreeInfo {
}
return ((ClassInfo)other).name.equals(this.name);
}
-
+
/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
@@ -1353,7 +1355,7 @@ public class ClassInfo extends TreeInfo {
* the class was already defined, then the original ClassInfo is returned
* from the internal cache. Otherwise a new ClassInfo is created and
* returned.
- *
+ *
* @param classNode
* @return
*/
@@ -1363,21 +1365,21 @@ public class ClassInfo extends TreeInfo {
info = new ClassInfo(classNode);
ClassInfo.cache.put(classNode.name, info);
}
-
+
return info;
}
/**
* Return a ClassInfo for the specified class name, fetches the ClassInfo
* from the cache where possible
- *
+ *
* @param className Binary name of the class to look up
* @return ClassInfo for the specified class name or null if the specified
* name cannot be resolved for some reason
*/
public static ClassInfo forName(String className) {
className = className.replace('.', '/');
-
+
ClassInfo info = ClassInfo.cache.get(className);
if (info == null) {
try {
@@ -1386,19 +1388,19 @@ public class ClassInfo extends TreeInfo {
} catch (Exception ex) {
ex.printStackTrace();
}
-
+
// Put null in the cache if load failed
ClassInfo.cache.put(className, info);
ClassInfo.logger.trace("Added class metadata for {} to metadata cache", className);
}
-
+
return info;
}
/**
* Return a ClassInfo for the specified class type, fetches the ClassInfo
* from the cache where possible and generates the class meta if not.
- *
+ *
* @param type Type to look up
* @return ClassInfo for the supplied type or null if the supplied type
* cannot be found or is a primitive type
diff --git a/src/main/java/org/spongepowered/asm/mixin/transformer/MixinTransformerModuleInterfaceChecker.java b/src/main/java/org/spongepowered/asm/mixin/transformer/MixinTransformerModuleInterfaceChecker.java
index 3a0f6e17..4643f620 100644
--- a/src/main/java/org/spongepowered/asm/mixin/transformer/MixinTransformerModuleInterfaceChecker.java
+++ b/src/main/java/org/spongepowered/asm/mixin/transformer/MixinTransformerModuleInterfaceChecker.java
@@ -52,35 +52,35 @@ import com.google.common.io.Files;
* implemented and generates reports to the console and to files on disk
*/
public class MixinTransformerModuleInterfaceChecker implements IMixinTransformerModule {
-
+
/**
* CSV Report file
*/
private final File csv;
-
+
/**
* Text Report file
*/
private final File report;
-
+
/**
* Methods from interfaces that are already in the class before mixins are
* applied.
*/
private final Multimap interfaceMethods = HashMultimap.create();
-
+
public MixinTransformerModuleInterfaceChecker() {
File debugOutputFolder = new File(MixinTransformer.DEBUG_OUTPUT, "audit");
debugOutputFolder.mkdirs();
this.csv = new File(debugOutputFolder, "mixin_implementation_report.csv");
this.report = new File(debugOutputFolder, "mixin_implementation_report.txt");
-
+
try {
Files.write("Class,Method,Signature,Interface\n", this.csv, Charsets.ISO_8859_1);
} catch (IOException ex) {
// well this sucks
}
-
+
try {
String dateTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
Files.write("Mixin Implementation Report generated on " + dateTime + "\n", this.report, Charsets.ISO_8859_1);
@@ -97,7 +97,7 @@ public class MixinTransformerModuleInterfaceChecker implements IMixinTransformer
@Override
public void preApply(String transformedName, ClassNode targetClass, SortedSet mixins) {
ClassInfo targetClassInfo = ClassInfo.forName(targetClass.name);
- for (Method m : targetClassInfo.getInterfaceMethods()) {
+ for (Method m : targetClassInfo.getInterfaceMethods(false)) {
this.interfaceMethods.put(targetClassInfo, m);
}
}
@@ -114,26 +114,26 @@ public class MixinTransformerModuleInterfaceChecker implements IMixinTransformer
String className = targetClassInfo.getName().replace('/', '.');
int missingMethodCount = 0;
PrettyPrinter printer = new PrettyPrinter();
-
+
printer.add("Class: %s", className).hr();
printer.add("%-32s %-47s %s", "Return Type", "Missing Method", "From Interface").hr();
- Set interfaceMethods = targetClassInfo.getInterfaceMethods();
- Set implementedMethods = new HashSet(targetClassInfo.getSuperClass().getInterfaceMethods());
+ Set interfaceMethods = targetClassInfo.getInterfaceMethods(true);
+ Set implementedMethods = new HashSet(targetClassInfo.getSuperClass().getInterfaceMethods(true));
implementedMethods.addAll(this.interfaceMethods.removeAll(targetClassInfo));
-
+
for (Method method : interfaceMethods) {
Method found = targetClassInfo.findMethodInHierarchy(method.getName(), method.getDesc(), true, Traversal.ALL);
if (found != null) {
continue;
}
-
+
// Don't blame the subclass for not implementing methods that it does not need to implement.
if (implementedMethods.contains(method)) {
continue;
}
-
+
if (missingMethodCount > 0) {
printer.add();
}
@@ -143,7 +143,7 @@ public class MixinTransformerModuleInterfaceChecker implements IMixinTransformer
missingMethodCount++;
printer.add("%-32s%s", signaturePrinter.getReturnType(), signaturePrinter);
printer.add("%-80s %s", "", iface);
-
+
this.appendToCSVReport(className, method, iface);
}
@@ -164,7 +164,7 @@ public class MixinTransformerModuleInterfaceChecker implements IMixinTransformer
private void appendToTextReport(PrettyPrinter printer) {
FileOutputStream fos = null;
-
+
try {
fos = new FileOutputStream(this.report, true);
PrintStream stream = new PrintStream(fos);