diff options
author | zaaarf <zaaarf@proton.me> | 2023-03-29 12:15:36 +0200 |
---|---|---|
committer | zaaarf <zaaarf@proton.me> | 2023-03-29 12:15:36 +0200 |
commit | d451cc3460fc162295874f0b8ddb2f058dadfa66 (patch) | |
tree | beb0688822876bfc9667010a63a516400439a298 /src/main/java/ftbsc/lll/processor/tools/containers | |
parent | dac2510de75839c7617c2fb648905541496494e0 (diff) |
fix: descriptor obfuscation now handled properly
Diffstat (limited to 'src/main/java/ftbsc/lll/processor/tools/containers')
-rw-r--r-- | src/main/java/ftbsc/lll/processor/tools/containers/FieldContainer.java | 15 | ||||
-rw-r--r-- | src/main/java/ftbsc/lll/processor/tools/containers/MethodContainer.java | 13 |
2 files changed, 22 insertions, 6 deletions
diff --git a/src/main/java/ftbsc/lll/processor/tools/containers/FieldContainer.java b/src/main/java/ftbsc/lll/processor/tools/containers/FieldContainer.java index 0b39a1c..b6a98bd 100644 --- a/src/main/java/ftbsc/lll/processor/tools/containers/FieldContainer.java +++ b/src/main/java/ftbsc/lll/processor/tools/containers/FieldContainer.java @@ -4,6 +4,7 @@ import ftbsc.lll.exceptions.AmbiguousDefinitionException; import ftbsc.lll.processor.annotations.Find; import ftbsc.lll.processor.annotations.Patch; import ftbsc.lll.processor.tools.obfuscation.ObfuscationMapper; +import org.objectweb.asm.Type; import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.VariableElement; @@ -11,6 +12,7 @@ import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; import static ftbsc.lll.processor.tools.ASTUtils.*; +import static ftbsc.lll.processor.tools.JavaPoetUtils.descriptorFromExecutableElement; import static ftbsc.lll.processor.tools.JavaPoetUtils.descriptorFromType; /** @@ -36,6 +38,12 @@ public class FieldContainer { public final String nameObf; /** + * The obfuscated descriptor of the field. + * If the mapper passed is null, then this will be identical to {@link #descriptor}. + */ + public final String descriptorObf; + + /** * The {@link ClassContainer} representing the parent of this field. * May be null if the parent is a class type that can not be checked * at processing time (such as an anonymous class) @@ -63,12 +71,13 @@ public class FieldContainer { throw new AmbiguousDefinitionException("Cannot use name-based lookups for fields of unverifiable classes!"); this.elem = null; this.name = name; - this.descriptor = mapper == null ? descriptor : mapper.obfuscateMethodDescriptor(descriptor); + this.descriptor = descriptor; + this.descriptorObf = mapper == null ? this.descriptor : mapper.obfuscateType(Type.getType(this.descriptor)).getDescriptor(); } else { this.elem = (VariableElement) findMember(parent, name, descriptor, descriptor != null, true); this.name = this.elem.getSimpleName().toString(); - String validatedDescriptor = descriptorFromType(this.elem.asType()); - this.descriptor = mapper == null ? descriptor : mapper.obfuscateMethodDescriptor(validatedDescriptor); + this.descriptor = descriptorFromType(this.elem.asType()); + this.descriptorObf = mapper == null ? this.descriptor : mapper.obfuscateType(Type.getType(this.descriptor)).getDescriptor(); } this.nameObf = findMemberName(parent.fqnObf, name, descriptor, mapper); } diff --git a/src/main/java/ftbsc/lll/processor/tools/containers/MethodContainer.java b/src/main/java/ftbsc/lll/processor/tools/containers/MethodContainer.java index d8ab04f..7f328d6 100644 --- a/src/main/java/ftbsc/lll/processor/tools/containers/MethodContainer.java +++ b/src/main/java/ftbsc/lll/processor/tools/containers/MethodContainer.java @@ -39,6 +39,12 @@ public class MethodContainer { public final String nameObf; /** + * The obfuscated descriptor of the field. + * If the mapper passed is null, then this will be identical to {@link #descriptor}. + */ + public final String descriptorObf; + + /** * The {@link ClassContainer} representing the parent of this method. * May be null if the parent is a class type that can not be checked * at processing time (such as an anonymous class) @@ -67,12 +73,13 @@ public class MethodContainer { throw new AmbiguousDefinitionException("Cannot use name-based lookups for methods of unverifiable classes!"); this.elem = null; this.name = name; - this.descriptor = mapper == null ? descriptor : mapper.obfuscateMethodDescriptor(descriptor); + this.descriptor = descriptor; + this.descriptorObf = mapper == null ? this.descriptor : mapper.obfuscateMethodDescriptor(this.descriptor); } else { this.elem = (ExecutableElement) findMember(parent, name, descriptor, descriptor != null && strict, false); this.name = this.elem.getSimpleName().toString(); - String validatedDescriptor = descriptorFromExecutableElement(this.elem); - this.descriptor = mapper == null ? descriptor : mapper.obfuscateMethodDescriptor(validatedDescriptor); + this.descriptor = descriptorFromExecutableElement(this.elem); + this.descriptorObf = mapper == null ? this.descriptor : mapper.obfuscateMethodDescriptor(this.descriptor); } this.nameObf = findMemberName(parent.fqnObf, name, descriptor, mapper); } |