AbstractMethodError when using kotlinc -Xplugin


#1

Hi, I’m trying to use command line compile with kapt plugin

I’m not sure how to specify the command line arguments appropriately. What I’m doing is giving me the error below (and I get the same error explicitly specifying the plugin id and options).

Any pointers / examples on using plugins with kotlinc ?

Thanks, Rob.

kotlinc -d target -cp ~/.m2/repository/javax/persistence/persistence-api/1.0/persistence-api-1.0.jar -Xplugin /home/rob/.m2/repository/org/jetbrains/kotlin/kotlin-annotation-processing/1.0.4/kotlin-annotation-processing-1.0.4.jar main/java/
exception: java.lang.AbstractMethodError: org.jetbrains.kotlin.annotation.processing.AnnotationProcessingComponentRegistrar.registerProjectComponents(Lcom/intellij/mock/MockProject;Lorg/jetbrains/kotlin/config/CompilerConfiguration;)V
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment.(KotlinCoreEnvironment.kt:153)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment.(KotlinCoreEnvironment.kt:98)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.createForProduction(KotlinCoreEnvironment.kt:301)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.createCoreEnvironment(K2JVMCompiler.kt:228)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:194)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:52)
at org.jetbrains.kotlin.cli.common.CLICompiler.exec(CLICompiler.java:199)
at org.jetbrains.kotlin.cli.common.CLICompiler.exec(CLICompiler.java:154)
at org.jetbrains.kotlin.cli.common.CLICompiler.exec(CLICompiler.java:66)
at org.jetbrains.kotlin.cli.common.CLICompiler.doMainNoExit(CLICompiler.java:305)
at org.jetbrains.kotlin.cli.common.CLICompiler.doMain(CLICompiler.java:295)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler$Companion.main(K2JVMCompiler.kt:262)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.main(K2JVMCompiler.kt)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.jetbrains.kotlin.preloading.Preloader.run(Preloader.java:73)
at org.jetbrains.kotlin.preloading.Preloader.main(Preloader.java:35)


#2

So my ComponentRegistrar expects project: com.intellij.mock.MockProject … and AnnotationProcessingComponentRegistrar in version 1.0.4 expects a project: org.jetbrains.kotlin.com.intellij.mock.MockProject

So I’d say that is why I see the AbstractMethodError.

Note sure why though, I’m using 1.0.4 of kotlin-compiler and kotlin-annotation-processing so not sure.


#3

I have logged this as https://youtrack.jetbrains.com/issue/KT-14478

I suspect kotlin-annotation-processing is designed to be used as a “gradle subplugin” rather than a compile plugin and perhaps that is why the MockProject is from 2 different packages.