aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/ftbsc/lll/processor/tools/ASTUtils.java
diff options
context:
space:
mode:
author zaaarf <zaaarf@proton.me>2023-04-12 00:53:36 +0200
committer zaaarf <zaaarf@proton.me>2023-04-12 00:53:36 +0200
commitabd9954ed3250f99a77f770fcdf9d41c75fd90a4 (patch)
tree1e996a4c362c9bde5e38b5120466d1c6c2e1d91d /src/main/java/ftbsc/lll/processor/tools/ASTUtils.java
parent524818a3782e00ea2ffd1aca1e50b1ee18595070 (diff)
feat: throw exception if bridge is not found correctly0.5.2
Diffstat (limited to 'src/main/java/ftbsc/lll/processor/tools/ASTUtils.java')
-rw-r--r--src/main/java/ftbsc/lll/processor/tools/ASTUtils.java25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/main/java/ftbsc/lll/processor/tools/ASTUtils.java b/src/main/java/ftbsc/lll/processor/tools/ASTUtils.java
index f8b05b5..6bd5864 100644
--- a/src/main/java/ftbsc/lll/processor/tools/ASTUtils.java
+++ b/src/main/java/ftbsc/lll/processor/tools/ASTUtils.java
@@ -331,6 +331,31 @@ public class ASTUtils {
}
/**
+ * Tries to find the "synthetic bridge" generated by the compiler for a certain overridden
+ * method. A "bridge" only exists in cases where type erasure is involved (i.e. when the
+ * method being overridden uses a generic parameter that is not preserved in the overriding
+ * method).
+ * @param context the {@link TypeElement} representing the parent class
+ * @param method an {@link ExecutableElement} stub representing the overloading method
+ * @param env the {@link ProcessingEnvironment} to perform the operation in
+ * @return the "bridge"
+ * @throws TargetNotFoundException if the method in question was not overriding anything, or
+ * if the method it was overriding does not require a bridge
+ * @since 0.5.2
+ */
+ public static ExecutableElement findSyntheticBridge(
+ TypeElement context, ExecutableElement method, ProcessingEnvironment env) throws TargetNotFoundException {
+ ExecutableElement overridding = findOverloadedMethod(context, method, env);
+ if(descriptorFromExecutableElement(overridding, env).equals(descriptorFromExecutableElement(method, env)))
+ throw new TargetNotFoundException(
+ "bridge method for",
+ overridding.getSimpleName().toString(),
+ context.getQualifiedName().toString()
+ );
+ else return overridding;
+ }
+
+ /**
* Utility method for finding out what type of proxy a field is.
* It will fail if the return type is not a known type of proxy.
* @param v the annotated {@link VariableElement}