From 3ccc611e5eaf6c6dad458b83e623ba6d3146dca1 Mon Sep 17 00:00:00 2001 From: Mumfrey Date: Wed, 23 Dec 2020 18:47:37 +0000 Subject: [PATCH] Use full annotation class names when resolving injectors, fixes #443 --- .../mixin/injection/struct/InjectionInfo.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/spongepowered/asm/mixin/injection/struct/InjectionInfo.java b/src/main/java/org/spongepowered/asm/mixin/injection/struct/InjectionInfo.java index 7fea5525c..646e6f735 100644 --- a/src/main/java/org/spongepowered/asm/mixin/injection/struct/InjectionInfo.java +++ b/src/main/java/org/spongepowered/asm/mixin/injection/struct/InjectionInfo.java @@ -117,19 +117,19 @@ static class InjectorEntry { final Class annotationType; - final Class type; + final Class injectorType; final Constructor ctor; - final String simpleName; + final String annotationDesc; final String prefix; InjectorEntry(Class annotationType, Class type) throws NoSuchMethodException { this.annotationType = annotationType; - this.type = type; + this.injectorType = type; this.ctor = type.getDeclaredConstructor(MixinTargetContext.class, MethodNode.class, AnnotationNode.class); - this.simpleName = annotationType.getSimpleName() + ";"; + this.annotationDesc = Type.getDescriptor(annotationType); HandlerPrefix handlerPrefix = type.getAnnotation(HandlerPrefix.class); this.prefix = handlerPrefix != null ? handlerPrefix.value() : InjectionInfo.DEFAULT_PREFIX; @@ -144,9 +144,9 @@ InjectionInfo create(MixinTargetContext mixin, MethodNode method, AnnotationNode throw (MixinException)cause; } Throwable ex = cause != null ? cause : itex; - throw new MixinError("Error initialising injector metaclass [" + this.type + "] for annotation " + annotation.desc, ex); + throw new MixinError("Error initialising injector metaclass [" + this.injectorType + "] for annotation " + annotation.desc, ex); } catch (ReflectiveOperationException ex) { - throw new MixinError("Failed to instantiate injector metaclass [" + this.type + "] for annotation " + annotation.desc, ex); + throw new MixinError("Failed to instantiate injector metaclass [" + this.injectorType + "] for annotation " + annotation.desc, ex); } } } @@ -620,7 +620,7 @@ public static InjectionInfo parse(MixinTargetContext mixin, MethodNode method) { } for (InjectorEntry injector : InjectionInfo.registry.values()) { - if (annotation.desc.endsWith(injector.simpleName)) { + if (annotation.desc.equals(injector.annotationDesc)) { return injector.create(mixin, method, annotation); } } @@ -660,7 +660,7 @@ public static String getInjectorPrefix(AnnotationNode annotation) { } for (InjectorEntry injector : InjectionInfo.registry.values()) { - if (annotation.desc.endsWith(injector.simpleName)) { + if (annotation.desc.endsWith(injector.annotationDesc)) { return injector.prefix; } } @@ -713,16 +713,16 @@ public static void register(Class type) { } catch (NoSuchMethodException ex) { throw new MixinError("InjectionInfo class " + type.getName() + " is missing a valid constructor"); } - InjectorEntry existing = InjectionInfo.registry.get(entry.simpleName); + InjectorEntry existing = InjectionInfo.registry.get(entry.annotationDesc); if (existing != null) { // && !existing.type.equals(type)) { MessageRouter.getMessager().printMessage(Kind.WARNING, String.format("Overriding InjectionInfo for @%s with %s (previously %s)", - annotationType.value().getSimpleName(), type.getName(), existing.type.getName())); + annotationType.value().getSimpleName(), type.getName(), existing.injectorType.getName())); } else { MessageRouter.getMessager().printMessage(Kind.OTHER, String.format("Registering new injector for @%s with %s", annotationType.value().getSimpleName(), type.getName())); } - InjectionInfo.registry.put(entry.simpleName, entry); + InjectionInfo.registry.put(entry.annotationDesc, entry); ArrayList> annotations = new ArrayList>(); for (InjectorEntry injector : InjectionInfo.registry.values()) {