mirror of
https://github.com/LegacyModdingMC/UniMix.git
synced 2026-11-22 01:32:12 +00:00
Merge remote-tracking branch 'FabricMC/main'
This commit is contained in:
commit
e1f361a6ea
23 files changed
+243
-167
No files matched your search
@@ -176,7 +176,7 @@ class AnnotatedMixin implements IMixinContext, IAnnotatedElement {
|
||||
this.mappings = this.obf.createMappingConsumer();
|
||||
this.messager = ap;
|
||||
this.mixin = type;
|
||||
this.handle = new TypeHandle(type);
|
||||
this.handle = new TypeHandle(type, ap.getTypeProvider());
|
||||
this.methods = new ArrayList<MethodHandle>(this.handle.getMethods());
|
||||
this.virtual = this.handle.getAnnotation(Pseudo.class).exists();
|
||||
this.annotation = this.handle.getAnnotation(Mixin.class);
|
||||
|
||||
+5
-15
@@ -46,8 +46,6 @@ import org.spongepowered.tools.obfuscation.mirror.FieldHandle;
|
||||
import org.spongepowered.tools.obfuscation.mirror.MethodHandle;
|
||||
import org.spongepowered.tools.obfuscation.mirror.TypeHandle;
|
||||
import org.spongepowered.tools.obfuscation.mirror.TypeUtils;
|
||||
import org.spongepowered.tools.obfuscation.mirror.TypeUtils.Equivalency;
|
||||
import org.spongepowered.tools.obfuscation.mirror.TypeUtils.EquivalencyResult;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
|
||||
@@ -304,19 +302,11 @@ class AnnotatedMixinElementHandlerAccessor extends AnnotatedMixinElementHandler
|
||||
}
|
||||
|
||||
private void registerFactoryForTarget(AnnotatedElementInvoker elem, TypeHandle target) {
|
||||
EquivalencyResult equivalency = TypeUtils.isEquivalentType(this.ap.getProcessingEnvironment(), elem.getReturnType(), target.getTypeMirror());
|
||||
if (equivalency.type != Equivalency.EQUIVALENT) {
|
||||
if (equivalency.type == Equivalency.EQUIVALENT_BUT_RAW && equivalency.rawType == 1) {
|
||||
elem.printMessage(this.ap, MessageType.INVOKER_RAW_RETURN_TYPE, "Raw return type for Factory @Invoker", SuppressedBy.RAW_TYPES);
|
||||
} else if (equivalency.type == Equivalency.BOUNDS_MISMATCH) {
|
||||
elem.printMessage(this.ap, MessageType.FACTORY_INVOKER_GENERIC_ARGS, "Invalid Factory @Invoker return type, generic type args of "
|
||||
+ target.getTypeMirror() + " are incompatible with " + elem.getReturnType() + ". " + equivalency);
|
||||
return;
|
||||
} else {
|
||||
elem.printMessage(this.ap, MessageType.FACTORY_INVOKER_RETURN_TYPE, "Invalid Factory @Invoker return type, expected "
|
||||
+ target.getTypeMirror() + " but found " + elem.getReturnType());
|
||||
return;
|
||||
}
|
||||
String returnType = TypeUtils.getTypeName(elem.getReturnType());
|
||||
if (!returnType.equals(target.toString())) {
|
||||
elem.printMessage(this.ap, MessageType.FACTORY_INVOKER_RETURN_TYPE, "Invalid Factory @Invoker return type, expected "
|
||||
+ target + " but found " + returnType);
|
||||
return;
|
||||
}
|
||||
if (!elem.isStatic()) {
|
||||
elem.printMessage(this.ap, MessageType.FACTORY_INVOKER_NONSTATIC, "Factory @Invoker must be static");
|
||||
|
||||
+1
-1
@@ -77,7 +77,7 @@ class AnnotatedMixinElementHandlerSoftImplements extends AnnotatedMixinElementHa
|
||||
}
|
||||
|
||||
try {
|
||||
TypeHandle iface = new TypeHandle(interfaceAnnotation.<DeclaredType>getValue("iface"));
|
||||
TypeHandle iface = this.ap.getTypeProvider().getTypeHandle(interfaceAnnotation.<DeclaredType>getValue("iface"));
|
||||
String prefix = interfaceAnnotation.<String>getValue("prefix");
|
||||
this.processSoftImplements(remap, iface, prefix);
|
||||
} catch (Exception ex) {
|
||||
|
||||
@@ -73,6 +73,7 @@ import org.spongepowered.tools.obfuscation.mirror.TypeHandle;
|
||||
import org.spongepowered.tools.obfuscation.mirror.TypeHandleASM;
|
||||
import org.spongepowered.tools.obfuscation.mirror.TypeHandleSimulated;
|
||||
import org.spongepowered.tools.obfuscation.mirror.TypeReference;
|
||||
import org.spongepowered.tools.obfuscation.mirror.TypeUtils;
|
||||
import org.spongepowered.tools.obfuscation.struct.InjectorRemap;
|
||||
import org.spongepowered.tools.obfuscation.validation.ParentValidator;
|
||||
import org.spongepowered.tools.obfuscation.validation.TargetValidator;
|
||||
@@ -370,17 +371,13 @@ final class AnnotatedMixins implements IMixinAnnotationProcessor, ITokenProvider
|
||||
return this.mixins.get(mixinType);
|
||||
}
|
||||
|
||||
public Collection<TypeMirror> getMixinsTargeting(TypeMirror targetType) {
|
||||
return this.getMixinsTargeting((TypeElement)((DeclaredType)targetType).asElement());
|
||||
}
|
||||
|
||||
public Collection<TypeMirror> getMixinsTargeting(TypeElement targetType) {
|
||||
List<TypeMirror> minions = new ArrayList<TypeMirror>();
|
||||
public Collection<TypeHandle> getMixinsTargeting(TypeHandle targetType) {
|
||||
List<TypeHandle> minions = new ArrayList<TypeHandle>();
|
||||
|
||||
for (TypeReference mixin : this.targets.getMixinsTargeting(targetType)) {
|
||||
TypeHandle handle = mixin.getHandle(this.processingEnv);
|
||||
if (handle != null && handle.hasTypeMirror()) {
|
||||
minions.add(handle.getTypeMirror());
|
||||
TypeHandle handle = mixin.getHandle(this);
|
||||
if (handle != null) {
|
||||
minions.add(handle);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -688,34 +685,39 @@ final class AnnotatedMixins implements IMixinAnnotationProcessor, ITokenProvider
|
||||
name = name.replace('/', '.');
|
||||
|
||||
Elements elements = this.processingEnv.getElementUtils();
|
||||
PackageElement pkg = null;
|
||||
|
||||
int lastDotPos = name.lastIndexOf('.');
|
||||
if (lastDotPos > -1) {
|
||||
String pkgName = name.substring(0, lastDotPos);
|
||||
pkg = elements.getPackageElement(pkgName);
|
||||
}
|
||||
|
||||
if (pkg != null) {
|
||||
// ASM gives the most and most accurate information. Try that first.
|
||||
TypeHandle asmTypeHandle = TypeHandleASM.of(pkg, name.substring(lastDotPos + 1), this);
|
||||
if (asmTypeHandle != null) {
|
||||
return asmTypeHandle;
|
||||
}
|
||||
}
|
||||
|
||||
// ASM may be unable to resolve the class, for example if it's currently being compiled.
|
||||
// Mirror is our next best bet.
|
||||
TypeElement element = this.getTypeElement(name, elements);
|
||||
if (element != null) {
|
||||
try {
|
||||
return new TypeHandle(element);
|
||||
return new TypeHandle(element, this);
|
||||
} catch (NullPointerException ex) {
|
||||
// probably bad package
|
||||
}
|
||||
}
|
||||
|
||||
int lastDotPos = name.lastIndexOf('.');
|
||||
if (lastDotPos > -1) {
|
||||
String pkgName = name.substring(0, lastDotPos);
|
||||
PackageElement pkg = elements.getPackageElement(pkgName);
|
||||
if (pkg != null) {
|
||||
// If we can resolve the package but not the class, it's possible
|
||||
// we're dealing with a class that mirror can't access, such as
|
||||
// an anonymous class. The class might be available via the
|
||||
// classpath though, so let's attempt to read the class with ASM
|
||||
TypeHandle asmTypeHandle = TypeHandleASM.of(pkg, name.substring(lastDotPos + 1), this);
|
||||
if (asmTypeHandle != null) {
|
||||
return asmTypeHandle;
|
||||
}
|
||||
|
||||
// Couldn't resolve the class, so just return an imaginary handle
|
||||
return new TypeHandle(pkg, name);
|
||||
}
|
||||
if (pkg != null) {
|
||||
// Couldn't resolve the class, but could resolve the package, so just return an imaginary handle.
|
||||
return new TypeHandle(pkg, name, this);
|
||||
}
|
||||
|
||||
// Couldn't even resolve the package, all hope is lost.
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -728,11 +730,11 @@ final class AnnotatedMixins implements IMixinAnnotationProcessor, ITokenProvider
|
||||
if (type instanceof TypeHandle) {
|
||||
return (TypeHandle)type;
|
||||
} else if (type instanceof DeclaredType) {
|
||||
return new TypeHandle((DeclaredType)type);
|
||||
return this.getTypeHandle(TypeUtils.getInternalName((DeclaredType) type));
|
||||
} else if (type instanceof Type) {
|
||||
return this.getTypeHandle(((Type)type).getClassName());
|
||||
} else if (type instanceof TypeElement) {
|
||||
return new TypeHandle((DeclaredType)((TypeElement)type).asType());
|
||||
return this.getTypeHandle(TypeUtils.getInternalName((TypeElement) type));
|
||||
} else if (type instanceof String) {
|
||||
return this.getTypeHandle(type.toString());
|
||||
}
|
||||
@@ -810,11 +812,11 @@ final class AnnotatedMixins implements IMixinAnnotationProcessor, ITokenProvider
|
||||
String pkg = name.substring(0, lastDotPos);
|
||||
PackageElement packageElement = this.processingEnv.getElementUtils().getPackageElement(pkg);
|
||||
if (packageElement != null) {
|
||||
return new TypeHandleSimulated(packageElement, name, simulatedTarget);
|
||||
return new TypeHandleSimulated(packageElement, name, simulatedTarget, this);
|
||||
}
|
||||
}
|
||||
|
||||
return new TypeHandleSimulated(name, simulatedTarget);
|
||||
return new TypeHandleSimulated(name, simulatedTarget, this);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
||||
@@ -28,13 +28,13 @@ import java.util.Collection;
|
||||
|
||||
import javax.annotation.processing.ProcessingEnvironment;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
import javax.lang.model.type.TypeMirror;
|
||||
|
||||
import org.spongepowered.asm.util.asm.IAnnotationHandle;
|
||||
import org.spongepowered.tools.obfuscation.interfaces.IMessagerSuppressible;
|
||||
import org.spongepowered.tools.obfuscation.interfaces.IMixinAnnotationProcessor;
|
||||
import org.spongepowered.tools.obfuscation.interfaces.IMixinValidator;
|
||||
import org.spongepowered.tools.obfuscation.interfaces.IOptionProvider;
|
||||
import org.spongepowered.tools.obfuscation.interfaces.ITypeHandleProvider;
|
||||
import org.spongepowered.tools.obfuscation.mirror.TypeHandle;
|
||||
|
||||
/**
|
||||
@@ -57,7 +57,12 @@ public abstract class MixinValidator implements IMixinValidator {
|
||||
* Option provider
|
||||
*/
|
||||
protected final IOptionProvider options;
|
||||
|
||||
|
||||
/**
|
||||
* Type handle provider
|
||||
*/
|
||||
protected final ITypeHandleProvider typeHandleProvider;
|
||||
|
||||
/**
|
||||
* Pass to run this validator in
|
||||
*/
|
||||
@@ -73,6 +78,7 @@ public abstract class MixinValidator implements IMixinValidator {
|
||||
this.processingEnv = ap.getProcessingEnvironment();
|
||||
this.messager = ap;
|
||||
this.options = ap;
|
||||
this.typeHandleProvider = ap.getTypeProvider();
|
||||
this.pass = pass;
|
||||
}
|
||||
|
||||
@@ -94,7 +100,7 @@ public abstract class MixinValidator implements IMixinValidator {
|
||||
|
||||
protected abstract boolean validate(TypeElement mixin, IAnnotationHandle annotation, Collection<TypeHandle> targets);
|
||||
|
||||
protected final Collection<TypeMirror> getMixinsTargeting(TypeMirror targetType) {
|
||||
protected final Collection<TypeHandle> getMixinsTargeting(TypeHandle targetType) {
|
||||
return AnnotatedMixins.getMixinsForEnvironment(this.processingEnv).getMixinsTargeting(targetType);
|
||||
}
|
||||
}
|
||||
@@ -196,13 +196,13 @@ public abstract class ObfuscationEnvironment implements IObfuscationEnvironment
|
||||
}
|
||||
|
||||
// See if we can get the superclass from the reference
|
||||
TypeMirror superClass = type.getElement().getSuperclass();
|
||||
if (superClass.getKind() != TypeKind.DECLARED) {
|
||||
TypeHandle superClass = type.getSuperclass();
|
||||
if (superClass == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Well we found it, let's inflect the class name and recurse the search
|
||||
String superClassName = ((TypeElement)((DeclaredType)superClass).asElement()).getQualifiedName().toString();
|
||||
String superClassName = superClass.getSimpleName();
|
||||
return this.getObfMethod(method.move(superClassName.replace('.', '/')));
|
||||
}
|
||||
|
||||
|
||||
@@ -135,16 +135,6 @@ public final class TargetMap extends HashMap<TypeReference, Set<TypeReference>>
|
||||
Set<TypeReference> mixins = this.getMixinsFor(target);
|
||||
mixins.add(mixin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get mixin classes which target the specified class
|
||||
*
|
||||
* @param target Target class
|
||||
* @return Collection of mixins registered as targetting the specified class
|
||||
*/
|
||||
Collection<TypeReference> getMixinsTargeting(TypeElement target) {
|
||||
return this.getMixinsTargeting(new TypeHandle(target));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get mixin classes which target the specified class
|
||||
|
||||
@@ -44,6 +44,7 @@ import org.spongepowered.asm.mixin.injection.selectors.ITargetSelectorByName;
|
||||
import org.spongepowered.asm.obfuscation.mapping.common.MappingMethod;
|
||||
import org.spongepowered.asm.util.Bytecode;
|
||||
import org.spongepowered.asm.util.asm.IAnnotationHandle;
|
||||
import org.spongepowered.tools.obfuscation.interfaces.ITypeHandleProvider;
|
||||
import org.spongepowered.tools.obfuscation.mirror.mapping.MappingMethodResolvable;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@@ -71,6 +72,12 @@ public class TypeHandle {
|
||||
* Actual type element, this is null for inaccessible classes
|
||||
*/
|
||||
private final TypeElement element;
|
||||
|
||||
/**
|
||||
* Type handle provider, we need this since we have to resolve type handles
|
||||
* for related classes (eg. superclass) without using mirror
|
||||
*/
|
||||
protected final ITypeHandleProvider typeProvider;
|
||||
|
||||
/**
|
||||
* Reference to this handle, for serialisation
|
||||
@@ -84,10 +91,11 @@ public class TypeHandle {
|
||||
* @param pkg Package
|
||||
* @param name FQ class name
|
||||
*/
|
||||
public TypeHandle(PackageElement pkg, String name) {
|
||||
public TypeHandle(PackageElement pkg, String name, ITypeHandleProvider typeProvider) {
|
||||
this.name = name.replace('.', '/');
|
||||
this.pkg = pkg;
|
||||
this.element = null;
|
||||
this.typeProvider = typeProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -95,10 +103,11 @@ public class TypeHandle {
|
||||
*
|
||||
* @param element ze element
|
||||
*/
|
||||
public TypeHandle(TypeElement element) {
|
||||
public TypeHandle(TypeElement element, ITypeHandleProvider typeProvider) {
|
||||
this.pkg = TypeUtils.getPackage(element);
|
||||
this.name = TypeUtils.getInternalName(element);
|
||||
this.element = element;
|
||||
this.typeProvider = typeProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,8 +115,8 @@ public class TypeHandle {
|
||||
*
|
||||
* @param type type
|
||||
*/
|
||||
public TypeHandle(DeclaredType type) {
|
||||
this((TypeElement)type.asElement());
|
||||
public TypeHandle(DeclaredType type, ITypeHandleProvider typeProvider) {
|
||||
this((TypeElement)type.asElement(), typeProvider);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -215,7 +224,7 @@ public class TypeHandle {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new TypeHandle((DeclaredType)superClass);
|
||||
return typeProvider.getTypeHandle(superClass);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -228,7 +237,7 @@ public class TypeHandle {
|
||||
|
||||
Builder<TypeHandle> list = ImmutableList.<TypeHandle>builder();
|
||||
for (TypeMirror iface : this.getTargetElement().getInterfaces()) {
|
||||
list.add(new TypeHandle((DeclaredType)iface));
|
||||
list.add(typeProvider.getTypeHandle(iface));
|
||||
}
|
||||
return list.build();
|
||||
}
|
||||
@@ -275,6 +284,31 @@ public class TypeHandle {
|
||||
public boolean isSimulated() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets whether this handle definitely does not represent an interface
|
||||
*/
|
||||
public boolean isNotInterface() {
|
||||
TypeElement target = this.getTargetElement();
|
||||
return target != null && !target.getKind().isInterface();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets whether this handle is a supertype of the other handle
|
||||
*/
|
||||
public boolean isSuperTypeOf(TypeHandle other) {
|
||||
List<TypeHandle> superTypes = new ArrayList<>();
|
||||
if (other.getSuperclass() != null) {
|
||||
superTypes.add(other.getSuperclass());
|
||||
}
|
||||
superTypes.addAll(other.getInterfaces());
|
||||
for (TypeHandle superType : superTypes) {
|
||||
if (this.name.equals(superType.name) || this.isSuperTypeOf(superType)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the TypeReference for this type, used for serialisation
|
||||
|
||||
@@ -76,12 +76,6 @@ public class TypeHandleASM extends TypeHandle {
|
||||
* ClassNode used for accessing information when not accessible via mirror
|
||||
*/
|
||||
private final ClassNode classNode;
|
||||
|
||||
/**
|
||||
* Type handle provider, we need this since we have to resolve type handles
|
||||
* for related classes (eg. superclass) without using mirror
|
||||
*/
|
||||
private final ITypeHandleProvider typeProvider;
|
||||
|
||||
/**
|
||||
* Ctor for imaginary elements, require the enclosing package and the FQ
|
||||
@@ -91,9 +85,8 @@ public class TypeHandleASM extends TypeHandle {
|
||||
* @param name FQ class name
|
||||
*/
|
||||
protected TypeHandleASM(PackageElement pkg, String name, ClassNode classNode, ITypeHandleProvider typeProvider) {
|
||||
super(pkg, name);
|
||||
super(pkg, name, typeProvider);
|
||||
this.classNode = classNode;
|
||||
this.typeProvider = typeProvider;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -146,8 +139,10 @@ public class TypeHandleASM extends TypeHandle {
|
||||
*/
|
||||
@Override
|
||||
public TypeHandle getSuperclass() {
|
||||
TypeHandle superClass = this.typeProvider.getTypeHandle(this.classNode.superName);
|
||||
return superClass;
|
||||
if (this.classNode.superName == null) {
|
||||
return null;
|
||||
}
|
||||
return this.typeProvider.getTypeHandle(this.classNode.superName);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -196,6 +191,14 @@ public class TypeHandleASM extends TypeHandle {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.spongepowered.tools.obfuscation.mirror.TypeHandle#isInterface()
|
||||
*/
|
||||
@Override
|
||||
public boolean isNotInterface() {
|
||||
return (this.classNode.access & Opcodes.ACC_INTERFACE) == 0;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.spongepowered.tools.obfuscation.mirror.TypeHandle#findDescriptor
|
||||
* (org.spongepowered.asm.mixin.injection.selectors.ITargetSelectorByName)
|
||||
@@ -272,7 +275,11 @@ public class TypeHandleASM extends TypeHandle {
|
||||
InputStream is = null;
|
||||
try {
|
||||
Filer filer = ap.getProcessingEnvironment().getFiler();
|
||||
is = filer.getResource(StandardLocation.CLASS_PATH, pkg.getQualifiedName(), name + ".class").openInputStream();
|
||||
try {
|
||||
is = filer.getResource(StandardLocation.CLASS_PATH, pkg.getQualifiedName(), name + ".class").openInputStream();
|
||||
} catch (FileNotFoundException ignored) {
|
||||
is = filer.getResource(StandardLocation.PLATFORM_CLASS_PATH, pkg.getQualifiedName(), name + ".class").openInputStream();
|
||||
}
|
||||
ClassNode classNode = new ClassNode();
|
||||
new ClassReader(is).accept(classNode, 0);
|
||||
TypeHandleASM typeHandle = new TypeHandleASM(pkg, fqName, classNode, ap.getTypeProvider());
|
||||
|
||||
@@ -35,6 +35,7 @@ import javax.lang.model.type.TypeMirror;
|
||||
import org.spongepowered.asm.mixin.injection.selectors.ITargetSelectorByName;
|
||||
import org.spongepowered.asm.obfuscation.mapping.common.MappingMethod;
|
||||
import org.spongepowered.asm.util.SignaturePrinter;
|
||||
import org.spongepowered.tools.obfuscation.interfaces.ITypeHandleProvider;
|
||||
|
||||
/**
|
||||
* A simulated type handle, used with virtual (pseudo) mixins. For obfuscation
|
||||
@@ -48,12 +49,12 @@ public class TypeHandleSimulated extends TypeHandle {
|
||||
|
||||
private final TypeElement simulatedType;
|
||||
|
||||
public TypeHandleSimulated(String name, TypeMirror type) {
|
||||
this(TypeUtils.getPackage(type), name, type);
|
||||
public TypeHandleSimulated(String name, TypeMirror type, ITypeHandleProvider typeProvider) {
|
||||
this(TypeUtils.getPackage(type), name, type, typeProvider);
|
||||
}
|
||||
|
||||
public TypeHandleSimulated(PackageElement pkg, String name, TypeMirror type) {
|
||||
super(pkg, name);
|
||||
public TypeHandleSimulated(PackageElement pkg, String name, TypeMirror type, ITypeHandleProvider typeProvider) {
|
||||
super(pkg, name, typeProvider);
|
||||
this.simulatedType = (TypeElement)((DeclaredType)type).asElement();
|
||||
}
|
||||
|
||||
@@ -152,14 +153,14 @@ public class TypeHandleSimulated extends TypeHandle {
|
||||
String rawSignature = TypeUtils.stripGenerics(signature);
|
||||
|
||||
// Try to locate a member anywhere in the hierarchy which matches
|
||||
MethodHandle method = TypeHandleSimulated.findMethodRecursive(this, name, signature, rawSignature, true);
|
||||
MethodHandle method = TypeHandleSimulated.findMethodRecursive(this, name, signature, rawSignature, true, this.typeProvider);
|
||||
|
||||
// If we find one, return it otherwise just simulate the method
|
||||
return method != null ? method.asMapping(true) : super.getMappingMethod(name, desc);
|
||||
|
||||
}
|
||||
|
||||
private static MethodHandle findMethodRecursive(TypeHandle target, String name, String signature, String rawSignature, boolean matchCase) {
|
||||
private static MethodHandle findMethodRecursive(TypeHandle target, String name, String signature, String rawSignature, boolean matchCase, ITypeHandleProvider typeProvider) {
|
||||
TypeElement elem = target.getTargetElement();
|
||||
if (elem == null) {
|
||||
return null;
|
||||
@@ -171,7 +172,7 @@ public class TypeHandleSimulated extends TypeHandle {
|
||||
}
|
||||
|
||||
for (TypeMirror iface : elem.getInterfaces()) {
|
||||
method = TypeHandleSimulated.findMethodRecursive(iface, name, signature, rawSignature, matchCase);
|
||||
method = TypeHandleSimulated.findMethodRecursive(iface, name, signature, rawSignature, matchCase, typeProvider);
|
||||
if (method != null) {
|
||||
return method;
|
||||
}
|
||||
@@ -182,15 +183,14 @@ public class TypeHandleSimulated extends TypeHandle {
|
||||
return null;
|
||||
}
|
||||
|
||||
return TypeHandleSimulated.findMethodRecursive(superClass, name, signature, rawSignature, matchCase);
|
||||
return TypeHandleSimulated.findMethodRecursive(superClass, name, signature, rawSignature, matchCase, typeProvider);
|
||||
}
|
||||
|
||||
private static MethodHandle findMethodRecursive(TypeMirror target, String name, String signature, String rawSignature, boolean matchCase) {
|
||||
private static MethodHandle findMethodRecursive(TypeMirror target, String name, String signature, String rawSignature, boolean matchCase, ITypeHandleProvider typeProvider) {
|
||||
if (!(target instanceof DeclaredType)) {
|
||||
return null;
|
||||
}
|
||||
TypeElement element = (TypeElement)((DeclaredType)target).asElement();
|
||||
return TypeHandleSimulated.findMethodRecursive(new TypeHandle(element), name, signature, rawSignature, matchCase);
|
||||
return TypeHandleSimulated.findMethodRecursive(typeProvider.getTypeHandle(target), name, signature, rawSignature, matchCase, typeProvider);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -24,6 +24,8 @@
|
||||
*/
|
||||
package org.spongepowered.tools.obfuscation.mirror;
|
||||
|
||||
import org.spongepowered.tools.obfuscation.interfaces.ITypeHandleProvider;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.annotation.processing.ProcessingEnvironment;
|
||||
@@ -82,15 +84,14 @@ public class TypeReference implements Serializable, Comparable<TypeReference> {
|
||||
/**
|
||||
* Fetch or attempt to generate the type handle
|
||||
*
|
||||
* @param processingEnv environment to create handle if it needs to be
|
||||
* @param typeHandleProvider provider to create handle if it needs to be
|
||||
* regenerated
|
||||
* @return type handle
|
||||
*/
|
||||
public TypeHandle getHandle(ProcessingEnvironment processingEnv) {
|
||||
public TypeHandle getHandle(ITypeHandleProvider typeHandleProvider) {
|
||||
if (this.handle == null) {
|
||||
TypeElement element = processingEnv.getElementUtils().getTypeElement(this.getClassName());
|
||||
try {
|
||||
this.handle = new TypeHandle(element);
|
||||
this.handle = typeHandleProvider.getTypeHandle(this.name);
|
||||
} catch (Exception ex) {
|
||||
// Class probably doesn't exist in scope :/
|
||||
ex.printStackTrace();
|
||||
|
||||
@@ -37,6 +37,7 @@ import javax.lang.model.element.TypeParameterElement;
|
||||
import javax.lang.model.element.VariableElement;
|
||||
import javax.lang.model.type.ArrayType;
|
||||
import javax.lang.model.type.DeclaredType;
|
||||
import javax.lang.model.type.IntersectionType;
|
||||
import javax.lang.model.type.TypeKind;
|
||||
import javax.lang.model.type.TypeMirror;
|
||||
import javax.lang.model.type.TypeVariable;
|
||||
@@ -454,6 +455,10 @@ public abstract class TypeUtils {
|
||||
throw new IllegalStateException("Generic symbol \"" + type + "\" is too complex, exceeded "
|
||||
+ TypeUtils.MAX_GENERIC_RECURSION_DEPTH + " iterations attempting to determine upper bound");
|
||||
}
|
||||
if (type instanceof IntersectionType) {
|
||||
TypeMirror first = ((IntersectionType) type).getBounds().get(0);
|
||||
return TypeUtils.getUpperBound0(first, --depth);
|
||||
}
|
||||
if (type instanceof DeclaredType) {
|
||||
return (DeclaredType)type;
|
||||
}
|
||||
|
||||
@@ -29,10 +29,8 @@ import java.util.Collection;
|
||||
import javax.lang.model.element.Element;
|
||||
import javax.lang.model.element.ElementKind;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
import javax.lang.model.type.DeclaredType;
|
||||
import javax.lang.model.type.TypeKind;
|
||||
import javax.lang.model.type.TypeMirror;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
import org.spongepowered.asm.util.asm.IAnnotationHandle;
|
||||
@@ -94,8 +92,7 @@ public class TargetValidator extends MixinValidator {
|
||||
}
|
||||
|
||||
for (TypeHandle target : targets) {
|
||||
TypeElement targetType = target.getElement();
|
||||
if (targetType != null && !(targetType.getKind() == ElementKind.INTERFACE)) {
|
||||
if (target != null && target.isNotInterface()) {
|
||||
this.messager.printMessage(MessageType.TARGET_VALIDATOR, "Targetted type '" + target + " of " + mixin + " is not an interface",
|
||||
mixin);
|
||||
}
|
||||
@@ -103,54 +100,32 @@ public class TargetValidator extends MixinValidator {
|
||||
}
|
||||
|
||||
private void validateClassMixin(TypeElement mixin, Collection<TypeHandle> targets) {
|
||||
TypeMirror superClass = mixin.getSuperclass();
|
||||
TypeHandle superClass = this.typeHandleProvider.getTypeHandle(TypeUtils.getInternalName(mixin)).getSuperclass();
|
||||
|
||||
for (TypeHandle target : targets) {
|
||||
TypeMirror targetType = target.getTypeMirror();
|
||||
if (targetType != null && !this.validateSuperClass(targetType, superClass)) {
|
||||
if (target != null && !this.validateSuperClass(target, superClass)) {
|
||||
this.messager.printMessage(MessageType.TARGET_VALIDATOR, "Superclass " + superClass + " of " + mixin
|
||||
+ " was not found in the hierarchy of target class " + targetType, mixin);
|
||||
+ " was not found in the hierarchy of target class " + target, mixin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean validateSuperClass(TypeMirror targetType, TypeMirror superClass) {
|
||||
if (TypeUtils.isAssignable(this.processingEnv, targetType, superClass)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return this.validateSuperClassRecursive(targetType, superClass);
|
||||
private boolean validateSuperClass(TypeHandle targetType, TypeHandle superClass) {
|
||||
return targetType.isImaginary() || targetType.isSimulated() || superClass.isSuperTypeOf(targetType) || this.checkMixinsFor(targetType, superClass);
|
||||
}
|
||||
|
||||
private boolean validateSuperClassRecursive(TypeMirror targetType, TypeMirror superClass) {
|
||||
if (!(targetType instanceof DeclaredType)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (TypeUtils.isAssignable(this.processingEnv, targetType, superClass)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
TypeElement targetElement = (TypeElement)((DeclaredType)targetType).asElement();
|
||||
TypeMirror targetSuper = targetElement.getSuperclass();
|
||||
if (targetSuper.getKind() == TypeKind.NONE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.checkMixinsFor(targetSuper, superClass)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return this.validateSuperClassRecursive(targetSuper, superClass);
|
||||
}
|
||||
|
||||
private boolean checkMixinsFor(TypeMirror targetType, TypeMirror superClass) {
|
||||
for (TypeMirror mixinType : this.getMixinsTargeting(targetType)) {
|
||||
if (TypeUtils.isAssignable(this.processingEnv, mixinType, superClass)) {
|
||||
private boolean checkMixinsFor(TypeHandle targetType, TypeHandle superMixin) {
|
||||
IAnnotationHandle annotation = superMixin.getAnnotation(Mixin.class);
|
||||
for (Object target : annotation.getList()) {
|
||||
if (this.typeHandleProvider.getTypeHandle(target).isSuperTypeOf(targetType)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
for (String target : annotation.<String>getList("targets")) {
|
||||
if (this.typeHandleProvider.getTypeHandle(target).isSuperTypeOf(targetType)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -38,7 +38,11 @@ public final class FabricUtil {
|
||||
public static final int COMPATIBILITY_LATEST = COMPATIBILITY_0_10_0;
|
||||
|
||||
public static String getModId(IMixinConfig config) {
|
||||
return getDecoration(config, KEY_MOD_ID, "(unknown)");
|
||||
return getModId(config, "(unknown)");
|
||||
}
|
||||
|
||||
public static String getModId(IMixinConfig config, String defaultValue) {
|
||||
return getDecoration(config, KEY_MOD_ID, defaultValue);
|
||||
}
|
||||
|
||||
public static String getModId(ISelectorContext context) {
|
||||
|
||||
@@ -50,6 +50,7 @@ import org.spongepowered.asm.mixin.transformer.MixinTargetContext;
|
||||
import org.spongepowered.asm.service.MixinService;
|
||||
import org.spongepowered.asm.util.Annotations;
|
||||
import org.spongepowered.asm.util.Bytecode;
|
||||
import org.spongepowered.asm.util.asm.MethodNodeEx;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Strings;
|
||||
@@ -355,7 +356,7 @@ public class AccessorInfo extends SpecialMethodInfo {
|
||||
* <tt>foo</tt> for example.
|
||||
*/
|
||||
protected String inflectTarget() {
|
||||
return AccessorInfo.inflectTarget(this.method.name, this.type, this.toString(), this,
|
||||
return AccessorInfo.inflectTarget(MethodNodeEx.getName(this.method), this.type, this.toString(), this,
|
||||
this.mixin.getEnvironment().getOption(Option.DEBUG_VERBOSE));
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ import org.spongepowered.asm.mixin.injection.struct.MemberInfo;
|
||||
import org.spongepowered.asm.mixin.transformer.MixinTargetContext;
|
||||
import org.spongepowered.asm.util.Bytecode;
|
||||
import org.spongepowered.asm.util.Constants;
|
||||
import org.spongepowered.asm.util.asm.MethodNodeEx;
|
||||
|
||||
/**
|
||||
* Information about an invoker
|
||||
@@ -54,7 +55,7 @@ class InvokerInfo extends AccessorInfo {
|
||||
return this.initType(mappedReference.replace('.', '/'), this.mixin.getTargetClassRef());
|
||||
}
|
||||
|
||||
AccessorName accessorName = AccessorName.of(this.method.name, false);
|
||||
AccessorName accessorName = AccessorName.of(MethodNodeEx.getName(this.method), false);
|
||||
if (accessorName != null) {
|
||||
for (String prefix : AccessorType.OBJECT_FACTORY.getExpectedPrefixes()) {
|
||||
if (prefix.equals(accessorName.prefix)) {
|
||||
|
||||
@@ -49,7 +49,7 @@ public class InjectorGroupInfo {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final InjectorGroupInfo NO_GROUP = new InjectorGroupInfo("NONE", true);
|
||||
private final InjectorGroupInfo noGroup = new InjectorGroupInfo("NONE", true);
|
||||
|
||||
@Override
|
||||
public InjectorGroupInfo get(Object key) {
|
||||
@@ -94,7 +94,7 @@ public class InjectorGroupInfo {
|
||||
*/
|
||||
public InjectorGroupInfo parseGroup(AnnotationNode annotation, String defaultGroup) {
|
||||
if (annotation == null) {
|
||||
return InjectorGroupInfo.Map.NO_GROUP;
|
||||
return noGroup;
|
||||
}
|
||||
|
||||
String name = Annotations.<String>getValue(annotation, "name");
|
||||
|
||||
@@ -28,7 +28,7 @@ import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.TreeMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.tools.Diagnostic.Kind;
|
||||
@@ -72,13 +72,13 @@ public final class ReferenceMapper implements IReferenceMapper, Serializable {
|
||||
* by the AP. Each entry is keyed by the owning mixin, with the value map
|
||||
* containing the actual remappings for each owner
|
||||
*/
|
||||
private final Map<String, Map<String, String>> mappings = Maps.newHashMap();
|
||||
private final Map<String, Map<String, String>> mappings = Maps.newTreeMap();
|
||||
|
||||
/**
|
||||
* All mapping sets, keyed by environment type, eg. "notch", "searge". The
|
||||
* format of each map within this map is the same as for {@link #mappings}
|
||||
*/
|
||||
private final Map<String, Map<String, Map<String, String>>> data = Maps.newHashMap();
|
||||
private final Map<String, Map<String, Map<String, String>>> data = Maps.newTreeMap();
|
||||
|
||||
/**
|
||||
* True if this refmap cannot be written. Only true for the
|
||||
@@ -225,13 +225,13 @@ public final class ReferenceMapper implements IReferenceMapper, Serializable {
|
||||
if (context != null) {
|
||||
mappings = this.data.get(context);
|
||||
if (mappings == null) {
|
||||
mappings = Maps.newHashMap();
|
||||
mappings = Maps.newTreeMap();
|
||||
this.data.put(context, mappings);
|
||||
}
|
||||
}
|
||||
Map<String, String> classMappings = mappings.get(className);
|
||||
if (classMappings == null) {
|
||||
classMappings = new HashMap<String, String>();
|
||||
classMappings = new TreeMap<String, String>();
|
||||
mappings.put(className, classMappings);
|
||||
}
|
||||
return classMappings.put(conformedReference, newReference);
|
||||
|
||||
@@ -36,6 +36,7 @@ import org.objectweb.asm.commons.Remapper;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.objectweb.asm.commons.ClassRemapper;
|
||||
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
|
||||
import org.spongepowered.asm.mixin.transformer.ClassInfo.Field;
|
||||
import org.spongepowered.asm.mixin.transformer.ClassInfo.Method;
|
||||
import org.spongepowered.asm.mixin.transformer.ext.IClassGenerator;
|
||||
import org.spongepowered.asm.mixin.transformer.throwables.InvalidMixinException;
|
||||
@@ -158,14 +159,33 @@ final class InnerClassGenerator implements IClassGenerator {
|
||||
classNode.accept(classVisitor);
|
||||
this.loadCounter++;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Used to remap synthetic accessor methods which have been renamed when
|
||||
* being applied to the target class.
|
||||
* Used to remap fields which have been renamed while being applied to
|
||||
* the target class or by an implementation of IRemapper.
|
||||
*
|
||||
* @see org.spongepowered.asm.mixin.extensibility.IRemapper
|
||||
*/
|
||||
@Override
|
||||
public String mapFieldName(String owner, String name, String descriptor) {
|
||||
if (this.ownerName.equals(owner)) {
|
||||
Field field = this.owner.getClassInfo().findField(name, descriptor, ClassInfo.INCLUDE_ALL);
|
||||
if (field != null) {
|
||||
return field.getName();
|
||||
}
|
||||
}
|
||||
return super.mapFieldName(owner, name, descriptor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to remap methods which have been renamed while being applied to
|
||||
* the target class or by an implementation of IRemapper.
|
||||
*
|
||||
* @see org.spongepowered.asm.mixin.extensibility.IRemapper
|
||||
*/
|
||||
@Override
|
||||
public String mapMethodName(String owner, String name, String desc) {
|
||||
if (this.ownerName.equalsIgnoreCase(owner)) {
|
||||
if (this.ownerName.equals(owner)) {
|
||||
Method method = this.owner.getClassInfo().findMethod(name, desc, ClassInfo.INCLUDE_ALL);
|
||||
if (method != null) {
|
||||
return method.getName();
|
||||
|
||||
@@ -32,14 +32,17 @@ import java.util.Map;
|
||||
import org.spongepowered.asm.logging.ILogger;
|
||||
import org.objectweb.asm.tree.FieldNode;
|
||||
import org.objectweb.asm.tree.MethodNode;
|
||||
import org.spongepowered.asm.mixin.FabricUtil;
|
||||
import org.spongepowered.asm.mixin.MixinEnvironment;
|
||||
import org.spongepowered.asm.mixin.injection.struct.InjectionInfo;
|
||||
import org.spongepowered.asm.mixin.transformer.ClassInfo.Method;
|
||||
import org.spongepowered.asm.mixin.transformer.MixinInfo.MixinMethodNode;
|
||||
import org.spongepowered.asm.service.MixinService;
|
||||
import org.spongepowered.asm.util.Counter;
|
||||
import org.spongepowered.asm.util.asm.MethodNodeEx;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.primitives.Chars;
|
||||
|
||||
/**
|
||||
* Maintains method remaps for a target class
|
||||
@@ -108,8 +111,17 @@ class MethodMapper {
|
||||
public String getHandlerName(MixinMethodNode method) {
|
||||
String prefix = InjectionInfo.getInjectorPrefix(method.getInjectorAnnotation());
|
||||
String classUID = MethodMapper.getClassUID(method.getOwner().getClassRef());
|
||||
String methodUID = MethodMapper.getMethodUID(method.name, method.desc, !method.isSurrogate());
|
||||
return String.format("%s$%s%s$%s", prefix, classUID, methodUID, method.name);
|
||||
String mod = FabricUtil.getModId(method.getOwner().getConfig(), "");
|
||||
String methodName = method.name;
|
||||
if (!mod.isEmpty()) {
|
||||
//It's common for mods to prefix their own handlers, let's account for that happening
|
||||
if (methodName.startsWith(mod) && methodName.length() > mod.length() + 1 && Chars.contains(new char[] {'_', '$'}, methodName.charAt(mod.length()))) {
|
||||
methodName = methodName.substring(mod.length() + 1);
|
||||
}
|
||||
mod += '$';
|
||||
}
|
||||
String methodUID = MethodMapper.getMethodUID(methodName, method.desc, !method.isSurrogate());
|
||||
return String.format("%s$%s%s$%s%s", prefix, classUID, methodUID, mod, methodName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -123,8 +135,23 @@ class MethodMapper {
|
||||
*/
|
||||
public String getUniqueName(MethodNode method, String sessionId, boolean preservePrefix) {
|
||||
String uniqueIndex = Integer.toHexString(this.nextUniqueMethodIndex++);
|
||||
String methodName = method.name;
|
||||
if (method instanceof MethodNodeEx) {
|
||||
String mod = FabricUtil.getModId(((MethodNodeEx) method).getOwner().getConfig(), "");
|
||||
if (!mod.isEmpty()) {
|
||||
//It's rarer for mods to prefix their @Unique methods, but let's account for it anyway
|
||||
if (methodName.startsWith(mod) && methodName.length() > mod.length() + 1 && Chars.contains(new char[] {'_', '$'}, methodName.charAt(mod.length()))) {
|
||||
methodName = methodName.substring(mod.length() + 1);
|
||||
}
|
||||
if (preservePrefix) {
|
||||
methodName += '$' + mod;
|
||||
} else {
|
||||
methodName = mod + '$' + methodName;
|
||||
}
|
||||
}
|
||||
}
|
||||
String pattern = preservePrefix ? "%2$s_$md$%1$s$%3$s" : "md%s$%s$%s";
|
||||
return String.format(pattern, sessionId.substring(30), method.name, uniqueIndex);
|
||||
return String.format(pattern, sessionId.substring(30), methodName, uniqueIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -212,10 +212,12 @@ class MixinApplicatorStandard {
|
||||
* receiving constructor.
|
||||
*/
|
||||
protected static final int[] INITIALISER_OPCODE_BLACKLIST = {
|
||||
Opcodes.RETURN, Opcodes.ILOAD, Opcodes.LLOAD, Opcodes.FLOAD, Opcodes.DLOAD, Opcodes.IALOAD, Opcodes.LALOAD, Opcodes.FALOAD, Opcodes.DALOAD,
|
||||
Opcodes.AALOAD, Opcodes.BALOAD, Opcodes.CALOAD, Opcodes.SALOAD, Opcodes.ISTORE, Opcodes.LSTORE, Opcodes.FSTORE, Opcodes.DSTORE,
|
||||
Opcodes.ASTORE, Opcodes.IASTORE, Opcodes.LASTORE, Opcodes.FASTORE, Opcodes.DASTORE, Opcodes.AASTORE, Opcodes.BASTORE, Opcodes.CASTORE,
|
||||
Opcodes.SASTORE
|
||||
Opcodes.RETURN, Opcodes.ILOAD, Opcodes.LLOAD, Opcodes.FLOAD, Opcodes.DLOAD,
|
||||
Opcodes.ISTORE, Opcodes.LSTORE, Opcodes.FSTORE, Opcodes.DSTORE, Opcodes.ASTORE,
|
||||
// Fabric: Array opcodes cause no problems in initialisers and should not be needlessly restricted.
|
||||
// Opcodes.IALOAD, Opcodes.LALOAD, Opcodes.FALOAD, Opcodes.DALOAD, Opcodes.AALOAD,
|
||||
// Opcodes.BALOAD, Opcodes.CALOAD, Opcodes.SALOAD, Opcodes.IASTORE, Opcodes.LASTORE,
|
||||
// Opcodes.FASTORE, Opcodes.DASTORE, Opcodes.AASTORE, Opcodes.BASTORE, Opcodes.CASTORE, Opcodes.SASTORE
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -954,6 +956,12 @@ class MixinApplicatorStandard {
|
||||
*/
|
||||
protected final void injectInitialiser(MixinTargetContext mixin, MethodNode ctor, Deque<AbstractInsnNode> initialiser) {
|
||||
Map<LabelNode, LabelNode> labels = Bytecode.cloneLabels(ctor.instructions);
|
||||
// Fabric: also clone labels from the initialiser as they will be merged.
|
||||
for (AbstractInsnNode node : initialiser) {
|
||||
if (node instanceof LabelNode) {
|
||||
labels.put((LabelNode) node, new LabelNode());
|
||||
}
|
||||
}
|
||||
|
||||
AbstractInsnNode insn = this.findInitialiserInjectionPoint(mixin, ctor, initialiser);
|
||||
if (insn == null) {
|
||||
@@ -963,10 +971,12 @@ class MixinApplicatorStandard {
|
||||
|
||||
for (AbstractInsnNode node : initialiser) {
|
||||
if (node instanceof LabelNode) {
|
||||
continue;
|
||||
// Fabric: Merge cloned labels instead of skipping them.
|
||||
// continue;
|
||||
}
|
||||
if (node instanceof JumpInsnNode) {
|
||||
throw new InvalidMixinException(mixin, "Unsupported JUMP opcode in initialiser in " + mixin);
|
||||
// Fabric: Jumps cause no issues if labels are cloned properly and should not be needlessly restricted.
|
||||
// throw new InvalidMixinException(mixin, "Unsupported JUMP opcode in initialiser in " + mixin);
|
||||
}
|
||||
AbstractInsnNode imACloneNow = node.clone(labels);
|
||||
ctor.instructions.insert(insn, imACloneNow);
|
||||
|
||||
@@ -84,7 +84,7 @@ public enum MixinInheritanceTracker implements IListener {
|
||||
int ownerSplit = owner.lastIndexOf('/');
|
||||
int childSplit = node.name.lastIndexOf('/');
|
||||
//There is a reasonable chance mixins are in the same package, so it is viable that a package private method is overridden
|
||||
if (ownerSplit != childSplit || (ownerSplit > 0 && !owner.regionMatches(0, child.getName(), 0, ownerSplit + 1))) break;
|
||||
if (ownerSplit != childSplit || (ownerSplit > 0 && !owner.regionMatches(0, node.name, 0, ownerSplit + 1))) break;
|
||||
|
||||
default:
|
||||
out.add(method);
|
||||
|
||||
+9
-6
@@ -628,13 +628,8 @@ class MixinPreProcessorStandard {
|
||||
mixinField.name = field.renameTo(target.name);
|
||||
}
|
||||
|
||||
if (!Bytecode.compareFlags(mixinField, target, Opcodes.ACC_STATIC)) {
|
||||
throw new InvalidMixinException(this.mixin, String.format("STATIC modifier of @Shadow field %s in %s does not match the target",
|
||||
mixinField.name, this.mixin));
|
||||
}
|
||||
|
||||
if (field.isUnique()) {
|
||||
if ((mixinField.access & (Opcodes.ACC_PRIVATE | Opcodes.ACC_PROTECTED)) != 0) {
|
||||
if (Bytecode.getVisibility(mixinField).isLessThan(Visibility.PUBLIC)) {
|
||||
String uniqueName = context.getUniqueName(mixinField);
|
||||
MixinPreProcessorStandard.logger.log(this.mixin.getLoggingLevel(), "Renaming @Unique field {}{} to {} in {}",
|
||||
mixinField.name, mixinField.desc, uniqueName, this.mixin);
|
||||
@@ -653,6 +648,14 @@ class MixinPreProcessorStandard {
|
||||
|
||||
iter.remove();
|
||||
continue;
|
||||
} else if (!Bytecode.compareFlags(mixinField, target, Opcodes.ACC_STATIC)) {
|
||||
if (isShadow) {
|
||||
throw new InvalidMixinException(this.mixin, String.format("STATIC modifier of @Shadow field %s in %s does not match the target",
|
||||
mixinField.name, this.mixin));
|
||||
} else {
|
||||
throw new InvalidMixinException(this.mixin, String.format("Field %s in %s conflicts with %sstatic field in the target (%s)",
|
||||
mixinField.name, mixin, Bytecode.isStatic(target) ? "" : "non-", context.getTarget()));
|
||||
}
|
||||
}
|
||||
|
||||
// Check that the shadow field has a matching descriptor
|
||||
|
||||
Reference in new issue
Block a user