From 66e04c91693f62672aa9f451a38e5798d26d7677 Mon Sep 17 00:00:00 2001 From: yyny <6576327+yyny@users.noreply.github.com> Date: Mon, 18 Jan 2021 10:20:31 +0100 Subject: [PATCH] Suppress warnings for public classes that cannot possibly be specified in value Could have also considered making such classes private in `DeclaredTarget.of` but this seems like a cleaner solution. --- .../asm/mixin/transformer/MixinInfo.java | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/spongepowered/asm/mixin/transformer/MixinInfo.java b/src/main/java/org/spongepowered/asm/mixin/transformer/MixinInfo.java index f18b3dbb1..4781166b8 100644 --- a/src/main/java/org/spongepowered/asm/mixin/transformer/MixinInfo.java +++ b/src/main/java/org/spongepowered/asm/mixin/transformer/MixinInfo.java @@ -1015,17 +1015,29 @@ private ClassInfo getTargetClass(DeclaredTarget target) throws InvalidMixinExcep } this.type.validateTarget(target.name, targetInfo); if (target.isPrivate && targetInfo.isPublic() && !this.isVirtual()) { - this.handleTargetError(String.format("@Mixin target %s is public in %s and should be specified in value", target.name, this)); + String errorMessage = String.format("@Mixin target %s is public in %s and should be specified in value", target.name, this); + this.handleTargetError(errorMessage, target.name.contains('$')); } return targetInfo; } private void handleTargetError(String message) { - if (this.strict) { - this.logger.error(message); - throw new InvalidMixinException(this, message); + handleTargetError(message, false); + } + + private void handleTargetError(String message, boolean nonfatal) { + if (nonfatal) { + if (this.strict) { + this.logger.warn(message); + } + this.logger.debug(message); + } else { + if (this.strict) { + this.logger.error(message); + throw new InvalidMixinException(this, message); + } + this.logger.warn(message); } - this.logger.warn(message); } /**