edvin / tornadofx-idea-plugin

TornadoFX Plugin for IntelliJ IDEA
Apache License 2.0
72 stars 20 forks source link

[BUG] java.lang.NoClassDefFoundError causes freeze of code analysis #113

Open RaphaelTarita opened 3 years ago

RaphaelTarita commented 3 years ago

I don't know what exactly I've done to cause this, but as of now, I can't perform the standard IntelliJ code analysis in my TornadoFX project as long as the TornadoFX plugin is active. I've tried everything, from restarting the IDE, disabling and enabling the plugin and also restarting the PC.

The IDE Error Log shows the following stacktrace of the error caused by the TornadoFX plugin:

java.lang.NoClassDefFoundError: javafx/scene/paint/Color
    at no.tornado.tornadofx.idea.annotator.CSSColorAnnotator.toColorType(CSSColorAnnotator.kt:166)
    at no.tornado.tornadofx.idea.annotator.CSSColorAnnotator.annotateTFXColor(CSSColorAnnotator.kt:113)
    at no.tornado.tornadofx.idea.annotator.CSSColorAnnotator.handelProperty(CSSColorAnnotator.kt:69)
    at no.tornado.tornadofx.idea.annotator.CSSColorAnnotator.handelProperty$default(CSSColorAnnotator.kt:66)
    at no.tornado.tornadofx.idea.annotator.CSSColorAnnotator.annotate(CSSColorAnnotator.kt:61)
    at com.intellij.codeInsight.daemon.impl.DefaultHighlightVisitor.runAnnotators(DefaultHighlightVisitor.java:136)
    at com.intellij.codeInsight.daemon.impl.DefaultHighlightVisitor.visit(DefaultHighlightVisitor.java:116)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.runVisitors(GeneralHighlightingPass.java:338)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.lambda$collectHighlights$5(GeneralHighlightingPass.java:271)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.analyzeByVisitors(GeneralHighlightingPass.java:297)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.lambda$analyzeByVisitors$6(GeneralHighlightingPass.java:300)
    at com.github.izhangzhihao.rainbow.brackets.visitor.RainbowHighlightVisitor.analyze(RainbowHighlightVisitor.kt:35)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.analyzeByVisitors(GeneralHighlightingPass.java:300)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.lambda$analyzeByVisitors$6(GeneralHighlightingPass.java:300)
    at com.intellij.codeInsight.daemon.impl.DefaultHighlightVisitor.analyze(DefaultHighlightVisitor.java:96)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.analyzeByVisitors(GeneralHighlightingPass.java:300)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.collectHighlights(GeneralHighlightingPass.java:268)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.collectInformationWithProgress(GeneralHighlightingPass.java:214)
    at com.intellij.codeInsight.daemon.impl.ProgressableTextEditorHighlightingPass.doCollectInformation(ProgressableTextEditorHighlightingPass.java:80)
    at com.intellij.codeHighlighting.TextEditorHighlightingPass.collectInformation(TextEditorHighlightingPass.java:54)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$doRun$1(PassExecutorService.java:399)
    at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1110)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$doRun$2(PassExecutorService.java:392)
    at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:629)
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:581)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:60)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.doRun(PassExecutorService.java:391)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$run$0(PassExecutorService.java:367)
    at com.intellij.openapi.application.impl.ReadMostlyRWLock.executeByImpatientReader(ReadMostlyRWLock.java:170)
    at com.intellij.openapi.application.impl.ApplicationImpl.executeByImpatientReader(ApplicationImpl.java:182)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.run(PassExecutorService.java:365)
    at com.intellij.concurrency.JobLauncherImpl$VoidForkJoinTask$1.exec(JobLauncherImpl.java:181)
    at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
    at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
    at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
    at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
    at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)
Caused by: java.lang.ClassNotFoundException: javafx.scene.paint.Color PluginClassLoader[PluginDescriptor(name=TornadoFX, id=no.tornado.tornadofx.idea, path=D:\JetBrains\IntelliJ\config\plugins\tornadofx-idea-plugin, version=1.7.20)] com.intellij.ide.plugins.cl.PluginClassLoader@32755498
    at com.intellij.ide.plugins.cl.PluginClassLoader.loadClass(PluginClassLoader.java:95)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
    ... 37 more

This error apparently causes the IDE code analysis to freeze or hang. In the top right corner of the editor, you normally see a badge with the number of warnings and errors in the current file. This badge is stuck to just displaying "Analyzing...". The "Problems" pane also just shows "Analyzing [File]". While this analysis is stuck, I don't have any error highlighting and also a greatly reduced syntax highlighting (just like the version you ususally see when you just opened up a project).

As I said, I don't really know what caused the error, but it seems to be linked to the file I was working on. For further information, here's that file:

package com.example

import javafx.scene.paint.Color
import javafx.scene.paint.Paint
import tornadofx.*

class Styles : Stylesheet() {
    companion object {
        // ======color palette======
        // b / w
        val white: Paint = Color.WHITE
        val textWhite: Paint = Color.ANTIQUEWHITE
        val black: Paint = Color.BLACK
        val textBlack: Paint = c("#0e1111")

        // primary
        val primary: Paint = c("#304ffe")
        val primaryLight: Paint = c("#7a7cff")
        val primaryDark: Paint = c("#0026ca")

        // secondary
        val secondary: Paint = c("#ff4081")
        val secondaryLight: Paint = c("#ff79b0")
        val secondaryDark: Paint = c("#c60055")
    }

    init {
        button {
            backgroundRadius += box(20.px)
            backgroundColor += primary
            textFill = textWhite

            and(hover) {
                backgroundColor += secondary
            }

            and(pressed) {
                backgroundColor += primaryDark
            }
        }

        tab {
            backgroundColor += white
            backgroundRadius += box(10.px, 10.px, 0.px, 0.px)

            and(selected) {
                backgroundColor += primaryLight
            }
        }
    }
}

Some version data:

RaphaelTarita commented 3 years ago

I tried a lot of other things (like removing the imports and all references to javafx.scene.paint.Color/Paint), but ultimately, uninstalling and re-installing the TornadoFX Plugin resolved the problem. I still don't know why it happened or how long it will take until I run into the same issue again, but it is a working quick fix.

Edit: Nope, wrong. Apparently, after uninstalling and reinstalling the plugin, it was still set to "disabled". That's why everything worked fine. Re-enabling the plugin brought back all problems.

iguanastin commented 3 years ago

I'm having the same issue exactly. Hope this gets fixed soon, as it's a major annoyance.

arm32x commented 3 years ago

I'm having the same issue. Could it be related to the package name change in Java 9 (com.sun.javafx to javafx)? As far as I know, the bundled JRE is Java 8, so it wouldn't have the new package.

RaphaelTarita commented 3 years ago

I'm not sure about this. The javafx change in Java 9 is a major topic in tornadofx, but it has been addressed. Now of course, this does not necessarily have to be the case for the IntelliJ plugin, but the logical implication of this would be that the plugin would fail for any symbol imported from javafx. Which is not the case AFAIK.

But on the other hand it would be a reasonable explanation. I really don't know.

liugangnhm commented 3 years ago

use IDEA with java8 bundled can fix the issue

dkowis commented 3 years ago

Yeah. I can't keep using java8 as the javafx community has moved on. I will have to disable the plugin :(

liugangnhm commented 3 years ago

Yeah. I can't keep using java8 as the javafx community has moved on. I will have to disable the plugin :(

you can delete that feature from your plugin jar file:

<annotator language="kotlin" implementationClass="no.tornado.tornadofx.idea.annotator.CSSColorAnnotator" order="first"/>

tornadofx-idea-plugin\lib\tornadofx-idea-plugin-1.7.17.2.jar\META-INF\plugin.xml

misty000 commented 3 years ago

if use java 8 copy jdk1.8.0/jre/lib/ext/jfxrt.jar to IntelliJIdea/plugins/tornadofx-idea-plugin/lib restart idea

lhDream commented 1 year ago

if use java 9+ install JavaFX Runtime for plugins restart idea