dokka: Could not read file exception with 1.8.10 + java 18

wDescribe the bug I am migrating my android library project to kotlin 1.8.10, but I started getting this exception:

Could not read file: /nvme/buildkite/builds/8192mb-4096cpu-android_603ae6562927_fc6092f/instacart/instacart-design-system-android/legacy-core/build/intermediates/compile_library_classes_jar/release/classes.jar!/com/instacart/design/itemcard/ItemCard.class; size in bytes: 3691; file type: CLASS
--
  | java.lang.UnsupportedOperationException: PermittedSubclasses requires ASM9

Expected behaviour

Not crashing would be very nice and polite

To Reproduce It seems to occur when a module refers to classes from another module (and both of these modules use dokka)

Dokka configuration

Kotlin 1.8.10
OpenJDK 64-Bit Server VM Zulu18.32+13-CA 

Installation

  • Operating system: macOS/Linux
  • Build tool: Gradle 8.0.2, happens on both CI and locally
  • Dokka version: 1.8.10 (I have another error if I try to only downgrade dokka to 1.7.20)

Additional context

Are you willing to provide a PR? Potentially yes, I might need some guidance to pinpoint the source thoug

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Reactions: 8
  • Comments: 15 (2 by maintainers)

Commits related to this issue

Most upvoted comments

Just updated a project to AGP 8.1.1 and Kotlin 1.9.10 and getting the same error when I try to publishToMavenLocal. We aren’t using anything fancy, just maven-publish plugin,

> Task :components:javaDocReleaseGeneration
Initializing plugins
Dokka is performing: documentation for :components
Validity check
Creating documentation models

WARN: Could not read file: compile_library_classes_jar/release/classes.jar!/com/x/x/components/ListItem.class; size in bytes: 12858; file type: CLASS
java.lang.UnsupportedOperationException: PermittedSubclasses requires ASM9
	at org.jetbrains.org.objectweb.asm.ClassVisitor.visitPermittedSubclass(ClassVisitor.java:266)
	at org.jetbrains.org.objectweb.asm.ClassReader.accept(ClassReader.java:684)
	at org.jetbrains.org.objectweb.asm.ClassReader.accept(ClassReader.java:402)
	at org.jetbrains.kotlin.load.kotlin.FileBasedKotlinClass.create(FileBasedKotlinClass.java:96)
	at org.jetbrains.kotlin.load.kotlin.VirtualFileKotlinClass$Factory$create$1.invoke(VirtualFileKotlinClass.kt:67)
	at org.jetbrains.kotlin.load.kotlin.VirtualFileKotlinClass$Factory$create$1.invoke(VirtualFileKotlinClass.kt:61)
	at org.jetbrains.kotlin.util.PerformanceCounter.time(PerformanceCounter.kt:101)
	at org.jetbrains.kotlin.load.kotlin.VirtualFileKotlinClass$Factory.create(VirtualFileKotlinClass.kt:61)
	at org.jetbrains.kotlin.load.kotlin.KotlinBinaryClassCache$Companion$getKotlinBinaryClassOrClassFileContent$aClass$1.compute(KotlinBinaryClassCache.kt:75)
	at org.jetbrains.kotlin.load.kotlin.KotlinBinaryClassCache$Companion$getKotlinBinaryClassOrClassFileContent$aClass$1.compute(KotlinBinaryClassCache.kt:73)
	at com.intellij.mock.MockApplication.runReadAction(MockApplication.java:178)
	at org.jetbrains.kotlin.load.kotlin.KotlinBinaryClassCache$Companion.getKotlinBinaryClassOrClassFileContent(KotlinBinaryClassCache.kt:73)
	at org.jetbrains.kotlin.load.kotlin.KotlinBinaryClassCache$Companion.getKotlinBinaryClassOrClassFileContent$default(KotlinBinaryClassCache.kt:59)
	at org.jetbrains.kotlin.load.kotlin.VirtualFileFinder.findKotlinClassOrContent(VirtualFileFinder.kt:34)
	at org.jetbrains.kotlin.load.java.lazy.descriptors.LazyJavaPackageScope$classes$1.invoke(LazyJavaPackageScope.kt:62)
	at org.jetbrains.kotlin.load.java.lazy.descriptors.LazyJavaPackageScope$classes$1.invoke(LazyJavaPackageScope.kt:54)
	at org.jetbrains.kotlin.storage.LockBasedStorageManager$MapBasedMemoizedFunction.invoke(LockBasedStorageManager.java:578)
	at org.jetbrains.kotlin.load.java.lazy.descriptors.LazyJavaPackageScope.findClassifier(LazyJavaPackageScope.kt:142)
	at org.jetbrains.kotlin.load.java.lazy.descriptors.LazyJavaPackageScope.getContributedClassifier(LazyJavaPackageScope.kt:132)
	at org.jetbrains.kotlin.load.java.lazy.descriptors.JvmPackageScope.getContributedClassifier(JvmPackageScope.kt:55)
	at org.jetbrains.kotlin.resolve.scopes.ChainedMemberScope.getContributedClassifier(ChainedMemberScope.kt:35)
	at org.jetbrains.kotlin.resolve.scopes.AbstractScopeAdapter.getContributedClassifier(AbstractScopeAdapter.kt:44)
	at org.jetbrains.kotlin.resolve.LazyExplicitImportScope.getContributedClassifier(LazyExplicitImportScope.kt:43)
	at org.jetbrains.kotlin.resolve.lazy.LazyImportScope$getClassifier$1.invoke(LazyImportScope.kt:256)
	at org.jetbrains.kotlin.resolve.lazy.LazyImportScope$getClassifier$1.invoke(LazyImportScope.kt:251)
	at org.jetbrains.kotlin.storage.LockBasedStorageManager.compute(LockBasedStorageManager.java:290)
	at org.jetbrains.kotlin.resolve.lazy.LazyImportScope.getClassifier(LazyImportScope.kt:251)
	at org.jetbrains.kotlin.resolve.lazy.LazyImportScope.getContributedClassifier(LazyImportScope.kt:247)
	at org.jetbrains.kotlin.resolve.scopes.utils.ScopeUtilsKt.findClassifier(ScopeUtils.kt:87)
	at org.jetbrains.kotlin.resolve.QualifiedExpressionResolver.resolveToPackageOrClassPrefix(QualifiedExpressionResolver.kt:516)
	at org.jetbrains.kotlin.resolve.QualifiedExpressionResolver.resolveToPackageOrClassPrefix$default(QualifiedExpressionResolver.kt:480)
	at org.jetbrains.kotlin.resolve.QualifiedExpressionResolver.resolveToPackageOrClass(QualifiedExpressionResolver.kt:468)
	at org.jetbrains.kotlin.resolve.QualifiedExpressionResolver.resolveQualifierPartListForType(QualifiedExpressionResolver.kt:141)
	at org.jetbrains.kotlin.resolve.QualifiedExpressionResolver.resolveDescriptorForType(QualifiedExpressionResolver.kt:129)
	at org.jetbrains.kotlin.resolve.TypeResolver.resolveDescriptorForType(TypeResolver.kt:931)
	at org.jetbrains.kotlin.resolve.TypeResolver$resolveTypeElement$1.visitUserType(TypeResolver.kt:246)
	at org.jetbrains.kotlin.psi.KtVisitorVoid.visitUserType(KtVisitorVoid.java:929)
	at org.jetbrains.kotlin.psi.KtVisitorVoid.visitUserType(KtVisitorVoid.java:21)
	at org.jetbrains.kotlin.psi.KtUserType.accept(KtUserType.java:42)
	at org.jetbrains.kotlin.psi.KtElementImplStub.accept(KtElementImplStub.java:60)
	at org.jetbrains.kotlin.resolve.TypeResolver.resolveTypeElement(TypeResolver.kt:244)
	at org.jetbrains.kotlin.resolve.TypeResolver.resolvePossiblyBareType(TypeResolver.kt:123)
	at org.jetbrains.kotlin.resolve.TypeResolver.resolveType(TypeResolver.kt:113)
	at org.jetbrains.kotlin.resolve.TypeResolver.resolveTypeProjections(TypeResolver.kt:884)
	at org.jetbrains.kotlin.resolve.TypeResolver.resolveTypeForClass(TypeResolver.kt:504)
	at org.jetbrains.kotlin.resolve.TypeResolver.resolveTypeForClassifier(TypeResolver.kt:471)
	at org.jetbrains.kotlin.resolve.TypeResolver$resolveTypeElement$1.visitUserType(TypeResolver.kt:262)
	at org.jetbrains.kotlin.psi.KtVisitorVoid.visitUserType(KtVisitorVoid.java:929)
	at org.jetbrains.kotlin.psi.KtVisitorVoid.visitUserType(KtVisitorVoid.java:21)
	at org.jetbrains.kotlin.psi.KtUserType.accept(KtUserType.java:42)
	at org.jetbrains.kotlin.psi.KtElementImplStub.accept(KtElementImplStub.java:60)
	at org.jetbrains.kotlin.resolve.TypeResolver.resolveTypeElement(TypeResolver.kt:244)
	at org.jetbrains.kotlin.resolve.TypeResolver.resolvePossiblyBareType(TypeResolver.kt:123)
	at org.jetbrains.kotlin.resolve.TypeResolver.resolveType(TypeResolver.kt:113)
	at org.jetbrains.kotlin.resolve.TypeResolver.resolveType(TypeResolver.kt:84)
	at org.jetbrains.kotlin.resolve.FunctionDescriptorResolver.resolveValueParameters(FunctionDescriptorResolver.kt:421)
	at org.jetbrains.kotlin.resolve.FunctionDescriptorResolver.createValueParameterDescriptors(FunctionDescriptorResolver.kt:298)
	at org.jetbrains.kotlin.resolve.FunctionDescriptorResolver.initializeFunctionDescriptorAndExplicitReturnType(FunctionDescriptorResolver.kt:191)
	at org.jetbrains.kotlin.resolve.FunctionDescriptorResolver.resolveFunctionDescriptor(FunctionDescriptorResolver.kt:124)
	at org.jetbrains.kotlin.resolve.FunctionDescriptorResolver.resolveFunctionDescriptor(FunctionDescriptorResolver.kt:91)
	at org.jetbrains.kotlin.resolve.lazy.descriptors.AbstractLazyMemberScope.getDeclaredFunctions(AbstractLazyMemberScope.kt:115)
	at org.jetbrains.kotlin.resolve.lazy.descriptors.AbstractLazyMemberScope.access$getDeclaredFunctions(AbstractLazyMemberScope.kt:36)
	at org.jetbrains.kotlin.resolve.lazy.descriptors.AbstractLazyMemberScope$declaredFunctionDescriptors$1.invoke(AbstractLazyMemberScope.kt:56)
	at org.jetbrains.kotlin.resolve.lazy.descriptors.AbstractLazyMemberScope$declaredFunctionDescriptors$1.invoke(AbstractLazyMemberScope.kt:56)
	at org.jetbrains.kotlin.storage.LockBasedStorageManager$MapBasedMemoizedFunction.invoke(LockBasedStorageManager.java:578)
	at org.jetbrains.kotlin.storage.LockBasedStorageManager$MapBasedMemoizedFunctionToNotNull.invoke(LockBasedStorageManager.java:651)
	at org.jetbrains.kotlin.resolve.lazy.descriptors.AbstractLazyMemberScope.doGetFunctions(AbstractLazyMemberScope.kt:96)
	at org.jetbrains.kotlin.resolve.lazy.descriptors.AbstractLazyMemberScope.access$doGetFunctions(AbstractLazyMemberScope.kt:36)
	at org.jetbrains.kotlin.resolve.lazy.descriptors.AbstractLazyMemberScope$functionDescriptors$1.invoke(AbstractLazyMemberScope.kt:49)
	at org.jetbrains.kotlin.resolve.lazy.descriptors.AbstractLazyMemberScope$functionDescriptors$1.invoke(AbstractLazyMemberScope.kt:49)
	at org.jetbrains.kotlin.storage.LockBasedStorageManager$MapBasedMemoizedFunction.invoke(LockBasedStorageManager.java:578)
	at org.jetbrains.kotlin.storage.LockBasedStorageManager$MapBasedMemoizedFunctionToNotNull.invoke(LockBasedStorageManager.java:651)
	at org.jetbrains.kotlin.resolve.lazy.descriptors.AbstractLazyMemberScope.getContributedFunctions(AbstractLazyMemberScope.kt:92)
	at org.jetbrains.kotlin.resolve.lazy.descriptors.AbstractLazyMemberScope.computeDescriptorsFromDeclaredElements(AbstractLazyMemberScope.kt:227)
	at org.jetbrains.kotlin.resolve.lazy.descriptors.LazyPackageMemberScope.getContributedDescriptors(LazyPackageMemberScope.kt:44)
	at org.jetbrains.kotlin.resolve.scopes.ResolutionScope$DefaultImpls.getContributedDescriptors$default(ResolutionScope.kt:50)
	at org.jetbrains.dokka.base.translators.descriptors.DokkaDescriptorVisitor.getDescriptorsWithKind(DefaultDescriptorToDocumentableTranslator.kt:687)
	at org.jetbrains.dokka.base.translators.descriptors.DokkaDescriptorVisitor$visitPackageFragmentDescriptor$2.invokeSuspend(DefaultDescriptorToDocumentableTranslator.kt:131)
	at org.jetbrains.dokka.base.translators.descriptors.DokkaDescriptorVisitor$visitPackageFragmentDescriptor$2.invoke(DefaultDescriptorToDocumentableTranslator.kt)
	at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:91)
	at kotlinx.coroutines.CoroutineScopeKt.coroutineScope(CoroutineScope.kt:194)
	at org.jetbrains.dokka.base.translators.descriptors.DokkaDescriptorVisitor.visitPackageFragmentDescriptor(DefaultDescriptorToDocumentableTranslator.kt:130)
	at org.jetbrains.dokka.base.translators.descriptors.DefaultDescriptorToDocumentableTranslator$$special$$inlined$parallelMap$1$1.invokeSuspend(parallelCollectionOperations.kt:19)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:738)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)

We’re running into this issue too, but I’m not convinced it’s purely a Dokka issue. The step that fails during execution, com.android.build.gradle.tasks.JavaDocGenerationTask$DokkaWorkAction, looks to come from AGP. And it still errors after removing Dokka related plugins, Gradle tasks, etc.

I’ve tried creating a minimal repo that recreates this, but I haven’t had any luck yet. All of the files that it shows in the errors. are sealed classes, but not all sealed classes are erroring.

I see the same error like @nate-eisner with Java 17 installed.

Among other things because JDK 17 will soon be necessary to run the android gradle plugin

AGP 8.0.0 is stable now so we are now there.

If you have this problem, you can temporarily disable this task. In my case this happened during maven publishing, I disabled this task and it worked fine.

// https://github.com/Kotlin/dokka/issues/2956
tasks.matching { task ->
  task.name.contains("javaDocReleaseGeneration", ignoreCase = true)
}.configureEach {
  enabled = false
}

interesting, so we have had more time to dig into this as we need to find a solution to adopt compose 1.5. We made some updates to our project -> Compile SDK 34 + Java 18 + Kotlin 1.8.22 + paparazzi 1.3.0 + AGP 8.1 + vanniktech publish plugin 0.25.3

This has allowed us to dig deeper into the doc generation as we still see this issue.

we are indeed using javaDocReleaseGeneration (via the vanniktech publish plugin)

our `solution’ has been to disable this task for the one specific module where this happens This is an old part of our library we don’t really care about, so this is an acceptable compromise to unblock the updates. The weird thing is that there isn’t anything that remarkable about this module. it depends on other modules, but so do other parts of our library, without causing this issue.

So I have tried to use dokkaHtmlMultiModule instead, if only to help understand what’s happening. This works! My suspicion is that we are hitting a variation of https://github.com/Kotlin/dokka/issues/1833

We will investigate further and decided whether to contribute a fix at the vanniktech level or to migrate to our own internal publish plugin (we already have one, still incubating). Hard to know for sure without digging more into its codebase, but I think that the core issue is due to how vanniktech declares dependencies between modules.

Thanks for researching it!

Execution failed for task ':legacy-bridge:javaDocReleaseGeneration'.
> A failure occurred while executing com.android.build.gradle.tasks.JavaDocGenerationTask$DokkaWorkAction
   > java.lang.reflect.InvocationTargetException (no error message)

This is interesting. Are you using a task called javaDocReleaseGeneration? Does it come from AGP? If yes, then you are not really using Dokka (at least not directly), as Dokka’s tasks are dokkaHtml and dokkaHtmlMultiModule.

AGP 7.1 did start bundling a very old version Dokka, which led to a bunch of compatibility problems for existing Dokka users (see #2472), so here there might be a similar problem here.

Judging by the stacktrace, it looks like the version of the kotlin compiler used to generate the docs does not support Java 18. If AGP bundles a very outdated version of Dokka, no wonder!


I’ve just tried running Dokka with Java 19, and it works just fine:

plugins {
    kotlin("jvm") version "1.8.10"
    id("org.jetbrains.dokka") version "1.8.10"
}

tasks.named("compileKotlin", org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile::class.java) {
    compilerOptions {
        jvmTarget.set(JvmTarget.JVM_19)
    }
}

Log:

[ignat@workstation dokka-debug-kts]$ java -version

openjdk version "19.0.2" 2023-01-17
OpenJDK Runtime Environment Temurin-19.0.2+7 (build 19.0.2+7)
OpenJDK 64-Bit Server VM Temurin-19.0.2+7 (build 19.0.2+7, mixed mode, sharing)

[ignat@workstation dokka-debug-kts]$ ./gradlew dokkaHtml

> Task :dokkaHtml
Initializing plugins
Dokka is performing: documentation for dokka-debug-kts
Validity check
Creating documentation models
Transforming documentation model before merging
Merging documentation models
Transforming documentation model after merging
Creating pages
Transforming pages
Rendering
Running post-actions


BUILD SUCCESSFUL in 10s
1 actionable task: 1 executed

So it might be an upstream bug of AGP.

Can you share which task you’re using just to make sure?

I tried to toggle more features on/off it turns out that I don’t have this exception if I set the project’s java language level to 11 (instead of 18 previously) both jdkVersion.set(x) for dokka and

android {
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_X
        targetCompatibility JavaVersion.VERSION_X
    }
    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_X.toString()
    }
}

for compilation modules

reverting to 11 is something we would really like NOT to have to do though. Among other things because JDK 17 will soon be necessary to run the android gradle plugin