Add workaround for IDEA-256707

Signed-off-by: Graham <gpe@openrs2.org>
bzip2
Graham 4 years ago
parent bdaf5aae2c
commit afcd1fac36
  1. 7
      README.md
  2. 15
      deob-processor/src/main/kotlin/org/openrs2/deob/processor/NameMapProcessor.kt

@ -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 Run `./gradlew` to download the dependencies, build the code, run the unit tests
and package it. 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 ## Links
* [Discord][discord] * [Discord][discord]

@ -14,6 +14,7 @@ import org.openrs2.deob.util.map.Method
import org.openrs2.deob.util.map.NameMap import org.openrs2.deob.util.map.NameMap
import org.openrs2.util.io.useAtomicBufferedWriter import org.openrs2.util.io.useAtomicBufferedWriter
import org.openrs2.yaml.Yaml import org.openrs2.yaml.Yaml
import java.lang.reflect.Proxy
import java.nio.file.Files import java.nio.file.Files
import java.nio.file.Path import java.nio.file.Path
import java.util.TreeMap import java.util.TreeMap
@ -51,10 +52,22 @@ public class NameMapProcessor : AbstractProcessor() {
override fun init(env: ProcessingEnvironment) { override fun init(env: ProcessingEnvironment) {
super.init(env) super.init(env)
trees = Trees.instance(env) trees = Trees.instance(unwrap(env))
localScanner = LocalVariableScanner(trees) 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? { private fun getPath(): Path? {
val map = processingEnv.options["map"] ?: return null val map = processingEnv.options["map"] ?: return null
return Path.of(map) return Path.of(map)

Loading…
Cancel
Save