Migrating from kapt to ksp gives error
See original GitHub issueI have a working Kapt processor, and I’ve move it over to KSP, its very basic, it just parses an json file and generates classes using KotlinPoet.
I’m using kotlin 1.5.31, ksp 1.5.31-1.0.0, and kotlinpoet 1.10.2
However, when running the ksp task never finished. I get the following error
Task :xxx-client:kspMyBuildFlavorReleaseKotlin FAILED
e: java.lang.StackOverflowError
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1017)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:800)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:698)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:621)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:579)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
at org.jetbrains.kotlin.storage.LockBasedStorageManager$MapBasedMemoizedFunction.invoke(LockBasedStorageManager.java:593)
at org.jetbrains.kotlin.storage.LockBasedStorageManager$MapBasedMemoizedFunctionToNotNull.invoke(LockBasedStorageManager.java:651)
at org.jetbrains.kotlin.resolve.lazy.descriptors.AbstractLazyMemberScope.getContributedVariables(AbstractLazyMemberScope.kt:139)
at org.jetbrains.kotlin.resolve.lazy.descriptors.LazyClassMemberScope.getContributedVariables(LazyClassMemberScope.kt:380)
at org.jetbrains.kotlin.resolve.lazy.LazyDeclarationResolver$resolveToDescriptor$1.visitProperty(LazyDeclarationResolver.kt:182)
at org.jetbrains.kotlin.resolve.lazy.LazyDeclarationResolver$resolveToDescriptor$1.visitProperty(LazyDeclarationResolver.kt:94)
at org.jetbrains.kotlin.psi.KtProperty.accept(KtProperty.java:58)
at org.jetbrains.kotlin.resolve.lazy.LazyDeclarationResolver.resolveToDescriptor(LazyDeclarationResolver.kt:94)
at org.jetbrains.kotlin.resolve.lazy.LazyDeclarationResolver.resolveToDescriptor(LazyDeclarationResolver.kt:91)
at org.jetbrains.kotlin.resolve.lazy.ResolveSession.resolveToDescriptor(ResolveSession.java:368)
at com.google.devtools.ksp.processing.impl.ResolverImpl.resolveDeclaration(ResolverImpl.kt:440)
at com.google.devtools.ksp.symbol.impl.kotlin.KSPropertyDeclarationImpl$propertyDescriptor$2.invoke(KSPropertyDeclarationImpl.kt:43)
at com.google.devtools.ksp.symbol.impl.kotlin.KSPropertyDeclarationImpl$propertyDescriptor$2.invoke(KSPropertyDeclarationImpl.kt:42)
at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
at com.google.devtools.ksp.symbol.impl.kotlin.KSPropertyDeclarationImpl.getPropertyDescriptor(KSPropertyDeclarationImpl.kt:42)
at com.google.devtools.ksp.symbol.impl.kotlin.KSPropertyDeclarationImpl.access$getPropertyDescriptor(KSPropertyDeclarationImpl.kt:34)
at com.google.devtools.ksp.symbol.impl.kotlin.KSPropertyDeclarationImpl$getter$2.invoke(KSPropertyDeclarationImpl.kt:68)
at com.google.devtools.ksp.symbol.impl.kotlin.KSPropertyDeclarationImpl$getter$2.invoke(KSPropertyDeclarationImpl.kt:65)
at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
at com.google.devtools.ksp.symbol.impl.kotlin.KSPropertyDeclarationImpl.getGetter(KSPropertyDeclarationImpl.kt:65)
at com.google.devtools.ksp.processing.impl.ResolverImpl$collectAnnotatedSymbols$visitor$1.visitPropertyDeclaration(ResolverImpl.kt:325)
at com.google.devtools.ksp.processing.impl.ResolverImpl$collectAnnotatedSymbols$visitor$1.visitPropertyDeclaration(ResolverImpl.kt:288)
at com.google.devtools.ksp.symbol.impl.kotlin.KSPropertyDeclarationImpl.accept(KSPropertyDeclarationImpl.kt:103)
at com.google.devtools.ksp.processing.impl.ResolverImpl$collectAnnotatedSymbols$visitor$1.visitClassDeclaration(ResolverImpl.kt:302)
at com.google.devtools.ksp.processing.impl.ResolverImpl$collectAnnotatedSymbols$visitor$1.visitClassDeclaration(ResolverImpl.kt:288)
at com.google.devtools.ksp.symbol.impl.kotlin.KSClassDeclarationImpl.accept(KSClassDeclarationImpl.kt:119)
at com.google.devtools.ksp.processing.impl.ResolverImpl$collectAnnotatedSymbols$visitor$1.visitFile(ResolverImpl.kt:296)
at com.google.devtools.ksp.processing.impl.ResolverImpl$collectAnnotatedSymbols$visitor$1.visitFile(ResolverImpl.kt:288)
at com.google.devtools.ksp.symbol.impl.kotlin.KSFileImpl.accept(KSFileImpl.kt:61)
at com.google.devtools.ksp.processing.impl.ResolverImpl.collectAnnotatedSymbols(ResolverImpl.kt:343)
at com.google.devtools.ksp.processing.impl.ResolverImpl.access$collectAnnotatedSymbols(ResolverImpl.kt:104)
at com.google.devtools.ksp.processing.impl.ResolverImpl$newAnnotatedSymbols$2.invoke(ResolverImpl.kt:354)
at com.google.devtools.ksp.processing.impl.ResolverImpl$newAnnotatedSymbols$2.invoke(ResolverImpl.kt:353)
at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
at com.google.devtools.ksp.processing.impl.ResolverImpl.getNewAnnotatedSymbols(ResolverImpl.kt:353)
at com.google.devtools.ksp.processing.impl.ResolverImpl.getSymbolsWithAnnotation(ResolverImpl.kt:280)
at com.google.devtools.ksp.processing.Resolver$DefaultImpls.getSymbolsWithAnnotation$default(Resolver.kt:47)
at dev.zacsweers.moshix.ksp.JsonClassSymbolProcessor.process(JsonClassSymbolProcessorProvider.kt:112)
at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension$doAnalysis$4$1.invoke(KotlinSymbolProcessingExtension.kt:186)
at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension$doAnalysis$4$1.invoke(KotlinSymbolProcessingExtension.kt:184)
at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension.handleException(KotlinSymbolProcessingExtension.kt:278)
at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension.doAnalysis(KotlinSymbolProcessingExtension.kt:184)
at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(TopDownAnalyzerFacadeForJVM.kt:120)
at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration$default(TopDownAnalyzerFacadeForJVM.kt:86)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:252)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:243)
at org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport.analyzeAndReport(AnalyzerWithCompilerReport.kt:113)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.analyze(KotlinToJVMBytecodeCompiler.kt:243)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.repeatAnalysisIfNeeded(KotlinToJVMBytecodeCompiler.kt:213)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.repeatAnalysisIfNeeded(KotlinToJVMBytecodeCompiler.kt:213)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.repeatAnalysisIfNeeded(KotlinToJVMBytecodeCompiler.kt:213)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.repeatAnalysisIfNeeded(KotlinToJVMBytecodeCompiler.kt:213)
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (1 by maintainers)
Top Results From Across the Web
Kapt to KSP migration errors - android - Stack Overflow
Show activity on this post. I am getting an error message when I try to migrate an android project using kapt to KSP...
Read more >Unable to process:xxxxx · Issue #786 · google/ksp · GitHub
cuz ksp SymbolProcessorclass havn't provide a method processingOver which is used to mark ... Migrating from kapt to ksp gives error #755.
Read more >[Solved]-Kapt to KSP migration errors-kotlin - appsloveworld
So, I would need to use both kapt and hilt in my project. The following build.gradle does that, plugins { id "kotlin-kapt ......
Read more >Question regarding KSP and KAPT in multimodule project.
What I want to ask is if migrating singular modules to use ksp is worth it in the big rather good modularized project...
Read more >KSP: Fact or kapt?. Fast and ergonomic annotation…
Firstly, KSP is faster since kapt depends on compiling Kotlin to Java stubs for consumption by the javax.lang.model API used by Java annotation ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Multi-round processing is designed for cooperation among processors. A typical use case is that a processor generates a file in round N and another processor picks it up in round N + 1. When there’s no new outputs, processors run to a fixed point and the entire processing terminates. KSP chose this somewhat implicit termination condition instead of having processors report an explicit flag, because it is a common approach in the communities when the API is designed.
In contrast to catching and ignoring the exception, you could also write the file once in SymbolProcessor.finish() if the generated files are not expected to be consumed by other processors.
@ting-yuan