Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin crashes with IntelliJ compiler #4

Closed
josdejong opened this issue Jun 12, 2018 · 11 comments
Closed

Plugin crashes with IntelliJ compiler #4

josdejong opened this issue Jun 12, 2018 · 11 comments
Assignees
Labels
bug Something isn't working

Comments

@josdejong
Copy link

Thanks for writing and sharing this plugin Fabian!

Running our application using gradle on the command line works fine, but we have an issue running the plugin inside IntelliJ IDEA, using kotlin version 1.2.41 and nl.fabianm.kotlin.plugin.generated version 1.0:

Error:Kotlin: [Internal Error] java.lang.IllegalStateException: The provided plugin nl.fabianm.kotlin.plugin.generated.GeneratedComponentRegistrar is not compatible with this version of compiler
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment.<init>(KotlinCoreEnvironment.kt:186)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment.<init>(KotlinCoreEnvironment.kt:119)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.createForProduction(KotlinCoreEnvironment.kt:418)
	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.createCoreEnvironment(K2JVMCompiler.kt:265)
	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:154)
	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:63)
	at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.java:107)
	at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.java:51)
	at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:96)
	at org.jetbrains.kotlin.daemon.CompileServiceImpl$compile$$inlined$ifAlive$lambda$1.invoke(CompileServiceImpl.kt:399)
	at org.jetbrains.kotlin.daemon.CompileServiceImpl$compile$$inlined$ifAlive$lambda$1.invoke(CompileServiceImpl.kt:98)
	at org.jetbrains.kotlin.daemon.CompileServiceImpl$doCompile$$inlined$ifAlive$lambda$2.invoke(CompileServiceImpl.kt:920)
	at org.jetbrains.kotlin.daemon.CompileServiceImpl$doCompile$$inlined$ifAlive$lambda$2.invoke(CompileServiceImpl.kt:98)
	at org.jetbrains.kotlin.daemon.common.DummyProfiler.withMeasure(PerfUtils.kt:137)
	at org.jetbrains.kotlin.daemon.CompileServiceImpl.checkedCompile(CompileServiceImpl.kt:950)
	at org.jetbrains.kotlin.daemon.CompileServiceImpl.doCompile(CompileServiceImpl.kt:919)
	at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:397)
	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 sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:357)
	at sun.rmi.transport.Transport$1.run(Transport.java:200)
	at sun.rmi.transport.Transport$1.run(Transport.java:197)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
	at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:573)
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:835)
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:688)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:687)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.AbstractMethodError: nl.fabianm.kotlin.plugin.generated.GeneratedComponentRegistrar.registerProjectComponents(Lcom/intellij/mock/MockProject;Lorg/jetbrains/kotlin/config/CompilerConfiguration;)V
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment.<init>(KotlinCoreEnvironment.kt:184)
	... 33 more

Any ideas how to get it working in IntelliJ?

@fabianishere fabianishere self-assigned this Jun 12, 2018
@fabianishere fabianishere added the bug Something isn't working label Jun 12, 2018
@fabianishere fabianishere changed the title java.lang.IllegalStateException: The provided plugin nl.fabianm.kotlin.plugin.generated.GeneratedComponentRegistrar is not compatible with this version of compiler Plugin crashes with IntelliJ compiler Jun 12, 2018
@fabianishere
Copy link
Owner

We also tried this and got the error. This is caused by the fact that this compiler plugin is built against the compiler-embedable artifact which uses the org.jetbrains.kotlin.com.intellij.mock.MockProject class while the actual compiler artifact used by IntelliJ uses the com.intellij.mock.MockProject class instead.

If we switch to the compiler artifact, the build will stop working for Gradle-only builds. A solution might be to write an IntelliJ plugin to load this plugin as seen in the Kotlin source (https://github.com/JetBrains/kotlin/tree/master/plugins/allopen). However, this requires some libraries which are not published as far as I know.

Jacoco recently landed support for recognizing Kotlin-generated code, so I would suggest using one of their snapshots builds (0.8.2-SNAPSHOT+) instead if possible. It has the advantage of not polluting your code with lombok.Generated annotations.

In Gradle, you can do that as follows:

repositories {
    // This repository is needed to get the latest snapshot of Jacoco
    maven { url = "https://oss.sonatype.org/content/repositories/snapshots" }
}

jacoco {
     toolVersion = '0.8.2-SNAPSHOT'
}

@josdejong
Copy link
Author

Thanks for the fast reply, we're going to to give the snapshot version a try, will let you know.

I hope you're having a good time at the Delft University of Technology, I've studied there too :)

@josdejong
Copy link
Author

@fabianishere JaCoCo 0.8.2-SNAPSHOT works like a charm, thanks for the advice!

@fabianishere
Copy link
Owner

Awesome! I will keep the issue open for future visitors

@fabianishere fabianishere reopened this Jun 14, 2018
@josdejong
Copy link
Author

Ah, sure, sorry

@x0a1b
Copy link

x0a1b commented Jul 16, 2018

I have Kotlin 1.2.51 with my IntelliJ and I am getting same error:

Error:Kotlin: [Internal Error] java.lang.IllegalStateException: The provided plugin nl.fabianm.kotlin.plugin.generated.GeneratedComponentRegistrar is not compatible with this version of compiler
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment.<init>(KotlinCoreEnvironment.kt:188)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment.<init>(KotlinCoreEnvironment.kt:120)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.createForProduction(KotlinCoreEnvironment.kt:433)
	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.createCoreEnvironment(K2JVMCompiler.kt:295)
	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:147)
	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:51)
	at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.java:95)
	at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.java:50)
	at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:88)
	at org.jetbrains.kotlin.daemon.CompileServiceImpl$compile$$inlined$ifAlive$lambda$1.invoke(CompileServiceImpl.kt:399)
	at org.jetbrains.kotlin.daemon.CompileServiceImpl$compile$$inlined$ifAlive$lambda$1.invoke(CompileServiceImpl.kt:98)
	at org.jetbrains.kotlin.daemon.CompileServiceImpl$doCompile$$inlined$ifAlive$lambda$2.invoke(CompileServiceImpl.kt:927)
	at org.jetbrains.kotlin.daemon.CompileServiceImpl$doCompile$$inlined$ifAlive$lambda$2.invoke(CompileServiceImpl.kt:98)
	at org.jetbrains.kotlin.daemon.common.DummyProfiler.withMeasure(PerfUtils.kt:137)
	at org.jetbrains.kotlin.daemon.CompileServiceImpl.checkedCompile(CompileServiceImpl.kt:957)
	at org.jetbrains.kotlin.daemon.CompileServiceImpl.doCompile(CompileServiceImpl.kt:926)
	at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:397)
	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 sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:357)
	at sun.rmi.transport.Transport$1.run(Transport.java:200)
	at sun.rmi.transport.Transport$1.run(Transport.java:197)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
	at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:573)
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:835)
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:688)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:687)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.AbstractMethodError
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment.<init>(KotlinCoreEnvironment.kt:186)
	... 33 more

Suggestions?

@fabianishere
Copy link
Owner

fabianishere commented Jul 16, 2018

@x0a1b This plugin cannot support IntelliJ at the moment due to limitations on their platform. I suggest using a snapshot version of JaCoCo if possible or using Gradle to build the project instead.

@fabianishere
Copy link
Owner

I've reported this issue to the Kotlin issue tracker. See https://youtrack.jetbrains.com/issue/KT-25596

@x0a1b
Copy link

x0a1b commented Jul 19, 2018

@fabianishere thanks for proactively jump onto this 👍 hopefully they will fix it sooner than later.

@henrik242
Copy link

henrik242 commented May 2, 2019

@fabianishere @josdejong Any progress on this? I'm seeing the same with https://github.com/henrik242/kotlin-really-allopen and updating to jacoco 0.8.3 doesn't seem to help.

@fabianishere
Copy link
Owner

fabianishere commented May 2, 2019

@henrik242 I think in order to make it work, you need to build an IntelliJ plugin (see https://github.com/JetBrains/kotlin/tree/master/plugins/kotlin-serialization/kotlin-serialization-ide). However, it seems like some of the libraries they use for this are not published on Maven.

As a workaround, you could delegate the build in IntelliJ to Gradle (Settings - Build, Execution, Deployment - Build Tools - Gradle - Runner - tick Delegate IDE build/run actions to Gradle).

fabianishere added a commit that referenced this issue May 3, 2019
This change adds a plugin for IntelliJ that replaces the Gradle plugin
jar with its own shaded compiler plugin in order to support the Kotlin
compiler within IntelliJ.

Fixes #4
fabianishere added a commit that referenced this issue May 3, 2019
This change adds a plugin for IntelliJ that replaces the Gradle plugin
jar with its own shaded compiler plugin in order to support the Kotlin
compiler within IntelliJ.

Fixes #4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants