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

KSP processing fails with Java enum #1482

Closed
dstepanov opened this issue Jul 31, 2023 · 8 comments · Fixed by #1635
Closed

KSP processing fails with Java enum #1482

dstepanov opened this issue Jul 31, 2023 · 8 comments · Fixed by #1635
Assignees

Comments

@dstepanov
Copy link
Contributor

Originally reported here micronaut-projects/micronaut-core#9642

I found a few different exceptions:

e: [ksp] java.lang.IllegalStateException: unexpected class: class com.google.devtools.ksp.symbol.impl.java.KSClassDeclarationJavaEnumEntryImpl
        at com.google.devtools.ksp.processing.impl.ResolverImpl.resolveClassDeclaration(ResolverImpl.kt:568)
        at com.google.devtools.ksp.processing.impl.ResolverImpl.mapToJvmSignatureInternal$compiler_plugin(ResolverImpl.kt:356)
        at com.google.devtools.ksp.processing.impl.ResolverImpl.mapToJvmSignature(ResolverImpl.kt:353)
        at io.micronaut.kotlin.processing.ExtensionsKt.getBinaryName(extensions.kt:47)
        at io.micronaut.kotlin.processing.visitor.KotlinClassElement$KotlinEnclosedElementsQuery.getElementName(KotlinClassElement.kt:628)
        at io.micronaut.kotlin.processing.visitor.KotlinClassElement$KotlinEnclosedElementsQuery.getElementName(KotlinClassElement.kt:619)
        at io.micronaut.inject.ast.utils.EnclosedElementsQuery.getAllElements(EnclosedElementsQuery.java:217)
e: [ksp] /Users/denisstepanov/dev/micronaut-core/test-suite-kotlin-ksp/src/test/kotlin/io/micronaut/core/beans/JavaEnum.java:3: Member must have a containing class: PsiMethod:valueOf
e: java.lang.AssertionError: Member must have a containing class: PsiMethod:valueOf
        at org.jetbrains.kotlin.load.java.structure.impl.JavaMemberImpl.getContainingClass(JavaMemberImpl.java:63)
        at com.google.devtools.ksp.symbol.impl.UtilsKt.resolveContainingClass(utils.kt:235)
        at com.google.devtools.ksp.processing.impl.ResolverImpl.resolveJavaDeclaration(ResolverImpl.kt:537)
        at com.google.devtools.ksp.processing.impl.ResolverImpl.resolveFunctionDeclaration(ResolverImpl.kt:577)
        at com.google.devtools.ksp.symbol.impl.java.KSFunctionDeclarationJavaImpl.findOverridee(KSFunctionDeclarationJavaImpl.kt:56)
        at io.micronaut.kotlin.processing.annotation.KotlinAnnotationMetadataBuilder.methodsHierarchy(KotlinAnnotationMetadataBuilder.kt:273)

"1.8.21-1.0.11"

@runenielsen
Copy link

Any news on this? I get this exact error following this example, but with a Kotlin application instead of Java: https://guides.micronaut.io/latest/micronaut-openapi-generator-server-gradle-java.html

Shame if the Micronaut OpenAPI server generator doesn't work with Kotlin.

@dstepanov
Copy link
Contributor Author

@runenielsen The solution should be to put the Java classes into the Java folder

@runenielsen
Copy link

runenielsen commented Aug 7, 2023

@dstepanov: Thanks, but the generated Java models are already in the path:

build/generated/openapi/generateServerOpenApiModels/src/main/java

... and this path is part of the Java source set of the application.

So they are already in a Java folder...

@dstepanov
Copy link
Contributor Author

I thought for the people in the issue that is a workaround

@opaquot
Copy link

opaquot commented Aug 25, 2023

Hi. I'm having the same issue. Are there any news on this?

@pshemass
Copy link

any update on this?

@sgammon
Copy link

sgammon commented Dec 3, 2023

makes ksp unusable with protobuf

@dstepanov
Copy link
Contributor Author

I have created a PR with a fix #1635

jgray1206 added a commit to jgray1206/light-the-lamp that referenced this issue Jan 4, 2024
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 a pull request may close this issue.

6 participants