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

Fix TypeNotPresentException in projects without KGP #2890

Merged
merged 1 commit into from
Feb 24, 2023

Conversation

IgnatBeresnev
Copy link
Member

@IgnatBeresnev IgnatBeresnev commented Feb 24, 2023

Regression from 0a09318#diff-127cb17801c64a32309502eaee33392ad749494ba8022bef47e8002359ea1b8eL17

Before, it was loading a specific java class, so it failed with NoClassDefFoundError that was caught, and we returned null.

With Kotlin DSL, findByType() is trying to load reified T through Class#getGenericSuperclass, which throws TypeNotPresentException.

We don't expect that TypeNotPresentException will be thrown, so it's not caught and the user project is failing with

Caused by: java.lang.TypeNotPresentException: Type org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension not present
        at org.gradle.api.reflect.TypeOf.captureTypeArgument(TypeOf.java:301)
        at org.gradle.api.reflect.TypeOf.<init>(TypeOf.java:97)
        at org.jetbrains.dokka.gradle.UtilsKt$kotlinOrNull$$inlined$findByType$1.<init>(TypeOfExtensions.kt:28)
        at org.jetbrains.dokka.gradle.UtilsKt.getKotlinOrNull(utils.kt:43)

This can be reproduced on projects that don't have KGP applied.

@IgnatBeresnev IgnatBeresnev merged commit 9297e6d into master Feb 24, 2023
@IgnatBeresnev IgnatBeresnev deleted the fix-kotlin-or-null branch February 24, 2023 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants