diff --git a/README.md b/README.md index 2f195b9d..a6b3be53 100644 --- a/README.md +++ b/README.md @@ -53,13 +53,6 @@ material from being accidentally included in the repository. Run `./gradlew` to download the dependencies, build the code, run the unit tests and package it. -IDEA 2020.3's built-in build system breaks with a cryptic -`java: java.lang.IllegalArgumentException` error message when compiling modules -that use the `deob-annotations` processor. A workaround is to add -`-Djps.track.ap.dependencies=false` to the 'Shared build process VM options' in -File -> Settings -> Build, Execution and Deployment -> Compiler. See -[IDEA-256707][idea-bug] for more information. - ## Links * [Discord][discord] diff --git a/deob-processor/src/main/kotlin/org/openrs2/deob/processor/NameMapProcessor.kt b/deob-processor/src/main/kotlin/org/openrs2/deob/processor/NameMapProcessor.kt index f53ec6e7..8630ef4e 100644 --- a/deob-processor/src/main/kotlin/org/openrs2/deob/processor/NameMapProcessor.kt +++ b/deob-processor/src/main/kotlin/org/openrs2/deob/processor/NameMapProcessor.kt @@ -14,6 +14,7 @@ import org.openrs2.deob.util.map.Method import org.openrs2.deob.util.map.NameMap import org.openrs2.util.io.useAtomicBufferedWriter import org.openrs2.yaml.Yaml +import java.lang.reflect.Proxy import java.nio.file.Files import java.nio.file.Path import java.util.TreeMap @@ -51,10 +52,22 @@ public class NameMapProcessor : AbstractProcessor() { override fun init(env: ProcessingEnvironment) { super.init(env) - trees = Trees.instance(env) + trees = Trees.instance(unwrap(env)) localScanner = LocalVariableScanner(trees) } + // see https://youtrack.jetbrains.com/issue/IDEA-256707 + private fun unwrap(env: ProcessingEnvironment): ProcessingEnvironment { + if (!Proxy.isProxyClass(env.javaClass)) { + return env + } + + val invocationHandler = Proxy.getInvocationHandler(env) + val field = invocationHandler.javaClass.getDeclaredField("val\$delegateTo") + field.isAccessible = true + return field.get(invocationHandler) as ProcessingEnvironment + } + private fun getPath(): Path? { val map = processingEnv.options["map"] ?: return null return Path.of(map)