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

Exception in thread "main" java.lang.NoSuchFieldError: FUN_KEYWORD #876

Closed
lechen26 opened this issue Aug 30, 2020 · 8 comments
Closed

Exception in thread "main" java.lang.NoSuchFieldError: FUN_KEYWORD #876

lechen26 opened this issue Aug 30, 2020 · 8 comments
Assignees
Labels
Milestone

Comments

@lechen26
Copy link

After upgrade ktlint to 38.1 (from 37.2) we get the following error:

> Task :ktlintFormat
Exception in thread "main" java.lang.NoSuchFieldError: FUN_KEYWORD
        at com.pinterest.ktlint.core.ast.ElementType.<clinit>(ElementType.kt:154)
        at com.pinterest.ktlint.ruleset.experimental.SpacingAroundAngleBracketsRule.<clinit>(SpacingAroundAngleBracketsRule.kt:94)
        at com.pinterest.ktlint.ruleset.experimental.ExperimentalRuleSetProvider.get(ExperimentalRuleSetProvider.kt:18)
        at com.pinterest.ktlint.KtlintCommandLine.loadRulesets(Main.kt:550)
        at com.pinterest.ktlint.KtlintCommandLine.run(Main.kt:222)
        at com.pinterest.ktlint.Main.main(Main.kt:62)

thanks
Chen

@romtsn
Copy link
Collaborator

romtsn commented Aug 30, 2020

Have you also updated kotlin to 1.4?

@zarebski-m
Copy link

I also get this error with ktlint 0.38.1 and Kotlin 1.4.0. No problem with Kotlin 1.3.72.

> Task :module:ktlintKotlinScriptCheck FAILED
Exception in thread "main" java.lang.NoSuchFieldError: FUN_KEYWORD
        at com.pinterest.ktlint.core.ast.ElementType.<clinit>(ElementType.kt:154)
        at com.pinterest.ktlint.ruleset.experimental.SpacingAroundAngleBracketsRule.<clinit>(SpacingAroundAngleBracketsRule.kt:94)
        at com.pinterest.ktlint.ruleset.experimental.ExperimentalRuleSetProvider.get(ExperimentalRuleSetProvider.kt:18)
        at com.pinterest.ktlint.KtlintCommandLine.loadRulesets(Main.kt:550)
        at com.pinterest.ktlint.KtlintCommandLine.run(Main.kt:222)
        at com.pinterest.ktlint.Main.main(Main.kt:62)

@eheinen
Copy link

eheinen commented Aug 31, 2020

Yeah, same here. I upgraded Kotlin to 1.4.0 and I cannot run the klint check anymore using Gradle.

@Tapchicoma Tapchicoma added bug and removed question labels Aug 31, 2020
@Tapchicoma Tapchicoma added this to the 0.39.0 milestone Aug 31, 2020
@Tapchicoma
Copy link
Collaborator

Do you have .gradle.kts files in your project?

@Tapchicoma
Copy link
Collaborator

Could you attach here file that failing with above error?

@zarebski-m
Copy link

I don't know if this is helpful, but ktlint fails on the following file (which is part of a bigger multi-module project):

plugins {
    application
    id("org.springframework.boot")
    id("com.gorylenko.gradle-git-properties")
}

dependencies {
    implementation("org.springframework.boot:spring-boot-starter-data-mongodb")
    implementation("org.springframework.boot:spring-boot-starter-web")
    implementation("org.springframework.cloud:spring-cloud-starter-stream-rabbit")
    implementation("org.springframework.cloud:spring-cloud-starter-vault-config")
    implementation("org.springframework.boot:spring-boot-starter-actuator")
    implementation("io.sentry:sentry-logback")
    implementation("mysql:mysql-connector-java")

    testImplementation("org.springframework.boot:spring-boot-starter-test")
    testImplementation("org.springframework.cloud:spring-cloud-stream-test-support")
    testImplementation("org.spockframework:spock-core")
    testImplementation("org.spockframework:spock-spring")
    testImplementation("com.h2database:h2")

    compileOnly("org.projectlombok:lombok")
    annotationProcessor("org.projectlombok:lombok")
    annotationProcessor("org.springframework.boot:spring-boot-configuration-processor")
}

springBoot {
    buildInfo()
}

application {
    mainClassName = "XXX" // redacted
}

tasks {
    jar { enabled = true }
    bootJar { archiveClassifier.set("app") }
    processResources {
        filesMatching(listOf("sentry.properties")) {
            expand(project.properties)
        }
    }
}

What might be helpful as well is that I'm not using pinterest/ktlint directly, but rather via JLLeitschuh/ktlint-gradle with the following configuration:

ktlint {
    version.set("0.38.1")
    verbose.set(true)
    disabledRules.set(setOf("import-ordering", "no-wildcard-imports"))
}

@Tapchicoma Tapchicoma self-assigned this Sep 1, 2020
@Tapchicoma
Copy link
Collaborator

I could reproduce it as well on my work project. Most probably related to ktlint-gradle plugin and not KtLint itself.

@Tapchicoma
Copy link
Collaborator

Please check this comment in ktlint-gradle: JLLeitschuh/ktlint-gradle#383 (comment)

Most probably this is your case and why it is not working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants