From e743c1450fc57cf1ed755f0cbc463dd54650a729 Mon Sep 17 00:00:00 2001 From: Mumfrey Date: Tue, 19 May 2015 13:36:17 +0100 Subject: [PATCH] Fix issue with LVT generation involving arrays, version bump to 0.4.2 --- gradle.properties | 4 +- .../asm/launch/MixinBootstrap.java | 2 +- .../asm/mixin/transformer/ClassInfo.java | 17 +++++++ .../asm/mixin/transformer/MixinVerifier.java | 45 ++++++++----------- 4 files changed, 39 insertions(+), 29 deletions(-) diff --git a/gradle.properties b/gradle.properties index acb7a703..bcb300d4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,5 +4,5 @@ packaging=jar url=http://spongepowered.org description=Mixin organization=SpongePowered -buildVersion=0.4.1 -buildType=RELEASE +buildVersion=0.4.2 +buildType=SNAPSHOT diff --git a/src/main/java/org/spongepowered/asm/launch/MixinBootstrap.java b/src/main/java/org/spongepowered/asm/launch/MixinBootstrap.java index 24b64f43..db84c35c 100644 --- a/src/main/java/org/spongepowered/asm/launch/MixinBootstrap.java +++ b/src/main/java/org/spongepowered/asm/launch/MixinBootstrap.java @@ -60,7 +60,7 @@ public abstract class MixinBootstrap { /** * Subsystem version */ - public static final String VERSION = "0.4.1"; + public static final String VERSION = "0.4.2"; /** * Blackboard key where the subsystem version will be stored to indicate 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 87c3d656..ff0b28f4 100644 --- a/src/main/java/org/spongepowered/asm/mixin/transformer/ClassInfo.java +++ b/src/main/java/org/spongepowered/asm/mixin/transformer/ClassInfo.java @@ -1365,4 +1365,21 @@ public class ClassInfo extends TreeInfo { 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 + */ + public static ClassInfo forType(org.spongepowered.asm.lib.Type type) { + if (type.getSort() == org.spongepowered.asm.lib.Type.ARRAY) { + return ClassInfo.forType(type.getElementType()); + } else if (type.getSort() < org.spongepowered.asm.lib.Type.ARRAY) { + return null; + } + return ClassInfo.forName(type.getClassName().replace('.', '/')); + } } diff --git a/src/main/java/org/spongepowered/asm/mixin/transformer/MixinVerifier.java b/src/main/java/org/spongepowered/asm/mixin/transformer/MixinVerifier.java index dbb593d5..7396405c 100644 --- a/src/main/java/org/spongepowered/asm/mixin/transformer/MixinVerifier.java +++ b/src/main/java/org/spongepowered/asm/mixin/transformer/MixinVerifier.java @@ -49,61 +49,54 @@ public class MixinVerifier extends SimpleVerifier { } @Override - protected boolean isInterface(final Type t) { - if (this.currentClass != null && t.equals(this.currentClass)) { + protected boolean isInterface(final Type type) { + if (this.currentClass != null && type.equals(this.currentClass)) { return this.isInterface; } - return this.getClassInfo(t).isInterface(); + return ClassInfo.forType(type).isInterface(); } @Override - protected Type getSuperClass(final Type t) { - if (this.currentClass != null && t.equals(this.currentClass)) { + protected Type getSuperClass(final Type type) { + if (this.currentClass != null && type.equals(this.currentClass)) { return this.currentSuperClass; } - ClassInfo c = this.getClassInfo(t).getSuperClass(); + ClassInfo c = ClassInfo.forType(type).getSuperClass(); return c == null ? null : Type.getType("L" + c.getName() + ";"); } @Override - protected boolean isAssignableFrom(final Type t, final Type u) { - if (t.equals(u)) { + protected boolean isAssignableFrom(final Type type, final Type other) { + if (type.equals(other)) { return true; } - if (this.currentClass != null && t.equals(this.currentClass)) { - if (this.getSuperClass(u) == null) { + if (this.currentClass != null && type.equals(this.currentClass)) { + if (this.getSuperClass(other) == null) { return false; } if (this.isInterface) { - return u.getSort() == Type.OBJECT || u.getSort() == Type.ARRAY; + return other.getSort() == Type.OBJECT || other.getSort() == Type.ARRAY; } - return this.isAssignableFrom(t, this.getSuperClass(u)); + return this.isAssignableFrom(type, this.getSuperClass(other)); } - if (this.currentClass != null && u.equals(this.currentClass)) { - if (this.isAssignableFrom(t, this.currentSuperClass)) { + if (this.currentClass != null && other.equals(this.currentClass)) { + if (this.isAssignableFrom(type, this.currentSuperClass)) { return true; } if (this.currentClassInterfaces != null) { for (int i = 0; i < this.currentClassInterfaces.size(); ++i) { Type v = this.currentClassInterfaces.get(i); - if (this.isAssignableFrom(t, v)) { + if (this.isAssignableFrom(type, v)) { return true; } } } return false; } - ClassInfo tc = this.getClassInfo(t); - if (tc.isInterface()) { - tc = ClassInfo.forName("java/lang/Object"); + ClassInfo typeInfo = ClassInfo.forType(type); + if (typeInfo.isInterface()) { + typeInfo = ClassInfo.forName("java/lang/Object"); } - return this.getClassInfo(u).hasSuperClass(tc); - } - - protected ClassInfo getClassInfo(final Type t) { - if (t.getSort() == Type.ARRAY) { - return ClassInfo.forName(t.getDescriptor().replace('/', '.')); - } - return ClassInfo.forName(t.getClassName().replace('.', '/')); + return ClassInfo.forType(other).hasSuperClass(typeInfo); } }