diff options
author | zaaarf <zaaarf@proton.me> | 2023-04-12 00:38:55 +0200 |
---|---|---|
committer | zaaarf <zaaarf@proton.me> | 2023-04-12 00:38:55 +0200 |
commit | 524818a3782e00ea2ffd1aca1e50b1ee18595070 (patch) | |
tree | d3874f2ac9f7a2c4df858d33c7fa85b013886729 /src/main | |
parent | 61fa43fb8d0f09d20687fe95c9caa47d82d354cf (diff) |
feat: matching the erasure bridge should be optional
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/ftbsc/lll/processor/annotations/Target.java | 8 | ||||
-rw-r--r-- | src/main/java/ftbsc/lll/processor/tools/containers/MethodContainer.java | 22 |
2 files changed, 18 insertions, 12 deletions
diff --git a/src/main/java/ftbsc/lll/processor/annotations/Target.java b/src/main/java/ftbsc/lll/processor/annotations/Target.java index e1e69f7..d397705 100644 --- a/src/main/java/ftbsc/lll/processor/annotations/Target.java +++ b/src/main/java/ftbsc/lll/processor/annotations/Target.java @@ -44,4 +44,12 @@ public @interface Target { * @since 0.3.0 */ boolean strict() default true; + + /** + * When set to true, tells the processor to match the synthetic "bridge" method + * generated by the compiler to handle type erasure. + * @return whether the bridge method should be targeted instead of the actual method + * @since 0.5.2 + */ + boolean bridge() default false; } 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 1892c28..6889129 100644 --- a/src/main/java/ftbsc/lll/processor/tools/containers/MethodContainer.java +++ b/src/main/java/ftbsc/lll/processor/tools/containers/MethodContainer.java @@ -59,13 +59,14 @@ public class MethodContainer { * @param parent the {@link ClassContainer} representing the parent * @param name the fully-qualified name of the target method * @param descriptor the descriptor of the target method - * @param strict whether the matching should be strict (see {@link Target#strict()} for more info). + * @param strict whether the matching should be strict (see {@link Target#strict()} for more info) + * @param bridge whether the "bridge" should be matched isntead (see {@link Target#bridge()} for more info) * @param env the {@link ProcessingEnvironment} to perform the operation in * @param mapper the {@link ObfuscationMapper} to be used, may be null */ private MethodContainer( - ClassContainer parent, String name, String descriptor, - boolean strict, ProcessingEnvironment env, ObfuscationMapper mapper) { + ClassContainer parent, String name, String descriptor, boolean strict, + boolean bridge, ProcessingEnvironment env, ObfuscationMapper mapper) { this.parent = parent; if(parent.elem == null) { //unverified if(descriptor == null) @@ -74,13 +75,10 @@ public class MethodContainer { this.name = name; this.descriptor = descriptor; } else { - this.elem = findOverloadedMethod( //to prevent type erasure from messing it all up - (TypeElement) this.parent.elem, - (ExecutableElement) findMember( - parent, name, descriptor, descriptor != null && strict,false, env - ), env + ExecutableElement tmp = (ExecutableElement) findMember( + parent, name, descriptor, descriptor != null && strict,false, env ); - + this.elem = bridge ? findOverloadedMethod((TypeElement) this.parent.elem, tmp, env) : tmp; this.name = this.elem.getSimpleName().toString(); this.descriptor = descriptorFromExecutableElement(this.elem, env); } @@ -108,13 +106,13 @@ public class MethodContainer { f, env, mapper ); - String name = t != null && !t.methodName().equals("") + String name = !t.methodName().equals("") ? t.methodName() //name was specified in target : stub.getSimpleName().toString(); - String descriptor = t != null && t.strict() + String descriptor = t.strict() ? descriptorFromExecutableElement(stub, env) : null; - return new MethodContainer(parent, name, descriptor, t != null && t.strict(), env, mapper); + return new MethodContainer(parent, name, descriptor, t.strict(), t.bridge(), env, mapper); } }
\ No newline at end of file |